/*------------------Front Page Script starts-----------------------*/

function displayProperty(selectbox){

	if(selectbox.value=="to sell a property"){

 		document.location.href="property_sell.php";

	}

	else if(selectbox.value=="to let a property"){

  		document.location.href="property_let.php";

	}

}

function checkSellFields(){

 	if(document.sellForm.propertyType.options[0].selected){

		alert("Please Enter Property Type");

		document.sellForm.propertyType.focus();

		return false;

	}

	if(document.sellForm.classifiedTitle.value==""){

		alert("Please Enter Classified Title");

		document.sellForm.classifiedTitle.focus();

		return false;

	}

	if(document.sellForm.classDes.value==""){

		alert("Please Enter Classified Description");

		document.sellForm.classDes.focus();

		return false;

	}

	if(document.sellForm.price.value==""){

		alert("Please Enter price");

		document.sellForm.price.focus();

		return false;

	}

	if(document.sellForm.image1.value==""){

		alert("Please Enter an image of your property");

		document.sellForm.image1.focus();

		return false;

	}

	return true; 

}

function checkLetFields(){

	if(document.letForm.propertyType.options[0].selected){

		alert("Please Enter Property Type");

		document.letForm.propertyType.focus();

		return false;

	}

	if(document.letForm.classifiedTitle.value==""){

		alert("Please Enter Classified Title");

		document.letForm.classifiedTitle.focus();

		return false;

	}

	if(document.letForm.classDes.value==""){

		alert("Please Enter Classified Description");

		document.letForm.classDes.focus();

		return false;

	}

	if(document.letForm.price.value==""){

		alert("Please Enter price");

		document.letForm.price.focus();

		return false;

	} 

	if(document.letForm.week.value=="" && document.letForm.month.value=="" ){

		alert("Please Enter Number of week/Month");

		document.letForm.week.focus();

		return false;

	}

	if(document.letForm.image1.value==""){

		alert("Please Enter an image of your property");

		document.letForm.image1.focus();

		return false;

	}

	return true;

}

function searchCheck(){

	if(document.saveSearchForm.searchName.value==""){

		alert("Please enter a search name");

		document.saveSearchForm.searchName.focus();

		return false;

	} 

	return true;

}

function CHSearch(sForn){

	if(sForn.searchkey.value==""){

		alert("Please enter a search key");

		sForn.searchkey.focus();

		return false;

	} 

	return true;

}

function checkPropertyEmail(){

if(document.emailPropertyForm.title.value==""){

		alert("Please enter title");

		document.emailPropertyForm.title.focus();

		return false;

	} 
	if(document.emailPropertyForm.firstName.value==""){

		alert("Please enter first name");

		document.emailPropertyForm.firstName.focus();

		return false;

	} 

	if(document.emailPropertyForm.lastName.value==""){

		alert("Please enter last name");

		document.emailPropertyForm.lastName.focus();

		return false;

	} 
	
	if(!checkEmail(emailPropertyForm.userEmail.value)){

		emailPropertyForm.userEmail.focus();

		return false;

	}
	 if(document.emailPropertyForm.address.value==""){

		alert("Please enter address");

		document.emailPropertyForm.address.focus();

		return false;

	} 
	if(document.getElementById("enquiry")){

		if(document.emailPropertyForm.enquiry.value==""){

			alert("Please enter enquiry");

			document.emailPropertyForm.enquiry.focus();

			return false;

		} 

	}

	return true;

} 



/* Register Form Validation starts*/



function validateRegister(frmRegister){

	if(frmRegister.user_title.value == ''){

		alert("Please select title");

		frmRegister.user_title.focus();

		return false;

	}

	if(frmRegister.user_first_name.value == ''){

		alert("Please enter your first name");

		frmRegister.user_first_name.focus();

		return false;

	}	

	if(frmRegister.user_surname.value == ''){

		alert("Please enter your last name");

		frmRegister.user_surname.focus();

		return false;

	}

/*	if(frmRegister.user_address.value == ''){

		alert("Please enter your address");

		frmRegister.user_address.focus();

		return false;

	}	

	if(frmRegister.user_postcode.value == ''){

		alert("Please enter postcode");

		frmRegister.user_postcode.focus();

		return false;

	}*/

	if(!checkEmail(frmRegister.user_email.value)){

		frmRegister.user_email.focus();

		return false;

	}

	/*if(frmRegister.user_daytime_tel.value == ''){

		alert("Please enter Daytime Telphone Number");

		frmRegister.user_daytime_tel.focus();

		return false;

	}

	if (!checkInternationalPhone(frmRegister.user_daytime_tel.value)){

		alert("Please Enter a valid Daytime Telphone Number");

		frmRegister.user_daytime_tel.focus();

		return false;

	}

	if(frmRegister.user_evening_tel.value == ''){

		alert("Please enter Evening Telphone Number");

		frmRegister.user_evening_tel.focus();

		return false;

	}

	if (!checkInternationalPhone(frmRegister.user_evening_tel.value)){

		alert("Please Enter a valid Evening Telphone Number");

		frmRegister.user_evening_tel.focus();

		return false;

	}

	if(frmRegister.user_mobile_tel.value == ''){

		alert("Please enter Mobile Number");

		frmRegister.user_mobile_tel.focus();

		return false;

	}

	if (!checkInternationalPhone(frmRegister.user_mobile_tel.value)){

		alert("Please Enter a valid Mobile Number");

		frmRegister.user_mobile_tel.focus();

		return false;

	}*/

	if(document.getElementById("regpass")){

		if(frmRegister.password.value == ''){

			alert("Please enter your password");

			frmRegister.password.focus();

			return false;

		}

		if(frmRegister.password.value.length < 6){

			alert("Password should have atleast 6 charactors");

			frmRegister.password.focus();

			return false;

		}

	}

	if(document.getElementById("profilepass")){

		if(frmRegister.password.value.length < 6 && frmRegister.password.value.length > 0){

			alert("Password should have atleast 6 charactors");

			frmRegister.password.focus();

			return false;

		}

	}

	if(frmRegister.password.value != frmRegister.password2.value){

		alert("Confirm Password doesn't match with password");

		frmRegister.password2.focus();

		return false;

	}

	return true;

}

/* Register Form Validation ends*/



function newwin(url){

	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

	winWidth = 500;

	winHeight = 470;

	

	sLeft = (sWidth - winWidth) / 2;

	sTop = (sHeight - winHeight) / 2;



	window.open(url, "newwindow", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");

}

function changerate(r){

	if(r == 'rate'){

		document.getElementById("rate2").value = '';

	}

	if(r == 'rate2'){

		document.getElementById("rate").selectedIndex = 0;

	}

}

/*------------------Front Page Script ends-----------------------*/

/*------------------backend Script starts-----------------------*/

function checkLogin(){

	if(document.indexForm.userName.value== ""){

		alert("Please enter User Name");

		document.indexForm.userName.focus();

		return false;

	}

	if(document.indexForm.userPassword.value== ""){

		alert("Please enter User Password");

		document.indexForm.userPassword.focus();

		return false;

	}

 	return true;

}

function checkPassword(){

	if(document.changePasswordForm.currentPassword.value== ""){

		alert("Please Enter Current Password");

		document.changePasswordForm.currentPassword.focus();

		return false;

	}

	if(document.changePasswordForm.newPassword.value== ""){

		alert("Please Enter New Password");

		document.changePasswordForm.newPassword.focus();

		return false;

	}

	if(document.changePasswordForm.retypePassword.value== ""){

		alert("Please Retype Password");

		document.changePasswordForm.retypePassword.focus();

		return false;

	}

	if(document.changePasswordForm.newPassword.value!=document.changePasswordForm.retypePassword.value){

		alert("New password & retype password must be same");

		document.changePasswordForm.retypePassword.select();

		return false;

	}

	return true;

}



function checkAddClassifieds(){

	if(document.addClassifiedsForm.classType.value == ''){

		alert("Please Select Classified Type");

		document.addClassifiedsForm.classType.focus();

		return false;

	}

	if(document.addClassifiedsForm.propertyType.value == ''){

		alert("Please Select Property Type");

		document.addClassifiedsForm.propertyType.focus();

		return false;

	}

	if(document.addClassifiedsForm.classTitle.value==""){

		alert("Please Enter Classified Title");

		document.addClassifiedsForm.classTitle.focus();

		return false;

	}

	if(document.addClassifiedsForm.classDes.value==""){

		alert("Please Enter Classified Description");

		document.addClassifiedsForm.classDes.focus();

		return false;

	}

	if(document.addClassifiedsForm.price.value==""){

		alert("Please Enter Price");

		document.addClassifiedsForm.price.focus();

		return false;

	}

	if(document.addClassifiedsForm.refNo.value==""){

		alert("Please Enter Referance Number");

		document.addClassifiedsForm.refNo.focus();

		return false;

	}

	if(document.addClassifiedsForm.postCode.value==""){

		alert("Please Enter PostCode");

		document.addClassifiedsForm.postCode.focus();

		return false;

	}

	if(document.addClassifiedsForm.classType.value == 'Let'){

		if((document.addClassifiedsForm.week.value=="") && (document.addClassifiedsForm.month.value=="")){

			alert("Please Enter Month / Week period");	

			document.addClassifiedsForm.week.focus();

			return false;

		}

	}

	return true;

}

function checkSearch(){

	if(document.searchForm.searchkey.value==""){

		alert("Please Enter Search Key");

		document.searchForm.searchkey.focus();

		return false;

	}

	return true;

}

function displaybannerImage(Id){

 	popupwin = window.open("imageDisplay_banner.php?Id="+Id,"tinywindow",'scrollbars,status,left=250,top=100,width=330,height=150');

}

function  displayImage(imageId){

  	sWidth = screen.availWidth;

 	sHeight = screen.availHeight;

 	winWidth = 330;

 	winHeight = 150;

 	sLeft = (sWidth - winWidth) / 2;

 	sTop = (sHeight - winHeight) / 2;

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

 	return;

}

function  displayImageplan(imageId){

  	sWidth = screen.availWidth;

 	sHeight = screen.availHeight;

 	winWidth = 330;

 	winHeight = 150;

 	sLeft = (sWidth - winWidth) / 2;

 	sTop = (sHeight - winHeight) / 2;

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

 	return;

}

function checkAddContent(){

	 if(document.addContentForm.menu.options[0].selected){

		alert("Please Select Menu Position");

		document.addContentForm.menu.focus();

		return false;

	}

 	if(document.addContentForm.pageTitle.value==""){

		alert("Please Enter Page Title");

		document.addContentForm.pageTitle.focus();

		return false;

	}

	if(document.addContentForm.pageLink.value==""){

		alert("Please Enter Page Link");

		document.addContentForm.pageLink.focus();

		return false;

	}

  	return true;

}



function checkAreaContent(){

	

 	if(document.addForm.city.value==""){

		alert("Please Select City");

		document.addForm.city.focus();

		return false;

	}

	if(document.addForm.city.value==""){

		alert("Please Select City");

		document.addForm.city.focus();

		return false;

	}

	if(document.addForm.area_name.value==""){

		alert("Please Enter Area");

		document.addForm.area_name.focus();

		return false;

	}

  	return true;

}



function checkCityContent(){

	

 	/*if(document.addCityForm.country.value==""){

		alert("Please Select Country");

		document.addCityForm.country.focus();

		return false;

	}*/

	if(document.addCityForm.city.value==""){

		alert("Please Enter City");

		document.addCityForm.city.focus();

		return false;

	}

  	return true;

}





function checkMortgage(){

	if(document.addMortgageForm.mortgageTitle.value==""){

		alert("Please enter mortgage title.");

		document.addMortgageForm.mortgageTitle.focus();

		return false;

	}

	if(document.addMortgageForm.mortgageRate.value==""){

		alert("Please enter mortgage rate.");

		document.addMortgageForm.mortgageRate.focus();

		return false;

	}

	return true;

}



/*Property applicant adding validation starts*/

/*function checkApplicants1(applnt)

{

	

	dateSplit = applnt.moving_date.value.split(dateSeperator);

	if(dateSplit.length != 3) 

	{

		alert("Please enter Moving date in "+dateDisplay+" format");

		applnt.moving_date.select();

		return false;

	}

	if(!checkDate(dateSplit[0], dateSplit[1], dateSplit[2])) {

			applnt.moving_date.focus();

			return false;

	}

	dateSplit1 = applnt.date_added.value.split(dateSeperator);

	if(dateSplit1.length != 3) 

	{

			alert("Please enter date in "+dateDisplay+" format");

			applnt.date_added.select();

			return false;

	}

	if(!checkDate(dateSplit1[0], dateSplit1[1], dateSplit1[2])) {

			applnt.date_added.focus();

			return false;

	}

}
*/




function pro_trans_popupCheck(applnt)

{

	

	dateSplit = applnt.t_date.value.split("-");

	if(dateSplit.length != 3) 

	{

		dateSplit=applnt.t_date.value.split("/");

		if(dateSplit.length != 3) 

		{

			alert("Please enter date in mm-dd-yyyy format");

			applnt.t_date.select();

			return false;

		}

	}

	if(!checkDate(dateSplit[0], dateSplit[1], dateSplit[2])) {

			applnt.t_date.focus();

			return false;

	}

	

	

	dateSplit1 = applnt.l_date.value.split("-");

	if(dateSplit1.length != 3) 

	{

		dateSplit1=applnt.l_date.value.split("/");

		if(dateSplit1.length != 3) 

		{

			alert("Please enter date in mm-dd-yyyy format");

			applnt.l_date.select();

			return false;

		}

	}

	if(!checkDate(dateSplit1[0], dateSplit1[1], dateSplit1[2])) {

			applnt.l_date.focus();

			return false;

	}

	

	

	

}



//popup_transaction___end





function checkBuyers(applnt)

{

	

	/*dateSplit = applnt.date_added.value.split("-");

	if(dateSplit.length != 3) 

	{

		dateSplit=applnt.date_added.value.split("/");

		if(dateSplit.length != 3) 

		{

			alert("Please enter date in mm-dd-yyyy format");

			applnt.date_added.select();

			return false;

		}

	}

	if(!checkDate(dateSplit[0], dateSplit[1], dateSplit[2])) {

			applnt.date_added.focus();

			return false;

	}*/
	
	return true;

}



function checkApplicants(applnt){

 	if(applnt.title.options[0].selected){

		alert("Please select title");

		applnt.title.focus();

		return false;

	}

	if(applnt.name.value==''){

		alert("Please enter first name");

		applnt.name.focus();

		return false;

	}	

	if(applnt.surname.value==''){

		alert("Please enter surname");

		applnt.surname.focus();

		return false;

	}

	if(applnt.mobile.value==''){

		alert("Please enter mobile number");

		applnt.mobile.focus();

		return false;

	}

	if(applnt.phoneHome.value==''){

		alert("Please enter home phone number");

		applnt.phoneHome.focus();

		return false;

	}

	if(applnt.phoneWork.value==''){

		alert("Please enter office phone number");

		applnt.phoneWork.focus();

		return false;

	}

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

		applnt.email.select();

		return false;

	}

	if(applnt.address.value==''){

		alert("Please enter your address");

		applnt.address.focus();

		return false;

	}

 	if(applnt.propertyType.options[0].selected){

		alert("Please select property type");

		applnt.propertyType.focus();

		return false;

	}

	if(applnt.bedNo.options[0].selected){

		alert("Please select bed number");

		applnt.bedNo.focus();

		return false;

	}

	return true;

}

/*Property applicant adding validation ends*/



/*Property landlord adding validation starts*/

function checklandlords(landlord){

 	if(landlord.title.value == ''){

		alert("Please select title");

		landlord.title.focus();

		return false;

	}

	if(landlord.firstName.value==''){

		alert("Please enter first name");

		landlord.firstName.focus();

		return false;

	}

	if(landlord.Surname.value==''){

		alert("Please enter surname");

		landlord.Surname.focus();

		return false;

	}

	if(landlord.mobile.value==''){

		alert("Please enter mobile number");

		landlord.mobile.focus();

		return false;

	} 

	if(landlord.phoneWork.value==''){

		alert("Please enter office phone");

		landlord.phoneWork.focus();

		return false;

	} 

	if(landlord.phoneHome.value==''){

		alert("Please enter home phone");

		landlord.phoneHome.focus();

		return false;

	} 

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

		landlord.email.select();

		return false;

	}

	if(landlord.address.value==''){

		alert("Please enter your address");

		landlord.address.focus();

		return false;

	}

 	if(landlord.IDCheck.value == ''){

		alert("Please select ID Check");

		landlord.IDCheck.focus();

		return false;

	}

 	return true;

}

/*Property landlord adding validation ends*/

/*Property Deposit - Rent page validation starts*/
/*
function depositRentCheck(depRent){

	

	if(depRent.deposit_amount.value=='' || depRent.deposit_amount.value=='£0.00'){

		alert("Please enter deposit amount");

		depRent.deposit_amount.select();

		return false;

	}

 

 	

	if(!formatCheck(depRent.deposit_received.value)){

		alert("Please enter deposit date in mm-dd-yyyy format");

		depRent.deposit_received.select();

		return false;

	}

	

	dateSplit = depRent.deposit_received.value.split("-");

	if(dateSplit.length != 3) {

		dateSplit=depRent.deposit_received.value.split("/");

		if(dateSplit.length != 3) {

			alert("Please enter deposit date in mm/dd/yyyy format");

			depRent.deposit_received.select();

			return false;

		}

	}

	if(!checkDate(dateSplit[0], dateSplit[1], dateSplit[2])) {

			depRent.deposit_received.focus();

			return false;

	}

	

	

	

   	if(depRent.deposit_held.options[0].selected){

		alert("Please select deposit held by");

		depRent.deposit_held.focus();

		return false;

	}

	

	

	if(!formatCheck(depRent.deposit_returned.value)){

		alert("Please enter deposit returned date in mm-dd-yyyy format");

		depRent.deposit_returned.select();

		return false;

	}

	

	dateSplit = depRent.deposit_returned.value.split("-");

	if(dateSplit.length != 3) {

		dateSplit=depRent.deposit_returned.value.split("/");

		if(dateSplit.length != 3) {

			alert("Please enter deposit returned date in mm/dd/yyyy format");

			depRent.deposit_returned.select();

			return false;

		}

	}

	if(!checkDate(dateSplit[0], dateSplit[1], dateSplit[2])) {

			depRent.deposit_returned.focus();

			return false;

	}

	

	



 	if(depRent.rent_amount.value=='' || depRent.rent_amount.value=='£0.00'){

		alert("Please enter rent amount");

		depRent.rent_amount.select();

		return false;

	}

	if(depRent.rent_per.options[0].selected){

		alert("Please select rent period");

		depRent.rent_per.focus();

		return false;

	}

 

 	if(!formatCheck(depRent.rent_startdate.value)){

		alert("Please enter rent start date in mm-dd-yyyy format");

		depRent.rent_startdate.select();

		return false;

	}

	

	dateSplit = depRent.rent_startdate.value.split("-");

	if(dateSplit.length != 3) {

		dateSplit=depRent.rent_startdate.value.split("/");

		if(dateSplit.length != 3) {

			alert("Please enter rent start date in mm/dd/yyyy format");

			depRent.rent_startdate.select();

			return false;

		}

	}

	if(!checkDate(dateSplit[0], dateSplit[1], dateSplit[2])) {

			depRent.rent_startdate.focus();

			return false;

	}

	

	

	if(!formatCheck(depRent.agree_startdate.value)){

		alert("Please enter agreement start date in mm-dd-yyyy format");

		depRent.agree_startdate.select();

		return false;

	}

	

	dateSplit = depRent.agree_startdate.value.split("-");

	if(dateSplit.length != 3) {

		dateSplit=depRent.agree_startdate.value.split("/");

		if(dateSplit.length != 3) {

			alert("Please enter agreement start date in mm/dd/yyyy format");

			depRent.agree_startdate.select();

			return false;

		}

	}

	if(!checkDate(dateSplit[0], dateSplit[1], dateSplit[2])) {

			depRent.agree_startdate.focus();

			return false;

	}

	

	if(depRent.agree_months.options[0].selected){

		alert("Please select agreement period");

		depRent.agree_months.focus();

		return false;

	}

	

	if(depRent.no_of_occup.options[0].selected){

		alert("Please select number of occupants");

		depRent.no_of_occup.focus();

		return false;

	}

 	if(depRent.closed_on.value != "" && depRent.closed_on.value !='00/00/0000'){

 		if(!formatCheck(depRent.closed_on.value)){

			alert("Please enter closed date in mm-dd-yyyy format");

			depRent.closed_on.select();

			return false;

		}

	

		dateSplit = depRent.closed_on.value.split("-");

		if(dateSplit.length != 3) {

			dateSplit=depRent.closed_on.value.split("/");

			if(dateSplit.length != 3) {

				alert("Please enter closed date in mm/dd/yyyy format");

				depRent.closed_on.select();

				return false;

			}

		}

		if(!checkDate(dateSplit[0], dateSplit[1], dateSplit[2])) {

				depRent.closed_on.focus();

				return false;

		}

	}



   	return true;

}*/

/*function expireDate(expDate){

	agreeDate=document.propRentForm.agree_dated.value;

	if(!formatCheck(agreeDate)){

		alert("Please enter agreement date in mm-dd-yyyy format");

		document.propRentForm.agree_months.value='';

		document.propRentForm.agree_dated.focus();

		return false;

	}

	

 	monthPeriod=expDate.value;

	if(monthPeriod==''){

		return false;

	}



 	dateSplit=agreeDate.split("/");

	if(dateSplit.length != 3) {

		dateSplit=agreeDate.split("-");

		if(dateSplit.length != 3) {

			alert("Please enter agreement date in mm/dd/yyyy format");

			document.propRentForm.agree_dated.select();

			return false;

		}

	}

	

	if(!checkDate(dateSplit[0], dateSplit[1], dateSplit[2])) {

			document.propRentForm.agree_dated.select();

			return false;

	}

	

	

	

	mydate= new Date(agreeDate);

	

	if(monthPeriod==6){

		

  		month=mydate.getMonth()+7;



		if(month>12){

			ext=month-12;

			month=ext;

		}

		if(month<10){

			month="0"+month;

		}

		date=dateSplit[1];

		year=dateSplit[2];

	}

	else if(monthPeriod==12){

 		month=dateSplit[0];

 		date=dateSplit[1];

		year=mydate.getYear()+1;

	}

	else if(monthPeriod==24){

		month=dateSplit[0];

 		date=dateSplit[1];

		year=mydate.getYear()+2;

	}

	else if(monthPeriod==36){

		month=dateSplit[0];

 		date=dateSplit[1];

		year=mydate.getYear()+3;

	}

	else if(monthPeriod==48){

		month=dateSplit[0];

 		date=dateSplit[1];

		year=mydate.getYear()+4;

	}

	 expDate=month+"/"+date+"/"+year;

   	document.propRentForm.agree_expi_date.value=expDate;

 

}
*/
/*Property Deposit - Rent page validation ends*/



/*Supplier validation Starts*/

function checkSupplier(supplierVal){

	if(supplierVal.supplierCatCode.options[0].selected){

		alert("Please select supplier");

		supplierVal.supplierCatCode.focus();

		return false;

	}

	if(supplierVal.supplierTitle.value==""){

		alert("Please enter supplier title");

		supplierVal.supplierTitle.focus();

		return false;

	}

	if(supplierVal.supplierPhone.value==""){

		alert("Please enter supplier phone");

		supplierVal.supplierPhone.focus();

		return false;

	}

 	if(!checkEmail(supplierVal.supplierEmail.value)){

		supplierVal.supplierEmail.focus();

		return false;

	}

	if(supplierVal.supplierAddress.value==""){

		alert("Please enter supplier address");

		supplierVal.supplierAddress.focus();

		return false;

	}

	return true;

}

 



function addSupplierCategory(url){

 	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

	winWidth = 500;

	winHeight = 200;

	

	sLeft = (sWidth - winWidth) / 2;

	sTop = (sHeight - winHeight) / 2;



	window.open(url, "Supplier", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");

}

function supplierCat(){

	if(document.catForm.catName.value==''){

		alert("Please enter category name");

		document.catForm.catName.focus();

		return false;

	}

	return true;

}



/*Supplier validation Ends*/

function checkdel(){

	return confirm("Are you sure you want to delete");

}

function popupImage(id,j){

    window.open("imgShow.php?id="+id+"&j="+j,"imgwindow",'scrollbars,status,left=250,top=100,width=520,height=300');

 }

function propertyWin(url,winWidth,winHeight){

 	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

 	sLeft = (sWidth - winWidth) / 2;

	sTop = (sHeight - winHeight) / 2;

/*	alert(winWidth);

	alert(winHeight);

*/ 	 window.open(url,"popup","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");

}

function checkAddCompany(val){

	if(val.Cname.value==''){

		alert("Please enter company name");

		val.Cname.focus();

		return false;

	}

	if(val.Cphone.value==''){

		alert("Please enter company phone");

		val.Cphone.focus();

		return false;

	}

	if(!checkEmail(val.Cemail.value)){

		val.Cemail.focus();

		return false;

	}

	if(document.getElementById("logo")){

		if(val.logo.value==''){

			alert("Please enter company logo");

			val.logo.focus();

			return false;

		}

	}

	return true;

}

function receiptIn(ReceiptVal){


	if(ReceiptVal.ReceiveFrom.value==""){

		alert("Please enter name");

		ReceiptVal.ReceiveFrom.focus();

		return false;

	}

	if(ReceiptVal.ReceiveAmount.value==""){

		alert("Please enter amount");

		ReceiptVal.ReceiveAmount.focus();

		return false;

	}

	return true;



}

function receiptOut(ReceiptOutVal){

	if(ReceiptOutVal.paidTo.value==""){

		alert("Please enter name");

		ReceiptOutVal.paidTo.focus();

		return false;

	}

	if(ReceiptOutVal.paidAmount.value==""){

		alert("Please enter amount");

		ReceiptOutVal.paidAmount.focus();

		return false;

	}

	return true;



}

/*search for sale list starts*/

function saleSearch(saleSearch){

 if( (saleSearch.searchkey.value=='') &&  (saleSearch.propertyType.options[0].selected) && (saleSearch.bedNo.options[0].selected)){

		alert("Please enter any of the search key");

		return false;

  }

  return true;

}

/*search for sale list ends*/





function checkCust(){

	 totRow=document.addressForm.elements["custId[]"].length;

 	 isSelect=false;

	 if(totRow >0 ){

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

			if(document.addressForm.elements["custId[]"][i].checked){

				isSelect=true;

				break;

			}

		 }

	 }

  	 if(!isSelect) {

		alert("Please select at least one checkbox item");

		return false;

	}

	return true;

}

function checkCompose(compose){

	if(compose.to.value==''){

		alert("Please enter to address");

		compose.to.focus();

		return false;

	}

	if(compose.subject.value==''){

		alert("Please enter subject");

		compose.subject.focus();

		return false;

	}

	return true;

	 

}



function transPopup(url){

 	sWidth = screen.availWidth;

	sHeight = screen.availHeight;

	//winWidth = 700;

	//winHeight = 450;

	

	

	winWidth = 800;

	winHeight = 600;

	 

	sLeft = (sWidth - winWidth) / 2;

	sTop = (sHeight - winHeight) / 2;



	window.open(url, "TransactionDetails", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");

}

/*------------------backend Script ends-----------------------*/



/*------------------General Function starts---------------------------*/



//validating date fields



 function formatCheck(dateStr) {

	dateSplit = dateStr.split("-");

	if(dateSplit.length != 3) {

		dateSplit = dateStr.split("/");

		if(dateSplit.length != 3) {

			return false;

		}

	}

	if(trimSpaces(dateSplit[0]).length <= 0 || trimSpaces(dateSplit[1]).length <= 0 || trimSpaces(dateSplit[2]).length <= 0) {

		return false;

	}

 	return true;

}

function checkDate(mmVal,ddVal,yyVal) {

	if(ddVal <= 0 || ddVal > 31 || mmVal <= 0 || mmVal > 12 || yyVal <= 0 || yyVal.length != 4) {

		alert("Please enter a valid date");

		return false;

	}

	monthArray = new Array("January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

	if(mmVal == 2) {

		if(yyVal % 4 == 0) {

			if(ddVal > 29) {

				alert("February " + yyVal + " has only 29 days");

				return false;

			}

		}

		else {

			if(ddVal > 28) {

				alert("February " + yyVal + " has only 28 days");

				return false;

			}

		}

	}

	else {

		if(mmVal == 4 || mmVal == 6 || mmVal == 9 || mmVal == 11) {

			if(ddVal > 30) {

				alert(monthArray[mmVal-1] + " has only 30 days");

				return false;

			}

		}

	}

	return true;

}





function trimSpaces(stringValue) {

	// Checks the first occurance of spaces and removes them

	for(i = 0; i < stringValue.length; i++) {

		if(stringValue.charAt(i) != " ") {

			break;

		}

	}

	if(i > 0) {

		stringValue = stringValue.substring(i);

	}

	

	// Checks the last occurance of spaces and removes them

	strLength = stringValue.length - 1;

	for(i = strLength; i >= 0; i--) {

		if(stringValue.charAt(i) != " ") {

			break;

		}

	}

	if(i < strLength) {

		stringValue = stringValue.substring(0, i + 1);

	}

	

	// Returns the string after removing leading and trailing spaces.

	return stringValue;

}





//Validating email address

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;

}





//validate phone numbers

function isInteger(s)

{   var i;

    for (i = 0; i < s.length; i++)

    {   

        // Check that current character is number.

        var c = s.charAt(i);

        if (((c < "0") || (c > "9"))) return false;

    }

    // All characters are numbers.

    return true;

}



function stripCharsInBag(s, bag)

{   var i;

    var returnString = "";

    // Search through string's characters one by one.

    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)

    {   

        // Check that current character isn't whitespace.

        var c = s.charAt(i);

        if (bag.indexOf(c) == -1) returnString += c;

    }

    return returnString;

}



function checkInternationalPhone(strPhone){

	var digits = "0123456789";

	var phoneNumberDelimiters = "()- ";

	var validWorldPhoneChars = phoneNumberDelimiters + "+";

	var minDigitsInIPhoneNumber = 10;

	s=stripCharsInBag(strPhone,validWorldPhoneChars);

	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);

}











/*******************ajax functions for selecting city ********************/

var req;

function loadXMLDoc(url) 

{

	req = false;

    // branch for native XMLHttpRequest object

    if(window.XMLHttpRequest && !(window.ActiveXObject)) {

    	try {

			req = new XMLHttpRequest();

        } catch(e) {

			req = false;

        }

    // branch for IE/Windows ActiveX version

    } else if(window.ActiveXObject) {

       	try {

        	req = new ActiveXObject("Msxml2.XMLHTTP");

      	} catch(e) {

        	try {

          		req = new ActiveXObject("Microsoft.XMLHTTP");

        	} catch(e) {

          		req = false;

        	}

		}

    }



	if(req) {

		req.onreadystatechange = processReqChange;

		req.open("GET", url, true);

		req.send("");

	}

} 



function display_city(value)	

{



var url="display_city.php?id="+value;

loadXMLDoc(url); 	

}



function processReqChange()

{

	if(req.readyState==4)

	{

		

		var result=req.responseText;

		var selectid=document.getElementById("cityDis");

		//alert(result);

		selectid.innerHTML = result;

		/*selectid.options.length=0;

		for(var i=1;i<result.length;i++)

		{

			var opt = document.createElement('OPTION');

			opt.value = result[i];

			opt.text = result[i];

			selectid.options.add(opt);

		}*/

		//alert(

			if(document.getElementById("city").value != ''){

				display_area(document.getElementById("city").value);

			} else {

				display_area(0);

			}

	}

}

function display_cityTable(value)	

{



var url="display_city.php?type=table&id="+value;

	loadXMLDoc(url); 	

}



/*function processReqChange()

{

	if(req.readyState==4)

	{

		

		var result=req.responseText;

		var selectid=document.getElementById("cityDis");

		selectid.innerHTML = result;	

	}

}

*/

/*function checkSearchContent(){

	//alert("Hello");

	 if(document.buySearchForm.city.options.selected){

		alert("Please Select Area");

		document.buySearchForm.city.focus();

		return false;

	}

 	

  	return true;

}*/

 

/*------------------General Function Ends---------------------------*/





/*******************ajax functions for selecting area ********************/







var req1;

function loadXMLDoc1(url) 

{

	req1= false;

    // branch for native XMLHttpRequest object

    if(window.XMLHttpRequest && !(window.ActiveXObject)) {

    	try {

			req1 = new XMLHttpRequest();

        } catch(e) {

			req1 = false;

        }

    // branch for IE/Windows ActiveX version

    } else if(window.ActiveXObject) {

       	try {

        	req1 = new ActiveXObject("Msxml2.XMLHTTP");

      	} catch(e) {

        	try {

          		req1 = new ActiveXObject("Microsoft.XMLHTTP");

        	} catch(e) {

          		req1 = false;

        	}

		}

    }



	if(req1) {

		req1.onreadystatechange = processReqChange1;

		req1.open("GET", url, true);

		req1.send("");

	}

} 















function display_area(value)	

{



var url="display_area.php?cityId="+value;

loadXMLDoc1(url); 	

}



function display_areaTable(value)	

{



var url="display_area.php?type=table&cityId="+value;

loadXMLDoc1(url); 	

}

function processReqChange1()

{

	if(req1.readyState==4)

	{

		var result=req1.responseText;

		var selectid=document.getElementById("areaDis");

		selectid.innerHTML = result;

	}

}



/* ---------------- */

var req;

function loadXMLDoc3(url) 

{

	req = false;

    // branch for native XMLHttpRequest object

    if(window.XMLHttpRequest && !(window.ActiveXObject)) {

    	try {

			req = new XMLHttpRequest();

        } catch(e) {

			req = false;

        }

    // branch for IE/Windows ActiveX version

    } else if(window.ActiveXObject) {

       	try {

        	req = new ActiveXObject("Msxml2.XMLHTTP");

      	} catch(e) {

        	try {

          		req = new ActiveXObject("Microsoft.XMLHTTP");

        	} catch(e) {

          		req = false;

        	}

		}

    }



	if(req) {

		req.onreadystatechange = processReqChange3;

		req.open("GET", url, true);

		req.send("");

	}

} 



function display_city_areaTable(value)	

{

//alert("here");

var url="display_city.php?id="+value+"&areaType=table&type=";

loadXMLDoc3(url); 	

}



function processReqChange3()

{

	if(req.readyState==4)

	{

		

		var result=req.responseText;

		var selectid=document.getElementById("cityDis");

		selectid.innerHTML = result;

		//alert(result);

		if(document.getElementById("city").value != ''){

			display_areaTable(document.getElementById("city").value);	

		} else {

			display_areaTable(0);

		}

	}

}



/*------------------General Function Ends---------------------------*/

function redirect(){

	location.replace("newsletterManager.php?start=0");

}



/*-------------chk news lettere---------------*/

function checkNewsletter(keyvalue){
	if(!checkEmail(keyvalue.email.value)){

		keyvalue.email.focus();

		return false;

	}

	return true;

}

/*-------------chk news---------------*/

function checkAddNews(val)

{

	if(val.newsHeading.value==""){

		alert("Please enter news heading");

		val.newsHeading.focus();

		return false;

	}

	if(val.shortdesc.value==""){

		alert("Please enter short description");

		val.shortdesc.focus();

		return false;

	}

	return true;

}
/*bottom menu starts*/

function addMenu_list(){
  for(i=document.menuPositionForm.pageName.options.length-1;i>=0;i--) {
	var pageName=document.menuPositionForm.pageName;
	if(document.menuPositionForm.pageName[i].selected){
	 addMenuOption(document.menuPositionForm.menuPageName, document.menuPositionForm.pageName[i].value, document.menuPositionForm.pageName[i].value);
	 removeOption(pageName,i);
    }
  }
}
function addMenuOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
  	optn.value = value;
	selectbox.options.add(optn);
 }
function RemoveMenuOption_list(){
  for(i=document.menuPositionForm.menuPageName.options.length-1;i>=0;i--) {
	var menuPageName=document.menuPositionForm.menuPageName;
	if(document.menuPositionForm.menuPageName[i].selected){
	RemoveMenuOption(document.menuPositionForm.pageName, document.menuPositionForm.menuPageName[i].value, document.menuPositionForm.menuPageName[i].value);
	removeOption(menuPageName,i);
      }
  }
}
function RemoveMenuOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
  	optn.value = value;
	selectbox.options.add(optn);
}
function checkMenuField(){
	var head;
	var len=document.menuPositionForm.menuPageName.options.length;
	for(i=0;i<len;i++){
		head=document.menuPositionForm.menuPageName.options[i].value;
 		document.menuPositionForm.frmAction.value=document.menuPositionForm.frmAction.value+","+head;
 	}
}
function removeOption(listbox,i)
{
	listbox.remove(i);
}


/*bottom menu  ends*/
function printWin(printurl){
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth = 600;
	winHeight = 680;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open(printurl, "newwindow", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
