function next_page(page,keyword,no_page)
 {
   //alert();
   if(document.getElementById('hid_order').value != "" )
   {
     var order_str = document.getElementById('hid_order').value;
   }
   else
   {
     var order_str = "";
   }

   //alert(order_str);

   window.location.href="advanced_search.php?action=search&page_no="+page+"&keyword="+keyword+"&no_page="+no_page+"&order_str="+order_str;
 }

 function scroll(direction,keyword,no_page)
 {
   //alert();

   var page=0;
   if((document.getElementById('hid_tot_page').value == document.getElementById('page').value ) && (direction == 1))
   {
     return;
   }
   else if((document.getElementById('page').value == 1 ) && (direction == -1))
   {
     return;
   }


   if(direction == 1)
     page = parseInt(document.getElementById('page').value) + 1;
   else if(direction == -1)
     page = parseInt(document.getElementById('page').value) - 1;

   if(document.getElementById('hid_order').value != "" )
   {
     var order_str = document.getElementById('hid_order').value;
   }
   else
   {
     var order_str = "";
   }

   //alert(page);

   window.location.href="advanced_search.php?paction=search&page_no="+page+"&keyword="+keyword+"&no_page="+no_page+"&order_str="+order_str;
 }


 function next_page_order(page,keyword,order_str,no_page)
 {
   document.getElementById('hid_order').value = order_str;
   window.location.href="advanced_search.php?action=search&page_no="+page+"&keyword="+keyword+"&order_str="+order_str+"&no_page="+no_page;
 }

 function per_page(page,keyword,no_page)
 {
   //alert("asdfasda");
   if(document.getElementById('hid_order').value != "" )
   {
     var order_str = document.getElementById('hid_order').value;
     window.location.href="advanced_search.php?action=search&page_no="+page+"&keyword="+keyword+"&no_page="+no_page+"&order_str="+order_str;
   }
   else
   {
     window.location.href="advanced_search.php?action=search&page_no="+page+"&keyword="+keyword+"&no_page="+no_page;
   }

 }




function check_adv_crt()
{
  return true;
  /*
if((document.getElementById("make1").value=="") && (document.getElementById("model").value=="") && (document.getElementById("year1").value=="") && (document.getElementById("car_type").value=="") && ((trimAll(document.getElementById("mileage").value)=="") || (trimAll(document.getElementById("to_mileage").value)=="")) && (document.getElementById("transmission").value=="") && (document.getElementById("fuel_type").value=="") && ((trimAll(document.getElementById("price_start_bid").value)=="") || (trimAll(document.getElementById("to_price_start_bid").value)=="")) && (trimAll(document.getElementById("keyword1").value)==""))
  {
    alert("Please Select Any One Search Criteria.")
    return false;
  } else if(isNaN(document.getElementById("mileage").value) || isNaN(document.getElementById("to_mileage").value))
  {
    alert("Mileage must be a Number.");
    return false;
  } else if(isNaN(document.getElementById("price_start_bid").value) || isNaN(document.getElementById("to_price_start_bid").value))
  {
    alert("Bid Price must be a Number.");
    return false;
  }
*/
}


function trimAll(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}


/*
function next_page(page,keyword)
 {
   //alert();
   window.location.href="advanced_search.php?action=search&page_no="+page+"&keyword="+keyword;
 }

 function next_page_order(page,keyword,order_str)
 {
   window.location.href="advanced_search.php?action=search&page_no="+page+"&keyword="+keyword+"&order_str="+order_str;
 }
*/

  function opwin_enq_car(make_name,model_name)
  {

      sid=Math.random();
      //window.open("<? echo MAIN_SITE_URL; ?>showmsg.php?car_id=1&member_id=2",5,"location=0,toolbar=no,scrollbars=yes,height=450,width=650,left=150,top=120");
      window.open("<? echo MAIN_SITE_URL; ?>enq_car.php?make_name="+make_name+"&model_name="+model_name+"&car_id=0",1,"location=0,toolbar=no,scrollbars=yes,height=500,width=500,left=150,top=120");

  }




  function checkval()
 {
    var emailID=document.frm_contact.email;
    var valid;
    valid=1;

    if(trimAll(document.getElementById('name').value)=="")
    {
       alert("Please enter your name");
       document.getElementById('name').focus();
       return false;
    } else if((emailID.value==null)||(emailID.value==""))
    {
       alert("Please insert email");
       document.getElementById('email').focus();
       return false;
    } else if (echeck(emailID.value)==false)
    {
      emailID.value="";
      emailID.focus();
      //valid=0;
      return false;
    } else if(trimAll(document.getElementById('message').value)=="")
    {
       alert("Please enter message");
       document.getElementById('message').focus();
       return false;
    }
    /*
    else if(document.getElementById('pass2').value!=document.getElementById('pass').value)
    {
       alert("Password confirmation failed. Please retype.");
       document.getElementById('pass2').focus();
       return false;
    } else if(trimAll(document.getElementById("fname").value)=="")
    {
       alert("Please insert your first name");
       document.getElementById('fname').focus();
       return false;
    } else if(trimAll(document.getElementById("lname").value)=="")
    {
       alert("Please insert your last name");
       document.getElementById('lname').focus();
       return false;
    } else if(trimAll(document.getElementById('zip').value)=="")
    {
       alert("Please insert zip");
       document.getElementById('zip').focus();
       return false;
    }*/
 }


               function echeck(str)
               {

                  var at="@"
                  var dot="."
                  var lat=str.indexOf(at)
                  var lstr=str.length
                  var ldot=str.indexOf(dot)
                  if (str.indexOf(at)==-1){
                     alert("Invalid E-mail ID")
                     return false
                  }

                  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
                     alert("Invalid E-mail ID")
                     return false
                  }

                  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
                      alert("Invalid E-mail ID")
                      return false
                  }

                   if (str.indexOf(at,(lat+1))!=-1){
                      alert("Invalid E-mail ID")
                      return false
                   }

                   if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
                      alert("Invalid E-mail ID")
                      return false
                   }

                   if (str.indexOf(dot,(lat+2))==-1){
                      alert("Invalid E-mail ID")
                      return false
                   }

                   if (str.indexOf(" ")!=-1){
                      alert("Invalid E-mail ID")
                      return false
                   }

                    return true
               }


function trimAll(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}

function reset_form()
{
  document.frm_contact.reset();
}

function GetXmlHttpObject() //ajax function for choosing car type
      {
      var xmlHttp=null;
      try
        {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
        }
      catch (e)
        {
        // Internet Explorer
        try
          {
          xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
          }
        catch (e)
          {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
          }
        }
      return xmlHttp;
      }

function show_car_type(str)
{
   //alert(cid+","+vid+","+day);
              //alert(str);
              xmlHttp=GetXmlHttpObject();
              if (xmlHttp==null)
              {
                alert ("Your browser does not support AJAX!");
                return;
              }
              var url="ajax_search.php?is_commercial="+str;
              url=url+"&sid="+Math.random();
              //alert(url);
              xmlHttp.onreadystatechange=stateChangedshow_car_type;
              xmlHttp.open("GET",url,true);
              xmlHttp.send(null);
}
 function stateChangedshow_car_type()
 {
            if (xmlHttp.readyState==4 || xmlHttp.readyState=="completed")
            {
                 //alert(xmlHttp.responseText);
                 document.getElementById("car_type").innerHTML=xmlHttp.responseText;
            }
 }