// JavaScript Document

function closeWindow() {

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

	parent.window.close();

}



function printWindow() 

{

	window.print();

}

function clientfunction()

			{



				var msg=""

				if(document.frmReg.title.value == "")				

				{

					alert("Title cannot be left blank\n");

					document.frmReg.title.select();

					return false

				}

				if((document.frmReg.category_id.value==0)&&(document.frmReg.category_other.value==""))

				{

					alert("You have selected others. So, New Category should be mentioned\n");

					document.frmReg.category_other.focus();

					return false

				}

				

				if(document.frmReg.completestory.value == "")
				{

					alert("Kindly enter a value for Complete Story");

					document.frmReg.completestory.focus();

					return false

				}



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

				document.frmReg.submit();

			}	

function getEditorValue( instanceName ) 

	{  

	  // Get the editor instance that we want to interact with.

	  var oEditor = FCKeditorAPI.GetInstance( instanceName ) ;

	  

	  // Get the editor contents as XHTML.

	  return oEditor.GetXHTML( true ) ;  // "true" means you want it formatted.

	}



function showCalendar(frmElement, dispElement) {

	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

	

	winWidth = 375;

	winHeight = 300;

	

	sLeft = (sWidth - winWidth) / 2;

	sTop = (sHeight - winHeight) / 2;



	window.open("showCalendar.php?frmElement=" + frmElement + "&dispElement=" + dispElement, "Calendar", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");

	return;

}

function openNewWindow(pagepath) {

	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

	

	winWidth = 550;

	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 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 checkRegistration() {

	if(trimSpaces(document.forms[0].businessCategory.options[document.forms[0].businessCategory.selectedIndex].value).length <= 0) 

	{

		alert("Please select the business category");

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

		return false;

	}

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

		alert("Please provide the business name");

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

		return false;

	}

	

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

		alert("Please provide the address");

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

		return false;

	}

	

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

}



function checkContact()

{

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

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

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

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

	

	if(visitorName == "")

	{

		alert("Please enter your name");

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

		return false;

	}

	if(visitorEmail == "")

	{

		alert("Please enter your email");

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

		return false;

	}

	if(!checkEmail(visitorEmail))

	{

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

		return false;

	}

	if(visitorPhone == "")

	{

		alert("Please enter your phone number");

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

		return false;

	}

	if(visitorComments == "")

	{

		alert("Please enter your comments");

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

		return false;

	}

	

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

	return true;

}



function checkBusinessListing()

{

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

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

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

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

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

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

	

	if(trimSpaces(document.forms[0].businessCategory.options[document.forms[0].businessCategory.selectedIndex].value).length <= 0) 

	{

			alert("Please select the business category");

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

			return false;

	}

	if(company_name.length<=0)

	{

	alert("Please Enter the Company name" );

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

	return false;

	}

	if(description.length<=0)

	{

	alert("Please Enter the Description");

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

	return false;

	}

	if(contact_person.length<=0)

	{

	alert("Please Enter the Name of the contact person");

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

	return false;

	}

	if(contact_phone.length<=0)

	{

	alert("Please Enter the contact phone");

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

	return false;

	}



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

}



function checkContact() {

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

	visitorEmail = trimSpaces(document.feedbackForm.visitorEmail.value);

	visitorPhone = trimSpaces(document.feedbackForm.visitorPhone.value);

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

	

	if(visitorName.length <= 0) {

		alert("Please provide your name before submitting the form");

		document.feedbackForm.visitorName.focus();

		return false;

	}

	

	if(visitorEmail.length <= 0) {

		alert("Please provide your email address before submitting the form");

		document.feedbackForm.visitorEmail.focus();

		return false;

	}

	

	if(!checkEmail(visitorEmail)) {

		document.feedbackForm.visitorEmail.focus();

		return false;

	}

	

	if(visitorComments.length <= 0) {

		alert("Please mention your queries or suggestions before submitting the form");

		document.feedbackForm.visitorComments.focus();

		return false;

	}

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

}



function checkSubscription(action)

{

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

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

	 {

	 	alert("Please enter your Name");

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

		return false;

	 }

	 	   	

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

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

	{

	 	alert("Please enter your Email Id");

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

		return false;

	}

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

	{

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

	    return false;

	}

	 

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

}



function showCoupon(galleryid) {

	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

	

	winWidth = 600;

	winHeight = 500;

	

	sLeft = (sWidth - winWidth) / 2;

	sTop = (sHeight - winHeight) / 2;



	window.open("showCouponFrame.php?couponid=" + galleryid , "picture", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");

	return;

}

function checkLogin() {

	document.loginForm.username.value = trimSpaces(document.loginForm.username.value);

	if(document.loginForm.username.value.length <= 0) {

		alert("Please enter the username");

		document.loginForm.username.focus();

		return false;

	}

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

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

		alert("Please enter password");

		document.loginForm.password.focus();

		return false;

	}

}



function checkLogin1() {



document.loginForm1.username.value = trimSpaces(document.loginForm1.username.value);

	if(document.loginForm1.username.value.length <= 0) {

		alert("Please enter the username");

		document.loginForm1.username.focus();

		return false;

	}

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

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

		alert("Please enter password");

		document.loginForm1.password.focus();

		return false;

	}

}





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 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 removeIcon(url,type,picId)

{

  document.forms[0].picId.value=picId;

  document.forms[0].url.value=url;

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

  document.forms[0].submit();

}

*/

function removeIcon(iconUrl) {

	if(iconUrl.length > 0) {

		if(confirm("Do you really want to delete this icon?")) {

			document.frmReg.frmAction.value = "removeIcon";

			document.frmReg.iconURL.value = iconUrl;

			document.frmReg.submit();

		}

		else {

			return;

		}

	}

}



function removeMemberPhoto(photoUrl,iconUrl) {

	if(photoUrl.length > 0) {

		if(confirm("Do you really want to delete this photo?")) {

			document.frmReg.frmAction.value = "removePhoto";

			document.frmReg.photoURL.value = photoUrl;

			document.frmReg.iconURL.value = iconUrl;

			document.frmReg.submit();

		}

		else {

			return;

		}

	}

}



function removePostingPhoto(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 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 postComments(){

	if(document.frmPost.name.value==""){

		alert("Name cannot be left blank");

		document.frmPost.name.select();

		return false;

	}

	if(valid_email(document.frmPost.email.value)){

		alert("Invalid Email Id \n");

		document.frmPost.email.select();

		return false;

	}

	if(document.frmPost.comments.value==""){

		alert("Comments cannot be left Blank");

		document.frmPost.comments.select();

		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 = "insert";

	document.frmPost.submit();

}



			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 postCommentsFeedback(){

	alert("inside postComment");

	if(document.feedback.name.value==""){

		alert("Name cannot be left blank");

		document.feedback.name.select();

		return false;

	}

	if(valid_email(document.feedback.email.value)){

		alert("Invalid Email Id \n");

		document.feedback.email.select();

		return false

	}

	//alert("inside postComment");

	document.feedback.frmAction.value = "insert";

	document.feedback.submit();

}

function checkEmail(emailString) {

	splitVal = emailString.split('@');

	if(splitVal.length <= 1) {

		alert("Please enter a valid email address");

		return false;

	}

	if(splitVal[0].length <= 0 || splitVal[1].length <= 0) {

		alert("Please enter a valid email address");

		return false;

	}

	

	splitDomain = splitVal[1].split('.');

	if(splitDomain.length <= 1) {

		alert("Please enter a valid email address");

		return false;

	}

	if(splitDomain[0].length <= 0 || splitDomain[1].length <= 1) {

		alert("Please enter a valid email address");

		return false;

	}

	return true;

}

function checkSubscription()

{

	document.contactForm.lastName.value=trimSpaces(document.contactForm.lastName.value);

	if(document.contactForm.lastName.value.length<=0)

	 {

	 	alert("Enter your Last Name");

		document.contactForm.lastName.focus();

		return false;

	 }



	document.contactForm.firstName.value=trimSpaces(document.contactForm.firstName.value);

	if(document.contactForm.firstName.value.length<=0)

	 {

	 	alert("Enter your First Name");

		document.contactForm.firstName.focus();

		return false;

	 }



	   	

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

	if(document.contactForm.email.value.length<=0)

	 {

	 	alert("Enter Email Id");

		document.contactForm.email.focus();

		return false;

	 }

	else

	 {

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

	   {

		document.contactForm.email.focus();

	    return false;

	   }

	 }  	 

	 

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

	document.contactForm.submit();

}



function checkLetter(){

	

	if(document.formletter.loc_id.options[document.formletter.loc_id.selectedIndex].value == "")

	{

		alert("Please select a Location"); 

		document.formletter.loc_id.focus();

		return false;

	}



	if(document.formletter.of_id.options[document.formletter.of_id.selectedIndex].value == "")

	{

		alert("Please select an official"); 

		document.formletter.of_id.focus();

		return false;

	}

	

	if(document.formletter.name.value == ""){

		alert("Sender Name cannot be left blank"); 

		document.formletter.name.select();

		return false;

	}

	if(valid_email(document.formletter.email.value)){

		alert("Invalid Email Id \n");

		document.formletter.email.select();

		return false

	}

	if(document.formletter.comments.value == ""){

		alert("Letter cannot be left blank"); 

		document.formletter.comments.select();

		return false;

	}

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

	//document.formletter.submit();

}	

function officialfunction(){

	

	if(document.formoff.state_id.value == "")

	{

		alert("Please select a state"); 

		document.formoff.state_id.focus();

		return false;

	}

	if(document.formoff.of_name.value==""){

		alert("Official's Name cannot be left blank"); 

		document.formoff.of_name.select();

		return false;

	}

	if(document.formoff.of_desig.value==""){

		alert("Official's Designaton cannot be left blank"); 

		document.formoff.of_desig.select();

		return false;

	}

	/*

	if(valid_email(document.formoff.of_email.value)){

		alert("Invalid Email Id \n");

		document.formoff.of_email.select();

		return false

	}

	*/

	if(document.formoff.of_profile.value==""){

		alert("Kindly enter a value for Profile");

		document.formoff.of_profile.select();

		return false;

	}



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

	document.formoff.submit();

	

}	

function showEmailto(url1,url2,url3,url4,url5) {

	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

	

	winWidth = 450;

	winHeight = 310;

	

	sLeft = (sWidth - winWidth) / 2;

	sTop = (sHeight - winHeight) / 2;



//window.open("showCalendar.php?frmElement=" + frmElement + "&dispElement=" + dispElement, "

			  

window.open("../php/showEmailtoFriend.php?url1=" + url1 + "&url2=" + url2 + "&url3=" + url3 + "&url4=" + url4 + "&url5=" + url5, "Calendar", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");

	return;

}

function chekemailtofriend()

{

	if(document.frm.yourname.value=="")

	{

		alert("Enter Your Name");

		document.frm.yourname.focus();

		return false;		

	}

	if(valid_email(document.frm.youraddress.value))

	{

		alert("Enter a valid  Email address");

		document.frm.youraddress.focus();

		return false;

		

	}

	if(document.frm.friendname.value=="")

	{

		alert("Enter Your friends Name");

		document.frm.friendname.focus();

		return false;		

	}

	if(valid_email(document.frm.friendemail.value))

	{

		alert("Enter a valid  friends Email address");

		document.frm.friendemail.focus();

		return false;

		

	}

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

	

}

function showcosign(url1) {

	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

	

	winWidth = 450;

	winHeight = 300;

	

	sLeft = (sWidth - winWidth) / 2;

	sTop = (sHeight - winHeight) / 2;

	  

window.open("../php/showCoSign.php?url1=" + url1, "Calendar", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");

	return;

}

function chekCosign()

{

	if(document.frm.yourname.value=="")

	{

		alert("Enter Your Name");

		document.frm.yourname.focus();

		return false;		

	}

	if(valid_email(document.frm.youraddress.value))

	{

		alert("Enter a valid  Email address");

		document.frm.youraddress.focus();

		return false;

		

	}

	

	if(document.frm.city.value=="")

	{

		alert("Enter city");

		document.frm.city.focus();

		return false;		

	}

	if(document.frm.m_country.value=="")

	{

		alert("Select country");

		document.frm.m_country.focus();

		return false;		

	}

	

	

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

	

}