function closeWindow() {

	parent.window.opener.window.focus();

	parent.window.close();

}



function printWindow() {

	window.print();

}







function chkuserlogin(toDo,linkid,f)

{	

	/*switch(linkid){

		case 35:

			if(!checkGB(f))

				return false;

			break;

		

		

	}*/

	if(toDo=="add")

	{	

		if(f.username.value=="")

		{

		alert("Enter Email address");

		f.username.focus();

		return false;

		}

	

		if(f.password.value=="")

		{

		alert("Enter password");

		f.password.focus();

		return false;

		

   		}

	}

	f.frmAction.value = "login";

	f.submit();	

}



function ChkReg(f){

	f.first_name.value = trimSpaces(f.first_name.value);

	if(f.first_name.value.length <= 0) {

		alert("Please enter your first name");

		f.first_name.focus();

		return false;

	}

	f.last_name.value = trimSpaces(f.last_name.value);

	if(f.last_name.value.length <= 0) {

		alert("Please enter your last name");

		f.last_name.focus();

		return false;

	}

	f.email.value = trimSpaces(f.email.value);

	if(!checkEmail(f.email.value)) {

		f.email.focus();

		return false;

	}

	

	f.city.value = trimSpaces(f.city.value);

	if(f.city.value.length <= 0) {

		alert("Please enter your city");

		f.city.focus();

		return false;

	}

	if(trimSpaces(f.birth_mon.options[f.birth_mon.selectedIndex].value).length <= 0) 

	{

		alert("Please select the birth month");

		f.birth_mon.focus();

		return false;

	}	

	if(trimSpaces(f.birth_year.options[f.birth_year.selectedIndex].value).length <= 0) 

	{

		alert("Please select the birth year");

		f.birth_year.focus();

		return false;

	}



	f.frmAction.value = "register";

	f.submit();

}

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.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 checkCommentForm() {

	document.forms[0].user_name.value = trimSpaces(document.forms[0].user_name.value);

	if(document.forms[0].user_name.value.length <= 0) {

		alert("Please enter your name");

		document.forms[0].user_name.focus();

		return false;

	}

	document.forms[0].politician_name.value = trimSpaces(document.forms[0].politician_name.value);

	if(document.forms[0].politician_name.value.length <= 0) {

		alert("Please enter your politician name");

		document.forms[0].politician_name.focus();

		return false;

	}

	document.forms[0].email.value = trimSpaces(document.forms[0].email.value);

	if(document.forms[0].email.value.length <= 0) {

		alert("Please enter your email address");

		document.forms[0].email.focus();

		return false;

	}

	if(!checkEmail(document.forms[0].email.value)) {

		document.forms[0].email.focus();

		document.forms[0].email.select();

		return false;

	}

	document.forms[0].comment.value = trimSpaces(document.forms[0].comment.value);

	if(document.forms[0].comment.value.length <= 0) {

		alert("Please enter your comments");

		document.forms[0].comment.focus();

		return false;

	}

	document.forms[0].frmAction.value = "update";

}

function ChkActivateEmail(f)

{

	if(trimSpaces(f.email.value).length <= 0) 

	{

		alert("Please enter your email");

		f.email.focus();

		return false;

	}

f.frmAction.value = "activate";	

}



function deletePhoto(photoName)

{

	if(confirm('Do you really want to delete Photo ?')) 

	{

	document.profForm.photoName.value = photoName;

	document.profForm.frmAction.value ='delphoto';

	document.profForm.submit();

	}	

}





function chkEditAccount(f)

{

		f.firstname.value = trimSpaces(f.firstname.value);

		if(f.firstname.value.length <= 0) {

			alert("Please enter your first name");

			f.firstname.focus();

			return false;

		}

		

		f.lastname.value = trimSpaces(f.lastname.value);

		if(f.lastname.value.length <= 0) {

			alert("Please enter your last name");

			f.lastname.focus();

			return false;

		}

		document.account.frmAction.value = "update";

}

function checkPassword()

{

	document.changePassword.password.value = trimSpaces(document.changePassword.password.value);

	if(document.changePassword.password.value.length <= 0){

		alert("Please enter the current password");

		document.changePassword.password.focus();

		return false;

	}

	document.changePassword.newPassword.value = trimSpaces(document.changePassword.newPassword.value);

	if(document.changePassword.newPassword.value.length <= 0){

		alert("Please enter the new password");

		document.changePassword.newPassword.focus();

		return false;

	}

	document.changePassword.retypePassword.value = trimSpaces(document.changePassword.retypePassword.value);

	if(document.changePassword.newPassword.value != document.changePassword.retypePassword.value){

		alert("Passwords does not match");

		document.changePassword.retypePassword.focus();

		return false;

	}

}



function valAddPhotos()

{

	document.photoForm.frmAction.value = 'update';

}





function valDelGalPic()

{

		rowSelected = false;

		if(document.forms[0].elements["delid[]"].length > 0) {

			for(itemCount = 0; itemCount < document.forms[0].elements["delid[]"].length; itemCount++) {

				if(document.forms[0].elements["delid[]"][itemCount].checked) {

					rowSelected = true;

				}

			}

		}

		else {

			if(document.forms[0].elements["delid[]"].checked) {

				rowSelected = true;

			}

		}

		if(!rowSelected) {

			alert("No item selected for deletion");

			return false;

		}

		else {

			if(!confirm("Do you really want to delete these photo(s)?")) {

				return false;

			}

			document.forms[0].frmAction.value = 'delPic';

			document.forms[0].submit();

		}

	}

	

function valPeopleSearch()

{

	pcat_id = document.searchFrm.pcat_id.options[document.searchFrm.pcat_id.selectedIndex].value;

	if (pcat_id == "")

	{

		alert("Please select a category");

		document.searchFrm.pcat_id.focus();

		return false;

	}

	

	document.searchFrm.frmAction.value = "search"

}

function openNewWindow(pagepath) {

	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

	

	winWidth = 500;

	winHeight = 400;

	

	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 chkSendComments()

{

	name = trimSpaces(document.sendcomments.name.value);

	if(name.length <= 0) 

	{

		alert("Please enter the name");

		sendcomments.name.focus();

		return false;

	}

	if(trimSpaces(sendcomments.email.value).length <= 0) 

	{

		alert("Please enter your email");

		sendcomments.email.focus();

		return false;

	}

	if(!checkEmail(document.sendcomments.email.value)){

		document.sendcomments.email.focus();

		 return false;

	    }

	thecode = trimSpaces(document.sendcomments.thecode.value);

	if(thecode.length <= 0) 

	{

		alert("Please enter the number");

		sendcomments.thecode.focus();

		return false;

	}	

		

	document.sendcomments.frmAction.value = "update";	

}

function markAsObjecction(comment_id)

{

	

	if (!confirm("Do you really want to mark this entry \n as objectionable?"))

		return;

	else

	{

		document.frm.frmAction.value ="objection";

		document.frm.comment_id.value = comment_id ;

		document.frm.submit();

	}

		

		

}



function checkGuestBook() {

	document.gfrm.name.value = trimSpaces(document.gfrm.name.value);

	if(document.gfrm.name.value.length <= 0) {

		alert("Please enter your name");

		document.gfrm.name.focus();

		return false;

	}

	document.gfrm.email.value = trimSpaces(document.gfrm.email.value);

	if(document.gfrm.email.value.length <= 0) {

		alert("Please enter your email address");

		document.gfrm.email.focus();

		return false;

	}

	if(!checkEmail(document.gfrm.email.value)) {

		document.gfrm.email.focus();

		document.gfrm.email.select();

		return false;

	}

	document.gfrm.comments.value = trimSpaces(document.gfrm.comments.value);

	if(document.gfrm.comments.value.length <= 0) {

		alert("Please enter your comments");

		document.gfrm.comments.focus();

		return false;

	}

	thecode = trimSpaces(document.gfrm.thecode.value);

	if(thecode.length <= 0) 

	{

		alert("Please enter the number");

		gfrm.thecode.focus();

		return false;

	}	

	document.gfrm.frmAction.value = "update";

}





function checkGuestBookResponse() {

	document.gfrm.visitorName.value = trimSpaces(document.gfrm.visitorName.value);

	if(document.gfrm.visitorName.value.length <= 0) {

		alert("Please enter your name");

		document.gfrm.visitorName.focus();

		return false;

	}

	document.gfrm.emailAddress.value = trimSpaces(document.gfrm.emailAddress.value);

	if(document.gfrm.emailAddress.value.length <= 0) {

		alert("Please enter your email address");

		document.gfrm.emailAddress.focus();

		return false;

	}

	if(!checkEmail(document.gfrm.emailAddress.value)) {

		document.gfrm.emailAddress.focus();

		document.gfrm.emailAddress.select();

		return false;

	}

	document.gfrm.visitorComments.value = trimSpaces(document.gfrm.visitorComments.value);

	if(document.gfrm.visitorComments.value.length <= 0) {

		alert("Please enter your comments");

		document.gfrm.visitorComments.focus();

		return false;

	}

	document.gfrm.frmAction.value = "update";

}



	function showIcon(iconUrl) {

	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

	

	winWidth = 300;

	winHeight = 300;

	

	sLeft = (sWidth - winWidth) / 2;

	sTop = (sHeight - winHeight) / 2;

	

	window.open("showIcon.php?iconUrl=" + iconUrl,"iconURL","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");

}

function detePhoto(id)

{

	m='Do you really want to delete Photo ?'; 	

	if(!confirm(m)) 

	{

	}else {

	document.Ypcatfrm.id.value=id;	

	document.Ypcatfrm.frmAction.value='delphoto';

	document.Ypcatfrm.submit();

	}	

}

function chkUserLogin2()

{	

		if(document.memberlogin.email.value=="")

		{

		alert("Enter Email address");

		document.memberlogin.email.focus();

		return false;

		}

		if(!checkEmail(document.memberlogin.email.value)){

		document.memberlogin.email.focus();

		 return false;

	    }

	

		if(document.memberlogin.password.value=="")

		{

		alert("Enter password");

		document.memberlogin.password.focus();

		return false;

		

   		}

		

	document.memberlogin.frmAction.value = "login";

}

function chkRecip()

{

   name=trimSpaces(document.addRecipe.contributor.value);

   email=trimSpaces(document.addRecipe.email.value);

   title=trimSpaces(document.addRecipe.rec_title.value);

   if(name.length<=0)

    {

	 alert("Please enter the name");

	 document.addRecipe.contributor.focus();

	 return false;

	}

	if(email.length<=0)

    {

	 alert("Please enter the email"); 

	 document.addRecipe.email.focus();

	 return false;

	}

	if(title.length<=0)

    {

	 alert("Please enter the Recipe Title");

	 document.addRecipe.rec_title.focus();

	 return false; 

	}

	if(document.addRecipe.category1.selectedIndex < 1)

	 {

	 alert("Please select the category");  

	 document.addRecipe.category1.focus();

	 return false;

	 }

document.addRecipe.frmAction.value="update";



}

function deteRecipesPhoto(id)

{

	m='Do you really want to delete Photo ?'; 	

	if(!confirm(m)) 

	{

	}else {

	document.addRecipe.id.value=id;	

	document.addRecipe.frmAction.value='delphoto';

	document.addRecipe.submit();

	}	

}

function showpicRecipe(id) 

{

	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

	winWidth=500;

	winHeight=600;

	sLeft = (sWidth - winWidth) / 2;

	sTop = (sHeight - winHeight) / 2; 



	window.open("showRecipePhoto.php?id="+id, "Recipes", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");

	return;

} 

function rateIt(id) {

	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

	winWidth=500;

	winHeight=500; 

	sLeft = (sWidth - winWidth) / 2;

	sTop = (sHeight - winHeight) / 2;



	window.open("ratethisRecipe.php?id="+id, "recipes", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");

	return;

} 

function checkrecipeMail()

{ 

  uname=trimSpaces(document.emailRecipe.uname.value);

  umail=trimSpaces(document.emailRecipe.umail.value);

  rmail1=trimSpaces(document.emailRecipe.rmail1.value);

  rmail2=trimSpaces(document.emailRecipe.rmail2.value);

  rmail3=trimSpaces(document.emailRecipe.rmail3.value);

  rmail4=trimSpaces(document.emailRecipe.rmail4.value);

  comments=trimSpaces(document.emailRecipe.comments.value);

  if(uname.length<=0)

   {

    alert("Please enter your name");

	document.emailRecipe.uname.focus();

	return false;

   }

  if(umail.length<=0)

  {

     alert("Please enter your e-mail");

	  document.emailRecipe.umail.focus();

	return false;

  }

  else

  {

    if(!checkEmail(umail))

	  {

	   document.emailRecipe.umail.focus();

	   return false;

	  }

	 

  }

 if(rmail1.length>0 || rmail2.length>0 || rmail3.length>0 || rmail4.length>0) 

  {

  if(rmail1.length>0)

  {

    if(!checkEmail(rmail1))

	  {

	   document.emailRecipe.rmail1.focus();

	   return false;

	  }

  

  } 

  }

  else

  {

  alert("You have to enter atleast a recipient e-mail");

  return false;

  }

   if(comments.length<=0)

   {

    alert("Please enter your comments");

	document.emailRecipe.comments.focus();

	return false;

   }

  document.emailRecipe.frmAction.value="send";

  document.emailRecipe.submit(); 



}





function doSiteSearch(frm)

{

	if (trimSpaces(frm.txtKey.value) == '' )

	{

		alert("Please enter the search keyword");

		frm.txtKey.focus();

		return false;

	}

	frm.frmAction.value = "search";

}



function deleteYpEntries(id)

{

	m='Do you really want to delete this record?'; 	

	if(!confirm(m)) 

	{

	}else {

	document.mYpent.id.value=id;	

	document.mYpent.frmAction.value='delYp';

	document.mYpent.submit();

	}	

}











