function closeWindow() {

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

	parent.window.close();

}



function printWindow() {

	window.print();

}





function chkUserLogin()

{	

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

		{

		alert("Enter Email address");

		document.userlogin.email.focus();

		return false;

		}

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

		document.userlogin.email.focus();

		 return false;

	    }

	

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

		{

		alert("Enter password");

		document.userlogin.password.focus();

		return false;

		

   		}

		

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

	document.userlogin.submit();	

}



function ChkUserRegn(){

	

	document.userreg.first_name.value = trimSpaces(document.userreg.first_name.value);

	if(document.userreg.first_name.value.length <= 0) {

		alert("Please enter your first name");

		document.userreg.first_name.focus();

		return false;

	}

	document.userreg.last_name.value = trimSpaces(document.userreg.last_name.value);

	if(document.userreg.last_name.value.length <= 0) {

		alert("Please enter your last name");

		document.userreg.last_name.focus();

		return false;

	}

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

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

		document.userreg.email.focus();

		return false;

	}

	

	document.userreg.city.value = trimSpaces(document.userreg.city.value);

	if(document.userreg.city.value.length <= 0) {

		alert("Please enter your city");

		document.userreg.city.focus();

		return false;

	}

	

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

	{

		alert("Please select the birth year");

		document.userreg.birth_year.focus();

		return false;

	}

	

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

	{

		alert("Please select the birth month");

		document.userreg.birth_mon.focus();

		return false;

	}	



	document.userreg.frmAction.value = "join";

	document.userreg.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 ChkActivateEmail(f)

{

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

	{

		alert("Please enter your email");

		f.email.focus();

		return false;

	}

f.frmAction.value = "activate";	

}





function valAddProfile()

{

	pcat_id = trimSpaces(document.profForm.pcat_id.value);

	if(pcat_id.length <= 0) 

	{

		alert("Please select the category");

		document.profForm.pcat_id.focus();

		return false;

	}

	prof_name = trimSpaces(document.profForm.prof_name.value);

	if(prof_name.length <= 0) 

	{

		alert("Please enter the name");

		profForm.prof_name.focus();

		return false;

	}

	if(trimSpaces(document.profForm.email.value)){

		if(!checkEmail(document.profForm.email.value)) 

		{

			document.profForm.email.focus();

			return false;

		}

	}

	dob = trimSpaces(document.profForm.dob.value);

	if(dob.length <= 0) 

	{

		alert("Please enter the date of birth");

		profForm.dob.focus();

		return false;

	}



	contents = trimSpaces(getEditorValue('prof_desc'));

	

	if(contents.length <= 0) 

	{

			alert("please enter the description");

			return false;

	}

	

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

}



function showProfilePhoto(id) {

	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

	

	winWidth = 450;

	winHeight = 400;

	

	sLeft = (sWidth - winWidth) / 2;

	sTop = (sHeight - winHeight) / 2;

	

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

}

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 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 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 checkGB(f) {

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

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

		alert("Please enter your name");

		f.name.focus();

		return false;

	}



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

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

		alert("Please enter your email address");

		f.email.focus();

		return false;

	}

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

		f.email.select();

		return false;

	}



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

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

		alert("Please enter your comments");

		f.comments.focus();

		return false;

	}
	f.thecode.value = trimSpaces(f.thecode.value);

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

		alert("Please enter the code above");

		f.thecode.focus();

		return false;

	}

	

	f.frmAction.value = "update";

	return true;

}

function checkPrayer() {

	

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

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

		alert("Please enter your first name");

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

		return false;

	}

	

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

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

		alert("Please enter your last name");

		document.forms[0].l_name.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].message.value = trimSpaces(document.forms[0].message.value);

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

		alert("Please enter your prayer");

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

		return false;

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

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

		alert("Please enter the code above");

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

		return false;

	}
	

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

}