﻿
function Validate()
{
ddlMinAmt=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlMinAmt;

ddlMaxAmt=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlMaxAmt;
ddlMinAmtType=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlMinAmtType;
ddlMaxAmtType=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlMaxAmtType;


if(parseInt(ddlMinAmt.value)!=0 && parseInt(ddlMinAmtType.value)!=0 && parseInt(ddlMaxAmt.value)!=0 && parseInt(ddlMaxAmtType.value)!=0)
{
if((parseInt(ddlMinAmt.value)*parseInt(ddlMinAmtType.value))>(parseInt(ddlMaxAmt.value)*parseInt(ddlMaxAmtType.value)))
{

alert("From Range Should be Less than To Range")
ddlMinAmt.selectedIndex=0;
ddlMaxAmt.selectedIndex=0;
ddlMinAmtType.selectedIndex=0;
ddlMaxAmtType.selectedIndex=0;
ddlMinAmt.focus();
}
}

ddlRMin=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlRMin;
ddlRUnit=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlRUnit;
ddlRMax=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlRMax;
ddlRUnitMax=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlRUnitMax;

if(ddlRMin!=null)
{
if(parseInt(ddlRMin.value)!=0 && parseInt(ddlRUnit.value)!=0 && parseInt(ddlRMax.value)!=0 && parseInt(ddlRUnitMax.value)!=0)
{
if((parseInt(ddlRMin.value)*parseInt(ddlRUnit.value))>(parseInt(ddlRMax.value)*parseInt(ddlRUnitMax.value)))
{

alert("From Range Should be Less than To Range")

ddlRMin.selectedIndex=0;
ddlRMax.selectedIndex=0;
ddlRUnit.selectedIndex=0;
ddlRUnitMax.selectedIndex=0;

ddlRMin.focus();
}
}
}

ddlRMin=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlLMin;
ddlRUnit=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlLMinUnit;
ddlRMax=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlLMax;
ddlRUnitMax=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlLMaxUnit;

if(ddlRMin!=null)
{
if(parseInt(ddlRMin.value)!=0 && parseInt(ddlRUnit.value)!=0 && parseInt(ddlRMax.value)!=0 && parseInt(ddlRUnitMax.value)!=0)
{
if((parseInt(ddlRMin.value)*parseInt(ddlRUnit.value))>(parseInt(ddlRMax.value)*parseInt(ddlRUnitMax.value)))
{

alert("From Range Should be Less than To Range")
ddlRMin.selectedIndex=0;
ddlRMax.selectedIndex=0;
ddlRUnit.selectedIndex=0;
ddlRUnitMax.selectedIndex=0;
ddlRMin.focus();
}
}
}
}
// JScript File
function AllowOnlyNumeric(e)
{
	
     var key = (window.event) ? event.keyCode : e.which;  
	//alert(key) 
if ( key > 47 && key < 58 || key == 46 || key==8 || key==45)  
   return;
 else
 {
   if (window.event) 
       window.event.returnValue = null;
     else 
     e.preventDefault(); 
	 }
}
// JScript File

function AllowOnlyNumericDotDash(e)
{
	
     var key = (window.event) ? event.keyCode : e.which;  
	alert(key)
if ( key > 47 && key < 58 || key == 46 || key==8 || key==45)  
   return;
 else
 {
   if (window.event) 
       window.event.returnValue = null;
     else 
     e.preventDefault(); 
	 }
}
function AllowOnlyNumericDot(e)
{
	
     var key = (window.event) ? event.keyCode : e.which;  
	
if ( key > 47 && key < 58 || key == 46 || key==8)  
   return;
 else
 {
   if (window.event) 
       window.event.returnValue = null;
     else 
     e.preventDefault(); 
	 }
}
function EnableCity(obj)
{
txtCity=document.aspnetForm.ctl00_ContentPlaceHolder1_txtCity;

if(obj.value=="0")
{

txtCity.style.display="inline";
}
else
{
txtCity.style.display="none";


}
}
function EnableStateText(obj)
{
ddlCity=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlCity;
txtState=document.aspnetForm.ctl00_ContentPlaceHolder1_txtState;
txtCity=document.aspnetForm.ctl00_ContentPlaceHolder1_txtCity;
if(obj.value=="36")
{


txtState.style.display="inline";
txtCity.style.display="inline";

}
else
{


txtState.style.display="none";
txtCity.style.display="none";
}
}
function EnableState(obj)
{

ddlCity=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlCity;
ddlState=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlState;
txtState=document.aspnetForm.ctl00_ContentPlaceHolder1_txtState;
txtCity=document.aspnetForm.ctl00_ContentPlaceHolder1_txtCity;

if(obj.value!="1")
{
ddlCity.style.display="none";
ddlState.style.display="none";
txtState.style.display="inline";
txtCity.style.display="inline";

}
else
{


ddlCity.style.display="inline";
ddlState.style.display="inline";
txtState.style.display="none";
txtCity.style.display="none";

}
}


function EnableControls(Val)
{
ddlArea=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlArea;
ddlPrice=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlPrice;

if(Val==3 || Val==4 || Val==12 || Val==20 || Val==22)
{
document.getElementById("divbed").style.display="block";
document.getElementById("divFloors").style.display="block";
document.getElementById("divAge").style.display="block";
document.getElementById("divBuilt").style.display="block";

}
else if(Val==1 || Val==2 || Val==5 || Val==6 || Val==14 || Val==15 || Val==19 || Val==21)
{
document.getElementById("divbed").style.display="none";
document.getElementById("divFloors").style.display="none";
document.getElementById("divAge").style.display="none";
document.getElementById("divBuilt").style.display="none";
}
else
{

document.getElementById("divbed").style.display="none";
document.getElementById("divFloors").style.display="block";
document.getElementById("divAge").style.display="block";

document.getElementById("divBuilt").style.display="block";

}


if(Val==4)
{
if(document.getElementById("divUArea")!=null)
{
document.getElementById("divUArea").style.display="block";
document.getElementById("divbed").style.display="none";
}
}
else
{
if(document.getElementById("divUArea")!=null)
document.getElementById("divUArea").style.display="none";

}
if(document.getElementById("ChangeArea")!=null)
{
if(Val==4)
{
document.getElementById("ChangeArea").innerHTML="Flat Area";
}
else if(Val==6 || Val==15 || Val==19|| Val==20)
{
document.getElementById("ChangeArea").innerHTML="Land Area";
}
else if(Val==8 || Val==9 || Val==10 || Val==11 || Val==16)
{
document.getElementById("ChangeArea").innerHTML="Empty Space Available";

}
else
{
document.getElementById("ChangeArea").innerHTML="Site Area";
}
}


if(Val==15 || Val==16 || Val==17 || Val==18 || Val==19 || Val==20 )
{
    if(ddlArea.length==4)
    {
      var elOptNew = document.createElement('option');
        elOptNew.text = "Acres";
        elOptNew.value = 2;

    ddlArea.add(elOptNew,2); 

    }
    if(ddlPrice.length==3)
    {
      var elOptNew = document.createElement('option');
        elOptNew.text = "Per Acre";
        elOptNew.value = 2;

    ddlPrice.add(elOptNew,2); 

    }

}
else
{
if(ddlArea.length==5)
ddlArea.remove(2);
if(ddlPrice!=null)
if(ddlPrice.length==4)
ddlPrice.remove(2);

}

}


function EnLocationText(Val)
{
txtLocation=document.aspnetForm.ctl00_ContentPlaceHolder1_txtLocation;

if(Val=="119" || Val=="1216")
{
txtLocation.style.display="inline";

}
else
{
txtLocation.style.display="none";


}
}


function isDimension(Val)
{
TextD1=document.aspnetForm.ctl00_ContentPlaceHolder1_TextD1;
TextD2=document.aspnetForm.ctl00_ContentPlaceHolder1_TextD2;
txtArea=document.aspnetForm.ctl00_ContentPlaceHolder1_txtArea;

if(Val==3 || Val==4)
{
TextD1.style.display="inline";
TextD2.style.display="inline";
txtArea.style.display="none";
document.getElementById("x").style.display="inline";
}
else
{
TextD1.style.display="none";
TextD2.style.display="none";
txtArea.style.display="inline";
document.getElementById("x").style.display="none";

}


}

function isDimensionSearch(Val)
{
TextD1=document.aspnetForm.ctl00_ContentPlaceHolder1_TextD1;
TextD2=document.aspnetForm.ctl00_ContentPlaceHolder1_TextD2;
txtAreaMin=document.aspnetForm.ctl00_ContentPlaceHolder1_txtAreaMin;
txtAreaMax=document.aspnetForm.ctl00_ContentPlaceHolder1_txtAreaMax;

if(Val==3 || Val==4)
{
TextD1.style.display="inline";
TextD2.style.display="inline";
txtAreaMin.style.display="none";
txtAreaMax.style.display="none";
document.getElementById("To").style.display="none";

document.getElementById("x").style.display="inline";
}
else
{
TextD1.style.display="none";
TextD2.style.display="none";
txtAreaMin.style.display="inline";
txtAreaMax.style.display="inline";
document.getElementById("To").style.display="inline";
document.getElementById("x").style.display="none";

}


}

function Display()
{
rdnType_0=document.aspnetForm.ctl00_ContentPlaceHolder1_rdnType_0;
ddlPtype=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlPtype;
if(rdnType_0.checked)
{
document.getElementById("div2").style.display="none";
document.getElementById("div1").style.display="block";
if(ddlPtype.length==3)
    {
      var elOptNew = document.createElement('option');
        elOptNew.text = "Commercial";
        elOptNew.value = 7;

    ddlPtype.add(elOptNew,4); 

    }
}
else
{

document.getElementById("div1").style.display="none";
document.getElementById("div2").style.display="block";
if(ddlPtype.length==4)
    {
     
    ddlPtype.remove(3); 

    }
}
}



function DisFloors()
    {

  
   var val=parseInt(document.getElementById("ctl00_ContentPlaceHolder1_ddlFloor").value)
    
    for(i=1;i<=5;i++)
   {
   
   document.getElementById("spn" + i).style.display="none";  
   
   
   
   }
   for(i=1;i<=5;i++)
   {
   if(i<=val)
   {
   document.getElementById("spn" + i).style.display="inline";  
   
   }
   
   }
      
   }
function CheckTitle(source, args)
{
 args.IsValid = true;
 txtTitle = document.getElementById("ct100_ContentPlaceHolder1_txtTitle").value
 if(txtTitle=="")
 {
 args.IsValid = false;
 }
 return args.IsValid;
}
 
function CheckDescription(source, args)
{
 args.IsValid = true;
 txtDesc = document.getElementById("ct100_ContentPlaceHolder1_txtDesc").value
 if(txtDesc=="")
 {
 args.IsValid = false;
 }
 return args.IsValid;
} 

function CheckPhoto(source, agrs)
{
args.IsValid = true;
fuImage = document.getElementById("ct100_ContentPlaceHolder1_fuImage").value

if(fuImage=="")
{
args.IsValid = false;
}
return args.IsValid;
}
   
function CheckPType(source, args)
{
args.IsValid = true;
ddlPtype=document.getElementById("ctl00_ContentPlaceHolder1_ddlPtype").value

if(ddlPtype=="0")
{
args.IsValid = false;

}
return args.IsValid;

}
function CheckCity(source, args)
{
args.IsValid = true;
ddlPtype=document.getElementById("ctl00_ContentPlaceHolder1_ddlCity").value
ddlCityText=document.getElementById("ctl00_ContentPlaceHolder1_txtCity").value
if(ddlPtype=="3")
{

 if(ddlCityText=="")
args.IsValid = false;

}
return args.IsValid;

}
function CheckCitySearch(source, args)
{
args.IsValid = true;
ddlPtype=document.getElementById("ctl00_ContentPlaceHolder1_ddlCity").value
if(ddlPtype=="Select")
{

 
args.IsValid = false;

}
return args.IsValid;

}
function CheckLayout(source, args)
{
args.IsValid = true;
ddlPtype=document.getElementById("ctl00_ContentPlaceHolder1_ddlCity").value
ddlLocation=document.getElementById("ctl00_ContentPlaceHolder1_ddlLocation").value
txtLocation=document.getElementById("ctl00_ContentPlaceHolder1_txtLocation").value
if(ddlPtype=="3")
{
if(txtLocation=="")
args.IsValid = false;
}
else
{

if(ddlLocation=="0")
args.IsValid = false;

if(ddlLocation=="119" || ddlLocation=="1216")
{
if(txtLocation=="")
args.IsValid = false;

}

}

return args.IsValid;

}



function CheckLayoutSearch(source, args)
{
args.IsValid = true;
ddlLocation=document.getElementById("ctl00_ContentPlaceHolder1_ddlLocation").value

if(ddlLocation=="Select")
args.IsValid = false;


return args.IsValid;

}



function CheckPrice(source, args)
{
args.IsValid = true;

ddlPrice=document.getElementById("ctl00_ContentPlaceHolder1_ddlPrice").value
ddlCAmount=document.getElementById("ctl00_ContentPlaceHolder1_ddlCAmount").value
ddlLAmount=document.getElementById("ctl00_ContentPlaceHolder1_ddlLAmount").value
ddlTAmount=document.getElementById("ctl00_ContentPlaceHolder1_ddlTAmount").value
ddlHAmount=document.getElementById("ctl00_ContentPlaceHolder1_ddlHAmount").value

if((ddlPrice!="0") && (ddlCAmount=="0" && ddlLAmount=="0" && ddlTAmount=="0" && ddlHAmount=="0"))
{
args.IsValid = false;
return args.IsValid;
}
if((ddlPrice=="0") && (ddlCAmount!="0" || ddlLAmount!="0" || ddlTAmount!="0" || ddlHAmount!="0"))
{
args.IsValid = false;
return args.IsValid;
}
return args.IsValid;

}
function CheckSiteArea(source, args)
{
args.IsValid = true;

ddlPrice=document.getElementById("ctl00_ContentPlaceHolder1_ddlArea").value
ddlCAmount=document.getElementById("ctl00_ContentPlaceHolder1_txtArea").value
ddlLAmount=document.getElementById("ctl00_ContentPlaceHolder1_TextD1").value
ddlTAmount=document.getElementById("ctl00_ContentPlaceHolder1_TextD2").value

if((ddlPrice=="0") || (ddlCAmount=="" && ddlLAmount=="" && ddlTAmount==""))
{
args.IsValid = false;
return args.IsValid;
}

if((ddlPrice=="1" || ddlPrice=="2") && (ddlCAmount==""))
{
args.IsValid = false;
return args.IsValid;
}
if((ddlPrice=="3" || ddlPrice=="4") && (ddlLAmount=="" || ddlTAmount==""))
{
args.IsValid = false;
return args.IsValid;
}

return args.IsValid;

}

function CheckSiteAreaSearch(source, args)
{
args.IsValid = true;

ddlArea=document.getElementById("ctl00_ContentPlaceHolder1_ddlArea").value
txtMinArea=document.getElementById("ctl00_ContentPlaceHolder1_txtAreaMin").value
txtMaxArea=document.getElementById("ctl00_ContentPlaceHolder1_txtAreaMax").value
TextD1=document.getElementById("ctl00_ContentPlaceHolder1_TextD1").value
TextD2=document.getElementById("ctl00_ContentPlaceHolder1_TextD2").value
if(ddlArea=="0")
{
    if(txtMinArea!="" || txtMaxArea!="" || TextD1!="" || TextD2!="")
    {
    args.IsValid=false;
    }
}
else if(ddlArea=="3")
{
if(TextD1=="" || TextD2=="")
    {
    args.IsValid=false;
    }
}
else
{
if(txtMinArea=="" || txtMaxArea=="")
    {
    args.IsValid=false;
    }

}


return args.IsValid;

}
function ValidBudget(source, args)
{
args.IsValid = true;

ddlMinPrice=document.getElementById("ctl00_ContentPlaceHolder1_ddlMinPrice").value
ddlMinPriceUnit=document.getElementById("ctl00_ContentPlaceHolder1_ddlMinPriceUnit").value
ddlMaxPrice=document.getElementById("ctl00_ContentPlaceHolder1_ddlMaxPrice").value
ddlMaxPriceUnit=document.getElementById("ctl00_ContentPlaceHolder1_ddlMaxPriceUnit").value
valP=parseInt(ddlMinPrice)*parseInt(ddlMinPriceUnit)
val=parseInt(ddlMaxPrice)*parseInt(ddlMaxPriceUnit)
if(valP>val)
{


args.IsValid = false;
}

return args.IsValid;

}

function CheckBuiltAreaSearch(source, args)
{
args.IsValid = true;

ddlArea=document.getElementById("ctl00_ContentPlaceHolder1_ddlBArea").value
txtMinArea=document.getElementById("ctl00_ContentPlaceHolder1_txtBAreaMin").value
txtMaxArea=document.getElementById("ctl00_ContentPlaceHolder1_txtBAreaMax").value
if((parseInt(ddlArea)!=0) && (txtMinArea=="" || txtMaxArea==""))
{


args.IsValid = false;
}

if(parseInt(ddlArea)==0 && (txtMinArea!="" || txtMaxArea!=""))
{

args.IsValid = false;
}


return args.IsValid;

}

function CheckBudget(source, args)
{
args.IsValid = true;

ddlMinPrice=document.getElementById("ctl00_ContentPlaceHolder1_ddlMinPrice").value
ddlMinPriceUnit=document.getElementById("ctl00_ContentPlaceHolder1_ddlMinPriceUnit").value
ddlMaxPrice=document.getElementById("ctl00_ContentPlaceHolder1_ddlMaxPrice").value
ddlMaxPriceUnit=document.getElementById("ctl00_ContentPlaceHolder1_ddlMaxPriceUnit").value
if(!((parseInt(ddlMinPriceUnit)==0) && (parseInt(ddlMinPrice)==0) &&(parseInt(ddlMaxPrice)==0) && (parseInt(ddlMaxPriceUnit)==0) ))
{
if((parseInt(ddlMinPriceUnit)==0) || (parseInt(ddlMinPrice)==0) ||(parseInt(ddlMaxPrice)==0) || (parseInt(ddlMaxPriceUnit)==0) )
{


args.IsValid = false;
}
}





return args.IsValid;

}

function CheckBuiltArea(source, args)
{
args.IsValid = true;

ddlPrice=document.getElementById("ctl00_ContentPlaceHolder1_ddlBArea").value
ddlCAmount=document.getElementById("ctl00_ContentPlaceHolder1_txtBArea").value

if((ddlPrice!="0") && (ddlCAmount==""))
{
args.IsValid = false;
return args.IsValid;
}
if((ddlPrice=="0") && (ddlCAmount!=""))
{
args.IsValid = false;
return args.IsValid;
}

return args.IsValid;

}
function ChangeArea()
{
ddlPrice=document.getElementById("ctl00_ContentPlaceHolder1_ddlPrice").value
ddlArea=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlArea;

if(ddlPrice=="1")
{
ddlArea.selectedIndex=1;
}
else if(ddlPrice=="2")
{
ddlArea.selectedIndex=2;
}
else
{
ddlArea.selectedIndex=0;
}
}





function EnableControlsSearch(Val)
{
ddlArea=document.aspnetForm.ctl00_ContentPlaceHolder1_ddlArea;

if(Val==3 || Val==4 || Val==12 || Val==20 || Val==22)
{
document.getElementById("divbed").style.display="block";

document.getElementById("divAge").style.display="block";


}
else if(Val==1 || Val==2 || Val==5 || Val==6 || Val==14 || Val==15 || Val==19 || Val==21)
{
document.getElementById("divbed").style.display="none";

document.getElementById("divAge").style.display="none";

}
else
{

document.getElementById("divbed").style.display="none";

document.getElementById("divAge").style.display="block";



}


if(Val==4)
{
if(document.getElementById("divUArea")!=null)
{
document.getElementById("divUArea").style.display="block";
document.getElementById("divbed").style.display="none";
}
}
else
{
if(document.getElementById("divUArea")!=null)
document.getElementById("divUArea").style.display="none";

}
if(document.getElementById("ChangeArea")!=null)
{
if(Val==4)
{
document.getElementById("ChangeArea").innerHTML="Flat Area";
}
else if(Val==6 || Val==15 || Val==19|| Val==20)
{
document.getElementById("ChangeArea").innerHTML="Land Area";
}
else if(Val==8 || Val==9 || Val==10 || Val==11 || Val==16)
{
document.getElementById("ChangeArea").innerHTML="Empty Space Available";

}
else
{
document.getElementById("ChangeArea").innerHTML="Site Area";
}
}


if(Val==15 || Val==16 || Val==17 || Val==18 || Val==19 || Val==20 )
{
    if(ddlArea.length==3)
    {
      var elOptNew = document.createElement('option');
        elOptNew.text = "Acres";
        elOptNew.value = 2;

    ddlArea.add(elOptNew,2); 

    }
   

}
else
{
if(ddlArea.length==4)
ddlArea.remove(2);


}

}
function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}
