﻿// JScript File

function getKeyCode(e)
{
    if (window.event)
       return window.event.keyCode;
    else if (e)
       return e.which;
    else
       return null;
}

function keyRestrict(e, validchars) 
{
    var key='', keychar='';
    key = getKeyCode(e);
    
    if (key == null) 
        return true;
        
    keychar = String.fromCharCode(key);
    keychar = keychar.toLowerCase();
    validchars = validchars.toLowerCase();
    
    if (validchars.indexOf(keychar) != -1)
        return true;
        
    if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
        return true;
        
    return false;
}

function Pop(CarId)
{
    window.open('car_gallery.aspx?aa=1&CarID=' + CarId,"Text","width:400px;height:400px;");
}

function Validate_Fuel(oSrc, args)
{
    if(document.getElementById('ctl00_car_Chk_Fuel_0').checked == false 
        && document.getElementById('ctl00_car_Chk_Fuel_1').checked == false
        && document.getElementById('ctl00_car_Chk_Fuel_2').checked == false)
    {
        args.IsValid = false;
    }
    else
    {
        args.IsValid = true;
    }
}

function Character_Limit()
{
  if(document.getElementById ('ctl00_car_txtMore_Comments').value.length > 500)
  {
    alert ('Comments Exceed from 500 Character');
    return false;
  }
  else  
  {
       document.getElementById('ctl00_car_lblComments').innerText=document.getElementById ('ctl00_car_txtMore_Comments').value.length ;
       return true;   
  }
}

function Validate_OhterVariant(oSrc, args)
{
    if(document.getElementById("<%=ddlVariant.ClientID%>").value == "-1")
    {
        if(document.getElementById("<%=txtOtherVariant.ClientID%>").value == "")
            args.IsValid = false;
        else
            args.IsValid = true;
    }
    else
        args.IsValid = true;
}

function EnalbeDisable_OtherVariant()
{
    document.getElementById("<%=txtOtherVariant.ClientID%>").value = "";
    if(document.getElementById("<%=ddlVariant.ClientID%>").value == "-1")
        document.getElementById("<%=txtOtherVariant.ClientID%>").disabled = false;
    else
        document.getElementById("<%=txtOtherVariant.ClientID%>").disabled = true;
}



