var popupStatus = 0;

function loadPopup(customMsg){	
	if(popupStatus==0){

		/* Hide Confirm Message And Show Form */
		jQuery('#popupContentRight').slideDown();
		jQuery('#ConfirmToEmail').html('');
		jQuery('#popupContentRightConfirmMessage').slideUp();	
		/******************************************************/		
		
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");

		popupStatus = 1;
	}
}

function disablePopup(){	
	if(popupStatus==1){
		$('#successTellFriend').text("");
		$('#successTellFriend').css("display","none");
		$('#formTellFriend').css("display","block");
		
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}

function centerPopup(customMsg){
	if (customMsg == 1) {
		$('#labelPopup').hide();
		$('#popupContent').hide();
		$('#popupContentCustomTitle').show();
		$('#popupContentCustomMessage').show();
	}
	else {
		$('#labelPopup').show();
		$('#popupContent').show();
		$('#popupContentCustomTitle').hide();
		$('#popupContentCustomMessage').hide();
	}
		
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	$("#popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	
	//only need force for IE6	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}
/*
$(document).ready(function(){
	Loading Popup
	$(".btnmailaFriends").click(function(){		
		centerPopup();		
		loadPopup();
		
		var Pid    = $(this).parent().parent().attr('id');
		var PidNum = Pid.slice( 8 , Pid.length );
		
		$('#popupProduct').attr('src', $('#product_'+PidNum+' .colSectionOne img').attr('src') );
		$('#popupProductTitle').html( $('#product_'+PidNum+' .colSectionTwo  h2').html()  );
		$('#tellFriendItenToSend').val(PidNum);
		
	});
				
	Closing Popup
	$("#popupContactClose").click(function(){
		cleanTellFriend();
		disablePopup();
	});
	
	 Click out 
	$("#backgroundPopup").click(function(){
		cleanTellFriend();
		disablePopup();
	});
	
	 Press ESC
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
});*/