
function loadMap(saddr,daddr, address, singleMap )
{
	var map="";
	if(singleMap=="N")
	{//alert(saddr  + "\n" +  daddr  + "\n" +  address );
	map="<iframe  width='799px' height='360' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.co.in/maps?f=d&amp;source=s_d&amp;" + saddr + "&amp;" + daddr + address  + "&amp;geocode=&amp;hl=en&amp;mra=ls&amp;sll=40.42391,-86.89191&amp;sspn=0.07305,0.181961&amp;ie=UTF8&amp;ll=40.42391,-86.89191&amp;spn=0.091476,0.145912&amp;z=12&amp;output=embed'></iframe>";
	}
	else
	{
		map="<iframe   style='border:1px solid #cccccc' width='100%' height='360' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=" + address + "&amp;sspn=0.008653,0.022745&amp;ie=UTF8&amp;spn=0.022855,0.036478&amp;z=14&amp;iwloc=A&amp;output=embed'></iframe>";
	}
	document.getElementById('gMap').innerHTML = map;
}



function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer")
{
	request_type = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
	request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();

/* -------------------------- */
/* INSERT */
/* -------------------------- */
/* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
var nocache = 0;

function ShowSearchblock(isGrid, IsSorting, IsSponsered) {
	

// Optional: Show a waiting message in the layer with ID login_response
//document.getElementById('insert_response').innerHTML = "";
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.



var chkBedroomsStudio='';

var SearchCriteria='';
var SelectedControls='';
if(document.getElementById('chkBedroomsStudio').checked==true)
	{		
		chkBedroomsStudio= encodeURI(document.getElementById('chkBedroomsStudio').value);
		SearchCriteria = SearchCriteria + 'Studio, ';
		SelectedControls =SelectedControls + ',chkBedroomsStudio';
	}
else
	chkBedroomsStudio= '';

var chkBedrooms1bed='';
if(document.getElementById('chkBedrooms1bed').checked==true)
	{
		var chkBedrooms1bed= encodeURI(document.getElementById('chkBedrooms1bed').value);
		SearchCriteria = SearchCriteria + '1, '; 
		SelectedControls =SelectedControls + ',chkBedrooms1bed';
	}
else
	chkBedrooms1bed= '';

var chkBedrooms2bed='';
if(document.getElementById('chkBedrooms2bed').checked==true)
	{
		var chkBedrooms2bed= encodeURI(document.getElementById('chkBedrooms2bed').value);
		SearchCriteria = SearchCriteria + '2, '; 
		SelectedControls =SelectedControls + ',chkBedrooms2bed';
	}
else
	chkBedrooms2bed= '';

var chkBedrooms3bed='';
if(document.getElementById('chkBedrooms3bed').checked==true)
	{
		var chkBedrooms3bed= encodeURI(document.getElementById('chkBedrooms3bed').value);
		SearchCriteria = SearchCriteria + '3, '; 
		SelectedControls =SelectedControls + ',chkBedrooms3bed';
	}
else
	chkBedrooms3bed= '';

var chkBedrooms4bed='';
if(document.getElementById('chkBedrooms4bed').checked==true)
	{
		var chkBedrooms4bed= encodeURI(document.getElementById('chkBedrooms4bed').value);
		SearchCriteria = SearchCriteria + '4, '; 
		SelectedControls =SelectedControls + ',chkBedrooms4bed';
	}
else
	chkBedrooms4bed= ''; 

var chkBedrooms5bed='';
if(document.getElementById('chkBedrooms5bed').checked==true)
	{
		var chkBedrooms5bed= encodeURI(document.getElementById('chkBedrooms5bed').value);
		SearchCriteria = SearchCriteria + '5+, '; 
		SelectedControls =SelectedControls + ',chkBedrooms5bed';
	}
else
	chkBedrooms5bed= '';

if (SearchCriteria !='')
{
	if (SearchCriteria == "Studio, ")
	{		
		SearchCriteria = SearchCriteria.substring(0, SearchCriteria.length -2 );
		SearchCriteria = SearchCriteria + " | " ; 
	}
	else
	{
		SearchCriteria = SearchCriteria.substring(0, SearchCriteria.length -2 );
		SearchCriteria = SearchCriteria + " Bedrooms | " ; 
	}
}
//var chkBedrooms2bed = encodeURI(document.getElementById('chkBedrooms2bed').value);
//var chkBedrooms3bed = encodeURI(document.getElementById('chkBedrooms3bed').value);
//var chkBedrooms4bed = encodeURI(document.getElementById('chkBedrooms4bed').value);
//var chkBedrooms5bed = encodeURI(document.getElementById('chkBedrooms5bed').value);

var baths = document.getElementById('baths').value;
var baths1 = document.getElementById('baths').selectedIndex;
if(baths1>0)
SelectedControls =SelectedControls + ',baths=' + baths1 ;
baths1 = document.getElementById('baths').options[baths1].text;

var prices = document.getElementById('prices').value;
var prices1 = document.getElementById('prices').selectedIndex;
if(prices1>0)
SelectedControls =SelectedControls + ',prices=' + prices1;
prices1 = document.getElementById('prices').options[prices1].text;

var unitsmonths = document.getElementById('unitsmonths').value;
var unitsmonths1 = document.getElementById('unitsmonths').selectedIndex;
if(unitsmonths1>0)
SelectedControls =SelectedControls + ',unitsmonths=' + unitsmonths1;

var squarefeet = document.getElementById('squarefeet').value;
var squarefeet1 = document.getElementById('squarefeet').selectedIndex;
if(squarefeet1>0)
SelectedControls =SelectedControls + ',squarefeet='+squarefeet1;
squarefeet1 = document.getElementById('squarefeet').options[squarefeet1].text;


var lease_mm = document.getElementById('lease_mm').value;
var lease_mm1 = document.getElementById('lease_mm').selectedIndex;
if(lease_mm1>0)
SelectedControls =SelectedControls + ',lease_mm='+lease_mm1;
lease_mm1 = document.getElementById('lease_mm').options[lease_mm1].text;

var lease_yy = lease_mm1.substr(0,4);


//var lease_mm = document.getElementById('lease_mm').selectedIndex;
//lease_mm = document.getElementById('lease_mm').options[lease_mm].value;

//var leasestartmonthtext = document.getElementById('lease_mm').selectedIndex;
//leasestartmonthtext = document.getElementById('lease_mm').options[leasestartmonthtext].text;

//var lease_yy = document.getElementById('lease_mm').selectedIndex;
//lease_yy = document.getElementById('lease_mm').options[lease_yy].text;


//var propertyall;
//if(isProperty!='')
//	propertyall = "M" + isProperty;
//else

var	propertyall = document.getElementById('propertyall').value;
if (propertyall==0)
{
	propertyall='all';
}
var propertydesc = document.getElementById('propertyall').selectedIndex;
if(propertydesc>0)
SelectedControls =SelectedControls + ',propertyall='+propertydesc;
propertydesc = document.getElementById('propertyall').options[propertydesc].text;



if (baths.toUpperCase()!='ANY')
	SearchCriteria = SearchCriteria + baths1 +', ';

if (prices.toUpperCase()!= 'ANY')
{
	SearchCriteria = SearchCriteria + prices1 + ' ';
	SearchCriteria = SearchCriteria + unitsmonths +', ';
}

if (squarefeet.toUpperCase()!='ANY' )
	SearchCriteria = SearchCriteria +  squarefeet1 + ', ';

if (lease_mm.toUpperCase()!='ANY' )
	SearchCriteria = SearchCriteria +  lease_mm1 + ', ';



//if (lease_yy.toUpperCase()!='ANY' )
//	SearchCriteria = SearchCriteria +  lease_yy + ', ';


if (propertyall.toUpperCase() !='ALL' )
	SearchCriteria = SearchCriteria + propertydesc + ', ';



if (SearchCriteria !='')
{
SearchCriteria = SearchCriteria.substring(0, SearchCriteria.length -2 );
SearchCriteria = SearchCriteria + " | "
}
var anyhouse='true';
if(document.getElementById('any').checked==false)
{
//	var anyhouse= encodeURI(document.getElementById('any').value);
//else
//	anyhouse= '';

anyhouse='false';
var chkHousingTypeAB='';
if(document.getElementById('chkHousingTypeAB').checked==true)
	{var chkHousingTypeAB= encodeURI(document.getElementById('chkHousingTypeAB').value);
	SearchCriteria = SearchCriteria + 'Apartment Building, '; 
	SelectedControls =SelectedControls + ',chkHousingTypeAB';
	}
else
	chkHousingTypeAB= '';

var chkHousingTypeAC='';
if(document.getElementById('chkHousingTypeAC').checked==true)
	{
	var chkHousingTypeAC= encodeURI(document.getElementById('chkHousingTypeAC').value);
	SearchCriteria = SearchCriteria + 'Apartment Complex, '; 
		SelectedControls =SelectedControls + ',chkHousingTypeAC';
	}
else
	chkHousingTypeAC= '';

var chkHousingTypeTownhome='';
if(document.getElementById('chkHousingTypeTownhome').checked==true)
	{
		var chkHousingTypeTownhome= encodeURI(document.getElementById('chkHousingTypeTownhome').value);
		SearchCriteria = SearchCriteria + 'Townhome, '; 
		SelectedControls =SelectedControls + ',chkHousingTypeTownhome';
	}
else
	chkHousingTypeTownhome= '';



//if(document.getElementById('chkHousingTypeAC').checked==true && 
//	document.getElementById('chkHousingTypeTownhome').checked==true)
//{
//SearchCriteria = SearchCriteria + 'Townhome Apartment Complex, '; 
//}


var chkHousingTypeEH='';
if(document.getElementById('chkHousingTypeEH').checked==true)
	{var chkHousingTypeEH= encodeURI(document.getElementById('chkHousingTypeEH').value);
		SearchCriteria = SearchCriteria + 'Entire House, '; 
	SelectedControls =SelectedControls + ',chkHousingTypeEH';
}
else
	chkHousingTypeEH= '';

var chkHousingTypeMUH='';
if(document.getElementById('chkHousingTypeMUH').checked==true)
	{var chkHousingTypeMUH= encodeURI(document.getElementById('chkHousingTypeMUH').value);
	SearchCriteria = SearchCriteria + 'Multi-Unit House, '; 
	SelectedControls =SelectedControls + ',chkHousingTypeMUH';
	}
else
	chkHousingTypeMUH= '';


}
//else
//{
//	SelectedControls =SelectedControls + ',any';
//}
//var anyhouse = encodeURI(document.getElementById('any').value);
//var chkHousingTypeAB = encodeURI(document.getElementById('chkHousingTypeAB').value);
//var chkHousingTypeAC = encodeURI(document.getElementById('chkHousingTypeAC').value);
//var chkHousingTypeTownhome = encodeURI(document.getElementById('chkHousingTypeTownhome').value);
//var chkHousingTypeEH = encodeURI(document.getElementById('chkHousingTypeEH').value);
//var chkHousingTypeMUH = encodeURI(document.getElementById('chkHousingTypeMUH').value);
if (SearchCriteria !='')
{
SearchCriteria = SearchCriteria.substring(0, SearchCriteria.length -2 );
SearchCriteria = SearchCriteria + " | "
}



var allloc='true';
if(document.getElementById('all').checked==false)
{
//	var allloc= encodeURI(document.getElementById('all').value);
//	
//else
//	allloc= '';

allloc='false';
var chkLocationCN='';
if(document.getElementById('chkLocationCN').checked==true)
	{
		var chkLocationCN= encodeURI(document.getElementById('chkLocationCN').value);
		SearchCriteria = SearchCriteria + 'On Campus, '; 
		SelectedControls =SelectedControls + ',chkLocationCN';
		}
else
	chkLocationCN= '';

var chkLocationCS='';
if (document.getElementById('chkLocationCS')!=null)
{
if(document.getElementById('chkLocationCS').checked==true)
	{
	var chkLocationCS= encodeURI(document.getElementById('chkLocationCS').value);
	SearchCriteria = SearchCriteria + 'On Campus, '; 
	SelectedControls =SelectedControls + ',chkLocationCS';
	}
else
	chkLocationCS= '';
}
var chkLocationNC='';
if(document.getElementById('chkLocationNC').checked==true)
	{var chkLocationNC= encodeURI(document.getElementById('chkLocationNC').value);
	SearchCriteria = SearchCriteria + 'Off Campus, '; 
	SelectedControls =SelectedControls + ',chkLocationNC';
	}
else
	chkLocationNC= '';

var chkLocationSC='';
if (document.getElementById('chkLocationSC')!=null)
{
if(document.getElementById('chkLocationSC').checked==true)
	{var chkLocationSC= encodeURI(document.getElementById('chkLocationSC').value);
	SearchCriteria = SearchCriteria + 'Off Campus, '; 
	SelectedControls =SelectedControls + ',chkLocationSC';
	}
else
	chkLocationSC= '';
}
var chkLocationDL='';
if(document.getElementById('chkLocationDL').checked==true)
	{var chkLocationDL= encodeURI(document.getElementById('chkLocationDL').value);
	SearchCriteria = SearchCriteria + 'Downtown Lafayette, '; 
		SelectedControls =SelectedControls + ',chkLocationDL';
	}
else
	chkLocationDL= '';

var chkLocationLafayette='';
if(document.getElementById('chkLocationLafayette').checked==true)
	{var chkLocationLafayette= encodeURI(document.getElementById('chkLocationLafayette').value);
	SearchCriteria = SearchCriteria + 'Lafayette, '; 
	SelectedControls =SelectedControls + ',chkLocationLafayette';
	}
else
	chkLocationLafayette= '';
}
/*else
SelectedControls =SelectedControls + ',all';
*/
var product_pg='';
//var allloc = encodeURI(document.getElementById('all').value);
//var chkLocationCN = encodeURI(document.getElementById('chkLocationCN').value);
//var chkLocationCS = encodeURI(document.getElementById('chkLocationCS').value);
//var chkLocationNC = encodeURI(document.getElementById('chkLocationNC').value);
//var chkLocationSC = encodeURI(document.getElementById('chkLocationSC').value);
//var chkLocationDL = encodeURI(document.getElementById('chkLocationDL').value);
//var chkLocationLafayette = encodeURI(document.getElementById('chkLocationLafayette').value);


//var Criteria = chkBedroomsStudio + ', '  + chkBedrooms1bed + '&chkBedrooms2bed=' + chkBedrooms2bed + '&chkBedrooms3bed=' + chkBedrooms3bed + '&chkBedrooms4bed=' + chkBedrooms4bed  + '&chkBedrooms5bed=' + chkBedrooms5bed+ '&baths=' + baths + '&prices=' + prices + '&unitsmonths=' + unitsmonths + '&squarefeet=' + squarefeet+ '&propertyall=' + propertyall+ '&anyhouse=' + anyhouse+'&chkHousingTypeAB=' + chkHousingTypeAB+'&chkHousingTypeAC=' + chkHousingTypeAC + '&chkHousingTypeTownhome=' + chkHousingTypeTownhome+ '&chkHousingTypeEH=' + chkHousingTypeEH+ '&chkHousingTypeMUH=' + chkHousingTypeMUH+'&allloc=' + allloc +'&chkLocationCN=' + chkLocationCN+ '&chkLocationCS=' + chkLocationCS+ '&chkLocationNC=' + chkLocationNC+ '&chkLocationSC=' + chkLocationSC+'&chkLocationDL=' + chkLocationDL+'&chkLocationLafayette=' + chkLocationLafayette; 
SearchCriteria = SearchCriteria.substring(0, SearchCriteria.length -2 );

document.getElementById('SearchCriteria').innerHTML = SearchCriteria;
	document.getElementById('SearchCriteria1').innerHTML = SearchCriteria;

var sortingby ='';

if (IsSorting === undefined || IsSorting=='' || IsSorting==0)
{}
else
{
	switch (IsSorting)
	{
		case 0:
			sortingby = "PropertyMgrName"
			break;
		case 1:
			sortingby = "TypeOfHouse"
			break;
		case 2:
			sortingby = "Location"
			break;
		case 3:
			sortingby = "bedrooms"
			break;
		case 4:
			sortingby = "Baths"
			break;
		case 5:
			sortingby = "Sq_feet"
			break;
		case 6:
			sortingby = "AAYear asc, AAMonth asc, AADay asc "
			break;
		case 7:
			sortingby = "RentPerUnit"
			break;
		case 8:
			sortingby = "RentPerBed"
			break;
		case 9:
			sortingby = "TotalMatched"
			break;
			
		default:
			sortingby = "SpListing desc,   CD desc"
	}

}


if(SelectedControls !='')
{
SelectedControls= SelectedControls.substring(1,SelectedControls.length  );	
}


//var totalAdvance=document.advancesearch.chkadvance.length;
var totalAdvance=document.searchForm.chkadvance.length;
var iCounter=0;
var strGroupDetailsId="";
var intTotalChecked=0;
while(iCounter<totalAdvance)
{
	if(document.searchForm.chkadvance[iCounter].checked==true)
	{
		
		if (strGroupDetailsId=="")
			strGroupDetailsId = strGroupDetailsId + document.searchForm.chkadvance[iCounter].value;
		else
		 strGroupDetailsId = strGroupDetailsId + "," + document.searchForm.chkadvance[iCounter].value;
		 intTotalChecked++;
	}
iCounter++;
}

var isErrorLink='N';
 if(document.getElementById('modify_search').style.display=="block")
 document.getElementById("advsrh4").style.display="block";
 isErrorLink='Y';





if (isGrid==1)
{
var url = "templates/getdata_fromdb.php?chkBedroomsStudio=" + chkBedroomsStudio + '&chkBedrooms1bed=' + chkBedrooms1bed + '&chkBedrooms2bed=' + chkBedrooms2bed + '&chkBedrooms3bed=' + chkBedrooms3bed + '&chkBedrooms4bed=' + chkBedrooms4bed  + '&chkBedrooms5bed=' + chkBedrooms5bed+ '&baths=' + baths + '&prices=' + prices + '&unitsmonths=' + unitsmonths + '&squarefeet=' + squarefeet+ '&propertyall=' + propertyall+ '&anyhouse=' + anyhouse+'&chkHousingTypeAB=' + chkHousingTypeAB+'&chkHousingTypeAC=' + chkHousingTypeAC + '&chkHousingTypeTownhome=' + chkHousingTypeTownhome+ '&chkHousingTypeEH=' + chkHousingTypeEH+ '&chkHousingTypeMUH=' + chkHousingTypeMUH+'&allloc=' + allloc +'&chkLocationCN=' + chkLocationCN+ '&chkLocationCS=' + chkLocationCS+ '&chkLocationNC=' + chkLocationNC+ '&chkLocationSC=' + chkLocationSC+'&chkLocationDL=' + chkLocationDL+'&chkLocationLafayette=' + chkLocationLafayette+'&sortingby=' + sortingby+'&product_pg='+product_pg+'&strGroupDetailsId='+strGroupDetailsId+'&intTotalChecked='+intTotalChecked+'&lease_mm='+lease_mm+'&lease_mm1='+lease_mm1+'&lease_yy='+lease_yy+'&SearchCriteria='+SearchCriteria+'&isErrorLink='+isErrorLink;
if (IsSponsered==1)
url= url + '&IsSponsered=1';
else
url= url + '&IsSponsered=0';


url= url + '&IsSearchOnce=1&SearchCriteria='+SearchCriteria+'&SelectedControls='+SelectedControls;




}

else if (isGrid==2)
{
	var url = "templates/columnview.php?chkBedroomsStudio=" + chkBedroomsStudio + '&chkBedrooms1bed=' + chkBedrooms1bed + '&chkBedrooms2bed=' + chkBedrooms2bed + '&chkBedrooms3bed=' + chkBedrooms3bed + '&chkBedrooms4bed=' + chkBedrooms4bed  + '&chkBedrooms5bed=' + chkBedrooms5bed+ '&baths=' + baths + '&prices=' + prices + '&unitsmonths=' + unitsmonths + '&squarefeet=' + squarefeet+ '&propertyall=' + propertyall+ '&anyhouse=' + anyhouse+'&chkHousingTypeAB=' + chkHousingTypeAB+'&chkHousingTypeAC=' + chkHousingTypeAC + '&chkHousingTypeTownhome=' + chkHousingTypeTownhome+ '&chkHousingTypeEH=' + chkHousingTypeEH+ '&chkHousingTypeMUH=' + chkHousingTypeMUH+'&allloc=' + allloc +'&chkLocationCN=' + chkLocationCN+ '&chkLocationCS=' + chkLocationCS+ '&chkLocationNC=' + chkLocationNC+ '&chkLocationSC=' + chkLocationSC+'&chkLocationDL=' + chkLocationDL+'&chkLocationLafayette=' + chkLocationLafayette+'&sortingby=' + sortingby+'&product_pg='+product_pg+'&strGroupDetailsId='+strGroupDetailsId+'&lease_mm='+lease_mm+'&lease_mm1='+lease_mm1 +'&lease_yy='+lease_yy+'&SearchCriteria='+SearchCriteria+'&isErrorLink='+isErrorLink+'&intTotalChecked='+intTotalChecked;

if (IsSponsered==1)
url= url + '&IsSponsered=1';
else
url= url + '&IsSponsered=0';


url= url + '&IsSearchOnce=1&SearchCriteria='+SearchCriteria+'&SelectedControls='+SelectedControls;

}




//+ '&baths=' + baths + '&prices=' + prices + '&unitsmonths=' + unitsmonths + '&squarefeet=' + squarefeet+ '&propertyall=' + propertyall+ '&anyhouse=' + anyhouse+'&chkHousingTypeAB=' + chkHousingTypeAB+'&chkHousingTypeAC=' + chkHousingTypeAC + '&chkHousingTypeTownhome=' + chkHousingTypeTownhome+ '&chkHousingTypeEH=' + chkHousingTypeEH+ '&chkHousingTypeMUH=' + chkHousingTypeMUH+'&allloc=' + allloc +'&chkLocationCN=' + chkLocationCN+ '&chkLocationCS=' + chkLocationCS+ '&chkLocationNC=' + chkLocationNC+ '&chkLocationSC=' + chkLocationSC+'&chkLocationDL=' + chkLocationDL+'&chkLocationLafayette=' + chkLocationLafayette;
// Set te random number to add to URL request

//Pass the login variables like URL variable
 

return url;

}

function insert(isGrid, IsSorting, IsSponsered, isProperty, IsSearchOnce, PreviousSearch, PreloaderReuired)
{
if (PreloaderReuired=='Y')
//if (isGrid==2 || isGrid==1)
{
	var url = "advertise.php";
    var st=advertise(url);
    document.getElementById('modal').innerHTML = st;
	Popup.showModal('modal',null, null, {'top':0,'offsetTop':0});
	
}




if (typeof(IsSearchOnce)!=0)
{
		//alert(PreviousSearch);
		if(typeof(PreviousSearch)!="undefined" && PreviousSearch!="")
		{
			var PreviousSearch1 = PreviousSearch.split("~!");
			var SelectedControl = PreviousSearch1[1].split(",");
			var i=0;
			var ids="";
			while (i < SelectedControl.length)
			 {
			  ids= SelectedControl[i];
			  if(ids.substring(0,3)=='chk')
				  document.getElementById(ids).checked=true;
			  else
			   {
				if (ids=='any')
				{
					document.getElementById(ids).checked=true;
					CheckAndSelectAllHousingType(1);
				}
				else if(ids=='all')
				{
					document.getElementById(ids).checked=true;
					CheckAndSelectAllLocation(1);
				}
				else
				{
				ids1= ids.split("=");
				//alert(ids1[0]);
				//alert(ids1[1]);				
				document.getElementById(ids1[0]).selectedIndex = ids1[1];
				}
			   }
			  i+=1;
			  }
		}
}


	if (typeof(isProperty)=="undefined")
	isProperty='';
	
	
	
	if (isProperty!=''  )
	{
	document.getElementById('propertyall').options[document.getElementById('propertyall').selectedIndex].value=isProperty;
	PropertyId = "M" + isProperty;
	
	var s= document.getElementById('propertyall');
	
	for ( var i = 0; i < s.options.length; i++ ) {
			if ( s.options[i].value ==  PropertyId ) {
				s.options[i].selected = true;
			}
		}
	
	} 
	//document.getElementById('vertical_view_div').style.display="block";
	 if(document.getElementById('insert_response')!=null) 
	document.getElementById('insert_response').innerHTML = "<image src='/images/loading_bak_sd.gif' width='28' height='28'>";
	
	
	var url =	ShowSearchblock(isGrid, IsSorting, IsSponsered);
	if (url!=undefined && url!='' )
	{
		//document.getElementById('vertical_view_div').innerHTML = "<image src='images/loading_bak_sd.gif' width='30' height='30'>";
		
		http.open('get', url);
		http.onreadystatechange = insertReply;
		http.send(null);
		 document.getElementById('showTable').style.display="none";
		 document.getElementById('showList').style.display="none";
		 document.getElementById('viewprop').style.display="none";
		// document.getElementById('add_prop_block').style.display="none";
		 document.getElementById('insert_response').style.display="block";
		
	}
	else
	 document.getElementById('insert_response').style.display="none";



}




function insertReply() 
{
	if(http.readyState == 4)
	{
		var response = http.responseText;


		if(response!="")
		{
         document.getElementById('insert_response').innerHTML = response;
		  document.getElementById('showTable').style.display="none";
		  //document.getElementById('dynamicdata').style.display="block";
		   document.getElementById('insert_response').style.display="block";
		   document.getElementById('vertical_view_div').style.display="none";
		   document.getElementById('grid_view_div').style.display="block";
		   document.getElementById('vertical_view_div').innerHTML ='';
//		    if (isGrid==2)
			//setTimeout("Popup.hide('modal');",5000); 
			//Popup.hide('modal');
			alert("A");
		}
		else
		{
		 document.getElementById('insert_response').style.display="none";
		 
		}
		// else if login is ok show a message: "Site added+ site URL".
		//document.getElementById('insert_response').innerHTML =response ;
		
	}
}



/*<!--function compareit()
{

	 var comparebox=document.getElementById('chkcompbox').length;
	 alert(comparebox);

}-->*/

 function displayJoin()
 {

   //document.getElementById('join_purdue').style.display="block";
    //document.getElementById('add_prop_block').style.display="none";
    document.getElementById('showTable').style.display="none";
   document.getElementById('showList').style.display="none";
   document.getElementById('viewprop').style.display="none";
}
function display_add_me()
{

   //document.getElementById('add_prop_block').style.display="block";
    document.getElementById('showTable').style.display="none";
   document.getElementById('showList').style.display="none";
   document.getElementById('viewprop').style.display="none";
   //document.getElementById('join_purdue').style.display="none";
   
}


 function displaydetail()
 {

   document.getElementById('display_detail').style.display="none";
   document.getElementById('modify_search').style.display="block";
   
 }
 function modifydetial()
 {

   document.getElementById('display_detail').style.display="block";
   document.getElementById('modify_search').style.display="none";
//   document.getElementById('viewprop').style.display="none";
//   document.getElementById('vertical_view_div').style.display="none";
//   document.getElementById('insert_response').style.display="block";
	if (document.getElementById('error1')!=null)
	document.getElementById('error1').innerHTML = "";
   

   
 }  
 
 function leftmenu()
 {
   document.getElementById('left_panel').style.display="none";
   document.getElementById('advlisting').style.display="block";
  
 /*   document.getElementById("11").style.display="block";
   document.getElementById("12").style.display="block";
    document.getElementById("13").style.display="block";
 
   if (document.getElementById("11").style.display=="none")
   {
	document.getElementById('imgme11').src="style/images/arrow trans_next.png";
   }
   
   if (document.getElementById("12").style.display=="none")
   {
	document.getElementById('imgme12').src="style/images/arrow trans_next.png";
   }
   
   if (document.getElementById("13").style.display=="none")
   {
	document.getElementById('imgme13').src="style/images/arrow trans_next.png";
   }
	*/
   
 }  
 

 function leftmenu_advance()
 {
   document.getElementById('left_panel').style.display="none";
   document.getElementById('advlisting').style.display="block";
   document.getElementById("11").style.display="none";
   document.getElementById("12").style.display="none";
    document.getElementById("13").style.display="none";
   
   if (document.getElementById("11").style.display=="none")
   {
	document.getElementById('imgme11').src="style/images/arrow trans_next.png";
   }
   
   if (document.getElementById("12").style.display=="none")
   {
	document.getElementById('imgme12').src="style/images/arrow trans_next.png";
   }
   
   if (document.getElementById("13").style.display=="none")
   {
	document.getElementById('imgme13').src="style/images/arrow trans_next.png";
   }
	
   
 }  


  
function CheckAndSelectAllHousingType(isAny)

{
 if (isAny==1)
 {
  if (document.getElementById('any').checked ==true)
  {

   document.getElementById('chkHousingTypeAB').checked =true;
   document.getElementById('chkHousingTypeAC').checked =true;
   document.getElementById('chkHousingTypeTownhome').checked =true;
   document.getElementById('chkHousingTypeEH').checked =true;
   document.getElementById('chkHousingTypeMUH').checked =true;
  }
  if (document.getElementById('any').checked ==false)
  {
   document.getElementById('chkHousingTypeAB').checked =false;
   document.getElementById('chkHousingTypeAC').checked =false;
   document.getElementById('chkHousingTypeTownhome').checked =false;
   document.getElementById('chkHousingTypeEH').checked =false;
   document.getElementById('chkHousingTypeMUH').checked =false;
  }
 }

 if (isAny==2)
 {

  if( document.getElementById('chkHousingTypeAB').checked ==true &&  document.getElementById('chkHousingTypeAC').checked ==true && 
   document.getElementById('chkHousingTypeTownhome').checked ==true &&  document.getElementById('chkHousingTypeEH').checked ==true &&
   document.getElementById('chkHousingTypeMUH').checked ==true )
  {
     
   document.getElementById('any').checked =true;
  }
  else
   {
   document.getElementById('any').checked =false;
   }
 }

}
 
 function CheckAndSelectAllLocation(isAny)
{

 if (isAny==1)
 {
  if (document.getElementById('all').checked ==true)
  {
   document.getElementById('chkLocationCN').checked =true;
   //document.getElementById('chkLocationCS').checked =true;
   document.getElementById('chkLocationNC').checked =true;
   //document.getElementById('chkLocationSC').checked =true;
   document.getElementById('chkLocationDL').checked =true;
   document.getElementById('chkLocationLafayette').checked =true;
   
  }
  if (document.getElementById('all').checked ==false)
  {
   document.getElementById('chkLocationCN').checked =false;
   //document.getElementById('chkLocationCS').checked =false;
   document.getElementById('chkLocationNC').checked =false;
   //document.getElementById('chkLocationSC').checked =false;
   document.getElementById('chkLocationDL').checked =false;
   document.getElementById('chkLocationLafayette').checked =false;
  }
 }

 if (isAny==2)
 {

  if( document.getElementById('chkLocationCN').checked ==true  &&  document.getElementById('chkLocationDL').checked ==true &&
   document.getElementById('chkLocationNC').checked ==true && document.getElementById('chkLocationLafayette').checked ==true )
  {
     
   document.getElementById('all').checked =true;
  }
  else
   {
   document.getElementById('all').checked =false;
   }
 }

}

//function hideblock_adv() 
//{
////alert(document.getElementById("chkAdvParent1").parentNode.id);
////if (document.getElementById("advsrh1")!=null)
////document.getElementById("advsrh1").style.display="none";
////
////if (document.getElementById("advsrh2")!=null)
////document.getElementById("advsrh2").style.display="none";
////
////if (document.getElementById("advsrh3")!=null)
////document.getElementById("advsrh3").style.display="none";
//
//if (document.getElementById("advsrh4")!=null)
//document.getElementById("advsrh4").style.display="none";
//
////alert(document.getElementById("advsrh4").childNodes[0].nodeValue);
//
//if (document.getElementById("advsrh5")!=null)
//document.getElementById("advsrh5").style.display="none";
//
//if (document.getElementById("advsrh6")!=null)
//document.getElementById("advsrh6").style.display="none";
//
//if (document.getElementById("advsrh7")!=null)
//document.getElementById("advsrh7").style.display="none";
//
//if (document.getElementById("advsrh8")!=null)
//document.getElementById("advsrh8").style.display="none";
//
//if (document.getElementById("advsrh9")!=null)
//document.getElementById("advsrh9").style.display="none";
//
//if (document.getElementById("advsrh10")!=null)
//document.getElementById("advsrh10").style.display="none";
//
//if (document.getElementById("advsrh11")!=null)
//document.getElementById("advsrh11").style.display="none";
//if (document.getElementById("advsrh12")!=null)
//document.getElementById("advsrh12").style.display="none";
//if (document.getElementById("advsrh13")!=null)
//document.getElementById("advsrh13").style.display="none";
//if (document.getElementById("advsrh14")!=null)
//document.getElementById("advsrh14").style.display="none";
//
//
//window.location.search.substring(1);
//
//}


function hideblock_adv() 
{
//alert(document.getElementById("chkAdvParent1").parentNode.id);
//if (document.getElementById("advsrh1")!=null)
//document.getElementById("advsrh1").style.display="none";
//
//if (document.getElementById("advsrh2")!=null)
//document.getElementById("advsrh2").style.display="none";
//
//if (document.getElementById("advsrh3")!=null)
//document.getElementById("advsrh3").style.display="none";


//alert(document.getElementById("advsrh4").childNodes[0].nodeValue);

if(document.searchForm.chkadvance[0].checked == true || document.searchForm.chkadvance[1].checked == true || document.searchForm.chkadvance[2].checked == true)
{
	document.getElementById('go_img0').style.display='block'; 
}
else
document.getElementById('go_img0').style.display='none';

if( document.searchForm.chkadvance[3].checked == true || document.searchForm.chkadvance[4].checked == true || document.searchForm.chkadvance[5].checked == true )
{
	document.getElementById('go_img1').style.display='block'; 
}
else
document.getElementById('go_img1').style.display='none';
if(document.searchForm.chkadvance[6].checked == true || document.searchForm.chkadvance[7].checked == true || document.searchForm.chkadvance[8].checked == true || document.searchForm.chkadvance[9].checked == true)
{
	document.getElementById('go_img2').style.display='block'; 
}
else
document.getElementById('go_img2').style.display='none';

/*********************** Heating/AC Start ************************/
if(document.searchForm.chkadvance[10].checked == true || document.searchForm.chkadvance[11].checked == true || document.searchForm.chkadvance[12].checked == true || document.searchForm.chkadvance[13].checked == true)
{
		document.getElementById("advsrh4").style.display="block";
		document.getElementById('imgme4').src="style/images/arrow trans_down.png";
		document.getElementById('go_img3').style.display='block';
}
else {
		//if (document.getElementById("advsrh4")!=null)
		document.getElementById("advsrh4").style.display="none";
		document.getElementById('imgme4').src="style/images/arrow trans_next.png";
		document.getElementById('go_img3').style.display='none';
}

/*********************** Heating/AC End *********************** */


//if(document.getElementById('active').checked==true)


/*********************** Utilities  ************************/
if(document.searchForm.chkadvance[14].checked == true || document.searchForm.chkadvance[15].checked == true || document.searchForm.chkadvance[16].checked == true || document.searchForm.chkadvance[17].checked == true || document.searchForm.chkadvance[18].checked == true || document.searchForm.chkadvance[19].checked == true)
{
	document.getElementById("advsrh5").style.display="block";
	document.getElementById('imgme5').src="style/images/arrow trans_down.png";
	document.getElementById('go_img4').style.display='block';
}
else{
//if (document.getElementById("advsrh5")!=null)
document.getElementById("advsrh5").style.display="none";
document.getElementById('imgme5').src="style/images/arrow trans_next.png";
document.getElementById('go_img4').style.display='none';
}

/*********************** Utilities End  ************************/



/*********************** Laundry   ************************/
if(document.searchForm.chkadvance[20].checked == true || document.searchForm.chkadvance[21].checked == true || document.searchForm.chkadvance[22].checked == true)
{
	document.getElementById("advsrh6").style.display="block";
	document.getElementById('imgme6').src="style/images/arrow trans_down.png";
	document.getElementById('go_img5').style.display='block';
}
else{
//if (document.getElementById("advsrh6")!=null)
document.getElementById("advsrh6").style.display="none";
document.getElementById('imgme6').src="style/images/arrow trans_next.png";
document.getElementById('go_img5').style.display='none';
}

/*********************** Laundry End   ************************/


/*********************** Pets ************************/
if(document.searchForm.chkadvance[23].checked == true || document.searchForm.chkadvance[24].checked == true || document.searchForm.chkadvance[25].checked == true || document.searchForm.chkadvance[26].checked == true)
{
	document.getElementById("advsrh7").style.display="block";
	document.getElementById('imgme7').src="style/images/arrow trans_down.png";
	document.getElementById('go_img6').style.display='block';
}
else
{
//if (document.getElementById("advsrh7")!=null)
document.getElementById("advsrh7").style.display="none";
document.getElementById('imgme7').src="style/images/arrow trans_next.png";
document.getElementById('go_img6').style.display='none';
}
/*********************** Pets End ************************/

/*********************** OutdoorSpace  ************************/
if(document.searchForm.chkadvance[27].checked == true || document.searchForm.chkadvance[28].checked == true || document.searchForm.chkadvance[29].checked == true)
{
	document.getElementById("advsrh8").style.display="block";
	document.getElementById('imgme8').src="style/images/arrow trans_down.png";
	document.getElementById('go_img7').style.display='block';
}
else
{
//if (document.getElementById("advsrh8")!=null)
document.getElementById("advsrh8").style.display="none";
document.getElementById('imgme8').src="style/images/arrow trans_next.png";
document.getElementById('go_img7').style.display='none';
}
/*********************** OutdoorSpace  End  ************************/

/*********************** Appliances   ************************/
if(document.searchForm.chkadvance[30].checked == true || document.searchForm.chkadvance[31].checked == true || document.searchForm.chkadvance[32].checked == true || document.searchForm.chkadvance[33].checked == true)
{
	document.getElementById("advsrh9").style.display="block";
	document.getElementById('imgme9').src="style/images/arrow trans_down.png";
	document.getElementById('go_img8').style.display='block';
}
else
{
//if (document.getElementById("advsrh9")!=null)
document.getElementById("advsrh9").style.display="none";
document.getElementById('imgme9').src="style/images/arrow trans_next.png";
document.getElementById('go_img8').style.display='none';
}
/*********************** Appliances End  ************************/


/*********************** Amenities    ************************/
if(document.searchForm.chkadvance[34].checked == true || document.searchForm.chkadvance[35].checked == true || document.searchForm.chkadvance[36].checked == true || document.searchForm.chkadvance[37].checked == true || document.searchForm.chkadvance[38].checked == true || document.searchForm.chkadvance[39].checked == true || document.searchForm.chkadvance[40].checked == true)
{
	document.getElementById("advsrh10").style.display="block";
	document.getElementById('imgme10').src="style/images/arrow trans_down.png";
	document.getElementById('go_img9').style.display='block';
}
else
{
//if (document.getElementById("advsrh10")!=null)
document.getElementById("advsrh10").style.display="none";
document.getElementById('imgme10').src="style/images/arrow trans_next.png";
document.getElementById('go_img9').style.display='none';
}
/*********************** Amenities  End  ************************/


/*********************** Security/Access ************************/
if(document.searchForm.chkadvance[41].checked == true || document.searchForm.chkadvance[42].checked == true || document.searchForm.chkadvance[43].checked == true)
{
	document.getElementById("advsrh11").style.display="block";
	document.getElementById('imgme11').src="style/images/arrow trans_down.png";
	document.getElementById('go_img10').style.display='block';
}
else
{
//if (document.getElementById("advsrh11")!=null)
document.getElementById("advsrh11").style.display="none";
document.getElementById('imgme11').src="style/images/arrow trans_next.png";
document.getElementById('go_img10').style.display='none';
}
/*********************** Security/Access End ************************/


/*********************** Furniture  ************************/
if(document.searchForm.chkadvance[44].checked == true || document.searchForm.chkadvance[45].checked == true || document.searchForm.chkadvance[46].checked == true || document.searchForm.chkadvance[47].checked == true)
{
	document.getElementById("advsrh12").style.display="block";
	document.getElementById('imgme12').src="style/images/arrow trans_down.png";
	document.getElementById('go_img11').style.display='block';
}
else
{
//if (document.getElementById("advsrh12")!=null)
document.getElementById("advsrh12").style.display="none";
document.getElementById('imgme12').src="style/images/arrow trans_next.png";
document.getElementById('go_img11').style.display='none';
}
/*********************** Furniture End ************************/


/*********************** Community   ************************/
if(document.searchForm.chkadvance[48].checked == true || document.forms[0].chkadvance[49].checked == true || document.searchForm.chkadvance[50].checked == true || document.searchForm.chkadvance[51].checked == true || document.searchForm.chkadvance[52].checked == true || document.searchForm.chkadvance[53].checked == true || document.searchForm.chkadvance[54].checked == true || document.searchForm.chkadvance[55].checked == true || document.searchForm.chkadvance[56].checked == true || document.searchForm.chkadvance[57].checked == true)
{
	document.getElementById("advsrh13").style.display="block";
	document.getElementById('imgme13').src="style/images/arrow trans_down.png";
	document.getElementById('go_img12').style.display='block';
}
else
{
//if (document.getElementById("advsrh13")!=null)
document.getElementById("advsrh13").style.display="none";
document.getElementById('imgme13').src="style/images/arrow trans_next.png";
document.getElementById('go_img12').style.display='none';
/*********************** Community  End ************************/
}

if (document.getElementById("advsrh14")!=null)
document.getElementById("advsrh14").style.display="none";



}


function toggleView(elementID)
{
   var objRef = document.getElementById(elementID);
   if (objRef.style.display=="none")
   {
      objRef.style.display="block";
	  	 
   } else 
   {
      objRef.style.display="none";
   }
}


cc1=0;
function changeimage1()
{
	
	if (cc1==0) 
	{
		cc1=1;
		document.getElementById('imgme1').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh1").style.display="block";
	}
	else
	{
		cc1=0;
		document.getElementById('imgme1').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh1").style.display="none";
		
	}
}

cc2=0
function changeimage2()
{
	if (cc2==0) 
	{
		cc2=1;
		document.getElementById('imgme2').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh2").style.display="block";
	}
	else
	{
		cc2=0;
		document.getElementById('imgme2').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh2").style.display="none";
	}
}

cc3=0;
function changeimage3()
{
	if (cc3==0) 
	{
		cc3=1;
		document.getElementById('imgme3').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh3").style.display="block";
	}
	else
	{
		cc3=0;
		document.getElementById('imgme3').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh3").style.display="none";
		
	}
}

cc4=0;
function changeimage4()
{
	if (cc4==0) 
	{
		cc4=1;
		document.getElementById('imgme4').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh4").style.display="none";
	}
	else
	{
		cc4=0;
		document.getElementById('imgme4').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh4").style.display="block";
	}
}

cc5=0;
function changeimage5()
{
	if (cc5==0) 
	{
		cc5=1;
		document.getElementById('imgme5').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh5").style.display="none";
	}
	else
	{
		cc5=0;
		document.getElementById('imgme5').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh5").style.display="block";
	}
}

cc6=0;
function changeimage6()
{
	if (cc6==0) 
	{
		cc6=1;
		document.getElementById('imgme6').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh6").style.display="none";
		
	}
	else
	{
		cc6=0;
		document.getElementById('imgme6').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh6").style.display="block";
	}
}

cc7=0;
function changeimage7()
{
	if (cc7==0) 
	{
		cc7=1;
		document.getElementById('imgme7').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh7").style.display="none";
	}
	else
	{
		cc7=0;
		document.getElementById('imgme7').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh7").style.display="block";
	}
}

cc8=0;
function changeimage8()
{
	if (cc8==0) 
	{
		cc8=1;
		document.getElementById('imgme8').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh8").style.display="none";
	}
	else
	{
		cc8=0;
		document.getElementById('imgme8').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh8").style.display="block";
	}
}

cc9=0;
function changeimage9()
{
	if (cc9==0) 
	{
		cc9=1;
		document.getElementById('imgme9').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh9").style.display="none";
	}
	else
	{
		cc9=0;
		document.getElementById('imgme9').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh9").style.display="block";
	}
}

cc10=0;
function changeimage10()
{
	if (cc10==0) 
	{
		cc10=1;
		document.getElementById('imgme10').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh10").style.display="none";
	}
	else
	{
		cc10=0;
		document.getElementById('imgme10').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh10").style.display="block";
	}
}

cc11=0;
function changeimage11()
{
	if (cc11==0) 
	{
		cc11=1;
		document.getElementById('imgme11').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh11").style.display="none";
	}
	else
	{
		cc11=0;
	
		document.getElementById('imgme11').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh11").style.display="block";
	}
}

 cc12=0;
function changeimage12()
{
	if (cc12==0) 
	{
		cc12=1;
		document.getElementById('imgme12').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh12").style.display="none";
	}
	else
	{
		cc12=0;
		document.getElementById('imgme12').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh12").style.display="block";
		
	}
}

cc13=0;
function changeimage13()
{
	if (cc13==0) 
	{
		cc13=1;
	
		document.getElementById('imgme13').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh13").style.display="none";
	}
	else
	{
		cc13=0;
		document.getElementById('imgme13').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh13").style.display="block";
	}
}

cc14=0;
function changeimage14()
{
	if (cc14==0) 
	{
		cc14=1;
		document.getElementById('imgme14').src="style/images/arrow trans_down.png";
		document.getElementById("advsrh14").style.display="none";
	}
	else
	{
		cc14=0;
		document.getElementById('imgme14').src="style/images/arrow trans_next.png";
		document.getElementById("advsrh14").style.display="block";
	}
} 

	

	
function propertyTable()
{
var urlprop = "../../templates/showList.php";

// Set te random number to add to URL request

// Pass the login variables like URL variable
http.open('get', urlprop);
http.onreadystatechange = getpropertydata;
http.send(null);

return false;
 
}


function getpropertydata() 
{
 if(http.readyState == 4)
 {
  var getpropertyd = http.responseText;
 
  if(getpropertyd!='')
  {
     
     if(document.getElementById('showList')!=null)
	 document.getElementById('showList').innerHTML = getpropertyd;
      //document.getElementById('showTable').style.display="none";
      //  document.getElementById('jommmmin_purdue').style.display="none";
  }
  else {
  
    if(document.getElementById('showList')!=null)
     document.getElementById('showList').innerHTML='';
	    //document.getElementById('showTable').style.display="block";
  
  }
  // else if login is ok show a message: "Site added+ site URL".
  //document.getElementById('insert_response').innerHTML =response ;
  
 }
}	

function viewpropertiesdetails(property_id)
{

	if(document.getElementById('view_detail_viewproperties'))
	self.location="viewpropertydetails.php?propertyid=" + property_id;
	
	if(document.getElementById('view_detail'))
	self.location="modules/propertymanager/viewpropertydetails.php?propertyid=" + property_id;
	
}	
function view_schedule(listingid)
{
if(document.getElementById('view_detail_schedule'))
	self.location="./schedule_visit.php?listingid=" + listingid;
	
	

}	

function viewproperties1(listing_id,pk_PropertyMrg_ID)
{
var	listingid=listing_id;
var	pk_PropertyMrg_ID=pk_PropertyMrg_ID;

if(document.getElementById('view_detail'))
	self.location="modules/propertymanager/viewproperties.php?listingid=" + listingid+'&pk_PropertyMrg_ID='+ pk_PropertyMrg_ID;
	
	if(document.getElementById('view_detail_viewproperties'))
	self.location="viewproperties.php?listingid=" + listingid+'&pk_PropertyMrg_ID='+ pk_PropertyMrg_ID;
	
/*	if(document.getElementById('view_detail_schedule'))
	self.location="modules/propertymanager/schedule_visit.php?listingid=" + listingid;
*/
}	


/*rajani*/
/*function viewproperties_self(listing_id)
{
listingid=listing_id;

self.location="viewproperties.php?listingid=" + listingid;
}
*/
/*rajani*/


function viewproperties(oval)
{

//first=document.getElementById('view_detail').title;

first=oval;

var urlprop = "templates/viewproperties.php?first=" + first;
 document.getElementById('showTable').style.display="none";
 document.getElementById('showList').style.display="none";
 document.getElementById('viewprop').style.display="block";
 document.getElementById('vertical_view_div').style.display="none";
// document.getElementById('add_prop_block').style.display="none";
 document.getElementById('insert_response').style.display="none";
http.open('get', urlprop);
http.onreadystatechange = getpropertyview;
http.send(null);
return false;
}


function getpropertyview() 
{
 if(http.readyState == 4)
 {
  var getpropertyv = http.responseText;
	
  if(getpropertyv!='')
  {
     document.getElementById('viewprop').innerHTML = getpropertyv;
	 
	 
     
  }
  else {
  
   	 	
     document.getElementById('viewprop').innerHTML='';
  
  }
  
  
 }
}	
/*ajax function for inserting record to database */	
function IsNumeric(sText)
		{
   			var ValidChars = "0123456789.";
   			var IsNumber=true;
   			var Char;

 
   			for (i = 0; i < sText.length && IsNumber == true; i++) 
      		{ 
      			Char = sText.charAt(i); 
      			if (ValidChars.indexOf(Char) == -1) 
        		 {
        		 IsNumber = false;
				 break;
        		 }
      		}
  			 return IsNumber;
   
  		 }	

function checkURL(value) {
var urlregex = new RegExp("^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)");
if(urlregex.test(value))
{
return(true);
}
return(false);
}


	
function displayRow(){  


document.getElementById("hide_ppar").style.display='block';


}
function hideRow(){  


document.getElementById("hide_ppar").style.display='none';


}
/* property manager and property entry login form */
function insert_recorddb(stdjoin, member)
{

var ProfileType;

if (member==null)
var member="";



if(stdjoin=='1')
{
	var selection = document.joinform.profiletype.value;	
	ProfileType=selection;	
}
else 
{
	var selection = document.joinform.profiletype;
	for (i=0; i<selection.length; i++)
	{
	  if (selection[i].checked == true)
	 ProfileType=selection[i].value;
	}
}
//alert(ProfileType);

//if(document.getElementById('profiletype').checked==true)
//var ProfileType = document.getElementById('profiletype').value;

//if(ProfileType==undefined)
//ProfileType='1';


if(document.getElementById('first_name')!=null)
var first_name = escape(document.getElementById('first_name').value);
//var middle_name = document.getElementById('middle_name').value;
if(document.getElementById('last_name')!=null)
var last_name = escape(document.getElementById('last_name').value);

if(document.getElementById('email')!=null)
var email = escape(document.getElementById('email').value);

if(document.getElementById('user_name')!=null)
var user_name =escape(document.getElementById('user_name').value);

if(document.getElementById('pass_word')!=null)
var pass_word= escape(document.getElementById('pass_word').value);

if(document.getElementById('confirm_password')!=null)
var confirm_password = escape(document.getElementById('confirm_password').value);

if(document.getElementById('con_per_mobile')!=null)
var con_per_mobile = escape(document.getElementById('con_per_mobile').value);

if(document.getElementById('comp_phone')!=null)
var comp_phone = escape(document.getElementById('comp_phone').value);


//ProfileType = document.getElementById('profiletype').options[ProfileType].value;



///company details
var com_name='';

if(document.getElementById('com_name')!=null)
var com_name = escape(document.getElementById('com_name').value);
//var txbDescription = document.getElementById('txbDescription').value;
var txbDescription='';

var comp_phone='';
if(document.getElementById('comp_phone')!=null)
var comp_phone = escape(document.getElementById('comp_phone').value);



if(document.getElementById('com_street_add')!=null)
var com_street_add = escape(document.getElementById('com_street_add').value);
else
com_street_add='';

var com_city='';
if(document.getElementById('com_city')!=null)
var com_city= escape(document.getElementById('com_city').value);


var com_state='';
if(document.getElementById('com_state')!=null)
var com_state = escape(document.getElementById('com_state').value);




var com_state='';

if(document.getElementById('com_state')!=null)
{
var com_state = document.getElementById('com_state').selectedIndex;
com_state =escape(document.getElementById('com_state').options[com_state].value);
}


var com_zip='';
if(document.getElementById('com_zip')!=null)
var com_zip = escape(document.getElementById('com_zip').value);

var com_website='';
if(document.getElementById('com_website')!=null)
var com_website = escape(document.getElementById('com_website').value);

///persondetail
//var cont_person = document.getElementById('cont_person').value;
//var con_per_mobile = document.getElementById('con_per_mobile').value;
var cont_person='';



var hiddencaptcha=document.getElementById('hiddenCaptcha').value;
var userCaptcha=document.getElementById('userCaptcha').value;



	


/*if(document.getElementById('active').checked==true)
var active =1;
else
active=0;*/

var active;

if(ProfileType==3)
{
	 active =1;
}
else if(ProfileType==1)
{
	 active =0;
}


//active =1;
if (stdjoin!='1')
{
	if  (first_name == "" ) 
	{
		alert( "Please Enter First name" );
		document.getElementById('first_name').focus();
		return false;
	}
	
	
/*if(middle_name == "" ) {
		alert( "Please Enter Middle" );
		document.getElementById('middle_name').focus();
		return false;
	}*/

	if  (last_name == "" ) 
	{
		alert( "Please Enter Last Name" );
		document.getElementById('last_name').focus();
		return false;
	}
}
/*	
	if  (mobile == "" ) {
		alert( "Please Enter mobile" );
	    document.getElementById('comp_phone').focus();
		return false;
	}	*/

if  (user_name == "" ) {
		alert( "Please Enter Username" );
		document.getElementById('user_name').focus();
		return false;
	}


if  ( email == "" ) {
		alert( "Please Enter Email." );
		document.getElementById('email').focus();
		return false;
	}
	else if( ( email.search("@") == -1 ) || ( email.search("[.*]" ) == -1 ) ) 
		{
			alert( "Please Enter Proper Email." );
			document.getElementById('email').focus();
			return false;
		}

if  (pass_word == "" ) {
		alert( "Please Enter password!" );
	    document.getElementById('pass_word').focus();
		return false;
	}
	
	
	if  (confirm_password =="") {
		alert( "Confirm Password does not match with Password" );
		document.getElementById('confirm_password').focus();
		return false;
	}
	
	if  (confirm_password != pass_word ) {
		alert( "Confirm Password does not match with Password" );
		document.getElementById('confirm_password').focus();
		return false;
	}
	
	


	
  /* else if(!IsNumeric(mobile))
	{
		alert( "Please Enter Proper Number of mobile" );
		    document.getElementById('mobile').focus();
		return false;
	}*/
///company detail validation

if(ProfileType=='1')
{

if  (com_name == "" ) {
		alert( "Please Enter Company Name" );
		document.getElementById('com_name').focus();
		return false;
	}

/*if  (txbDescription == "" ) {
		alert( "Please Enter Description" );
	    document.getElementById('txbDescription').focus();
		return false;
	}*/
	
	
/*if(comp_phone == "" ) {
		alert( "Please Enter Company Phone Number" );
		document.getElementById('comp_phone').focus();
		return false;
	}
	 else if(!IsNumeric(comp_phone))
	{
		alert( "Please Enter Proper Company Phone Number" );
		    document.getElementById('comp_phone').focus();
		return false;
	}*/

if  (com_street_add == "" ) {
		alert( "Please Enter Street Address" );
		document.getElementById('com_street_add').focus();
		return false;
	}

if  (com_city == "" ) {
		alert( "Please Enter City" );
	    document.getElementById('com_city').focus();
		return false;
	}
	

	
if  (com_zip == "" ) {
		alert( "Please Enter Zip Code" );
	    document.getElementById('com_zip').focus();
		return false;
	}
	
	
/*if(com_website == "" ) {
		alert( "Please Enter website" );
		document.getElementById('com_website').focus();
		return false;
	}
 else if(!checkURL(com_website))
	{
		alert( "Please Enter Proper Website URL" );
		document.getElementById('com_website').focus();
		return false;
	}*/
///contact person

/*if  (cont_person == "" ) {
		alert( "Please Enter Contact Person Name" );
		document.getElementById('cont_person').focus();
		return false;
	}

if  (con_per_mobile == "" ) {
		alert( "Please Enter Contact Person Mobile Number" );
	    document.getElementById('con_per_mobile').focus();
		return false;
	}
	 else if(!IsNumeric(con_per_mobile))
	{
		alert( "Please Enter Proper Contact Person Mobile Number" );
		    document.getElementById('con_per_mobile').focus();
		return false;
	}
*/
}
	if  (userCaptcha =="") {
		alert( "Please Enter verification Code");
		document.getElementById('userCaptcha').focus();
		return false;
	}
	//alert(userCaptcha);
	//alert(hiddencaptcha);
	if  (userCaptcha != hiddencaptcha ) {
		alert( "verification Code not matching" );
		document.getElementById('userCaptcha').focus();
		return false;
	}

if (stdjoin=='1' )
{
	first_name = user_name;
	last_name ="";
}

	  
	  
var urlrecdb = "../../templates/joindata_save.php?user_name=" + user_name + '&first_name=' + first_name + '&last_name=' + last_name + '&pass_word=' + pass_word  + '&confirm_password=' + confirm_password+ '&email=' + email+ '&ProfileType=' + ProfileType+ '&active=' + active + '&com_name=' + com_name + '&txbDescription=' + txbDescription + '&comp_phone=' + comp_phone + '&com_street_add=' + com_street_add  + '&com_city=' + com_city+ '&com_state=' + com_state + '&com_zip=' + com_zip + '&com_website=' + com_website+ '&cont_person=' + cont_person+ '&con_per_mobile=' + con_per_mobile+ '&member=' + member;


// Set te random number to add to URL request
//alert(urlrecdb);
// Pass the login variables like URL variable
http.open('get', urlrecdb);
http.onreadystatechange = getresult_db;
http.send(null);
return false;
 
}


function getresult_db() 
{
 if(http.readyState == 4)
 {

var getres_save = http.responseText ;

  if(getres_save!='')
  {

		var getres_save1 = getres_save.replace(/^\s+|\s+$/g,"");
 	
	
	if (getres_save1=="USER_ERROR")
			getres_save1 = "User already Exist!";
	if (getres_save1=="EMAIL_ERROR")
			getres_save1 = "Email already Exist!";
	if (getres_save1=="ERROR")
			 getres_save1 = "Please Check And Fill Form Again";
	
	if (getres_save1=="SAVE3")
		{
			

            getres_save1 = "Congratulations! Your Profile Has Been Created. Please sign in with your login details.";
			window.location.href='/welcomestudents.php';
			 
		
			 //alert(getres_save1);
			/* document.getElementById('user_name').value='';
			 document.getElementById('first_name').value='';
			 document.getElementById('middle_name').value='';
			// document.getElementById('last_name').value='';
			 document.getElementById('email').value='';
			 document.getElementById('com_name').value='';
			 document.getElementById('txbDescription').value='';
			 document.getElementById('comp_phone').value='';
			 document.getElementById('com_street_add').value='';
			 document.getElementById('com_city').value='';
			 document.getElementById('com_state').value='';
			 document.getElementById('com_zip').value='';
			 document.getElementById('com_website').value='';
			 document.getElementById('cont_person').value='';
			 document.getElementById('con_per_mobile').value='';*/
			
		}
		else if(getres_save1=="SAVE1")
		{
					
		//getres_save1='Now, please check your email. You must click on the activation link in the email we just sent you in order to complete your registration.';
		
		getres_save1='';
		window.location.href='/joinresult.php';
		
	   }
	   else if(getres_save1=="SAVE_MEMBER")
	   {
   		getres_save1='';
	   	window.location.href='/thanks.php';
	   }
	
		// document.getElementById('display_message').display="block";
		    document.getElementById('display_message').style.display="block";
		   
		   document.getElementById('display_message').innerHTML = getres_save1;
		 document.getElementById('pass_word').value='';
		 document.getElementById('confirm_password').value='';


  }
  else {
  
   	 if (document.getElementById('viewprop')!=null)	
     document.getElementById('viewprop').innerHTML='';
  
  }
  // else if login is ok show a message: "Site added+ site URL".
  //document.getElementById('insert_response').innerHTML =response ;
  
 }
}	

function validate_propertydb()
{
	
//var property_type = document.getElementById('property_type').value;

//var location = document.getElementById('location').selectedIndex;
//location = document.getElementById('location').options[location].value;

var count = document.property_form.location.length;
var location=0; 
var intCounter=0;
while(intCounter<count)
{
	if(document.property_form.location[intCounter].checked==true)
	{
		location = document.property_form.location[intCounter].value;
	}
	intCounter++;
}


var propertyname = document.getElementById('propertyname').value;
//var description = document.getElementById('description').value;

var description = tinyMCE.get('description').getContent();
//tinyMCE.get('editor1').setContent('<h1>This is Ronen Site 1</h1>');



var address = document.getElementById('address').value;
//var other_physical_address = document.getElementById('other_physical_address').value;
var mailing_address = document.getElementById('mailing_address').value;
var city = document.getElementById('city').value;

var state= document.getElementById('state').value;

//var country = document.getElementById('country').value;
var zip_code = document.getElementById('zip_code').value;
var fax = document.getElementById('fax').value;
var phoneone = document.getElementById('phoneone').value;

var phonetwo = document.getElementById('phonetwo').value;
var email_ur = document.getElementById("email_ur").value;

var web_url = document.getElementById('web_url').value;



var location_directions = document.getElementById('location_directions').value;
//var trash = document.getElementById('trash').value;


var property_par = document.getElementById('property_par').selectedIndex;
property_par = document.getElementById('property_par').options[property_par].value;

var con_per_name = document.getElementById('con_per_name').value;

var longitude = document.getElementById('longitude').value;

var latitude = document.getElementById('latitude').value;

if(document.getElementById('active').checked==true)
var active =1;
else
active=0;

//if(document.getElementById('featured').checked==true)
//var featured =1;
//else
featured=0;


var user_name = document.getElementById('user_name').value;

var pass_word= document.getElementById('pass_word').value;

var confirm_password = document.getElementById('confirm_password').value;


if (location =="") {
		alert( "Please select location" );
	    document.getElementById('location').focus();
		return false;
	}	

if  (propertyname == "" ) {
		alert( "Please Enter Propety Name" );
		document.getElementById('propertyname').focus();
		return false;
	}
	  if (description =="") {
		alert( "Please enter description" );
	    document.getElementById('description').focus();
		return false;
	}	
	
if (con_per_name =="") {
		alert( "Please enter contact person" );
	    document.getElementById('con_per_name').focus();
		return false;
	}
	
	

if  (address == "" ) {
		alert( "Please Enter address" );
	    document.getElementById('address').focus();
		return false;
	}

/*if  (other_physical_address == "" ) {
		alert( "Please Enter Physical address" );
	    document.getElementById('other_physical_address').focus();
		return false;
	}*/

 if(city == "" ) {
		alert( "Please Enter city" );
		document.getElementById('city').focus();
		return false;
	}

if  (state == "" ) {
		alert( "Please Enter state" );
		document.getElementById('state').focus();
		return false;
	}

/*if  (country == "" ) {
		alert( "Please Enter country" );
	    document.getElementById('country').focus();
		return false;
	}
	*/
	
	if  (zip_code =="") {
		alert( "Please  Enter zip code" );
		document.getElementById('zip_code').focus();
		return false;
	}
	
	
/*	if  (fax =="") {
		alert( "Please  Enter fax" );
		document.getElementById('fax').focus();
		return false;
	}*/
	if  (phoneone =="") {
		alert( "Please  Enter Phone1" );
		document.getElementById('phoneone').focus();
		return false;
	}
	
	

if  (mailing_address == "" ) {
		alert( "Please Enter Mailing address" );
	    document.getElementById('mailing_address').focus();
		return false;
	}	
	if  (longitude == "" ) 
	{
		alert( "Please Enter Longitude" );
		document.getElementById('longitude').focus();
		return false;
	}
	
	if  (latitude == "" ) 
	{
		alert( "Please Enter Latitude" );
		document.getElementById('latitude').focus();
		return false;
	}

		/*else if(!IsNumeric(phoneone))
	{
		alert( "Please Enter Proper Phone1 Number" );
		    document.getElementById('phoneone').focus();
		return false;
	}*/
	//else if(!IsNumeric(phonetwo))
//	{
//		alert( "Please Enter Proper Phone2 Number" );
//		    document.getElementById('phonetwo').focus();
//		return false;
//	}
	

	
	
/*	if  (email_ur == "" ) {
		alert( "Please Enter Email." );
		document.getElementById('email_ur').focus();
		return false;
	}
	else if( ( email_ur.search("@") == -1 ) || ( email_ur.search("[.*]" ) == -1 ) ) 
		{
			alert( "Please Enter Proper Email." );
			document.getElementById('email_ur').focus();
			return false;
		}*/
	
/*	if  (web_url == "" ) 
	   {
		alert( "Please Enter Web URL");
	    document.getElementById('web_url').focus();
		return false;
		} 
	else if(!checkURL(web_url))
	{
		alert( "Please Enter Proper Website URL" );
		document.getElementById('web_url').focus();
		return false;
	}
*/

if  (pass_word != "" && user_name=="" ) 
{
		alert( "Please Enter Username" );
		document.getElementById('user_name').focus();
		return false;
}

if  (confirm_password != "" && (user_name=="" || pass_word=="")) 
{
		alert( "User Name or Password is Missing" );
		document.getElementById('user_name').focus();
		return false;
}


if  (user_name != "" ) 
{
	//	alert( "Please Enter Username" );
	//	document.getElementById('user_name').focus();
	//	return false;

	if  (pass_word == "" ) 
	{
		alert( "Please Enter password" );
	   document.getElementById('pass_word').focus();
		return false;
	}

	if  (confirm_password =="") 
	{
		alert( "Confirm Password does not match with Password" );
		document.getElementById('confirm_password').focus();
		return false;
	}
}






/*if  (location_directions == "" ) {
		alert( "Please Enter Location Directions");
	    document.getElementById('location_directions').focus();
		return false;
	} */
/*if  (trash == "" ) {
		alert( "Please Enter Trash");
	    document.getElementById('trash').focus();
		return false;
	}	 */
	


/*var urlrecdb = "../../templates/listproperty_save.php?property_type=" + property_type + '&propertyname=' + propertyname + '&description=' + description + '&location=' + location + '&address=' + address +  '&city=' + city  + '&state=' + state+ '&country=' + country + '&zip_code=' + zip_code + '&fax=' + fax+ '&phoneone=' + phoneone+ '&phonetwo=' + phonetwo + '&email_ur=' + email_ur + '&web_url=' + web_url + '&other_physical_address=' + other_physical_address + '&mailing_address=' + mailing_address + '&location_directions=' + location_directions + '&trash=' + trash + '&property_par=' + property_par+ '&active='+ active+'&featured='+ featured+'&con_per_name='+ con_per_name;*/

var urlrecdb = "../../templates/checkuerexist.php?user_name=" + user_name;
// Set te random number to add to URL request

// Pass the login variables like URL variable
http.open('get', urlrecdb);
http.onreadystatechange = get_propertydata;
http.send(null);
return false;
 
}

function get_propertydata() 
{
  if(http.readyState == 4)
  {
	
     var get_resp_property = http.responseText;
	   
	   get_resp_property=get_resp_property.replace(/^\s+|\s+$/g,"");
	 
     if(get_resp_property=="USER_ERROR")
     {
         alert("user already exist");
		 document.getElementById('user_name').focus();
  
      }
	  else{
		  
		  document.property_form.submit();		  
		  
		  }
  
  
   }
}	


function validate_property(fk_profile_id)
{
	
	//var property_type = document.getElementById('property_type').value;

var propertyname = document.getElementById('propertyname').value;
//var description = document.getElementById('description').value;

var description = tinyMCE.get('description').getContent();
//tinyMCE.get('editor1').setContent('<h1>This is Ronen Site 1</h1>');

var count = document.frmEditProperty.location.length;
var location=0; 
var intCounter=0;
while(intCounter<count)
{
	if(document.frmEditProperty.location[intCounter].checked==true)
	{
		location = document.frmEditProperty.location[intCounter].value;
	}
	intCounter++;
}
//document.getElementById('location').selectedIndex;
//location = document.getElementById('location').options[location].value;

var address = document.getElementById('address').value;
//var other_physical_address = document.getElementById('other_physical_address').value;
var mailing_address = document.getElementById('mailing_address').value;
var city = document.getElementById('city').value;

var state= document.getElementById('state').value;

//var country = document.getElementById('country').value;
var zip_code = document.getElementById('zip_code').value;
//var fax = document.getElementById('fax').value;
var phoneone = document.getElementById('phoneone').value;

var phonetwo = document.getElementById('phonetwo').value;
var email_ur = document.getElementById("email_ur").value;

var web_url = document.getElementById('web_url').value;
var location_directions = document.getElementById('location_directions').value;
//var trash = document.getElementById('trash').value;


/*var property_par = document.getElementById('property_par').selectedIndex;
property_par = document.getElementById('property_par').options[property_par].value;*/

var con_per_name = document.getElementById('con_per_name').value;

var longitude = document.getElementById('longitude').value;
var latitude = document.getElementById('latitude').value;




if(document.getElementById('active').checked==true)
var active =1;
else
active=0;

//if(document.getElementById('featured').checked==true)
//var featured =1;
//else
featured=0;

var user_name = document.getElementById('user_name').value;

//var pass_word= document.getElementById('pass_word').value;

//var confirm_password = document.getElementById('confirm_password').value;
if(location==0)
{		alert( "Please Select Location" );
		document.getElementById('location').focus();
		return false;
}

if  (propertyname == "" ) {
		alert( "Please Enter Propety Name" );
		document.getElementById('propertyname').focus();
		return false;
	}
	
if (con_per_name =="") {
		alert( "Please enter contact person" );
	    document.getElementById('con_per_name').focus();
		return false;
	}
	


if  (address == "" ) {
		alert( "Please Enter address" );
	    document.getElementById('address').focus();
		return false;
	}

/*if  (other_physical_address == "" ) {
		alert( "Please Enter Physical address" );
	    document.getElementById('other_physical_address').focus();
		return false;
	} */
	
	

 if(city == "" ) {
		alert( "Please Enter city" );
		document.getElementById('city').focus();
		return false;
	}

if  (state == "" ) {
		alert( "Please Enter state" );
		document.getElementById('state').focus();
		return false;
	}

/*if  (country == "" ) {
		alert( "Please Enter country" );
	    document.getElementById('country').focus();
		return false;
	}
*/	
	
	if  (zip_code =="") {
		alert( "Please  Enter zip code" );
		document.getElementById('zip_code').focus();
		return false;
	}
	
	
	/*if  (fax =="") {
		alert( "Please  Enter fax" );
		document.getElementById('fax').focus();
		return false;
	} */
	if  (phoneone =="") {
		alert( "Please  Enter Phone1" );
		document.getElementById('phoneone').focus();
		return false;
	}
	/*	else if(!IsNumeric(phoneone))
	{
		alert( "Please Enter Proper Phone1 Number" );
		    document.getElementById('phoneone').focus();
			
		return false;
	}
	else if(!IsNumeric(phonetwo))
	{
		alert( "Please Enter Proper Phone2 Number" );
		    document.getElementById('phonetwo').focus();
		return false;
	}*/
	
	/*if  (email_ur == "" ) {
		alert( "Please Enter Email." );
		document.getElementById('email_ur').focus();
		return false;
	}
	else if( ( email_ur.search("@") == -1 ) || ( email_ur.search("[.*]" ) == -1 ) ) 
		{
			alert( "Please Enter Proper Email." );
			document.getElementById('email_ur').focus();
			return false;
		}*/
	
/*	if  (web_url == "" ) 
	   {
		alert( "Please Enter Web URL");
	    document.getElementById('web_url').focus();
		return false;
		}
	else if(!checkURL(web_url))
	{
		alert( "Please Enter Proper Website URL" );
		document.getElementById('web_url').focus();
		return false;
	}*/


/*if  (pass_word != "" && user_name=="" ) 
{
		alert( "Please Enter Username" );
		document.getElementById('user_name').focus();
		return false;
}
*/
//if  (confirm_password != "" && (user_name=="" || pass_word=="")) 
//{
//		alert( "User Name or Password is Missing" );
//		document.getElementById('user_name').focus();
//		return false;
//}


/*if  (user_name != "" ) 
{
		//alert( "Please Enter Username" );
		//document.getElementById('user_name').focus();
		//return false;

	if  (pass_word == "" ) 
	{
		alert( "Please Enter password" );
	   document.getElementById('pass_word').focus();
		return false;
	}

	if  (confirm_password =="") 
	{
		alert( "Confirm Password does not match with Password" );
		document.getElementById('confirm_password').focus();
		return false;
	}
	
	if  (confirm_password != pass_word ) 
	{
		alert( "Confirm Password does not match with Password" );
		document.getElementById('confirm_password').focus();
		return false;
	}


}*/



/*   if  (user_name == "" ) {
		alert( "Please Enter Username" );
		document.getElementById('user_name').focus();
		return false;
	}
if  (pass_word == "" ) {
		alert( "Please Enter password" );
	    document.getElementById('pass_word').focus();
		return false;
	}
	
	
	if  (confirm_password =="") {
		alert( "The password don't match" );
		document.getElementById('confirm_password').focus();
		return false;
	}
	
	if  (confirm_password != pass_word ) {
		alert( "Password not matching" );
		document.getElementById('confirm_password').focus();
		return false;
	}*/
	
	if (longitude =="") {
		alert( "Please enter Longitude" );
	    document.getElementById('longitude').focus();
		return false;
	}	
	
	if (latitude =="") {
		alert( "Please enter Latitude" );
	    document.getElementById('latitude').focus();
		return false;
	}	

if (description =="") {
		alert( "Please enter description" );
	    document.getElementById('description').focus();
		return false;
	}	
	


if  (mailing_address == "" ) {
		alert( "Please Enter Mailing address" );
	    document.getElementById('mailing_address').focus();
		return false;
	}

if (location =="") {
		alert( "Please select location" );
	    document.getElementById('location').focus();
		return false;
	}	


//var fk_profile_id = document.getElementById(fk_profile_id).value;

/*if  (location_directions == "" ) {
		alert( "Please Enter Location Directions");
	    document.getElementById('location_directions').focus();
		return false;
	} */
/*if  (trash == "" ) {
		alert( "Please Enter Trash");
	    document.getElementById('trash').focus();
		return false;
	}	*/
	
var urlcheckexist = "../../templates/checkuerexist.php?user_name=" + user_name + '&fk_profile_id='+fk_profile_id;
// Set te random number to add to URL request

// Pass the login variables like URL variable
http.open('get', urlcheckexist);
http.onreadystatechange = get_propertyupdatecheck;
http.send(null);
return false;
 
}

function get_propertyupdatecheck() 
{
  if(http.readyState == 4)
  {
	 
     var get_property_up = http.responseText;
	   
	   get_property_up=get_property_up.replace(/^\s+|\s+$/g,"");
	
	 
     if(get_property_up=="USER_ERROR")
     {
         alert("user already exist");
		 document.getElementById('user_name').focus();
  
      }
	  if(get_property_up=="SAVE")
	  {
		    document.frmEditProperty.submit();		  
	  }
  
  
   }
}	

function forget_pass()
{
		var urlprop = "../../templates/forget_pass.php";

// Set te random number to add to URL request

// Pass the login variables like URL variable
http.open('get', urlprop);
http.onreadystatechange = getpassword;
http.send(null);

return false;
}


function imagehover(listingid)
{
urlprop = "../tooltip/imagehover.php?listingid=" + listingid;
http.open('get', urlprop);
http.onreadystatechange =getibigimage;
http.send(null);

}

function getibigimage()
{
	if(http.readyState == 4)
	{
  	var imagehover = http.responseText;
	}
}
//function getpassword() 
//{
 //if(http.readyState == 4)
 //{
  //var getpass = http.responseText;
 
//  if(getpass!='')
  //{
     
    // document.getElementById('forget_pass').innerHTML = getpass;
      //document.getElementById('showTable').style.display="none";
      //  document.getElementById('jommmmin_purdue').style.display="none";
  //}
  //else {
  
    
    // document.getElementById('forget_pass').innerHTML='';
	    //document.getElementById('showTable').style.display="block";
  
  //}
  // else if login is ok show a message: "Site added+ site URL".
  //document.getElementById('insert_response').innerHTML =response ;
  
 //}
//}	




// Function to manage the photos and floorplans

//function manage_photos()
//{
//var urlPhoto='';
//
////if (pk_listing_id!='')
////	urlPhoto = "Modules/propertymanager/manage_photos.php?pk_propertymgr_id=" + pk_propertymgr_id + '&pk_listing_id=' + pk_listing_id;
////else
////	urlPhoto = "Modules/propertymanager/manage_photos.php?pk_propertymgr_id=" + pk_propertymgr_id;
//
//
//urlPhoto = "manage_photos.php";
//
//
//alert(urlPhoto);
//http.open('get', urlPhoto);
//http.onreadystatechange = getPhoto;
//http.send(null);
//return false;
//}
//
//
//function getPhoto() 
//{
// if(http.readyState == 4)
// {
//  var getPhotov = http.responseText;
// 
//  alert(getPhotov);
//  if(getPhotov!='')
//       {
//		   
//		   document.getElementById('manage_photos').innerHTML = getPhotov;
//	   	   document.getElementById('manage_photos').style.display="block";
//		   document.getElementById('manage_property_photos').style.display="block";
//	   }
//  else 
//     {
//		 document.getElementById('manage_photos').innerHTML='';
//	 	document.getElementById('manage_photos').style.display="block";
//		document.getElementById('manage_property_photos').style.display="block";
//	 }
//  
// }
//}	


function validate_profileform(profiletype) {

	

	
var user_name = document.getElementById('user_name').value;

var first_name = document.getElementById('first_name').value;

var last_name = document.getElementById('last_name').value;

var email = document.getElementById('email').value;


///company details





///persondetail







if  (first_name == "" ) {
		alert( "Please Enter First name" );
	    document.getElementById('first_name').focus();
		return false;
	}
	
	


if  (last_name == "" ) {
		alert( "Please Enter Last Name" );
		document.getElementById('last_name').focus();
		return false;
	}


	
	if  ( email == "" ) {
		alert( "Please Enter Email." );
		document.getElementById('email').focus();
		return false;
	}
	else if( ( email.search("@") == -1 ) || ( email.search("[.*]" ) == -1 ) ) 
		{
			alert( "Please Enter Proper Email." );
			document.getElementById('email').focus();
			return false;
		}

  if  (user_name == "" ) {
		alert( "Please Enter Username" );
		document.getElementById('user_name').focus();
		return false;
	}


if(profiletype=='1')
{

	
var com_name = document.getElementById('com_name').value;


var comp_phone = document.getElementById('comp_phone').value;

var com_street_add = document.getElementById('com_street_add').value;

var com_city= document.getElementById('com_city').value;

var com_state = document.getElementById('com_state').value;


var com_state = document.getElementById('com_state').selectedIndex;
com_state = document.getElementById('com_state').options[com_state].value;


var com_zip = document.getElementById('com_zip').value;

var com_website = document.getElementById('com_website').value;



if  (com_name == "" ) {
		alert( "Please Enter Company Name" );
		document.getElementById('com_name').focus();
		return false;
	}


if  (com_street_add == "" ) {
		alert( "Please Enter Street Address" );
		document.getElementById('com_street_add').focus();
		return false;
	}

if  (com_city == "" ) {
		alert( "Please Enter City" );
	    document.getElementById('com_city').focus();
		return false;
	}
	
if  (com_state =="") {
		alert( "Please Enter Company State" );
		document.getElementById('com_state').focus();
		return false;
	}
	
if  (com_zip == "" ) {
		alert( "Please Enter Zip Code" );
	    document.getElementById('com_zip').focus();
		return false;
	}
	
	
/*if(com_website == "" ) {
		alert( "Please Enter website" );
		document.getElementById('com_website').focus();
		return false;
	}
 else if(!checkURL(com_website))
	{
		alert( "Please Enter Proper Website URL" );
		document.getElementById('com_website').focus();
		return false;
	}*/

}
}



function checkQuickListing(listingid)
{
	if (!listingid=='')
	{
		urlprop = "/templates/QuickListing.php?listingid=" + listingid;
		http.open('get', urlprop);
		http.onreadystatechange =getQuickListingDetails;
		http.send(null);
	}
	else
	{
		document.getElementById('quickError').innerHTML= "Please Enter Listing #";
		document.getElementById('quick_listing').style.height='45px';
	}
}

function getQuickListingDetails()
{
	if(http.readyState == 4)
	{
  	var isExist = http.responseText;
	isExist = isExist.replace(/^\s+|\s+$/g,"");
	if (isExist !='')
	{
		location.href = isExist;
		document.getElementById('quickError').innerHTML= "";
	}
	else
	{
		if (document.getElementById('quickError')!=null)
		{
		document.getElementById('quickError').innerHTML= "This listing # is not currently available or does not exist!";
		document.getElementById('quick_listing').style.height='45px';
		}
	}
	}
}




function checkQuickProperty(propertyid)
{

	if (!propertyid=='')
	{
		urlprop = "/templates/QuickProperty.php?propertyid=" + propertyid;
	http.open('get', urlprop);
		http.onreadystatechange =getQuickPropertyDetails;
		http.send(null);
	}
}

function getQuickPropertyDetails()
{
	if(http.readyState == 4)
	{
  	var isExist = http.responseText;
	isExist = isExist.replace(/^\s+|\s+$/g,"");
	if (isExist !='')
	{
		location.href = isExist;
		document.getElementById('quickError').innerHTML= "";
	}
	else
	{
		if (document.getElementById('quickError')!=null)
		{
		document.getElementById('quickError').innerHTML= "This Property is not currently available or does not exist!";
		document.getElementById('quick_listing').style.height='75px';
		}
	}
	}
}









function changeStatus(pk_listing_id, status)
{
	var isActive;
	//id= "sponsored_checkbox[" +  pk_listing_id + "]";
	id= "txtSponsored[" +  pk_listing_id + "]";

	//if(document.getElementById(id).checked==false)
	if(document.getElementById(id).value<=0)
	{
	if (status==0)
		isActive = confirm("Do you really want to make listing " +  pk_listing_id + " Active?");
	else
		isActive = confirm("Do you really want to make listing " +  pk_listing_id + " InActive?");

		if (isActive==true)
		{
			if(status==0)
				document.getElementById(id).disabled=false;
			else
			document.getElementById(id).disabled=true;
		
		urlprop = "setStatus.php?listingid=" + pk_listing_id + "&status=" + status;
		http.open('get', urlprop);
		http.onreadystatechange =SetStatus;
		http.send(null);
		}
  }
	else
		alert("Please make this listing unsponsored first, if you want to inactivate it! \nPut zero in Sponsored text box to make it inactive");

}

function SetStatus()
{
	
	if(http.readyState == 4)
	{
  	var Status = http.responseText;
	var listing = Status.split('~');
	id = "img" + listing[0];
	document.getElementById(id).innerHTML = listing[1];

	}
}


//To Make Listing Featured

function MakeFeatured(pk_listing_id, status)
{
	var isFeatured;
	id= "image" + pk_listing_id;


	if (status==0)
		isFeatured = confirm("Do you really want to make listing " +  pk_listing_id + " Featured?");
	else
		isFeatured = confirm("Do you really want to make listing " +  pk_listing_id + " Non Featured?");

		if (isFeatured==true)
		{
			urlprop = "/modules/propertymanager/setFeatured.php?listingid=" + pk_listing_id + "&status=" + status;
			http.open('get', urlprop);
			http.onreadystatechange =SetFeatured;
			http.send(null);
		}

}

function SetFeatured()
{
	
	if(http.readyState == 4)
	{
  	var Status = http.responseText;
	var listing = Status.split('~');
	id = "image" + listing[0];
	document.getElementById(id).innerHTML = listing[1];

	}
}

function deleteLisitng(listingId)
{
		var isDeleted = confirm("Do you really want to delete this listing " +  listingId );

		if (isDeleted==true)
		{
			urlprop = "deleteData.php?deleteCase=Listing&listingID=" + listingId;
			http.open('get', urlprop);
			http.onreadystatechange =confirmDelete;
			http.send(null);
		}
}

function confirmDelete()
{
	if(http.readyState == 4)
	{
		var Status = http.responseText;
		if(Status==1)
		   window.location.href ="/modules/propertymanager/property_listing_view.php";
		
	}
}



function popSoldout(URL) {


day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=300,height=150,left = 440,top = 362');");
}
function popRegform(URL) {

day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=yes,statusbar=0,menubar=0,resizable=1,width=530,height=570,left = 440,top = 100');");
}

function validate_claimform()
{
var first_name = document.getElementById('first_name').value;

var last_name = document.getElementById('last_name').value;

var email = document.getElementById('email').value;


var com_name = document.getElementById('com_name').value;



var con_per_mobile = document.getElementById('con_per_mobile').value;




///company details



var comp_phone = document.getElementById('comp_phone').value;
var com_street_add = document.getElementById('com_street_add').value;

var com_city= document.getElementById('com_city').value;

var com_state = document.getElementById('com_state').value;


var com_state = document.getElementById('com_state').selectedIndex;
com_state = document.getElementById('com_state').options[com_state].value;


var com_zip = document.getElementById('com_zip').value;
var com_website = document.getElementById('com_website').value;




var hiddencaptcha=document.getElementById('hiddenCaptcha').value;
var userCaptcha=document.getElementById('userCaptcha').value;






if(first_name == "" ) {
		alert( "Please Enter First name" );
	    document.getElementById('first_name').focus();
		return false;
	}
	


if  (last_name == "" ) {
		alert( "Please Enter Last Name" );
		document.getElementById('last_name').focus();
		return false;
	}
	


if  ( email == "" ) {
		alert( "Please Enter Email." );
		document.getElementById('email').focus();
		return false;
	}
	else if( ( email.search("@") == -1 ) || ( email.search("[.*]" ) == -1 ) ) 
		{
			alert( "Please Enter Proper Email." );
			document.getElementById('email').focus();
			return false;
		}


if  (com_name == "" ) {
		alert( "Please Enter Company Name" );
		document.getElementById('com_name').focus();
		return false;
	}



if  (com_street_add == "" ) {
		alert( "Please Enter Street Address" );
		document.getElementById('com_street_add').focus();
		return false;
	}

if  (com_city == "" ) {
		alert( "Please Enter City" );
	    document.getElementById('com_city').focus();
		return false;
	}
	

	
if  (com_zip == "" ) {
		alert( "Please Enter Zip Code" );
	    document.getElementById('com_zip').focus();
		return false;
	}
	
	

	if  (userCaptcha =="") {
		alert( "Please Enter verification Code");
		document.getElementById('userCaptcha').focus();
		return false;
	}
	
	if  (userCaptcha != hiddencaptcha ) {
		alert( "verification Code not matching" );
		document.getElementById('userCaptcha').focus();
		return false;
	}	

if(!document.getElementById('agreement').checked)
	{
		
	    alert( "Please check the Terms of Use and Privacy Policy" );
	    document.getElementById('agreement').focus();
		return false;	
    }

 if(!document.getElementById('propertyright').checked)
	{
		
	    alert( "Please check  owner or manager of this property and have the right to update information regarding it" );
	    document.getElementById('propertyright').focus();
		return false;	
    }

}





function GetSponsered(fk_propertymgr_id, pk_listing_id, status)
{

var isSponsered;
	var id = "sponsored_checkbox[" + pk_listing_id + "]";
	var ids = "sponsored[" + pk_listing_id + "]";
	if (status==true)
	{
		isSponsered=true;
	//isSponsered = confirm("Do you really want to make listing " +  pk_listing_id + " Sponsered?");
	//if (isSponsered==true)
		urlprop = "getSponsered.php?listingid=" + pk_listing_id + "&status=" + status + "&fk_propertymgr_id=" + fk_propertymgr_id+ "&isSponsered=" + isSponsered;
	//else
	//	{
	//		document.getElementById(id).checked = false ;
	//		document.getElementById(ids).value=0;
	//	}
	}
	else
	{
		isSponsered=true;
	//isSponsered = confirm("Do you really want to make listing " +  pk_listing_id + " Un Sponsered?");
	//if (isSponsered==true)
			urlprop = "getSponsered.php?listingid=" + pk_listing_id + "&status=" + status + "&fk_propertymgr_id=" + fk_propertymgr_id+ "&isSponsered=" + isSponsered;
	//	else
	//	{
	//		document.getElementById(id).checked = true;
	//		document.getElementById(ids).value=1;
	//	}
	}
	
http.open('get', urlprop);
	http.onreadystatechange =GetSponser;
	http.send(null);
	
	
	
}
	


function GetSponser()
{
	
	if(http.readyState == 4)
	{
  	var Status = http.responseText;
	var listing = Status.split('~');
	var id = "sponsored_checkbox[" + listing[0] + "]";
	var ids = "sponsored[" + listing[0] + "]";
	Status =  listing[1];
	if(Status==0)
	{
		document.getElementById(id).checked = false ;
		document.getElementById(ids).value=0;
	}
	
	if(Status==-1)
	{
	alert("You have insufficient balance in your account! Please purchase the credit to make this listing sponsored..");
	document.getElementById(id).checked = false ;
	document.getElementById(ids).value=0;
	}
	}
}


function setmyFav(pk_listing_id)
{


	//urlprop = "templates/getdata_fromdb.php?listingid=" + pk_listing_id + "&status=" + status + "&fk_propertymgr_id=" + fk_propertymgr_id+ "&isSponsered=" + isSponsered;
    urlprop = "/templates/getmyfav.php?listingid=" + pk_listing_id;
	http.open('get', urlprop);
    http.onreadystatechange =Getmyfav;
	http.send(null);
	
	
	
}
	


function Getmyfav()
{
	
	if(http.readyState == 4)
	{
  		var listingid = http.responseText;
	   
	   var listing = listingid.split('~');
	   
	   var mess=listing[0];
	   var status=listing[1];
	     
	
	   if(status==3)
	   {
		
		window.location.href="/modules/propertymanager/member-registration.php";   
		 }
	   else {
	   
	   alert(mess);

	   }
     	if(status==0)
       {


	   }
       else if(status==1)
	    {
         window.location.reload(true);
	    }
	    
	}
return false;
}

function deletemyFav(FAV_pk_fav_id)
{

   var isActive;
   
   isActive = confirm("Do you really want to remove this listing from 'My Favorites'?");


if(isActive==true)
{
    urlprop = "deletemyfav.php?FAV_pk_fav_id=" + FAV_pk_fav_id;
	http.open('get', urlprop);
    http.onreadystatechange =deltmyfav;
	http.send(null);
}

}
	


function deltmyfav()
{
	
	if(http.readyState == 4)
	{
  		var listingid = http.responseText;
	    alert(listingid);
	   
	   location.href='/modules/propertyviewer/myfav.php';
	//alert("listing"+listingid+"have added to ur my Favorite");
	
	 return false;
	}
}

function savesearchStud(arrsearch)
{
	//document.getElementById('chkBedrooms2bed').checked=true;	
	
var	SearchCriteria=document.getElementById('SearchCriteria').innerHTML;

//Sanjeevs Saved Search Commented By Mukul	
/*if(SearchCriteria=='')
{
	if(document.getElementById('any').checked ==true)
	{
	SearchCriteria='Any Housing Type';	
	}

	if(document.getElementById('all').checked ==true)
	{
		
	SearchCriteria='All Location';	
	}
	if((document.getElementById('any').checked ==true) && (document.getElementById('all').checked ==true))
	{
	SearchCriteria='Any Housing Type | All Location';	
	}
}

if(SearchCriteria=='')
{
	alert("You need to first define a search criteria to Save it!");
	exit();
}
	
var arrss=arrsearch.split('|');
var arrbeds=arrss[0].split('~');
var 	beds=arrbeds[0];
var	    baths=arrss[1];
var	    prices=arrss[2];
var	    unitsmonths=arrss[3];
var	    squarefeet=arrss[4];
var	    leasedate=arrss[5];
var	    propertyall=arrss[6];
var	    housetype=arrss[7];
var	    locationtype=arrss[8];*/
// urlsearch = "/modules/propertyviewer/searchstd.php?beds=" + beds + "&baths=" + baths + "&prices=" + prices+ "&unitsmonths=" + unitsmonths + "&squarefeet=" + squarefeet + "&leasedate=" + leasedate+ "&propertyall=" + propertyall + "&housetype=" + housetype+ "&locationtype=" + locationtype+"&SearchCriteria="+SearchCriteria;
//Sanjeevs Saved Search Commented By Mukul	
	//alert(SearchCriteria);
	var queryString = window.location.search.substring();
	urlsearch = "/modules/propertyviewer/saveStudentSearch.php?queryString=" + queryString +"&searchCriteria="+SearchCriteria;

	http.open('get',urlsearch);
    http.onreadystatechange =getsearchresponse;
	http.send(null);
}

function getsearchresponse()
{
	if(http.readyState == 4)
	{
  		var searchresps = http.responseText;
         searchresps=searchresps.split('~');
		 alert(searchresps[0]);
		 if(searchresps[1]!=0)
		 {
			 location.href='/search.php';	
		 }
//	 location.href='/';
	}
}

function deletemysearch(pk_search_id)
{
   var isActive;
   isActive = confirm(" Are you sure to delete your saved search??");
	if(isActive==true)
	{
    urlprop = "deletemysearch.php?pk_search_id=" + pk_search_id;
	http.open('get', urlprop);
    http.onreadystatechange =deltmysearch;
	http.send(null);
	}
}
	
function deltmysearch()
{
	
	if(http.readyState == 4)
	{
  		var listingid = http.responseText;
	   // alert(listingid);
	   
	  window.location='/modules/propertyviewer/mysearch.php';
	//alert("listing"+listingid+"have added to ur my Favorite");
	
	 return false;
	}
}

function createDuplicateListing(listingId)
{
	var is_confirmed = confirm('Do you want to make duplicate of this listing');
    if (is_confirmed) 
	{
		url = "createDuplicateListing.php?listingId=" + listingId;
		http.open('get', url);
		http.onreadystatechange =confirmDuplicate;
		http.send(null);
	}
}

function confirmDuplicate()
{
	if(http.readyState == 4 )
	{
			var res = http.responseText;
			if(res!=0)
			{
				alert("Duplicate Listing Created With New Listing Number " + res);
				//window.location.reload();
				window.location.href="/modules/propertymanager/more_list_detail.php?pklistingid=" + res;
			}
			else
				alert("Unable to create duplicate listing ");

	 return false;
	}
}

function runMySearch(searchUrl)
{
	window.location.href= "/search.php" + searchUrl;
}


function runSearch(searchid,status)
{
  if(status!='')
  {
  window.location="/index.php?stds="+searchid;	
  }
  else
  {
	
		
	
	urlprop = '/modules/propertyviewer/runmysearch.php?pk_search_id='+ searchid;
	//alert(urlprop);
	
/*	http.open('get', urlprop);
    http.onreadystatechange =grunsearch;
	http.send(null);*/
   var strp=requestFile(urlprop);
   
   
   
  // var searchresult = http.responseText;
	  
	  
	//alert(searchresult);
	    var searchrstarr=strp.split('~');
	

	
	 
	   var bedsarr= new Array();
	  
	  var bedsarr=searchrstarr[0].split(',');  
	  

	  if(searchrstarr[0]!='falsev')
	    {
	       for(i=0;i<bedsarr.length;i++)
	        {
			  if(document.getElementById(bedsarr[i])!=null)
			   {
				
	             document.getElementById(bedsarr[i]).checked=true;	
			   }
            }
	
	    }
	 
	// alert(searchrstarr[1]);
	document.getElementById('prices').value=searchrstarr[1];
	 if(searchrstarr[1]!='')
	  {
		document.getElementById('prices').value=searchrstarr[1];
		
	  }
	  
	  if(searchrstarr[2]!='')
	  {
		document.getElementById('unitsmonths').value=searchrstarr[2];
		
	  }
	   if(searchrstarr[3]!='')
	    {
		document.getElementById('baths').value=searchrstarr[3];
		
	   }
	    if(searchrstarr[4]!='')
	    {
		document.getElementById('squarefeet').value=searchrstarr[4];
		
	   }
	   
	  // alert(searchrstarr[5]);
	   if(searchrstarr[5]!='')
	    {
		   document.getElementById('lease_mm').value=searchrstarr[5];
		
	   }
	
	  
	  if(searchrstarr[6]!='')
	    {
		document.getElementById('propertyall').value=searchrstarr[6];
		
	   }
	   
	   
	  //alert(searchrstarr[7]);
	  
	
	
	   var housingarr= new Array();
	  
	  var housingarr=searchrstarr[7].split(',');  
	 
	 
	// alert(searchrstarr[7]);
	 
	  if(searchrstarr[7]!='falsev')
	    {
			
			
			
	       for(i=0;i<housingarr.length;i++)
	        {
	            document.getElementById(housingarr[i]).checked=true;	
		
            }
	
	    }
		
   if (document.getElementById('any').checked ==true)
     {

       document.getElementById('chkHousingTypeAB').checked =true;
       document.getElementById('chkHousingTypeAC').checked =true;
       document.getElementById('chkHousingTypeTownhome').checked =true;
       document.getElementById('chkHousingTypeEH').checked =true;
       document.getElementById('chkHousingTypeMUH').checked =true;
   }
	   
	
	//alert(searchrstarr[8]);
	   var locationarr= new Array();
	  
	  var locationarr=searchrstarr[8].split(',');  
	  
 //alert(locationarr.length);


	  if(searchrstarr[8]!='falsev')
	    {
	       for(i=0;i<locationarr.length;i++)
	        {
	            document.getElementById(locationarr[i]).checked=true;	
		
            }
	
	    }
	    displaydetail();
	   
	  //document.getElementById('display_detail').style.display="none";
	   //alert("testing");
		insert('1');
	  


   }
}


function requestFile(url) {
  http.open('get', url, false);
  http.send(null);  // synchronous; returns when response is complete
  return http.responseText;
}



/*function grunsearch()
{
	
	
	if(http.readyState == 4)
	{
  		var searchresult = http.responseText;
	  
	  
	//alert(searchresult);
	    var searchrstarr=searchresult.split('~');
	

	
	 
	   var bedsarr= new Array();
	  
	  var bedsarr=searchrstarr[0].split(',');  
	  

	  if(searchrstarr[0]!='falsev')
	    {
	       for(i=0;i<bedsarr.length;i++)
	        {
			  if(document.getElementById(bedsarr[i])!=null)
			   {
				
	             document.getElementById(bedsarr[i]).checked=true;	
			   }
            }
	
	    }
	 
	// alert(searchrstarr[1]);
	document.getElementById('prices').value=searchrstarr[1];
	 if(searchrstarr[1]!='')
	  {
		document.getElementById('prices').value=searchrstarr[1];
		
	  }
	  
	  if(searchrstarr[2]!='')
	  {
		document.getElementById('unitsmonths').value=searchrstarr[2];
		
	  }
	   if(searchrstarr[3]!='')
	    {
		document.getElementById('baths').value=searchrstarr[3];
		
	   }
	    if(searchrstarr[4]!='')
	    {
		document.getElementById('squarefeet').value=searchrstarr[4];
		
	   }
	   
	  // alert(searchrstarr[5]);
	   if(searchrstarr[5]!='')
	    {
		   document.getElementById('lease_mm').value=searchrstarr[5];
		
	   }
	
	  
	  if(searchrstarr[6]!='')
	    {
		document.getElementById('propertyall').value=searchrstarr[6];
		
	   }
	   
	   
	  //alert(searchrstarr[7]);
	  
	
	
	   var housingarr= new Array();
	  
	  var housingarr=searchrstarr[7].split(',');  
	 
	 
	// alert(searchrstarr[7]);
	 
	  if(searchrstarr[7]!='falsev')
	    {
			
			
			
	       for(i=0;i<housingarr.length;i++)
	        {
	            document.getElementById(housingarr[i]).checked=true;	
		
            }
	
	    }
		
   if (document.getElementById('any').checked ==true)
     {

       document.getElementById('chkHousingTypeAB').checked =true;
       document.getElementById('chkHousingTypeAC').checked =true;
       document.getElementById('chkHousingTypeTownhome').checked =true;
       document.getElementById('chkHousingTypeEH').checked =true;
       document.getElementById('chkHousingTypeMUH').checked =true;
   }
	   
	
	alert(searchrstarr[8]);
	   var locationarr= new Array();
	  
	  var locationarr=searchrstarr[8].split(',');  
	  
 //alert(locationarr.length);


	  if(searchrstarr[8]!='falsev')
	    {
	       for(i=0;i<locationarr.length;i++)
	        {
	            document.getElementById(locationarr[i]).checked=true;	
		
            }
	
	    }
	    //displaydetail();
	   
	  //document.getElementById('display_detail').style.display="none";
	   //alert("testing");
		insert('1');
	  
	
	//alert("hiiiii2");
	/*  
	  if(searchrstarr[0]!="")
	  {
		document.getElementById('chkBedrooms1bed').checked=true;	  
	  }
	  


	

	}
 
}*/

function getXMLHTTPRequest()
 {
 var req = false;
 try
   {
  req = new XMLHttpRequest(); /* e.g. Firefox */
   }
 catch(err1)
   {
   try
  {
   req = new ActiveXObject("Msxml2.XMLHTTP");
   /* some versions IE */
  }
   catch(err2)
  {
  try
    {
     req = new ActiveXObject("Microsoft.XMLHTTP");
   /* some versions IE */
    }
    catch(err3)
   {
    req = false;
   }
  }
   }
 return req;
 }
var ajax_test=0;
var myRequest = getXMLHTTPRequest();



//**************************************************************************************************************
//Function Name: 		getPropertyListings	
//Author Name:			Mukul Chauhan		
//Date:					08-Oct-2009
//Input Parameters:		intPkPropertyID
//Purpose:				To get all the listing of the given property on click of (+) button on Properties Page.	
//**************************************************************************************************************




function getPropertyListings(strPropertyId, strOrderBy, intPkListingsID, bedrooms, showTitle)
{

   var url = "/templates/getPropertyListings.php?strPropertyId=" + strPropertyId + "&strOrderBy=" + strOrderBy + "&intPkListingsID=" + intPkListingsID+ "&bedrooms=" + bedrooms + "&showTitle=" + showTitle;
	
var st=setPropertyListing(url);
   return st;
}
	


function setPropertyListing(url)
{
	myRequest.open('get', url, false);
    myRequest.send(null);  // synchronous; returns when response is complete
	//alert(myRequest.responseText);
return myRequest.responseText;
	
	
	

	/*var listing = Status.split('~');
	var id = "sponsored_checkbox[" + listing[0] + "]";
	var ids = "sponsored[" + listing[0] + "]";
	Status =  listing[1];
	if(Status==0)
	{
		document.getElementById(id).checked = false ;
		document.getElementById(ids).value=0;
	}
	
	if(Status==-1)
	{
	alert("You have insufficient balance in your account! Please purchase the credit to make this listing sponsored..");
	document.getElementById(id).checked = false ;
	document.getElementById(ids).value=0;
	}*/
	
}

//**************************************************************************************************************
//Function Name: 		getPropertyListings	
//Author Name:			sanjeev		
//Date:					21-Oct-2009
//Input Parameters:		intPkListingsID,bedrooms, strOrderBy
//Purpose:				To get all the listing of the given beds number .	
//**************************************************************************************************************

function getBedroomsListings(intPkListingsID,bedrooms, strPropertyId, strOrderBy)
{
	  //alert(strPropertyId);
var url = "/templates/getBedroomslistings.php?pk_listingid=" + intPkListingsID + "&beds_number=" + bedrooms + "&strPropertyId=" + strPropertyId + "&strOrderBy=" + strOrderBy;
	
   var st=setBedroomsListings(url);
   return st;
}
	


function setBedroomsListings(url)
{
	myRequest.open('get', url, false);
    myRequest.send(null);  // synchronous; returns when response is complete
   	return myRequest.responseText;
}


function advertise(url) 
{
	myRequest.open('get', url, false);
    myRequest.send(null);  // synchronous; returns when response is complete
    return myRequest.responseText;
}


function getListingDetailsForMap(propertyid)
{
	var url = "/getData.php?propertyid=" + propertyid; 
    var st=getMapListingDetails(url);
    return st;
}


function getMapListingDetails(url)
{
	myRequest.open('get', url, false);
    myRequest.send(null);  // synchronous; returns when response is complete
	return myRequest.responseText;
}





//-------------------------------  End User Scripts -----------------------------------




//-------------------------------  Start Admin Scripts -----------------------------------



