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 chkUserLogin1()
{	
		if(document.userlogin1.email.value=="")
		{
		alert("Enter Email address");
		document.userlogin1.email.focus();
		return false;
		}
		if(!checkEmail(document.userlogin1.email.value)){
		document.userlogin1.email.focus();
		 return false;
	    }
	
		if(document.userlogin1.password.value=="")
		{
		alert("Enter password");
		document.userlogin1.password.focus();
		return false;
		
   		}
		
	document.userlogin1.frmAction.value = "login";
	document.userlogin1.submit();	
}

function ChkUserRegn(){
	
	userreg.first_name.value = trimSpaces(userreg.first_name.value);
	if(userreg.first_name.value.length <= 0) {
		alert("Please enter your first name");
		userreg.first_name.focus();
		return false;
	}
	userreg.last_name.value = trimSpaces(userreg.last_name.value);
	if(userreg.last_name.value.length <= 0) {
		alert("Please enter your last name");
		userreg.last_name.focus();
		return false;
	}
	userreg.email.value = trimSpaces(userreg.email.value);
	if(!checkEmail(userreg.email.value)) {
		userreg.email.focus();
		return false;
	}
	
	userreg.city.value = trimSpaces(userreg.city.value);
	if(userreg.city.value.length <= 0) {
		alert("Please enter your city");
		userreg.city.focus();
		return false;
	}
	
	if(trimSpaces(userreg.birth_year.options[userreg.birth_year.selectedIndex].value).length <= 0) 
	{
		alert("Please select the birth year");
		userreg.birth_year.focus();
		return false;
	}
	
	if(trimSpaces(userreg.birth_mon.options[userreg.birth_mon.selectedIndex].value).length <= 0) 
	{
		alert("Please select the birth month");
		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 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 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;
		}
	}
	

	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 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 delProfile(profile_id)
{
	if(confirm('Do you really want to delete this profile ?')) 
	{
	document.profForm.frmAction.value ='delProf';
	document.profForm.profile_id.value =profile_id;
	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 == 0)
	{
		alert("Please select a category");
		document.searchFrm.pcat_id.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;
	}
	comments = trimSpaces(document.sendcomments.comments.value);
	if(comments.length <= 0) 
	{
		alert("Please enter the comments");
		sendcomments.comments.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 chkSendCommentsandLogin()
{ 

	name = trimSpaces(document.sendcomments.name.value);
	if(name.length <= 0) 
	{
		alert("Please enter the name");
		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");
		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 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 invalidcomments()
{
	
	
	
	userreg.name.value = trimSpaces(userreg.name.value);
	if(userreg.name.value.length <= 0) {
		alert("Please enter your  name");
		userreg.name.focus();
		return false;
	}
	userreg.comments.value = trimSpaces(userreg.comments.value);
	if(userreg.comments.value.length <= 0) {
		alert("Please enter your  comments");
		userreg.comments.focus();
		return false;
	}
	userreg.thecode.value = trimSpaces(userreg.thecode.value);
	if(userreg.thecode.value.length <= 0) {
		alert("Please enter  thecode");
		userreg.thecode.focus();
		return false;
	}
	
	
	
	userreg.first_name.value = trimSpaces(userreg.first_name.value);
	if(userreg.first_name.value.length <= 0) {
		alert("Please enter your first name");
		userreg.first_name.focus();
		return false;
	}
	userreg.last_name.value = trimSpaces(userreg.last_name.value);
	if(userreg.last_name.value.length <= 0) {
		alert("Please enter your last name");
		userreg.last_name.focus();
		return false;
	}
	
	userreg.email.value = trimSpaces(userreg.email.value);
	if(!checkEmail(userreg.email.value)) {
		userreg.email.focus();
		return false;
	}
	
	userreg.city.value = trimSpaces(userreg.city.value);
	if(userreg.city.value.length <= 0) {
		alert("Please enter your city");
		userreg.city.focus();
		return false;
	}
	
	if(trimSpaces(userreg.birth_year.options[userreg.birth_year.selectedIndex].value).length <= 0) 
	{
		alert("Please select the birth year");
		userreg.birth_year.focus();
		return false;
	}
	
	if(trimSpaces(userreg.birth_mon.options[userreg.birth_mon.selectedIndex].value).length <= 0) 
	{
		alert("Please select the birth month");
		userreg.birth_mon.focus();
		return false;
	}	

	document.userreg.frmAction.value = "join";
	document.userreg.submit();
}
function showSentComments(id)
{
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth = 450;
	winHeight = 320;
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open("showSentPosts.php?profileid=" +id,"Details","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");

}
