﻿/***************************/
//@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(){
	//loads popup only if it is disabled
	$("#sucmess").css("display","none");
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(a){
	
	$("#form2").show();
	$("#sucmess").hide();
	
	$("#Name").val("");
	$("#Address").val("");
	$("#Email").val("");
	$("#Comments").val("");
	$("#Phone").val("");
	
	/*document.form2.Name.value="";
	document.form2.Address.value="";	
	document.form2.Email.value="";
	document.form2.Comments.value="";
	document.form2.Phone.value="";*/
	
	
	$("#packegetype").val(a);
	$("#pchoies").html(a);
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	//centering
	$("#popupContact").css('position','absolute');
	$("#popupContact").css("top", ((windowHeight - $("#popupContact").outerHeight()) / 2) + $(window).scrollTop() + "px");
	$("#popupContact").css('left',windowWidth/2-$("#popupContact").width()/2);
	//only need force for IE6
	//alert($("#popupContact").css('top'));
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	loadPopup();
}
//$("#setalert_"+id).css("top", ((winH - $("#setalert_"+id).outerHeight()) / 2) + $(window).scrollTop() + "px");
//windowHeight/2-popupHeight/2
/*
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#button").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose").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 show_success(){
		$("#form2").hide("slow");
		$("#sucmess").fadeIn("slow");
}
