﻿function PS_ValidateSearch()
{
  __FormErrorCount=0;
  __ValidateNotEmpty(PS_ID+"SearchTextBox");
  document.getElementById("NoLocationError").style.display=(__FormErrorCount==0?"none":"inline");
  return(__FormErrorCount==0);
}
function PS_ChageView(mode)
{
  var lis=document.getElementById("PropertySearchNav").getElementsByTagName("li");
  for(var i=0;i<lis.length;i++)
  {
    lis[i].removeAttribute("className");
    lis[i].removeAttribute("dataSrc");
  }
  switch(mode)
  {
    case 1:
      document.getElementById(PS_ID+"PropertySearchTab2").className="current";
      document.getElementById(PS_ID+"PropertySearchTab2").setAttribute("dataSrc","current");
      document.getElementById(PS_ID+"SearchOptions").style.display="block";
      document.getElementById(PS_ID+"SalePriceOptions").style.display="none";
      document.getElementById(PS_ID+"RentPriceOptions").style.display="inline";
      document.getElementById(PS_ID+"LettingTypeOptions").style.display="inline";
      document.getElementById(PS_ID+"FurnishedOptions").style.display="inline";
      document.getElementById(PS_ID+"SearchMode").value=1;
      if(document.getElementById(PS_ID+"MySearches")!=null)
      {
        document.getElementById(PS_ID+"MySearches").style.display="none";
      }
      if(document.getElementById(PS_ID+"MyShortList")!=null)
      {
        document.getElementById(PS_ID+"MyShortList").style.display="none";
      }
      break;
    case 2:
      document.getElementById(PS_ID+"SavedSearchesTab").className="current";
      document.getElementById(PS_ID+"SavedSearchesTab").setAttribute("dataSrc","current");
      document.getElementById(PS_ID+"SearchOptions").style.display="none";
      document.getElementById(PS_ID+"MySearches").style.display="block";
      if(document.getElementById(PS_ID+"MyShortList")!=null)
      {
        document.getElementById(PS_ID+"MyShortList").style.display="none";
      }
      break;
    case 3:
      document.getElementById(PS_ID+"MyShortlistTab").className="current";
      document.getElementById(PS_ID+"MyShortlistTab").setAttribute("dataSrc","current");
      document.getElementById(PS_ID+"SearchOptions").style.display="none"; 
      if(document.getElementById(PS_ID+"MySearches")!=null)
      {
        document.getElementById(PS_ID+"MySearches").style.display="none";
      }
      document.getElementById(PS_ID+"MyShortList").style.display="block";
      break;
    default:
      document.getElementById(PS_ID+"PropertySearchTab").className="current";
      document.getElementById(PS_ID+"PropertySearchTab").setAttribute("dataSrc","current");
      document.getElementById(PS_ID+"SearchOptions").style.display="block";
      if(document.getElementById(PS_ID+"MySearches")!=null)
      {
        document.getElementById(PS_ID+"MySearches").style.display="none";
      }
      if(document.getElementById(PS_ID+"MyShortList")!=null)
      {
        document.getElementById(PS_ID+"MyShortList").style.display="none";
      }
      if(document.getElementById(PS_ID+"SalePriceOptions")!=null&&document.getElementById(PS_ID+"RentPriceOptions")!=null)
      {
        document.getElementById(PS_ID+"SalePriceOptions").style.display="inline";
        document.getElementById(PS_ID+"RentPriceOptions").style.display="none";
        document.getElementById(PS_ID+"LettingTypeOptions").style.display="none";
        document.getElementById(PS_ID+"FurnishedOptions").style.display="none";
        document.getElementById(PS_ID+"SearchMode").value=0;
      }
      break;
  }
}
function PS_CheckPriceSelect(obj)
{
  var min;
  var max;
  var id;
  var isMin;
  if(obj.id==PS_ID+"MinSalePriceDropDownList"||obj.id==PS_ID+"MaxSalePriceDropDownList")
  {
    min=__GetNumericValue(PS_ID+"MinSalePriceDropDownList");
    max=__GetNumericValue(PS_ID+"MaxSalePriceDropDownList");
    id=(obj.id==PS_ID+"MinSalePriceDropDownList"?PS_ID+"MaxSalePriceDropDownList":PS_ID+"MinSalePriceDropDownList");
    isMin=(obj.id==PS_ID+"MinSalePriceDropDownList"?true:false);    
  }
  else
  {
    min=__GetNumericValue(PS_ID+"MinRentPriceDropDownList");
    max=__GetNumericValue(PS_ID+"MaxRentPriceDropDownList");
    id=(obj.id==PS_ID+"MinRentPriceDropDownList"?PS_ID+"MaxRentPriceDropDownList":PS_ID+"MinRentPriceDropDownList");
    isMin=(obj.id==PS_ID+"MinRentPriceDropDownList"?true:false);
  }
  if(isMin&&min!=0&&min>max&&max!=0)
  {
    __SetValue(id,min);
  }
  else
  {
    if(!isMin&&max!=0&&max<min&&min!=0)
    {
      __SetValue(id,max);
    }
  }
}
