// JavaScript Document

var popupOpen = 0;

function popupInit(Height) {

	getScrollOffset();
	
	leftOffset	= Math.floor((winW-415)/2)+tempX;
	topOffset	= Math.floor((winH-Height)/2)+tempY;
	
	//alert(document.getElementById('bodyContent').offsetHeight+' '+document.body.scrollTop+' '+document.body.innerHeight);
	//alert(IE+' '+tempY+' '+Height+' '+winH+' '+document.body.scrollTop+' '+document.body.innerHeight);
	
	document.body.style.overflow = "hidden";
	
	document.getElementById('shadow').style.left = tempX + "px";
	document.getElementById('shadow').style.top = tempY + "px";
	if (IE) {
	document.getElementById('shadow').style.width = (winW+40) + "px";
	document.getElementById('shadow').style.height = (winH+10) + "px";
	} else {
	document.getElementById('shadow').style.width = winW + "px";
	document.getElementById('shadow').style.height = winH + "px";
	}
	
	document.getElementById('popup').style.left = leftOffset + "px";
	document.getElementById('popup').style.top = topOffset + "px";
	document.getElementById('popup').style.height = Height + "px";
	
	document.getElementById('shadow').style.visibility = "visible";
	document.getElementById('popup').style.visibility = "visible";
	
	popupOpen = 1;

}

function popupClose() {
	
	document.getElementById('shadow').style.left = "0px";
	document.getElementById('shadow').style.top = "0px";
	document.getElementById('shadow').style.width = "0px";
	document.getElementById('shadow').style.height = "0px";
	
	document.getElementById('popup').style.left = "0px";
	document.getElementById('popup').style.top = "0px";
	document.getElementById('popup').style.height = "0px";
	
	document.getElementById('shadow').style.visibility = "hidden";
	document.getElementById('popup').style.visibility = "hidden";
	
	document.getElementById('popup').innerHTML = '';
	
	document.body.style.overflow = "auto";
	
	popupOpen = 0;
	
}

function popupConf(num) {

	popupInit(220);
	
	ajaxDiv = 'popup';
	
	sendAjax('popups.php?type=7&Num='+num,processAjax);
	
}

function popupSuggest() {

	popupInit(420);
	
	ajaxDiv = 'popup';
	
	sendAjax('popups.php?type=1',processAjax);
	
}

function popupJobs() {

	popupInit(440);
	
	ajaxDiv = 'popup';
	
	sendAjax('popups.php?type=3',processAjax);
	
}

function popupNewsletter() {

	popupInit(290);
	
	ajaxDiv = 'popup';
	
	sendAjax('popups.php?type=2',processAjax);
	
}

function popupCoupon(CouponId) {

	popupInit(440);
	
	ajaxDiv = 'popup';
	
	//alert(CouponId);
	
	sendAjax('popups.php?type=4&CouponId='+CouponId,processAjax);
	
}

function popupCouponSave() {
	
	var CouponId = document.CouponForm.CouponId.value;
	
	var LastName = document.CouponForm.LastName.value;
	var FirstName = document.CouponForm.FirstName.value;
	var Email = document.CouponForm.Email.value;
	if (document.CouponForm.City) {
		var City = document.CouponForm.City.value;
		var BirthDay = document.CouponForm.BirthDay.value;
		var BirthMonth = document.CouponForm.BirthMonth.value;
		var BirthYear = document.CouponForm.BirthYear.value;
	} else {
		var City = '';
		var BirthDay = 1;
		var BirthMonth = 1;
		var BirthYear = 1900;
	}
	
	sendAjax('popups.php?type=5&CouponId='+CouponId+'&LastName='+LastName+'&FirstName='+FirstName+'&Email='+Email+'&City='+City+'&BirthDay='+BirthDay+'&BirthMonth='+BirthMonth+'&BirthYear='+BirthYear,processAjax);
	
}

function submitCouponSec() {

	document.CouponForm.submit();
	
}

function submitCoupon() {

	if (document.getElementById('ConfirmCoupon').checked)
		document.CouponForm.submit();
	else
		document.getElementById('confirmText').style.color = "red";
	
}

function popupCouponConfirm() {
	
	var CouponId = document.CouponForm.CouponId.value;
	
	var LastName = document.CouponForm.LastName.value;
	var FirstName = document.CouponForm.FirstName.value;
	var Email = document.CouponForm.Email.value;
	var City = document.CouponForm.City.value;
	var BirthDay = document.CouponForm.BirthDay.value;
	var BirthMonth = document.CouponForm.BirthMonth.value;
	var BirthYear = document.CouponForm.BirthYear.value;
	
	sendAjax('popups.php?type=6&CouponId='+CouponId+'&LastName='+LastName+'&FirstName='+FirstName+'&Email='+Email+'&City='+City+'&BirthDay='+BirthDay+'&BirthMonth='+BirthMonth+'&BirthYear='+BirthYear,processAjax);
	
}

