
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='';
if (document.getElementById('chkBedroomsStudio')!=null)
{
if(document.getElementById('chkBedroomsStudio').checked==true)
	{		
		chkBedroomsStudio= encodeURI(document.getElementById('chkBedroomsStudio').value);
		SearchCriteria = SearchCriteria + 'Studio, ';
	}
else
	chkBedroomsStudio= '';
}
var chkBedrooms1bed='';
if (document.getElementById('chkBedrooms1bed')!=null)
{
if(document.getElementById('chkBedrooms1bed').checked==true)
	{var chkBedrooms1bed= encodeURI(document.getElementById('chkBedrooms1bed').value);
	SearchCriteria = SearchCriteria + '1, '; }
else
	chkBedrooms1bed= '';
}
var chkBedrooms2bed='';
if (document.getElementById('chkBedrooms2bed')!=null)
{
if(document.getElementById('chkBedrooms2bed').checked==true)
	{var chkBedrooms2bed= encodeURI(document.getElementById('chkBedrooms2bed').value);
	SearchCriteria = SearchCriteria + '2, '; }
else
	chkBedrooms2bed= '';
}
var chkBedrooms3bed='';
if (document.getElementById('chkBedrooms3bed')!=null)
{
if(document.getElementById('chkBedrooms3bed').checked==true)
	{var chkBedrooms3bed= encodeURI(document.getElementById('chkBedrooms3bed').value);
		SearchCriteria = SearchCriteria + '3, '; }
else
	chkBedrooms3bed= '';
}
var chkBedrooms4bed='';
if (document.getElementById('chkBedrooms4bed')!=null)
{
if(document.getElementById('chkBedrooms4bed').checked==true)
	{var chkBedrooms4bed= encodeURI(document.getElementById('chkBedrooms4bed').value);
		SearchCriteria = SearchCriteria + '4, '; }
else
	chkBedrooms4bed= ''; 
}

var chkBedrooms5bed='';
if (document.getElementById('chkBedrooms5bed')!=null)
{
if(document.getElementById('chkBedrooms5bed').checked==true)
	{var chkBedrooms5bed= encodeURI(document.getElementById('chkBedrooms5bed').value);
		SearchCriteria = SearchCriteria + '5+, '; }
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);

if (IsSponsered==0)
{
var baths = document.getElementById('baths').value;

var baths1 = document.getElementById('baths').selectedIndex;
baths1 = document.getElementById('baths').options[baths1].text;

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

var prices1 = document.getElementById('prices').selectedIndex;
prices1 = document.getElementById('prices').options[prices1].text;

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

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

var squarefeet1 = document.getElementById('squarefeet').selectedIndex;
squarefeet1 = document.getElementById('squarefeet').options[squarefeet1].text;


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

var lease_mm1 = document.getElementById('lease_mm').selectedIndex;
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
//if(document.getElementById('propertyall') !=null)
//{
var	propertyall = document.getElementById('propertyall').value;
var propertydesc = document.getElementById('propertyall').selectedIndex;
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 (document.getElementById('propertyall') !=null)
//{

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, '; }
else
	chkHousingTypeAB= '';

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

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



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


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


}
//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, '; }
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, '; }
else
	chkLocationCS= '';
}
else
chkLocationCS= '';


var chkLocationNC='';
if(document.getElementById('chkLocationNC').checked==true)
	{var chkLocationNC= encodeURI(document.getElementById('chkLocationNC').value);
	SearchCriteria = SearchCriteria + 'Off Campus, '; }
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, '; }
	else
		chkLocationSC= '';
}
var chkLocationDL='';
if(document.getElementById('chkLocationDL').checked==true)
	{var chkLocationDL= encodeURI(document.getElementById('chkLocationDL').value);
	SearchCriteria = SearchCriteria + 'Downtown Lafayette, '; }
else
	chkLocationDL= '';

var chkLocationLafayette='';
if(document.getElementById('chkLocationLafayette').checked==true)
	{var chkLocationLafayette= encodeURI(document.getElementById('chkLocationLafayette').value);
	SearchCriteria = SearchCriteria + 'Lafayette, '; }
else
	chkLocationLafayette= '';
}
}
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 = "AYear, AMonth, ADay "
			break;
		case 7:
			sortingby = "RentPerUnit"
			break;
		case 8:
			sortingby = "RentPerBed"
			break;
		case 9:
			sortingby = "TotalMatched"
			break;
			
		default:
			sortingby = "CD"
	}

}



var totalAdvance=document.advancesearch.chkadvance.length;
var iCounter=0;
var strGroupDetailsId="";
var intTotalChecked=0;
while(iCounter<totalAdvance)
{
	if(document.advancesearch.chkadvance[iCounter].checked==true)
	{
		
		if (strGroupDetailsId=="")
			strGroupDetailsId = strGroupDetailsId + document.advancesearch.chkadvance[iCounter].value;
		else
		 strGroupDetailsId = strGroupDetailsId + "," + document.advancesearch.chkadvance[iCounter].value;
		 intTotalChecked++;
	}
iCounter++;
}
var isErrorLink='N';
 if(document.getElementById('modify_search').style.display=="block")
 isErrorLink='Y';
//alert(strGroupDetailsId);


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


}

else if (isGrid==2)
{
	var url = "templates/gridview_display.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;;

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


}




//+ '&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)
{


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


if (document.getElementById('insert_response')!=null)
{
document.getElementById('insert_response').innerHTML = "<image src='images/loading_bak_sd.gif' width='30' height='30'>";
}


var url =	ShowSearchblock(isGrid, IsSorting, IsSponsered);

if (url!=undefined && url!='' )
{
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 = '';
         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";
		}
		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('error')!=null)
   document.getElementById('error').innerHTML = "";

   
 }  
/* 
 function leftmenu()
 {
   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_bak.jpg";
   }
   
   if (document.getElementById("12").style.display="none")
   {
	
	document.getElementById('imgme12').src="style/images/arrow_bak.jpg";
   }
   
   if (document.getElementById("13").style.display="none")
   {
	
	document.getElementById('imgme13').src="style/images/arrow_bak.jpg";
   }
	
   
 }  */
 


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

	//removed from the below condtion document.getElementById('chkHousingTypeEH').checked ==true && to remove the entire house
  if( document.getElementById('chkHousingTypeAB').checked ==true &&  document.getElementById('chkHousingTypeAC').checked ==true && 
   document.getElementById('chkHousingTypeTownhome').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)
 {

	//document.getElementById('chkLocationSC').checked ==true &&  removed from the below condition  to remove the south of campus location
	
  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 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_down_bak.jpg";
	}
	else
	{
		cc1=0;
		
		document.getElementById('imgme1').src="style/images/arrow_bak.jpg";
	}
}

cc2=0
function changeimage2()
{
	if (cc2==0) 
	{
		cc2=1;
		
		document.getElementById('imgme2').src="style/images/arrow_down_bak.jpg";
	}
	else
	{
		cc2=0;
		document.getElementById('imgme2').src="style/images/arrow_bak.jpg";
	}
}

cc3=0;
function changeimage3()
{
	if (cc3==0) 
	{
		cc3=1;
		document.getElementById('imgme3').src="style/images/arrow_down_bak.jpg";
	}
	else
	{
		cc3=0;
		
		document.getElementById('imgme3').src="style/images/arrow_bak.jpg";
	}
}

cc4=0;
function changeimage4()
{
	if (cc4==0) 
	{
		cc4=1;
			document.getElementById('imgme4').src="style/images/arrow_down_bak.jpg";
	}
	else
	{
		cc4=0;
	
		
		document.getElementById('imgme4').src="style/images/arrow_bak.jpg";
	}
}

cc5=0;
function changeimage5()
{
	if (cc5==0) 
	{
		cc5=1;
		document.getElementById('imgme5').src="style/images/arrow_down_bak.jpg";
	}
	else
	{
		cc5=0;
		
		document.getElementById('imgme5').src="style/images/arrow_bak.jpg";
	}
}

cc6=0;
function changeimage6()
{
	if (cc6==0) 
	{
		cc6=1;
		document.getElementById('imgme6').src="style/images/arrow_down_bak.jpg";
	}
	else
	{
		cc6=0;
		
		document.getElementById('imgme6').src="style/images/arrow_bak.jpg";
	}
}

cc7=0;
function changeimage7()
{
	if (cc7==0) 
	{
		cc7=1;
		document.getElementById('imgme7').src="style/images/arrow_down_bak.jpg";
	}
	else
	{
		cc7=0;
		
		document.getElementById('imgme7').src="style/images/arrow_bak.jpg";
	}
}

cc8=0;
function changeimage8()
{
	if (cc8==0) 
	{
		cc8=1;
		document.getElementById('imgme8').src="style/images/arrow_down_bak.jpg";
	
	}
	else
	{
		cc8=0;
			document.getElementById('imgme8').src="style/images/arrow_bak.jpg";
	}
}

cc9=0;
function changeimage9()
{
	if (cc9==0) 
	{
		cc9=1;
			document.getElementById('imgme9').src="style/images/arrow_down_bak.jpg";
	}
	else
	{
		cc9=0;
	
		document.getElementById('imgme9').src="style/images/arrow_bak.jpg";
	}
}

cc10=0;
function changeimage10()
{
	if (cc10==0) 
	{
		cc10=1;
		document.getElementById('imgme10').src="style/images/arrow_down_bak.jpg";
	}
	else
	{
		cc10=0;
		document.getElementById('imgme10').src="style/images/arrow_bak.jpg";
	}
}

cc11=0;
function changeimage11()
{
	if (cc11==0) 
	{
		cc11=1;
		//document.getElementById('imgme11').src="style/images/arrow_down_bak.jpg";
	    document.getElementById('imgme11').src="style/images/arrow_down_bak.jpg";
	}
	else
	{
		cc11=0;
		//document.getElementById('imgme11').src="style/images/arrow_bak.jpg";
		document.getElementById('imgme11').src="style/images/arrow_bak.jpg";
	}
}

/* cc12=0;
function changeimage12()
{
	if (cc12==0) 
	{
		cc12=1;
		document.getElementById('imgme12').src="style/images/arrow_down_bak.jpg";
	}
	else
	{
		cc12=0;
		document.getElementById('imgme12').src="style/images/arrow_bak.jpg";
	}
}

cc13=0;
function changeimage13()
{
	if (cc13==0) 
	{
		cc13=1;
		document.getElementById('imgme13').src="style/images/arrow_down_bak.jpg";
	}
	else
	{
		cc13=0;
		document.getElementById('imgme13').src="style/images/arrow_bak.jpg";
	}
}

cc14=0;
function changeimage14()
{
	if (cc14==0) 
	{
		cc14=1;
		document.getElementById('imgme14').src="style/images/arrow_bak.jpg";
	}
	else
	{
		cc14=0;
		document.getElementById('imgme14').src="style/images/arrow_down_bak.jpg";
	}
} */

	

	
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!='')
  {
     
     document.getElementById('showList').innerHTML = getpropertyd;
      //document.getElementById('showTable').style.display="none";
      //  document.getElementById('jommmmin_purdue').style.display="none";
  }
  else {
  
    
     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()
{

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

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

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

var confirm_password = document.getElementById('confirm_password').value;
var email = document.getElementById('email').value;
//var mobile = document.getElementById('mobile').value;

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


///company details

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

var txbDescription = document.getElementById('txbDescription').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_zip = document.getElementById('com_zip').value;
var com_website = document.getElementById('com_website').value;

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

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




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

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  (pass_word == "" ) {
		alert( "Please Enter password" );
	    document.getElementById('pass_word').focus();
		return false;
	}
	
	
	if  (confirm_password =="") {
		alert( "Please enter password correctly" );
		document.getElementById('confirm_password').focus();
		return false;
	}
	
	if  (confirm_password != pass_word ) {
		alert( "Password not matching" );
		document.getElementById('confirm_password').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  (mobile == "" ) {
		alert( "Please Enter mobile" );
	    document.getElementById('mobile').focus();
		return false;
	}*/
	
  /* else if(!IsNumeric(mobile))
	{
		alert( "Please Enter Proper Number of mobile" );
		    document.getElementById('mobile').focus();
		return false;
	}*/
///company detail validation

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_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;
	}
///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;
	}




var urlrecdb = "../../templates/joindata_save.php?user_name=" + user_name + '&first_name=' + first_name + '&middle_name=' + middle_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;
// Set te random number to add to URL request

// 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!='')
  {
     document.getElementById('dis_message').innerHTML = getres_save;
   document.getElementById('user_name').value='';

 document.getElementById('first_name').value='';
 document.getElementById('middle_name').value='';
 document.getElementById('last_name').value='';

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

 document.getElementById('confirm_password').value='';
 document.getElementById('email').value='';
// document.getElementById('mobile').value='';
// document.getElementById('title').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 {
  
   	 	
     document.getElementById('viewprop').innerHTML='';
  
  }
  // else if login is ok show a message: "Site added+ site URL".
  //document.getElementById('insert_response').innerHTML =response ;
  
 }
}	

function insert_propertydb()
{
	


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 location = 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;




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

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




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 (description =="") {
		alert( "Please enter description" );
	    document.getElementById('description').focus();
		return false;
	}	
	

if (location =="") {
		alert( "Please select location" );
	    document.getElementById('location').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  (mailing_address == "" ) {
		alert( "Please Enter Mailing address" );
	    document.getElementById('mailing_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  (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;


// 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;
	
  if(get_resp_property!='')
  {
     document.getElementById('display_mess_prop').innerHTML = get_resp_property;
	 hideTable();
	 showTable();
	// document.getElementById('show_propery_entry_form').style.display="none";
  // document.getElementById('propertyname').value='';

if (document.getElementById("address")!=null)
	document.getElementById('address').value='';

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

if (document.getElementById("state")!=null)
	document.getElementById('state').value='';

if (document.getElementById("other_physical_address")!=null)
 	document.getElementById('other_physical_address').value='';

if (document.getElementById("description")!=null)
	tinyMCE.get('description').setContent('');

if (document.getElementById("mailing_address")!=null)
	document.getElementById('mailing_address').value='';

if (document.getElementById("country")!=null)
	document.getElementById('country').value='';

if (document.getElementById("zip_code")!=null)
	document.getElementById('zip_code').value='';

if (document.getElementById("fax")!=null)
	document.getElementById('fax').value='';

if (document.getElementById("phoneone")!=null)
	document.getElementById('phoneone').value='';

if (document.getElementById("phonetwo")!=null)
	document.getElementById('phonetwo').value='';
 
if (document.getElementById("email_ur")!=null)
	document.getElementById('email_ur').value='';

if (document.getElementById("web_url")!=null)
	document.getElementById('web_url').value='';
 
if (document.getElementById("location_directions")!=null)
	document.getElementById('location_directions').value='';

if (document.getElementById("trash")!=null)
	document.getElementById('trash').value='';


if (document.getElementById("propertyname")!=null)
	document.getElementById('propertyname').value='';

if (document.getElementById("con_per_name")!=null)
	document.getElementById('con_per_name').value='';

if (document.getElementById("location")!=null)
{
	var selLocation = document.getElementById('location');
	selLocation.selectedIndex = 0;

}




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



function validate_property()
{
	
	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 location = 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;




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

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




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 (description =="") {
		alert( "Please enter description" );
	    document.getElementById('description').focus();
		return false;
	}	
	

if (location =="") {
		alert( "Please select location" );
	    document.getElementById('location').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  (mailing_address == "" ) {
		alert( "Please Enter Mailing address" );
	    document.getElementById('mailing_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  (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;
	}	*/
	
}

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

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

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



}
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 Name: 		getPropertyListings	
//Author Name:			Mukul Chauhan		
//Date:					13-Oct-2009
//Input Parameters:		intPkPropertyID
//Purpose:				To get all the listing of the given property on click of (+) button on Properties Page.	
//**************************************************************************************************************


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 getPropertyListings(intPkPropertyID, strOrderBy)
{
   var url = "templates/getPropertyListings.php?PkPropertyID=" + intPkPropertyID + "&sortbyname=" + strOrderBy;
   var st=setPropertyListing(url);
   return st;
}
	


function setPropertyListing(url)
{
	
	myRequest.open('get', url, false);
    myRequest.send(null);  // synchronous; returns when response is complete
	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;
	}*/
	
}

