//banner function

function chkLogin2()  

{   

     path = '../php/';

	 logUsername1 = trimSpaces(document.frmLogin.logUsername1.value);

	logPassword1 = trimSpaces(document.frmLogin.logPassword1.value);

	if (logUsername1 == "")

	{

		alert("Please enter the Email ID");

		document.frmLogin.logUsername1.focus(); 

	}else

	if (logPassword1 == "")

	{

		alert("Please enter the password");

		document.frmLogin.logPassword1.focus();

		

	}else

	{

	document.frmLogin.action = path+"login.php"; 

	document.frmLogin.frmAction.value = "Login";

	document.frmLogin.logout.value = "true";

	document.frmLogin.submit(); 

	} 

}



function checkBannerHome(obj) {

	j = 0;

	

	if(obj.value == 'HO') { //home page

		count = homeBannerText.length;

		document.frmBanner.banner_type_id.length = count;

		for(i=0; i < count; ++i) {

			document.frmBanner.banner_type_id.options[i].text = homeBannerText[i];

			document.frmBanner.banner_type_id.options[i].value = homeBannerValue[i];

		}

	}else if(obj.value == 'NE' || obj.value == 'SH'){ // other pages/wedding shopping

		count = newsBannerText.length;

		document.frmBanner.banner_type_id.length = count;

		for(i=0; i < count; ++i) {

			document.frmBanner.banner_type_id.options[i].text = newsBannerText[i];

			document.frmBanner.banner_type_id.options[i].value = newsBannerValue[i];

		}

	}



}

function checkTravelogue() {

  fName = trimSpaces(document.frmTravelog.fName.value);

  if(fName.length <= 0) {

		alert("Please enter your first name.");

		document.frmTravelog.fName.focus();

		return false;   

	}

	

	lName = trimSpaces(document.frmTravelog.lName.value);

	if(lName.length <= 0) {

		alert("Please enter your last name.");

		document.frmTravelog.lName.focus();

		return false;

	}

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

	if(email.length <= 0) {

		alert("Please enter your email ID");

		document.frmTravelog.email.focus();

		return false;

	}

	if(email.length > 0){

		if(!checkEmail(email)){

			document.frmTravelog.email.focus();

			return false;

		}

	}

	add = trimSpaces(document.frmTravelog.add.value);

	if(add.length <= 0) {

		alert("Please enter your Address");

		document.frmTravelog.add.focus();

		return false;

	}

	caption = trimSpaces(document.frmTravelog.caption.value);

	if(caption.length <= 0) {

		alert("Please enter the caption");

		document.frmTravelog.caption.focus();

		return false;

	}

 desc = trimSpaces(document.frmTravelog.desc.value);

	if(desc.length <= 0) {

		alert("Please enter the description");

		document.frmTravelog.desc.focus();

		return false; 

	}	

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

 document.frmTravelog.action = "submitTravelogue.php";   

}

function checkPhotos() {

	

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

	if(first_name.length <= 0) {

		alert("Please enter your first name.");

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

		return false;

	}

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

	if(last_name.length <= 0) {

		alert("Please enter your last name.");

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

		return false;

	}

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

	if(email.length <= 0) {

		alert("Please enter your email.");

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

		return false;

	}

	if(email.length > 0){

		if(!checkEmail(email)){

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

			return false;

		}

	}

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

	document. forms[0].submit();

}

function chkstate()

{

link1="http://"+document.forms[0].state.options[document.forms[0].state.selectedIndex].value;

window.open(link1);

}

function chkcity()

{

link1="http://"+document.forms[0].city.options[document.forms[0].city.selectedIndex].value;

window.open(link1);

}

function chkcategory()

{

if(document.forms[0].category.options[document.forms[0].category.selectedIndex].value=="X")

   {

    alert("Please select one under that category");

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

   }

else

   {

    link1="http://"+document.forms[0].category.options[document.forms[0].category.selectedIndex].value;

    window.open(link1);

   }

  }

function checkBannerSlot(linkid) {

	count = document.frmBanner.page_type.length;

	for(i = 0; i < count; ++i) {

		if(document.frmBanner.page_type[i].checked && document.frmBanner.page_type[i].value == 'NE') {

			val1 = document.frmBanner.link_id_search.options[document.frmBanner.link_id_search.selectedIndex].value;

			if(val1 == '') {	

				alert("Please select a page");

				document.frmBanner.link_id_search.focus(); 

				return false;

			}

		}

	}

	if(document.frmBanner.banner_start_date.value == '' || document.frmBanner.banner_end_date.value == '') {

		alert("Start date or End date cannot be blank");

		return false;

	}



	document.frmBanner.action = 'searchBanner.php?linkid='+linkid;

	document.frmBanner.frmType.value = 'Search';	

	document.frmBanner.submit();

}

function checkBannerEmail() {

	if(document.frmBanForm.existing_email.value == '') {

		document.frmBanForm.existing_email.focus();

		alert("Enter your email");

		return false;

	}	

	document.frmBanForm.action = 'displayUserDetailsBanner.php';

	document.frmBanForm.frmType.value = 'existing_user';

	document.frmBanForm.submit();

}

function checkbannerUser() { 

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

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

		alert("Please enter the Your Name");

		document.frmBanForm.name.focus();

		return false;

	}

	document.frmBanForm.street.value = trimSpaces(document.frmBanForm.street.value);

	if(document.frmBanForm.street.value.length <= 0) {

		alert("Please enter street");

		document.frmBanForm.street.focus();

		return false;

	}

	document.frmBanForm.addCity.value = trimSpaces(document.frmBanForm.addCity.value);

	if(document.frmBanForm.addCity.value.length <= 0) {

		alert("Please enter city");

		document.frmBanForm.addCity.focus();

		return false;

	}

	document.frmBanForm.addState.value = trimSpaces(document.frmBanForm.addState.value);

	if(document.frmBanForm.addState.value.length <= 0) {

		alert("Please enter state");

		document.frmBanForm.addState.focus();

		return false;

	}

	document.frmBanForm.country.value = trimSpaces(document.frmBanForm.country.value);

	if(document.frmBanForm.country.value.length <= 0) {

		alert("Please enter country");

		document.frmBanForm.country.focus();

		return false;

	}

	document.frmBanForm.zip.value = trimSpaces(document.frmBanForm.zip.value);

	if(document.frmBanForm.zip.value.length <= 0) {

		alert("Please enter zip code");

		document.frmBanForm.zip.focus();

		return false;

	}					

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

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

		alert("Please enter Email");

		document.frmBanForm.email.focus();

		return false;

	}

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

	{

		document.frmBanForm.email.select();

		document.frmBanForm.email.focus();

		return false;

	}

	document.frmBanForm.phone.value = trimSpaces(document.frmBanForm.phone.value);

	if(document.frmBanForm.phone.value.length <= 0) {

		alert("Please enter phone");

		document.frmBanForm.phone.focus();

		return false;

	}

	document.frmBanForm.fax.value = trimSpaces(document.frmBanForm.fax.value);

	document.frmBanForm.action='displayUserDetailsBanner.php';

	document.frmBanForm.frmType.value = 'new_user';

	document.frmBanForm.submit()

}

function checkBannerConfirm() {

	if(document.frmBanForm.banner_image_url.value == '') {

		document.frmBanForm.banner_image_url.focus();

		alert("Enter your banner image");

		return false;

	}

	document.frmBanForm.frmType.value = 'Update';

	document.frmBanForm.action = 'displayUserDetailsBanner.php';

	document.frmBanForm.submit();

}



//used for banners  --end--



function closeWindow() {

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

	parent.window.close();

}



function printWindow() 

{

	window.print();

}

function chkIndexLogin(page)

{ 

	page == 'home' ? path = 'php/' : path = '';

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

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

	if (username == "")

	{

		alert("Please enter the Email ID");

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

		return false;

	}

	if (password == "")

	{

		alert("Please enter the password");

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

		return false;

	}

	document.forms[0].action = path+"login.php";

	document.forms[0].linkid.value = 14;

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

	document.forms[0].submit();

}

// function used in the login.php

function chkLogin(page)

{ 

	page == 'home' ? path = 'php/' : path = '';

	logUsername = trimSpaces(document.frmLog.logUsername.value);

	logPassword = trimSpaces(document.frmLog.logPassword.value);

	if (logUsername == "")

	{

		alert("Please enter the Email ID");

		document.frmLog.logUsername.focus();

		return false;

	}

	if (logPassword == "")

	{

		alert("Please enter the password");

		document.frmLog.logPassword.focus();

		return false;

	}

	document.frmLog.action = path+"login.php";

	document.frmLog.frmAction.value = "Login";

	document.frmLog.submit();

}

// function used in the forgotPassword.php

function chkForm()

{

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

	if (username == "")

	{

		alert("Please enter the Email ID");

		document.frmPass.username.focus();

		return false;

	}

	document.frmPass.frmAction.value="Send";

	document.frmPass.submit();

}



// function usd for search in home page and sub pages

function chkSearch(page)

{

	page == 'home' ? path = 'php/' : path = '';

	document.frmSearch.keywords.value = trimSpaces(document.frmSearch.keywords.value);

	if(document.frmSearch.keywords.value == "")

	{

		alert("Please enter your search keywords");

		document.frmSearch.keywords.focus();

		return false;		

	}

	if(document.frmSearch.keywords.value.length < 3)

	{

		alert("Search keywords should be greater than 3");

		document.frmSearch.keywords.select();

		return false;		

	}

	document.frmSearch.action = path+"loadSearchData.php";

	document.frmSearch.searchPage.value = "true";

	document.frmSearch.submit();

}



// function to validate registerMember form

function chkRegistration()

{ 

	document.frmRegister.regUsername.value = trimSpaces(document.frmRegister.regUsername.value);

	document.frmRegister.regPassword.value = trimSpaces(document.frmRegister.regPassword.value);

	document.frmRegister.cRegPassword.value = trimSpaces(document.frmRegister.cRegPassword.value);

	document.frmRegister.fullname.value = trimSpaces(document.frmRegister.fullname.value);

	document.frmRegister.company_name.value = trimSpaces(document.frmRegister.company_name.value);

	document.frmRegister.street.value = trimSpaces(document.frmRegister.street.value);

	document.frmRegister.description.value = trimSpaces(document.frmRegister.description.value);

	

	if(document.frmRegister.regUsername.value == "")

	{

		alert("Please enter Email Id");

		document.frmRegister.regUsername.focus();

		return false;

	}

	if(!checkEmail(document.frmRegister.regUsername.value ))

	{

		document.frmRegister.regUsername.select();

		return false;

	}

	if(document.frmRegister.regPassword.value == "")

	{

		alert("Please enter password");

		document.frmRegister.regPassword.focus();

		return false;

	}

	if(document.frmRegister.regPassword.value.length < 4)

	{

		alert("Password should be greater than four letters");

		document.frmRegister.regPassword.select();

		return false;

	}

	if(document.frmRegister.regPassword.value != document.frmRegister.cRegPassword.value)

	{

		alert("Confirm password is not matching");

		document.frmRegister.cRegPassword.focus();

		return false;

	}

	if(document.frmRegister.city_id.options[document.frmRegister.city_id.selectedIndex].value == "")

	{

		alert("Please select a city");

		document.frmRegister.city_id.focus();

		return false;

	}

	if(document.frmRegister.fullname.value == "")

	{

		alert("Please enter your name");

		document.frmRegister.fullname.focus();

		return false;

	}

	if(document.frmRegister.member_type_id.options[document.frmRegister.member_type_id.selectedIndex].value == "")

	{

		alert("Please select a member type");

		document.frmRegister.member_type_id.focus();

		return false;

	}

	if(document.frmRegister.company_name.value == "")

	{

		alert("Please enter your company name");

		document.frmRegister.company_name.focus();

		return false;

	}

	if(document.frmRegister.street.value == "")

	{

		alert("Please enter your street address");

		document.frmRegister.street.focus();

		return false;

	}

	if(document.frmRegister.description.value == "")

	{

		alert("Please enter your description");

		document.frmRegister.description.focus();

		return false;

	}

	

	document.frmRegister.frmAction.value = "Register";

	document.frmRegister.submit();

}



// function used in the editprofile.php



function chkProfile()

{

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

	document.frmChange.cpassword.value = trimSpaces(document.frmChange.cpassword.value);

	document.frmChange.fullname.value = trimSpaces(document.frmChange.fullname.value);

	

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

	{

		alert("Please enter password");

		document.frmChange.password.focus();

		return false;

	}

	if(document.frmChange.password.value.length < 4)

	{

		alert("Password should be greater than four letters");

		document.frmChange.password.select();

		return false;

	}

	if(document.frmChange.password.value != document.frmChange.cpassword.value)

	{

		alert("Confirm password is not matching");

		document.frmChange.cpassword.focus();

		return false;

	}

	if(document.frmChange.fullname.value == "")

	{

		alert("Please enter your name");

		document.frmChange.fullname.focus();

		return false;

	}

	

	document.frmChange.frmAction.value = "Update";

	document.frmChange.submit();

}



// function used in the addMemberDetails.php

function chkMemberDetails()

{

	document.frmProfile.company_name.value = trimSpaces(document.frmProfile.company_name.value);

	document.frmProfile.street.value = trimSpaces(document.frmProfile.street.value);

	document.frmProfile.description.value = trimSpaces(document.frmProfile.description.value);

	

	if(document.frmProfile.airport_id.options[document.frmProfile.airport_id.selectedIndex].value == "")

	{

		alert("Please select a city");

		document.frmProfile.airport_id.focus();

		return false;

	}

	if(document.frmProfile.member_type_id.options[document.frmProfile.member_type_id.selectedIndex].value == "")

	{

		alert("Please select a member type");

		document.frmProfile.member_type_id.focus();

		return false;

	}

	if(document.frmProfile.company_name.value == "")

	{

		alert("Please enter your company name");

		document.frmProfile.company_name.focus();

		return false;

	}

	if(document.frmProfile.street.value == "")

	{

		alert("Please enter your street address");

		document.frmProfile.street.focus();

		return false;

	}

	if(document.frmProfile.description.value == "")

	{

		alert("Please enter your description");

		document.frmProfile.description.focus();

		return false;

	}

	

	document.frmProfile.frmAction.value = "Update";

	document.frmProfile.submit();

}


function modMemberDetails()

{

	document.frmModify.company_name.value = trimSpaces(document.frmModify.company_name.value);

	document.frmModify.street.value = trimSpaces(document.frmModify.street.value);

	document.frmModify.description.value = trimSpaces(document.frmModify.description.value);

	

	if(document.frmModify.airport_id.options[document.frmModify.airport_id.selectedIndex].value == "")

	{

		alert("Please select a city");

		document.frmModify.airport_id.focus();

		return false;

	}

	if(document.frmModify.member_type_id.options[document.frmModify.member_type_id.selectedIndex].value == "")

	{

		alert("Please select a member type");

		document.frmModify.member_type_id.focus();

		return false;

	}

	if(document.frmModify.company_name.value == "")

	{

		alert("Please enter your company name");

		document.frmModify.company_name.focus();

		return false;

	}

	if(document.frmModify.street.value == "")

	{

		alert("Please enter your street address");

		document.frmModify.street.focus();

		return false;

	}

	if(document.frmModify.description.value == "")

	{

		alert("Please enter your description");

		document.frmModify.description.focus();

		return false;

	}

	

	document.frmModify.frmAction.value = "Update";

	document.frmModify.submit();

}



function checkDelete(frmElement) 

{

	rowSelected = false;

	if(document.frmModify.elements[frmElement].length > 0) 

	{

		for(itemCount = 0; itemCount < document.frmModify.elements[frmElement].length; itemCount++) 

		{

			if(document.frmModify.elements[frmElement][itemCount].checked) 

			{

				rowSelected = true;

			}

		}

	}

	else 

	{

		if(document.frmModify.elements[frmElement].checked)

		{

				rowSelected = true;

		}

	}

	if(!rowSelected) 

	{

		alert("No item selected for deletion");

		return false;

	}

	else 

	{

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

		{

			return false;

		}

	}

		

	document.frmModify.frmAction.value = "Delete";

	document.frmModify.submit();



}

function checkContact() {  

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

	if(document.frmContact.lastName.value.length <= 0) {

		alert("Please enter your Last name");

		document.frmContact.lastName.focus();

		return false;

	}

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

	if(document.frmContact.firstName.value.length <= 0) {

		alert("Please enter your First Name");

		document.frmContact.firstName.focus();

		return false;

	}



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

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

		alert("Please enter your email address");

		document.frmContact.email.focus();

		return false;

	}

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

		document.frmContact.email.focus();

		document.frmContact.email.select();

		return false;

	}

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

}



//function used in the showGuestBook.php

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

	document.forms[0].submit();

}

// function to go next page

function goNext()

{

	page = parseInt(document.forms[0].page.value) + 1 

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

	document.forms[0].submit();

}

// function to go previous page

function goPrevious()

{

	document.forms[0].page.value = document.forms[0].page.value - 1;

	document.forms[0].submit();

}

//function to add email subscription

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

	document.forms[0].submit();

}



//function used in the showMembers.php

function chkGoCity()

{

	if(document.forms[0].city_id.options[document.forms[0].city_id.selectedIndex].value == "p")

	{

		alert("Please select a city");

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

		return false;

	}

	else

	{

		document.forms[0].submit();

	}

}



// function used in the index page to go to url

function goToURL()

{

	url = document.frmAirport.airport.options[document.frmAirport.airport.selectedIndex].value;

	if(url != "")

		{

		window.open(url);

		return false;

		} 

	else

		{

		return false;

		} 

}

function chkLogin1()  

{   

     path = 'php/';

	 logUsername = trimSpaces(document.frmLogin.logUsername.value);

	logPassword = trimSpaces(document.frmLogin.logPassword.value);

	if (logUsername == "")

	{

		alert("Please enter the Email ID");

		document.frmLogin.logUsername.focus(); 

	}else

	if (logPassword == "")

	{

		alert("Please enter the password");

		document.frmLogin.logPassword.focus();

		

	}else

	{

	document.frmLogin.action = path+"login.php"; 

	document.frmLogin.frmAction.value = "Login";

	document.frmLogin.logout.value = "true";

	document.frmLogin.submit(); 

	} 

}

