/*
 Most Important Javascript Functions
 Written By Charbel Al Batal: http://www.charbelbatal.com
 Copyright W8: http://www.wondereight.com
*/
function shareFacebook()
{
	u=location.href;
	t="";
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;		
}

function tweetPage(title)
{
	u=location.href;t=title;
	window.open('http://twitter.com/share?url='+encodeURIComponent(u)+'&text='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

function subModifyFooterHeight(){	
	var windowHeight;
	var mainDocumentBodyHeight = $("#wrapper").height();
		$("#footer").css("height","50px")
	if (document.documentElement){
		if(document.documentElement.offsetHeight>document.documentElement.clientHeight)  windowHeight = document.documentElement.offsetHeight-4
		else windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body){
		if(document.body.offsetHeight>document.body.clientHeight)  windowHeight = document.body.offsetHeight;
		else windowHeight  = document.body.clientHeight;
	}
	if(windowHeight>mainDocumentBodyHeight){
		height = windowHeight - mainDocumentBodyHeight;
		$("#footer").css("height",height +"px");
	}
}
subModifyFooterHeight();

var popupStatus = 0;  
//loading popup with jQuery magic!  
function loadPopup(id,backid){  
	//begin centering the popup 
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = jQuery("#"+id).height();
	var popupWidth = jQuery("#"+id).width();
	//centering
	jQuery("#"+id).css({
		"position": "fixed",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6	
	jQuery("#"+backid).css({"height": windowHeight});
	if(popupStatus==0){  			
	  jQuery("#"+backid).css({"opacity": "0.76"});  
	  jQuery("#"+backid).fadeIn("slow");  
	  jQuery("#"+id).fadeIn("slow");	
	  jQuery("#"+id+" #closeBtn").unbind('click');  
	  jQuery("#"+id+" #closeBtn").click(function(){
		disablePopup(id,backid);
	  });
	  popupStatus = 1;  
	}  
}  
//disabling popup with jQuery magic!
function disablePopup(id,backid){
	//disables popup only if it is enabled
	if(popupStatus==1){
		jQuery("#"+backid).fadeOut("slow");
		jQuery("#"+id).fadeOut("slow");
		
		popupStatus = 0;
	}
}
