$(document).ready(function()
{

		$('div.homeintro').cycle({
			fx: 'fade',
			timeout: 10000, 
			delay:  2000, 
			speed:  500
		});


		/* 
		===	DROP DOWN NAVIGATION 
		*/
		
		//$('#jsddm > li').bind('mouseover', jsddm_open);
		//$('#jsddm > li').bind('mouseout',  jsddm_timer);

		$('div#navigation ul li').hover(function()
		{
			//$(this).children("div.meganav").toggle("slide", { direction: "up", easing: "easeOutCubic" }, 200);
			$(this).children("ul").css("display", "block");
			$(this).addClass("hover");


		}, function()
		{
			//$(this).children("div.meganav").toggle("slide", { direction: "up", easing: "easeOutCubic" }, 200);
			$(this).children("ul").css("display", "none");
			$(this).removeClass("hover");
		});



	/* 
	===	LOGIN BOX 
	*/

		// some functions to resuse
		function slideboxin(){	$("div#loginbox").animate({"marginTop": "+=50px", "opacity": "toggle"}, "slow");}
		function slideboxout(){	$("div#loginbox").animate({"marginTop": "+=50px", "opacity": "toggle"}, "slow");}
		function fademaskout(){	$("div#loginmask").fadeOut("fast")}

		// login button
		$('div#loginbutton').click(function()
		{
			$("div#loginmask").fadeIn("fast", slideboxin)

		}, function()
		{
			$("div#loginmask").fadeOut("fast", slideboxout)
		});

		// click mask to dismiss
		$("div#loginmask").click(function(){
				$("div#loginbox").animate({"marginTop": "-=50px", "opacity": "toggle"}, "slow", fademaskout);
		});

		// or closeme button
		$("span#closeme").click(function(){
			$("div#loginbox").animate({"marginTop": "-=50px", "opacity": "toggle"}, "slow", fademaskout);
		});

		// input hints for login inputs
		$('div#loginbox input[title!=""]').hint();

		// logged in notification
		$("p#loginstatus").fadeOut('slow').fadeIn('slow').fadeOut('slow').fadeIn('slow').fadeOut('slow').fadeIn('slow');



	/* 
	===	SEARCH 
	*/
		
		$('div#search input[title!=""]').hint();



	/* 
	===	LANGUAGE SELECT 
	*/

		$('div#lang').hover(function()
		{
			//$("div#langchoice").toggle("slide", { direction: "up", easing: "easeOutCubic" }, 200);
			//$("div#langchoice").css("display", "block");
			$("div#langchoice").slideToggle(300);

		}, function()
		{
			//$("div#langchoice").toggle("slide", { direction: "up", easing: "easeOutCubic" }, 200);
			//$("div#langchoice").css("display", "none");
			$("div#langchoice").slideToggle(300);
		});


	
	
	/* 
	===	FONT RESIZING 
	*/

		$("li#fdef").click(function(event){
			event.preventDefault();
			$("#thecontent").css("font-size","14px");
			$.cookie("reload","10px");
		});

		$("li#fla1").click(function(event){
			event.preventDefault();
			$("#thecontent").css("font-size","18px");
			$.cookie("reload","12px");
		});

		$("li#fla2").click(function(event){
			event.preventDefault();
			$("#thecontent").css("font-size","22px");
			$.cookie("reload","14px");
		});

		// Cookie
		var reload = $.cookie("reload");

		// Calling cookie
		if(reload == "10px"){$("#thecontent").css("font-size","14px");};
		if(reload == "12px"){$("#thecontent").css("font-size","18px");};
		if(reload == "14px"){$("#thecontent").css("font-size","22px");};





	/*
	=== CUSTOM LIGHTBOX
	*/

		$('.ngg-galleryoverview img').click(function()
		{
			$('div#loginmask').animate(
			{
				'opacity' : '.8',
				'FILTER' : 'alpha(opacity=80)'
			}, 1000).css(
			{
				'width' : $(document).width(),
				'height' : $(document).height()
			});

			var newImage = $('<img />');

			var lbwidth = $('body').width();
			var lbheight = $('body').height();

			$(newImage).attr('src', $(this).parent().attr('href')).attr('id', 'largeImage').css(
			{
				'left' : lbwidth/2 - 415
				//'top' : lbheight/2 - 300
			});

			// $(this).parent().attr('href','#');

			$('body').append(newImage).children('#image').hide();

			$(newImage).fadeIn(2000, function()
			{
				$(this).bind('click', function()
				{
					$(this).fadeOut(1000);

					$('div#loginmask').fadeOut(1000, function()
					{
						$(this).remove();
					});
				});
			});

			return false;

		});


		$("#book").hide();
        $("#showme").show();

		$('#showme').click(function(){
		$("#book").slideToggle();
		});




});
