function showCoupon(galleryid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showCouponFrame.php?couponid=" + galleryid , "picture", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}

function openCustomWindow(pageURL) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 550;
	winHeight = 400;
	
	sTop = (sHeight - winHeight) / 2;
	sLeft = (sWidth - winWidth) / 2;
	window.open(pageURL, "custFrame", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}

function showPicture(productid, photoType,categoryid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showPictureFrame.php?productid=" + productid + "&photoType=" + photoType + "&category="+categoryid, "picture", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}
function showPicturefromHome(productid, photoType,categoryid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("php/showPictureFrame.php?productid=" + productid + "&photoType=" + photoType + "&category="+categoryid, "picture", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}
function checkMailing(){

	/*members = trimSpaces(document.forms[0].members.value);
	if(members.length <= 0) {
		alert("Please select a member.");
		document.forms[0].members.focus();
		return false;
	}*/
	
	firstName = trimSpaces(document.forms[0].firstName.value);
	
	if(firstName.length <= 0) {
		alert("Please enter your first name.");
		document.forms[0].firstName.focus();
		return false;
	}
	
	lastName = trimSpaces(document.forms[0].lastName.value);
	if(lastName.length <= 0) {
		alert("Please enter your last name.");
		document.forms[0].lastName.focus();
		return false;
	}
	
	subscriberEmail = trimSpaces(document.forms[0].subscriberEmail.value);
	if(subscriberEmail.length <= 0) {
		alert("Please enter your email.");
		document.forms[0].subscriberEmail.focus();
		return false;
	}
	if(subscriberEmail.length > 0){
		if(!checkEmail(subscriberEmail)){
			document.forms[0].subscriberEmail.focus();
			return false;
		}
	}
	
	document.forms[0].frmAction.value = "yes";

}
function showFamilyPicture(galleryid, photoType,linkid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showfamilyPictureFrame.php?galleryid=" + galleryid + "&photoType=" + photoType + "&linkid="+linkid, "picture", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}
function checkGiftCertificate() {
	senderName = trimSpaces(document.forms[0].senderName.value);
	if(senderName.length <= 0) {
		alert("Plese enter your name");
		document.forms[0].senderName.focus();
		return false;
	}
	
	senderAddress = trimSpaces(document.forms[0].senderAddress.value);
	if(senderAddress.length <= 0) {
		alert("Plese enter your address");
		document.forms[0].senderAddress.focus();
		return false;
	}

	senderCity = trimSpaces(document.forms[0].senderCity.value);
	if(senderCity.length <= 0) {
		alert("Plese enter your city");
		document.forms[0].senderCity.focus();
		return false;
	}
	
	senderState = trimSpaces(document.forms[0].senderState.value);
	if(senderState.length <= 0) {
		alert("Plese enter your state");
		document.forms[0].senderState.focus();
		return false;
	}

	senderZip = trimSpaces(document.forms[0].senderZip.value);
	if(senderZip.length <= 0) {
		alert("Plese enter your ZIP");
		document.forms[0].senderZip.focus();
		return false;
	}
	
	senderPhone = trimSpaces(document.forms[0].senderPhone.value);
	if(senderPhone.length <= 0) {
		alert("Plese enter your telephone number");
		document.forms[0].senderPhone.focus();
		return false;
	}

	senderEmail = trimSpaces(document.forms[0].senderEmail.value);
	if(senderEmail.length <= 0) {
		alert("Plese enter your email address");
		document.forms[0].senderEmail.focus();
		return false;
	}
	if(!checkEmail(senderEmail)) {
		document.forms[0].senderEmail.focus();
		return false;
	}
	
	certificateQuantity = trimSpaces(document.forms[0].certificateQuantity.value);
	certificateAmount = trimSpaces(document.forms[0].certificateAmount.value);
	if(certificateQuantity.length <= 0 && certificateAmount.length <= 0) {
		if(certificateQuantity.length <= 0) {
			alert("Plese enter the certificate quantity");
			document.forms[0].certificateQuantity.focus();
			return false;
		}
		if(certificateAmount.length <= 0) {
			alert("Plese enter the certificate amount");
			document.forms[0].certificateAmount.focus();
			return false;
		}
	}
	
	document.forms[0].frmAction.value = "send";
}
function checkFeedBack() {
	document.forms[0].visitorName.value = trimSpaces(document.forms[0].visitorName.value);
	if(document.forms[0].visitorName.value.length <= 0) {
		alert("Please enter your name");
		document.forms[0].visitorName.focus();
		return false;
	}

	document.forms[0].emailAddress.value = trimSpaces(document.forms[0].emailAddress.value);
	if(document.forms[0].emailAddress.value.length <= 0) {
		alert("Please enter your email address");
		document.forms[0].emailAddress.focus();
		return false;
	}
	if(!checkEmail(document.forms[0].emailAddress.value)) {
		document.forms[0].emailAddress.focus();
		document.forms[0].emailAddress.select();
		return false;
	}
	document.forms[0].visitorComments.value = trimSpaces(document.forms[0].visitorComments.value);
	if(document.forms[0].visitorComments.value.length <= 0) {
		alert("Please enter your comments");
		document.forms[0].visitorComments.focus();
		return false;
	}
	document.forms[0].frmAction.value = "update";
}
function closeWindow() {
	parent.window.opener.window.focus();
	parent.window.close();
}

function printWindow() {
	parent.mainFrame.focus();
	window.print(parent.mainFrame);
}
function checkSubscription() {
	subscribername = trimSpaces(document.forms[0].subscribername.value);
	subscriberemail = trimSpaces(document.forms[0].subscriberemail.value);
	
	if(subscribername.length <= 0) {
		alert("Please enter your name");
		document.forms[0].subscribername.focus();
		return false;
	}
	if(subscriberemail.length <= 0) {
		alert("Please enter your email");
		document.forms[0].subscriberemail.focus();
		return false;
	}
	if(!checkEmail(subscriberemail)) {
		document.forms[0].subscriberemail.focus();
		return false;
	}
	document.forms[0].frmAction.value = "update";
}
function checkMaillist() {

	subscribername = trimSpaces(document.forms[0].subscribername.value);
	subscriberemail = trimSpaces(document.forms[0].subscriberemail.value);
	
	if(subscribername.length <= 0) {
		alert("Please enter your name");
		document.forms[0].subscribername.focus();
		return;
	}
	if(subscriberemail.length <= 0) {
		alert("Please enter your email");
		document.forms[0].subscriberemail.focus();
		return;
	}

	if(!checkEmail(subscriberemail)) {
		document.forms[0].subscriberemail.focus();
		return;
	}

	document.forms[0].frmAction.value = "update";
	document.forms[0].linkid.value = 16;
	document.forms[0].action = "php/subpage.php";
	document.forms[0].submit();
	
	
}
function showFaqs(newsid, pageType,categoryid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 650;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	if(pageType == "home") {
		pageUrl = "php/";
	}
	else {
		pageUrl = "";
	}

	window.open(pageUrl + "showFaqsFrame.php?newsid=" + newsid +"&category="+categoryid, "faq", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}
function checkContact() {
	
	visitorName = trimSpaces(document.forms[0].visitorName.value);
	visitorEmail = trimSpaces(document.forms[0].visitorEmail.value);
	visitorPhone = trimSpaces(document.forms[0].visitorPhone.value);
	visitorComments = trimSpaces(document.forms[0].visitorComments.value);
	
	if(visitorName.length <= 0) {
		alert("Please provide your name before submitting the form");
		document.forms[0].visitorName.focus();
		return false;
	}
	
	if(visitorEmail.length <= 0) {
		alert("Please provide your email address before submitting the form");
		document.forms[0].visitorEmail.focus();
		return false;
	}
	
	if(!checkEmail(visitorEmail)) {
		document.forms[0].visitorEmail.focus();
		return false;
	}
	
	if(visitorComments.length <= 0) {
		alert("Please mention your queries or suggestions before submitting the form");
		document.forms[0].visitorComments.focus();
		return false;
	}
	document.forms[0].frmAction.value = "send";
}
function showColorPicture(imgURL, imgType) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	if(imgType == "photo") {
		winWidth = 600;
		winHeight = 300;
	}
	else {
		winWidth = 200;
		winHeight = 200;
	}
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showColorPicture.php?imgURL=" + imgURL, "sudhirPicture", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}

function printCoupon(couponid,flag, pageTgt){
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;

	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	if(pageTgt == 'lipet') {
		window.open("http://www.thelipetcoop.com/php/showCouponFrame.php?flag=" + flag + "&couponid=" + couponid, "printCoupon", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	}
	else {
		window.open("showCouponFrame.php?flag=" + flag + "&couponid=" + couponid, "printCoupon", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	}
	return;
}
function checkCouponMail() {
	senderName = trimSpaces(document.forms[0].senderName.value);
	senderEmail = trimSpaces(document.forms[0].senderEmail.value);
	receiverEmail = trimSpaces(document.forms[0].receiverEmail.value);
	if(senderName.length <= 0) {
		alert("You have to enter your name.");
		document.forms[0].senderName.focus();
		return false;
	}
	if(senderEmail.length <= 0) {
		alert("You have to enter your email address.");
		document.forms[0].senderEmail.focus();
		return false;
	}
	if(!checkEmail(senderEmail)) {
		document.forms[0].senderEmail.focus();
		return false;
	}
	if(receiverEmail.length <= 0) {
		alert("You have to enter your friend's email address.");
		document.forms[0].receiverEmail.focus();
		return false;
	}
	if(!checkEmail(receiverEmail)) {
		document.forms[0].receiverEmail.focus();
		return false;
	}
	document.forms[0].frmAction.value = "yes";
}
