/**
 * @author Jorge Albaladejo 
 */
var resize_timeout = null;

/**
 * Onload methods
 */
$(document).ready( function ()
{
	setTimeout(function()
		{
			resizeCalendar();
		}, 500);
	

	externalLinks();

	
});

/**
 * Opens external links in a new window
 *
 */
function externalLinks() 
{
	if (!document.getElementsByTagName) return;
 
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) 
 	{
 		var anchor = anchors[i];
   		var attr = String(anchor.getAttribute("rel"));
   		if (anchor.getAttribute("href") && attr.toLowerCase().match("external"))
    		anchor.target = "_blank";
 	}
}

/**
 * Onresize methods
 */
$(window).resize( function() {resizeCalendar();} );

/**
 * Resizes map according to window size
 *
 */
function resizeCalendar() 
{
	// vars
    var wnd_h 		= $(window).height();
	var min_h 		= 500;
	var h			= 0;
	var offset		= 50;
		
	if ( wnd_h < min_h )
	{
		h = min_h;
	}
	else
	{
		h = wnd_h;	
	}
	
	h-=offset;
	
	// now, apply calculations if there has been a switch
	clearTimeout(resize_timeout); 
	resize_timeout = setTimeout(function() 
	{
		$('#calendar span').animate(
			{
				paddingTop: h
			} ,
			500 ,
			function()
			{
				/*console.log('new calendar size: ' + h);	*/
			}
		);
	}, 200);
		
}



