﻿                                                                     
                                                                     
                                                                     
                                             
/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$(".popup").fadeIn("slow");
		popupStatus = 1;
	}
}


function disablePopup(){
	
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$(".popup").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){

	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $(".popup").height();
	var popupWidth = $(".popup").width();
	
	$(".popup").css({
		"position": "fixed",
		"top": "30px",
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}

$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$(".more").click(function(){
		
		//centering with css
		centerPopup();
		//load popup
		
		loadPopup();

		
	});
				
	//CLOSING POPUP
	//Click the x event!
	$(".popupClose").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});

	$(function(){
		$('.tooltip').hide();
		$('li.headlink').hover(
			function() { $('ul', this).fadeIn('slow'); },
			function() { $('ul', this).fadeOut('slow'); });

		$('#leftNav').slideDown('slow');
		$('.popupContent1').hide();
		$('.popupContent2').hide();
		$('.popupContent3').hide();
		
			$('.moreDetails a').each(function(){
			$(this).mouseover(function(){
			var pos = $(this).position();
			$('span', this).fadeIn();
			$('span', this).css({'display':'block','left':pos.left,'top':pos.top + 25});
			});
			});
			$('a', this).mouseout(function(){
				$('.tooltip').fadeOut();
			});

			$('#more1').click(function(){
				$('.popupContent1').show();
				$('.popupContent2').hide();
				$('.popupContent3').hide();
			});
			$('#more2').click(function(){
				$('.popupContent1').hide();
				$('.popupContent2').show();
				$('.popupContent3').hide();

			});
			$('#more3').click(function(){
				$('.popupContent1').hide();
				$('.popupContent2').hide();
				$('.popupContent3').show();
			});
			var contentHeight1 = $('.popupContent1').height();
			var contentHeight2 = $('.popupContent2').height();
			var contentHeight3 = $('.popupContent3').height();

			
});
