// 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 showCalendar(frmElement, dispElement) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 375;
	winHeight = 300;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showCalendar.php?frmElement=" + frmElement + "&dispElement=" + dispElement, "Calendar", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");
	return;
}
function checkComplaint(action)
{
	if (document.forms[0].bribe_type.options[document.forms[0].bribe_type.selectedIndex].value == "")  
	{
		alert("Select the Bribe Type");
		document.forms[0].bribe_type.focus();
		return false;			
	}
	document.forms[0].official_name.value = trimSpaces(document.forms[0].official_name.value);
	if(document.forms[0].official_name.value.length <= 0) {
		alert("Please enter Official Name");
		document.forms[0].official_name.focus();
		return false;
	}
	document.forms[0].occured_date.value = trimSpaces(document.forms[0].occured_date.value);
	if(document.forms[0].occured_date.value.length <= 0) {
		alert("Please enter date of occurrence");
		document.forms[0].occured_date.focus();
		return false;
	}
	if (document.forms[0].place_id.value == "")  
	{
		alert("Select the Place of Occurrence");
		document.forms[0].place_id.focus();
		return false;			
	}
	if (document.forms[0].office_id.options[document.forms[0].office_id.selectedIndex].value == "")  
	{
		alert("Select the Office of Occurrence");
		document.forms[0].office_id.focus();
		return false;			
	}
	document.forms[0].frmAction.value="update";
	document.forms[0].submit();
}
