function closeWindow() {
	parent.window.opener.window.focus();
	parent.window.close();
}

function printWindow() 
{
	window.print();
}

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 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 del(f,c){
		count		=	c;
		flag		=	0;
		if(count==0){
			alert("Nothing to delete");
			return false;
		}
		if(count>1){
			for(i=0;i<count;i++){
				if(f.elements["delid[]"][i].checked&&flag==0){
					flag	=	1;
				}
		
			}
		}else if(count==1)		
			if(f.elements["delid[]"].checked&&flag==0){
				flag	=	1;
			}
		if(flag == 0){
			alert("Nothing selected for deletion");
			return false;
		}else{
			if(!confirm("Do you really want to delete these items?")) {
				return false;
			}
		}
		
		f.frmAction.value='delete';
		f.submit();
	}
	
	
function checkGB(f) {
	f.visitorName.value = trimSpaces(f.visitorName.value);
	if(f.visitorName.value.length <= 0) {
		alert("Please enter your name");
		f.visitorName.focus();
		return false;
	}

	f.emailAddress.value = trimSpaces(f.emailAddress.value);
	if(f.emailAddress.value.length <= 0) {
		alert("Please enter your email address");
		f.emailAddress.focus();
		return false;
	}
	if(!checkEmail(f.emailAddress.value)) {
		f.emailAddress.select();
		return false;
	}

	f.visitorComments.value = trimSpaces(f.visitorComments.value);
	if(f.visitorComments.value.length <= 0) {
		alert("Please enter your comments");
		f.visitorComments.focus();
		return false;
	}
	
	if(f.thecode.value==""){
		alert("The verification number must be entered as in the above image");
		f.thecode.select();
		return false;
	}
	f.frmAction.value = "login";
	return true;
}
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 postComments(){
	if(document.frmPost.name.value==""){
		alert("Please enter your name");
		document.frmPost.name.select();
		return false;
	}
	
	
	document.frmPost.email.value = trimSpaces(document.frmPost.email.value);
	if(document.frmPost.email.length <= 0) {
		alert("Please enter your email address");
		document.frmPost.email.focus();
		return false;
	}
	if(!checkEmail(document.frmPost.email.value)) {
		document.frmPost.email.focus();
		document.frmPost.email.select();
		return false;
	}
	
	if(trimSpaces(document.frmPost.comments.value) == ""){
		alert("Please enter your comments");
		document.frmPost.comments.focus();
		return false;
	}
	if(document.frmPost.thecode.value==""){
		alert("The verification number must be entered as in the above image");
		document.frmPost.thecode.select();
		return false;
	}
	//alert("inside postComment");
	document.frmPost.frmAction.value = "update";
	document.frmPost.submit();
}


function ChkUserLogin(f,linkid)
{	
		
	switch(linkid){
		case 10:
	
			if(!checkGB(f))
				return false;
			break;
		case 0:
			if(!checkGB(f))
				return false;
			
			if(linkid == 0 ){
				return true;
			}
			break;
	}

	if(f.email.value=="")
	{
		alert("Enter Email address");
		f.email.focus();
		return false;
	}
	if(!checkEmail(f.email.value)){
		f.email.focus();
		 return false;
	}

	if(f.password.value=="")
	{
		alert("Enter password");
		f.password.focus();
		return false;
	}
		
	f.frmAction.value = "login";
	
	f.submit();	
}

function ChkUserRegn(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_year.options[f.birth_year.selectedIndex].value).length <= 0) 
	{
		alert("Please select the birth year");
		f.birth_year.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;
	}	

	f.frmAction.value = "join";
	f.submit();
}

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 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;
		}
		f.frmAction.value = "update";
}
function valAddEvent()
{
	event_date = trimSpaces(document.evntFrm.event_date.value);
	if (event_date == '')
	{
		alert("Please select event date");
		document.evntFrm.event_date.focus();
		return false;
	}

	event_head = trimSpaces(document.evntFrm.event_head.value);
	if (event_head == '')
	{
		alert("Please enter event heading");
		document.evntFrm.event_head.focus();
		return false;
	}

	if(trimSpaces(getEditorValue('event_desc')) == "") {
		alert("please enter the description");
		return false;
	}
document.evntFrm.frmAction.value = "update";
}

function searchFromHome(page)
{
	if(page == 'home') {
		val = 'php/';
	}else {val = '../php/';}
	txtKey = trimSpaces(document.searchFrm.txtKey.value);
	if(txtKey == '') {
		alert("Enter search string");
		document.searchFrm.txtKey.focus();
		if(page=='home')
			return false;
		else
    		return false;
	}
	document.searchFrm.frmAction.value = "search";
	document.searchFrm.action = val+"searchResults.php";
	
}

 function doClear(theText) 
{
     if (theText.value == theText.defaultValue)
 {
         theText.value = ""
     }
 }
 
 
 function checkKey(page){
	if(window.event.keyCode == 13) {
		if(page == 'home') {
			val = 'php/';
		}else {val = '';}

		txtKey = trimSpaces(document.searchFrm.txtKey.value);
		if(txtKey == '') {
			alert("Enter search string");
			document.searchFrm.txtKey.focus();
			return false;
		}else {
			document.searchFrm.action = val+"displaySearch.php";
			document.searchFrm.submit();
		}		
	}
}

function chkSendComments()
{
	name = trimSpaces(document.sendcomments.name.value);
	if(name.length <= 0) 
	{
		alert("Please enter the name");
		document.sendcomments.name.focus();
		return false;
	}
	comments = trimSpaces(document.sendcomments.comments.value);
	if(comments.length <= 0) 
	{
		alert("Please enter the comments");
		document.sendcomments.comments.focus();
		return false;
	}
	

	thecode = trimSpaces(document.sendcomments.thecode.value);
	if(thecode.length <= 0) 
	{
		alert("Please enter the number");
		document.sendcomments.thecode.focus();
		return false;
	}	
		
	document.sendcomments.frmAction.value = "update";	
}
function chkSendCommentsandLogin()
{ 

	name = trimSpaces(document.sendcomments.name.value);
	if(name.length <= 0) 
	{
		alert("Please enter the name");
		document.sendcomments.name.focus();
		return false;
	}
	
	
	

	document.sendcomments.comments.value = trimSpaces(document.sendcomments.comments.value);	
	if(document.sendcomments.comments.value.length <= 0) {
		alert("Please enter comments");
		document.sendcomments.comments.focus();
		return false;
	}
	
	
	
	
	thecode = trimSpaces(document.sendcomments.thecode.value);
	if(thecode.length <= 0) 
	{
		alert("Please enter the number");
		document.sendcomments.thecode.focus();
		return false;
	}	
	document.sendcomments.emailAddress.value = trimSpaces(document.sendcomments.emailAddress.value);
	
	
	
	if(document.sendcomments.emailAddress.value.length <= 0) {
		alert("Please enter your email address");
		document.sendcomments.emailAddress.focus();
		return false;
	}
	if(!checkEmail(document.sendcomments.emailAddress.value)) {
		document.sendcomments.emailAddress.focus();
		document.sendcomments.emailAddress.select();
		return false;
	}
	document.sendcomments.password.value = trimSpaces(document.sendcomments.password.value);	
	if(document.sendcomments.password.value.length <= 0) {
		alert("Please enter Password");
		document.sendcomments.password.focus();
		return false;
	}
	
	
		
		
	document.sendcomments.frmAction.value = "update";	
}

function invalidcomments()
{
	
	
	
	document.userreg.name.value = trimSpaces(document.userreg.name.value);
	if(document.userreg.name.value.length <= 0) {
		alert("Please enter your  name");
		document.userreg.name.focus();
		return false;
	}
	document.userreg.comments.value = trimSpaces(document.userreg.comments.value);
	if(document.userreg.comments.value.length <= 0) {
		alert("Please enter your  comments");
		document.userreg.comments.focus();
		return false;
	}
	document.userreg.thecode.value = trimSpaces(document.userreg.thecode.value);
	if(document.userreg.thecode.value.length <= 0) {
		alert("Please enter  thecode");
		document.userreg.thecode.focus();
		return false;
	}
	
	
	
	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 showForgotPass()
{
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth = 400;
	winHeight = 220;
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open("../php/forgotPasswordTwo.php","Details","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}

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");
		document.profForm.prof_name.focus();
		return false;
	}
	if(trimSpaces(document.profForm.email.value)){
		if(!checkEmail(document.profForm.email.value)) 
		{
			document.profForm.email.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 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 validate(f){
	if(trimSpaces(f.pcat_id.options[f.pcat_id.selectedIndex].value).length <= 0) {
		alert("Select a category");
		f.pcat_id.select;
		return false;
	}
	if(trimSpaces(f.profile_id.options[f.profile_id.selectedIndex].value).length <= 0) {
		alert("Select a profile");
		f.profile_id.select;
		return false;
	}
}

function ChkGBUser(f){
	f.visitorName.value = trimSpaces(f.visitorName.value);
	if(f.visitorName.value.length <= 0) {
		alert("Please enter your name");
		f.visitorName.focus();
		return false;
	}

	f.emailAddress.value = trimSpaces(f.emailAddress.value);
	if(f.emailAddress.value.length <= 0) {
		alert("Please enter your email address");
		f.emailAddress.focus();
		return false;
	}
	if(!checkEmail(f.emailAddress.value)) {
		f.emailAddress.select();
		return false;
	}

	f.visitorComments.value = trimSpaces(f.visitorComments.value);
	if(f.visitorComments.value.length <= 0) {
		alert("Please enter your comments");
		f.visitorComments.focus();
		return false;
	}
	
	if(f.thecode.value==""){
		alert("The verification number must be entered as in the above image");
		f.thecode.select();
		return false;
	}
	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_year.options[f.birth_year.selectedIndex].value).length <= 0) 
	{
		alert("Please select the birth year");
		f.birth_year.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;
	}	

	f.frmAction.value = "join";
	f.submit();
}