Site = {}
Site.footer = {}
Site.header = {}
Site.nav = {}

/****************************************************************************
** Variables
****************************************************************************/
var flashvars = {};
var params = {};
var attributes = {};
params.wmode = 'transparent';

/****************************************************************************
** Site.header
****************************************************************************/
Site.header.load = function () {

	swfobject.embedSWF('/swf/volver.swf', 'volver', '35', '75', '9.0.0', false, flashvars, params, attributes);
	swfobject.embedSWF('/swf/home.swf', 'home', '1500', '618', '9.0.0', false, flashvars, params, attributes);

	$('div#menu div.menu a').wrapInner('<span></span>');

}

/****************************************************************************
** Site.footer
****************************************************************************/
Site.footer.load = function () {

	var footer = $('div#footer');
	var w = $(window);
	
	w.resize(function () {
	
		var padding = w.height() - 619 - 57;
		if (padding > 0) {
			footer.css("padding-bottom",  padding);
			
		}
	
	});
	
	w.trigger('resize'); 
}

/****************************************************************************
** Site.nav
****************************************************************************/
Site.nav.load = function () {

	$('div#menu div.menu a').click(function () {
	
		var url = $(this).attr('href');
		Site.nav.go(url);
	
		return false;
		
	});

}

Site.nav.go = function (url) {
	
	var content = $('div#content div.ajax');
	
	if (url == '/pages/home') {
		
		$('div#header').css('display', 'block');
		content.parent().css('display', 'none');
		
	} else {
		
		$.ajax({
		
			url: url,
			success: function (html) {

				var pos = content.offset();

				if (pos.top < -500) {

					$('div#header').css('display', 'none');
					content.html(html);
					content.parent().css('display', 'block');
					
				} else {
					
					content.fadeOut('fast', function () {

						if (typeof tips_timeout != 'undefined') clearInterval(tips_timeout);
						
						$('div#header').css('display', 'none');
						content.html(html)
						content.fadeIn('fast');
						content.parent().css('display', 'block');

					});

				}
			
			}
		
		});
	
	}
	
}

$(document).ready(function () {

	Site.footer.load();
	Site.header.load();
	Site.nav.load()

});