// JavaScript Document
function closeWindow() {
	parent.window.opener.window.focus();
	parent.window.close();
}

function printWindow() 
{
	window.print();
}
function valid_email(eml)
{
	//declare the required variables
	var mint_len;
	var mstr_eml=eml;
	var mint_at=0;
	var mint_atnum=0;
	var mint_dot=0;
	var mint_dotnum=0;
	
	mint_len=eml.length; //takes the length of the email address entered
	
	//checking for the symbol single quote. If found replace it with its html code
	if (mstr_eml.indexOf("'")!=-1)
	{
		mstr_eml=mstr_eml.replace("'","&#39;");
	}
	
	//checking for the (@) & (.) symbol
	for(var iloop=0;iloop<mint_len;iloop++)
	{
		if(mstr_eml.charAt(iloop)=="@")
		{
			mint_at=iloop+1;
			mint_atnum=mint_atnum+1;
		}
		if(mstr_eml.charAt(iloop)==".")
		{
			mint_dot=iloop+1;
			mint_dotnum=mint_dotnum+1;
		}
	}
	
	//if nothing entered in the field
	if (mstr_eml=="")
	{
		return true;
	}
	
	//if @ entered more than once & dot (.) entered more than 4 times
	else if((mint_atnum!=1)||(mint_dotnum>4)||((mint_dot-mint_at)<2)||((mint_len-mint_dot)<2)||(mint_at<3))
	{
		return true;
	}
	
	//if any blank space is entered in the email address
	else if (mstr_eml.indexOf(" ")!=-1)
	{
		return true;
	}
	return false;
}

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 showPhoto(photoUrl) {
	//photoUrl="../"+photoUrl;
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	window.open("showIcon.php?iconUrl=" + photoUrl,"photoURL","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function removeBannerPhoto(photoUrl) {
	if(photoUrl.length > 0) {
		if(confirm("Do you really want to delete this posting photo?")) {
			document.form1.frmAction.value = "removePhoto";
			document.form1.photoURL.value = photoUrl;
			document.form1.submit();
		}
		else {
			return;
		}
	}
}
function openNewWindow(pagepath) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 550;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open(pagepath,"Details","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function checkContactus() {
	document.feedback.firstname.value = trimSpaces(document.feedback.firstname.value);
	if(document.feedback.firstname.value.length <= 0) {
		alert("Please enter your first name");
		document.feedback.firstname.focus();
		return false;
	}
	document.feedback.lastname.value = trimSpaces(document.feedback.lastname.value);
	if(document.feedback.lastname.value.length <= 0) {
		alert("Please enter your last name");
		document.feedback.lastname.focus();
		return false;
	}
	document.feedback.phone.value = trimSpaces(document.feedback.phone.value);
	if(document.feedback.phone.value.length <= 0) {
		alert("Please enter your Phone Number");
		document.feedback.phone.focus();
		return false;
	}
	document.feedback.email.value = trimSpaces(document.feedback.email.value);
	if(document.feedback.email.value.length <= 0) {
		alert("Please enter your email address");
		document.feedback.email.focus();
		return false;
	}
	if(!checkEmail(document.feedback.email.value)) {
		document.feedback.email.focus();
		document.feedback.email.select();
		return false;
	}
	document.feedback.frmAction.value = "update";
}
function checksite()
{

if(prodForm.category.value=="")
{
alert("Select a category");
prodForm.category.focus();
return false;
}
if(prodForm.subCategory.value=="")
{
alert("Select a site");
prodForm.subCategory.focus();
return false;
}

else
prodForm.frmAction.value='search';


}
