
// ok
jQuery.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++) {
		jQuery("<img>").attr("src", arguments[i]);
	}
}
$menu = $.cookie('menu');

if($menu != 'visible') { $.cookie('menu', 'invisible') };

document.write('<style type="text/css">#content img,#content h2,#content p,#logo_intro,#logo_intro2,#trigger,#arrows,#nav {display:none}</style>');

$(document).ready(function(){

	// $("#content h2,#content p").hide();
	
	$("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank");
	$("area[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank");

	// ok
	if($('body').attr('class') == 'home')
	{
		$('#nav').hide();
		$('#content img').fadeIn(1000);
	}
	else
	{
		$('#content img').show();
	}

	if($('body').attr('class') == 'home')
	{
		$('#arrows').fadeIn(250, function(){
			 $('#trigger').slideDown(150);
		});
	}
	else if($menu == 'visible')
	{
		$('#nav').show();
		$('#arrows').show();
		$('#trigger').slideDown(250);
	}
	else
	{
		$('#arrows').fadeIn(250, function(){
			 $('#trigger').slideDown(150);
		});
	}


	// ok
	if($('body').attr('class') == 'intro')
	{
	 	$("#logo_intro").fadeIn(1000).animate({opacity: "1"}, 2000).animate({opacity: "0"}, 1000, function(){
			$("#logo_intro2").fadeIn(1000).animate({opacity: "1"}, 3500).animate({opacity: "0"}, 1000, function() {
				window.location.href = '/home/';
			})
		});
	}

	// ok
	$("#nav").mouseleave(function(){
		$("#nav").slideUp(350, function(){
			$("#trigger").animate({opacity: "1"}, 250)
		});
    });

	// ok
	$("#trigger a").mouseenter(function(){
		$("#trigger").animate({opacity: "0"}, 100, function(){
			$("#nav").slideDown(500);
		});
	});	

	$("li.site a").click(function () {
		$.cookie('menu', 'visible');
		window.location.href = $(this).attr('href');
		return false;
	});

	$("div#arrows a").click(function () {
		$.cookie('menu', 'invisible');
		window.location.href = $(this).attr('href');
		return false;
	});
	
	$("#arrows a.dl").qtip({
		content: '<img src="/assets/img/pdf.gif" width="130" height="30" />',
		position: {
			corner: {
				tooltip: 'bottomRight',
				target: 'leftMiddle'
			},
			adjust: {
				x : 16,
				y : -6
			},
			fixed:false

		},
		style: {
			border: {
				width: 1
			},
			padding: 0, 
			textAlign: 'center'
			}
	});

	// $("map#downloadmap area.link").qtip({
	// 	content: '<img src="/assets/img/pdf.gif" width="130" height="30" />',
	// 	position: {
	// 		corner: {
	// 			tooltip: 'topLeft',
	// 			target: 'bottomMiddle'
	// 		},
	// 		adjust: {
	// 			x : 16,
	// 			y : -6
	// 		},
	// 		fixed:false
	// 	},
	// 	style: {
	// 		border: {
	// 			width: 1
	// 		},
	// 		tip: {
	// 			corner:'topLeft',
	// 			color:'#cccccc',
	// 			size: {
	// 				x: 6,
	// 				y : 6
	// 				}
	// 		},
	// 		padding: 0, 
	// 		textAlign: 'center'
	// 		}
	// });

});	

