/***************************/
//@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 contact_seller
//0 means disabled; 1 means enabled;
var contact_sellerStatus = 0;

//loading contact_seller with jQuery magic!
function loadcontact_seller(){
	//loads contact_seller only if it is disabled
	if(contact_sellerStatus==0){
		$("#backgroundcontact_seller").css({
			"opacity": "0.7"
		});
		$("#backgroundcontact_seller").fadeIn("slow");
		$("#contact_sellerContact").fadeIn("slow");
		contact_sellerStatus = 1;
	}
}

//disabling contact_seller with jQuery magic!
function disablecontact_seller(){
	//disables contact_seller only if it is enabled
	if(contact_sellerStatus==1){
		$("#backgroundcontact_seller").fadeOut("slow");
		$("#contact_sellerContact").fadeOut("slow");
		contact_sellerStatus = 0;
	}
}

//centering contact_seller
function centercontact_seller(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var contact_sellerHeight = $("#contact_sellerContact").height();
	var contact_sellerWidth = $("#contact_sellerContact").width();
	//centering
	$("#contact_sellerContact").css({
		"position": "absolute",
		"top": windowHeight/2-contact_sellerHeight/2,
		"left": windowWidth/2-contact_sellerWidth/2
	});
	//only need force for IE6
	
	$("#backgroundcontact_seller").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING contact_seller
	//Click the button event!
	$("#contacteaza_vanzatoru").click(function(){
		//centering with css
		centercontact_seller();
		//load contact_seller
		loadcontact_seller();
	});
				
	//CLOSING contact_seller
	//Click the x event!
	$("#contact_sellerContactClose").click(function(){
		disablecontact_seller();
	});
	//Click out event!
	$("#backgroundcontact_seller").click(function(){
		disablecontact_seller();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && contact_sellerStatus==1){
			disablecontact_seller();
		}
	});

});
