
$(document).ready(function() {
			$('#do_you_known_1').fancyZoom({closeOnClick: true,width:600, height:300});
			$('#do_you_known_2').fancyZoom({closeOnClick: true,width:600, height:300});
			$('#do_you_known_3').fancyZoom({closeOnClick: true,width:600, height:300});
			$('#do_you_known_4').fancyZoom({closeOnClick: true,width:600, height:300});
			$('#do_you_known_5').fancyZoom({closeOnClick: true,width:600, height:300});

		});

/*************** tool tips ********************/
$(document).ready(function() {
    //Tooltips
    $(".tip_trigger").hover(function(){
        tip = $(this).find('.tip');
        tip.show(); //Show tooltip
    }, function() {
        tip.hide(); //Hide tooltip
    }).mousemove(function(e) {
        var mousex = e.pageX + 20; //Get X coodrinates
        var mousey = e.pageY + 20; //Get Y coordinates
        var tipWidth = tip.width(); //Find width of tooltip
        var tipHeight = tip.height(); //Find height of tooltip

        //Distance of element from the right edge of viewport
        var tipVisX = $(window).width() - (mousex + tipWidth);
        //Distance of element from the bottom of viewport
        var tipVisY = $(window).height() - (mousey + tipHeight);

        if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
            mousex = e.pageX - tipWidth - 20;
        } if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
            mousey = e.pageY - tipHeight - 20;
        }
        //Absolute position the tooltip according to mouse position
        tip.css({  top: mousey, left: mousex });
    });
});

/***** <a href="#" class="tip_trigger">Your Link Key Word <span class="tip">This will show up in the tooltip</span></a> ****/

/*************************** slide page ********************************************/
$(document).ready(function() {


	$("#main_menu,#header_menu").show();
	$("#main_menu a:first").addClass("active");
		
	//var imageWidth = $("#load_content #blocked").width();
	var imageWidth = 1100;
	var imageSum = $("#load_content #blocked").size();
	var imageReelWidth = imageWidth * imageSum;


	$("#load_content").css({'width' : imageReelWidth});
	

	rotate = function(){	
		var triggerID = $active.attr("rel") - 1; 
		var image_reelPosition = triggerID * imageWidth;

		$("#main_menu a,#header_menu a").removeClass('active');
		$active.addClass('active');
		
		//Slider Animation
		$("#load_content").animate({ 
			left: -image_reelPosition
		}, 500 );
		
		
		var number_page=$active.attr("rel")*(Math.round(400/imageSum));
		$('#body').animate({ 
			backgroundPosition:"(-"+number_page+"px 0px)"
		}, 500 );

		
		load_content($active.attr("title"),$active.attr("id"));
		
		
	}; 
	
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ 
			$active = $('#main_menu a.active,#header_menu a.active').next();
			if ( $active.length === 0) { 
				$active = $('#main_menu a:first'); 
			}
			rotate(); 
		}, 5000000000); 
	};
	
	rotateSwitch(); //Run function on launch
	
	//On Hover
	$("#load_content #blocked").hover(function() {
		clearInterval(play); 
	}, function() {
		rotateSwitch(); 
	});	
	
	//On Click
	$("#main_menu a.slide_page,#header_menu a.slide_page,a.slide_page_source").click(function() {	
		$active = $(this);
		clearInterval(play);
		rotate(); 
		rotateSwitch();
		return false; 
	});	
	
	
	function load_content(file,area){ 
	
		//$('#load_content .'+area).fadeTo(0, 0);
		$('#load_content .'+area).html('<div class="ajax_preloader"></div>');

				$.ajax({
				  url: 'pages/'+file+'.php',
				  cache: false,
				  success: function(data) {
					
					$('.ajax_preloader').remove();
					$('#load_content .'+area).html(data);
				  }
				});
	}
	

});

/*********************************** nav *********************************************/

$(document).ready(function() {
	

	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('slow', 0.7).show();
		//.stop().animate({bottom:'42px'},{queue:false, duration:600, easing: 'easeOutBounce'}).fadeTo('fast', 1).show();
		
		//.stop().fadeTo('fast', 1).show();
			
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
		
		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {							   
				$(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			$(this).find(".sub").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			$(this).calcSubWidth();
			//Set Width
			$(this).find(".sub").css({'width' : rowWidth});
			
		}
	}
	
	function megaHoverOut(){ 
	 $(this).find(".sub").stop().fadeTo('slow', 0).hide();
	}


	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 100, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 500, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul#topnav li .sub").css({'opacity':'0'});
	$("ul#topnav li").hoverIntent(config);



});

function load_in_content(file,area){ 
		$('#'+area).html('<div class="ajax_preloader"></div>');
				$.ajax({
				  url: 'pages/'+file+'.php',
				  cache: false,
				  success: function(data) {
					$('.ajax_preloader').remove();
					$('#'+area).html(data);
				  }
				});
	}


function load_content(file,area){ 
	
		//$('#load_content .'+area).fadeTo(0, 0);
		$('#load_content .'+area).html('<div class="ajax_preloader"></div>');

				$.ajax({
				  url: 'pages/'+file+'.php',
				  cache: false,
				  success: function(data) {
					
					$('.ajax_preloader').remove();
					$('#load_content .'+area).html(data);
				  }
				});
	}


