// JavaScript Document
function setMenuItem() {
	category = document.forms[0].category.options[document.forms[0].category.selectedIndex].value;
	hashIndex = category.indexOf("#");
	if(hashIndex < 0){
		anchorName = "";
		document.forms[0].submit();
	}
	else{
		anchorName = category.substr(hashIndex, category.length);
		window.location.href = anchorName;
	}
}

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 printCoupon(couponid){
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showCouponFrame.php?couponid=" + couponid, "printCoupon", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}

function closeWindow() {
	parent.window.opener.window.focus();
	parent.window.close();
}

function printWindow() {
	parent.mainFrame.focus();
	window.print(parent.mainFrame);
}

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";
}

function checkSubscription(action)
{

 if(action=="sub")
  {
	document.forms[0].lastName.value=trimSpaces(document.forms[0].lastName.value);
	if(document.forms[0].lastName.value.length<=0)
	 {
	 	alert("Enter your Last Name");
		document.forms[0].lastName.focus();
		return false;
	 }

	document.forms[0].firstName.value=trimSpaces(document.forms[0].firstName.value);
	if(document.forms[0].firstName.value.length<=0)
	 {
	 	alert("Enter your First Name");
		document.forms[0].firstName.focus();
		return false;
	 }

	   	
	document.forms[0].email.value=trimSpaces(document.forms[0].email.value);
	if(document.forms[0].email.value.length<=0)
	 {
	 	alert("Enter Email Id");
		document.forms[0].email.focus();
		return false;
	 }
	else
	 {
	   if(!checkEmail(document.forms[0].email.value))
	   {
		document.forms[0].email.focus();
	    return false;
	   }
	 }  	 
	 
	document.forms[0].frmAction.value="update";
	document.forms[0].submit();
 }
 else
  {	
  	document.forms[0].email.value=trimSpaces(document.forms[0].email.value);
	if(document.forms[0].email.value.length<=0)
	 {
	 	alert("Enter Email Id");
		document.forms[0].email.focus();
		return false;
	 }
	else
	 {
	   if(!checkEmail(document.forms[0].email.value))
	   {
	    return false;
	   }
	 }  	 
	 
	document.forms[0].frmAction.value="delete";
	alert();
	document.forms[0].submit();
}
}
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 showPicture(image) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showPicture.php?image=" + image, "picture", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}

function checkEmailList() {
	
	firstName = trimSpaces(document.forms[0].firstName.value);
	if(firstName.length <= 0) {
		alert("Please enter your 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 = "update";

}

function checkMailing(){
	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 checkMailingss(){
	alert(document.petgal.elements[17].name);
	alert(document.petgal.pettype[1].value);
	firstName = trimSpaces(document.petgal.firstName.value);
	if(firstName.length <= 0) {
		alert("Please enter your first name.");
		document.petgal.firstName.focus();
		return false;
	}
	
	lastName = trimSpaces(document.petgal.lastName.value);
	if(lastName.length <= 0) {
		alert("Please enter your last name.");
		document.petgal.lastName.focus();
		return false;
	}
	
	subscriberEmail = trimSpaces(document.petgal.subscriberEmail.value);
	if(subscriberEmail.length <= 0) {
		alert("Please enter your email.");
		document.petgal.subscriberEmail.focus();
		return false;
	}
	if(subscriberEmail.length > 0){
		if(!checkEmail(subscriberEmail)){
			document.petgal.subscriberEmail.focus();
			return false;
		}
	}
	
	//document.forms[0].frmAction.value = "yes";

}*/
function showIcon(iconUrl,menu) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 300;
	winHeight = 300;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	window.open("showIcon.php?iconUrl=" + iconUrl + "&menu=" + menu,"iconURL","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");
}
