
//Ajax For Search****************************************************************
var ajax = new Array();
function getFor(id)
{
		document.getElementById('sub_cat').options.length = 0;	// Empty city select box
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'getCategory.php?id='+id;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCat(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	//}
}

function createCat(index)
{
	var obj = document.getElementById('sub_cat');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
	
	//create type when category load
	document.getElementById('type').options.length = 0;
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'getType.php?id='+0;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createtypes(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	
	// create type end
		
}
//load type ajax
function getTypeList(sel)
{

	var id = sel.options[sel.selectedIndex].value;
	document.getElementById('type').options.length = 0;	// Empty city select box
	
	if(id.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'getType.php?id='+id;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createtypes(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createtypes(index)
{
	var obj = document.getElementById('type');
	//alert("hai");
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
	
	document.getElementById('distId').options.length = 0;
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'selDistrict.php?id='+0;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createdist(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	
}


//loadtype ajax end

function getCityList(sel)
{

	var id = sel.options[sel.selectedIndex].value;
	var typid = document.getElementById('type').value;
	document.getElementById('cityId').options.length = 0;	// Empty city select box
	//alert(id);
	//alert(typid);
	if(id.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'selCity.php?id='+id+'&tid='+typid;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities(index) };	// Specify function that will be executed after file has been found
		
		ajax[index].runAJAX();		// Execute AJAX function
		
	}
}

function createCities(index)
{
	var obj = document.getElementById('cityId');
	//alert("hai");
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

function getdistList(sel)
{

	var id = sel.options[sel.selectedIndex].value;
	document.getElementById('distId').options.length = 0;	// Empty city select box
	
	if(id.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'selDistrict.php?id='+id;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createdist(index) };	// Specify function that will be executed after file has been found
		
		ajax[index].runAJAX();		// Execute AJAX function
		
	}
}

function createdist(index)
{
	var obj = document.getElementById('distId');
	//alert("hai");
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
	document.getElementById('cityId').options.length = 0;
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'selCity.php?id='+0;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
}

//addproperty
function getCityadd(sel)
{

	var id = sel.options[sel.selectedIndex].value;
	document.getElementById('cityId1').options.length = 0;	// Empty city select box
	
	if(id.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'selCityadd.php?id='+id;	// Specifying which file to get
		//alert(id);
		ajax[index].onCompletion = function(){ createCitiesAdd(index) };	// Specify function that will be executed after file has been found
		
		ajax[index].runAJAX();		// Execute AJAX function
		
	}
}

function createCitiesAdd(index)
{
	var obj = document.getElementById('cityId1');
	//alert("hai");
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
	//getfor id//
	document.getElementById('pr_cat').options.length = 0;	// Empty city select box
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'getPropCategory.php?id='+1;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createPropCat(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
		//get for id end//
}

////addproperty
//******************************************Load Property type on Add Proprty*************************************//

function getForadd(id)
{
		document.getElementById('pr_cat').options.length = 0;	// Empty city select box
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'getPropCategory.php?id='+id;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createPropCat(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	//}
}

function createPropCat(index)
{
	var obj = document.getElementById('pr_cat');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

//loadPropType
function getproptype(sel)
{

	var id = sel.options[sel.selectedIndex].value;
	document.getElementById('pr_typeId').options.length = 0;	// Empty city select box
		if(id.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'getPropType.php?id='+id;	// Specifying which file to get
		//alert(id);
		ajax[index].onCompletion = function(){ createPropType(index) };	// Specify function that will be executed after file has been found
		
		ajax[index].runAJAX();		// Execute AJAX function
		
	}
}
function createPropType(index)
{
	var obj = document.getElementById('pr_typeId');
	
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
	//alert("hai");
}

////addproperty











//******************************************Load Property type on Add Proprty*************************************//

//Ajax For Search END************************************************************************************************************

function checkSearch() {
	if(document.search1.cityId.value.length<=""){
		alert("Select city");
		document.search1.cityId.focus();
		return false;
	};
}

function checkEnquiry(){
	//alert("gfgf");
	document.enquiryForm.e_name.value = trimSpaces(document.enquiryForm.e_name.value);
	if(document.enquiryForm.e_name.value.length <= 0){
			alert("Please enter your name!");
			document.enquiryForm.e_name.focus();
			return false;
	}
	document.enquiryForm.e_phone.value= trimSpaces(document.enquiryForm.e_phone.value);
	if(document.enquiryForm.e_phone.value.length <= 0){
			alert("Please enter your phone number!");
			document.enquiryForm.e_phone.focus();
			return false;
	}
	
	document.enquiryForm.e_email.value= trimSpaces(document.enquiryForm.e_email.value);
	if(document.enquiryForm.e_email.value.length <= 0){
			alert("Please enter your email ID!");
			document.enquiryForm.e_email.focus();
			return false;
	}
	if(!checkEmail(document.enquiryForm.e_email.value)){
			//alert("Please enter Correct email");
			document.enquiryForm.e_email.focus();
			return false;		
	}
	document.enquiryForm.e_comment.value = trimSpaces(document.enquiryForm.e_comment.value);
	if(document.enquiryForm.e_comment.value.length <= 0){
			alert("Please enter the comment!");
			document.enquiryForm.e_comment.focus();
			return false;
	}
document.enquiryForm.frmAction.value = "addEnquiry";
}
function checkLogin() {
	//alert("hi");
	document.loginForm.userName.value = trimSpaces(document.loginForm.userName.value);
	//alert(document.loginForm.userName.value);
	if(document.loginForm.userName.value.length <= 0) {
    alert("Please enter your username");
		document.loginForm.userName.focus();
		return false;
	}
	document.loginForm.userPassword.value = trimSpaces(document.loginForm.userPassword.value);
	//alert(document.loginForm.userPassword.value);
	if(document.loginForm.userPassword.value.length <= 0) {
		alert("Please enter your password");
		document.loginForm.userPassword.focus();
		return false;
	}
	//document.loginForm.frmAction.value = "loginCheck";
}
function checkEditMember() {
	
	document.editMember.memName.value = trimSpaces(document.editMember.memName.value);
		if(document.editMember.memName.value.length <= 0) {
		alert("Please enter the name");
		document.editMember.memName.focus();
		return false;
	}
	document.editMember.address.value = trimSpaces(document.editMember.address.value);
		if(document.editMember.address.value.length <= 0) {
		alert("Please enter the address");
		document.editMember.address.focus();
		return false;
	}
	 if(document.editMember.mobile.value.length <= 0) {
			alert("Please enter the mobile");
			document.editMember.mobile.focus();
			return false;
		}
		if(document.editMember.email.value.length <= 0) {
			alert("Please enter the email");
			document.editMember.email.focus();
			return false;
		}
		if(!checkEmail(document.editMember.email.value)){
			//alert("Please enter Correct email");
			document.editMember.email.focus();
			return false;		
		}
		if(document.editMember.city.value.length <= 0) {
			alert("Please enter the city");
			document.editMember.city.focus();
			return false;
		}
		if(document.editMember.state.value.length <= 0) {
			alert("Please enter the state");
			document.editMember.state.focus();
			return false;
		}
		if(document.editMember.country.value.length <= 0) {
			alert("Please enter the country");
			document.editMember.country.focus();
			return false;
		}
		if(document.editMember.zip.value.length <= 0) {
			alert("Please enter the pincode");
			document.editMember.zip.focus();
			return false;
		}
		if(!IsNumeric(document.editMember.zip.value)){
		alert("Invalid pincode code");
		document.editMember.zip.select();
		return false;
	 }
	document.editMember.frmAction.value = "process";
}

function checkPayment() {
	
	document.payment.pay_name.value = trimSpaces(document.payment.pay_name.value);
		if(document.payment.pay_name.value.length <= 0) {
		alert("Please enter the name");
		document.payment.pay_name.focus();
		return false;
	}
	document.payment.pay_address.value = trimSpaces(document.payment.pay_address.value);
		if(document.payment.pay_address.value.length <= 0) {
		alert("Please enter the address");
		document.payment.pay_address.focus();
		return false;
	}
	 if(document.payment.pay_phone.value.length <= 0) {
			alert("Please enter the Phone");
			document.payment.pay_phone.focus();
			return false;
		}
		if(document.payment.pay_mail.value.length <= 0) {
			alert("Please enter the email");
			document.payment.pay_mail.focus();
			return false;
		}
		if(!checkEmail(document.payment.pay_mail.value)){
			//alert("Please enter Correct email");
			document.payment.pay_mail.focus();
			return false;		
		}
		if(document.payment.pay_city.value.length <= 0) {
			alert("Please enter the city");
			document.payment.pay_city.focus();
			return false;
		}
		if(document.payment.pay_state.value.length <= 0) {
			alert("Please enter the state");
			document.payment.pay_state.focus();
			return false;
		}
		
		if(document.payment.pay_zip.value.length <= 0) {
			alert("Please enter the pincode");
			document.payment.pay_zip.focus();
			return false;
		}
		if(!IsNumeric(document.payment.pay_zip.value)){
		alert("Invalid pincode");
		document.payment.pay_zip.select();
		return false;
	 }
	 if(document.payment.pay_country.value.length <= 0) {
			alert("Please enter the country");
			document.payment.pay_country.focus();
			return false;
		}
		 if(document.payment.pay_type.value.length <= 0) {
			alert("Please enter the payment type");
			document.payment.pay_type.focus();
			return false;
		}
	document.payment.frmAction.value = "process";
}
function checkRegister(){
	//alert("hi");
	document.registerForm.r_name.value = trimSpaces(document.registerForm.r_name.value);
	if(document.registerForm.r_name.value.length <= 0){
			alert("Please enter your name!");
			document.registerForm.r_name.focus();
			return false;
	}
	document.registerForm.r_address.value = trimSpaces(document.registerForm.r_address.value);
	if(document.registerForm.r_address.value.length <= 0){
			alert("Please enter your address!");
			document.registerForm.r_address.focus();
			return false;
	}
	document.registerForm.r_mobile.value = trimSpaces(document.registerForm.r_mobile.value);
	if(document.registerForm.r_mobile.value.length <= 0){
			alert("Please enter your mobile number!");
			document.registerForm.r_mobile.focus();
			return false;
	}
	document.registerForm.r_email.value = trimSpaces(document.registerForm.r_email.value);
	if(document.registerForm.r_email.value.length <= 0){
			alert("Please enter your email-Id!");
			document.registerForm.r_email.focus();
			return false;
	}
	if(!checkEmail(document.registerForm.r_email.value)){
			//alert("Please enter Correct email");
			document.registerForm.r_email.focus();
			return false;		
	}
	if(document.registerForm.city.value.length <= 0){
			alert("Please enter your city!");
			document.registerForm.city.focus();
			return false;
	}
	if(document.registerForm.state.value.length <= 0){
			alert("Please enter your state!");
			document.registerForm.state.focus();
			return false;
	}
	if(document.registerForm.country.value.length <= 0){
			alert("Please enter your country");
			document.registerForm.country.focus();
			return false;
	}
	if(document.registerForm.zip.value.length <= 0){
			alert("Please enter your pincode!");
			document.registerForm.zip.focus();
			return false;
	}
	if(!IsNumeric(document.registerForm.zip.value)){
		alert("Invalid pincode");
		document.registerForm.zip.select();
		return false;
	 }
	document.registerForm.frmAction.value = "addMember";
}

function checkAddproperty(){
	document.addProperty.cityId1.value = trimSpaces(document.addProperty.cityId1.value);
		if(document.addProperty.cityId1.value=='') {
		alert("Please select a City");
		document.addProperty.cityId1.focus();
		return false;
	}
	document.addProperty.pTitle.value = trimSpaces(document.addProperty.pTitle.value);
		if(document.addProperty.pTitle.value.length <= 0) {
		alert("Please enter a title");
		document.addProperty.pTitle.focus();
		return false;
	}	
	document.addProperty.pr_typeId.value = trimSpaces(document.addProperty.pr_typeId.value);
		if(document.addProperty.pr_typeId.value=='') {
		alert("Please select a property tyype");
		document.addProperty.pr_typeId.focus();
		return false;
	}
	
	
	document.addProperty.pdetails.value = trimSpaces(document.addProperty.pdetails.value);
		if(document.addProperty.pdetails.value.length <= 0) {
		alert("Please enter the details");
		document.addProperty.pdetails.focus();
		return false;
	}
	document.addProperty.pArea.value = trimSpaces(document.addProperty.pArea.value);
		if(document.addProperty.pArea.value.length <= 0) {
		alert("Please enter the area");
		document.addProperty.pArea.focus();
		return false;
	}
	document.addProperty.pPrice.value = trimSpaces(document.addProperty.pPrice.value);
		if(document.addProperty.pPrice.value.length <= 0) {
		alert("Please enter the price");
		document.addProperty.pPrice.focus();
		return false;
	}
	/*if(!IsNumeric(document.addProperty.pPrice.value)){
		alert("Please enter digit only as price");
		document.addProperty.pPrice.select();
		return false;
	 }*/
	document.addProperty.frmAction.value = "addproperty";	
}

function checkpack(){
var radioSelected = false;
for (i = 0;  i < document.package.pk_id.length;  i++)
{
if (document.package.pk_id[i].checked)
radioSelected = true;
}
if (!radioSelected)
{
alert("Please select one of the \"package\" options.");
return false;
}
}
function checkmail(){
	if(document.sendMail.email.value.length <= 0) {
			alert("Please enter the email");
			document.sendMail.email.focus();
			return false;
		}
		if(!checkEmail(document.sendMail.email.value)){
			//alert("Please enter Correct email");
			document.sendMail.email.focus();
			return false;		
		}
	document.sendMail.frmAction.value = "process";
}
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;
	}
	document.changePassword.frmAction.value = "change";
}
function deleteMember(pId) {
	//categoryName = document.forms[0].depId.options[document.forms[0].depId.selectedIndex].text;
	if(confirm("Do you really want to delete the selected Property")) {
		document.editMem.frmAction.value = "delete";
		document.editMem.propId.value = pId;
		document.editMem.submit();
		return;
	}
}
function soldOut(pId) {
	//categoryName = document.forms[0].depId.options[document.forms[0].depId.selectedIndex].text;
	if(confirm("Do you really want to set property status as sold out")) {
		document.editMem.frmAction.value = "sold";
		document.editMem.propId.value = pId;
		document.editMem.submit();
		return;
	}
}
function showPhotoDoc(prId,ph) {
	//alert(ph);
	if(ph==1){
		photo=document.property.photo.value;
	}
	if(ph==2){
		photo=document.property.photo1.value;	
	}
	if(ph==3){
		photo=document.property.photo2.value;	
	}
	if(ph==4){
		photo=document.property.photo3.value;	
	}
	if(ph==5){
		photo=document.property.photo4.value;	
	}
	if(ph==6){
		photo=document.property.photo5.value;	
	}
	if(ph==7){
		photo=document.property.photo6.value;	
	}
	if(ph==8){
		photo=document.property.photo7.value;	
	}
	if(ph==9){
		photo=document.property.photo8.value;	
	}
	if(ph==10){
		photo=document.property.photo9.value;	
	}
sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth =  200;
	winHeight = 300;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	//alert(photo);
	window.open("showDoc.php?$pro_id=" + prId + "&name=" + photo, "PropertyPhoto", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");
	return;
}
function deletePhotoDoc(prId,ph) {
	if(!confirm("Do you really want to delete the photograph?")) {
		return;
	}
	else {
			if(ph==1){
				document.property.photoname.value='pro_pict1';
				//alert(document.forms[0].photoname1.value);
			}
			if(ph==2){
				document.property.photoname.value='pro_pict2';	
			}
			if(ph==3){
				document.property.photoname.value='pro_pict3';	
			}
			if(ph==4){
				document.property.photoname.value='pro_pict4';	
			}
			if(ph==5){
				document.property.photoname.value='pro_pict5';	
			}
			if(ph==6){
				document.property.photoname.value='pro_pict6';	
			}
			if(ph==7){
				document.property.photoname.value='pro_pict7';	
			}
			if(ph==8){
				document.property.photoname.value='pro_pict8';	
			}
			if(ph==9){
				document.property.photoname.value='pro_pict9';	
			}
			if(ph==10){
				document.property.photoname.value='pro_pict10';	
			}
		document.property.frmAction.value = "deletePhotoProp";
				document.property.submit();
		return;
	}
}
function editphotos(id,value){
	if(value==0){
			document.property.photoname.value='pro_pict1';
			//alert(document.forms[0].photoname1.value);
			document.property.idValue.value=0;
			}
			if(value==1){
				document.property.photoname.value='pro_pict2';	
				document.property.idValue.value=1;
			}
			if(value==2){
				document.property.photoname.value='pro_pict3';
				document.property.idValue.value=2;
			}
			if(value==3){
				document.property.photoname.value='pro_pict4';
				document.property.idValue.value=3;
			}
			if(value==4){
				document.property.photoname.value='pro_pict5';
				document.property.idValue.value=4;
			}
			if(value==5){
				document.property.photoname.value='pro_pict6';
				document.property.idValue.value=5;
			}
			if(value==6){
				document.property.photoname.value='pro_pict7';
				document.property.idValue.value=6;
			}
			if(value==7){
				document.property.photoname.value='pro_pict8';
				document.property.idValue.value=7;
			}
			if(value==8){
				document.property.photoname.value='pro_pict9';
				document.property.idValue.value=8;
			}
			if(value==9){
				document.property.photoname.value='pro_pict10';
				document.property.idValue.value=9;
			}
		document.property.frmAction.value = "editprphoto";
				document.property.submit();
		return;
	}
	function editpropertydetails(prpId){
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 600;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	window.open("editPropertydetails.php?prp_Id=" + prpId, "ActiveProperty", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=1");
	return;
}
function editpropertytype(prpId){
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 200;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	window.open("editPropertytype.php?prp_Id=" + prpId, "ActiveProperty", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=1");
	return;
}
function checkProdistrict(){
	document.forms[0].frmAction.value = "editprDistrict";
	document.forms[0].submit();
}
function checkProtype(){
	if(document.forms[0].pr_typeId.value.length <= 0) {
			alert("Please select property type");
			document.forms[0].fortype[0].focus();
			return false;
		}
	document.forms[0].frmAction.value = "editprType";
	document.forms[0].submit();
}
function editpropDetails(){
	document.forms[0].frmAction.value = "editDetails";
	document.forms[0].submit();
}
function editpropertydistrict(pId){
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 150;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	window.open("editPropdistrict.php?prp_Id=" + pId, "ActiveProperty", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=1");
	return;
}
function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}

function hotsearch(){

}