﻿
 
    function ShowIcon() {

      
        var e = document.getElementById("Please wait......");
        e.style.visibility = (e.style.visibility == 'visible') ? 'hidden' : 'hidden';
    }
    function StopIcon() {
    
        var e = document.getElementById("Please wait......");
      
        e.style.visibility = 'hidden';
       
    }
    
    
    function hov(loc,cls)
  {
     if(loc.className)
        loc.className=cls;
}
    function Identification_onclick() {
        var value;
        if (document.getElementById("radioVIN").checked == true) {

           document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_txtRegoNumber").value = "";
            document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_txtRegoNumber").disabled = true;
            document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_txtRegoNumber").style.background = '#dedede';

            document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_cmbRegoExpiryDate").disabled = true;
            document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_txtVIN").disabled = false;
            document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_txtVIN").style.background = '#FFFFFF';
            //Enabled first validator
           // document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_RequiredFieldValidator12").disabled = false;
            var Reg0Validation = document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_RequiredFieldValidator11");
            ValidatorEnable(Reg0Validation, false);
            
             var RegDate0Validation = document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_RequiredFieldValidator15");
            ValidatorEnable(RegDate0Validation, false);
           
            
            
            
            var VINValidaion = document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_RequiredFieldValidator12");
            ValidatorEnable(VINValidaion, true);
            
        }
        else if(document.getElementById("radioVIN").checked == false)
         {
            document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_txtRegoNumber").disabled = false;            
            document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_txtRegoNumber").style.background = '#FFFFFF';
            document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_cmbRegoExpiryDate").disabled = false;
            document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_txtVIN").value = "";
            document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_txtVIN").disabled = true;
            document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_txtVIN").style.background = '#dedede';
            
            var Reg0Validation = document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_RequiredFieldValidator11");
            ValidatorEnable(Reg0Validation, true);
            
            var RegDateValidation = document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_RequiredFieldValidator15");
            ValidatorEnable(RegDateValidation, true);
            
            var VINValidaion = document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_RequiredFieldValidator12");
            ValidatorEnable(VINValidaion, false);
            
        }
         
    }
    
    
    
    
    
   /* function checkContol()
    {
         if (document.getElementById("radioVIN").checked == true) 
         {
            var Reg0Validation = document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_RequiredFieldValidator11");
            ValidatorEnable(Reg0Validation, false);
            
            var VINValidaion = document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_RequiredFieldValidator12");
            ValidatorEnable(VINValidaion, true);
         }
         else
         {
            var Reg0Validation = document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_RequiredFieldValidator11");
            ValidatorEnable(Reg0Validation, true);
            
            var VINValidaion = document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_RequiredFieldValidator12");
            ValidatorEnable(VINValidaion, false);
         }
    }*/
    
    
 //Tool Tips JS
   function ShowTooltip(name) {

         var newname = name.replace(/--NL--/g, "\n");


         //alert(newname);
         document.getElementById("td0").innerText = newname;
         //    x = event.clientX + document.body.clientWidth ;
         //    y = event.clientY + document.body.clientHeight;
         x = mouseX(event);
         y = mouseY(event);
         Popup.style.display = "block";
         Popup.style.left = x;
         Popup.style.top = y;
     }

     function HideTooltip() {
         Popup.style.display = "none";
     }
     function mouseX(evt) {
         if (evt.pageX) return evt.pageX;
         else if (evt.clientX)
             return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
         else return null;
     }
     function mouseY(evt) {
         if (evt.pageY) return evt.pageY;
         else if (evt.clientY)
             return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
         else return null;
     }
     
     function EnablebthAddImage()
     {
     document.getElementById("ctl00_HeaderContent_CaptureVechicelDetails1_btnAddImage").disabled = false;
         
     }
function open_win(url_add)
   {
   window.open(url_add,'Details','width=930,height=750,menubar=no,status=yes, location=no,toolbar=no,scrollbars=yes,resizable=yes');
   }
function OpenEmailToFriend(url_add)
{   
    window.open(url_add,'EmailToFriend','width=750,height=700,menubar=no,status=yes, location=no,toolbar=no,scrollbars=yes,resizable=yes');
}

 var txtEmail; 

     
   
      function ShowImage() {

          document.getElementById('ctl00_PageContent_AdvanceSearchControl1_txtPostcode').style.backgroundImage = 'url(App_Themes/Default/Images/ajax-loader.gif)';  

             document.getElementById('ctl00_PageContent_AdvanceSearchControl1_txtPostcode').style.backgroundRepeat = 'no-repeat';  

             document.getElementById('ctl00_PageContent_AdvanceSearchControl1_txtPostcode').style.backgroundPosition = 'right';  
        }  
         function HideImage() {  

             document.getElementById('ctl00_PageContent_AdvanceSearchControl1_txtPostcode').style.backgroundImage = 'none';  

         } 
         
         
/* Max Length function for Comments*/
function fnClicked(txtBox, maxLength)
 {

   
    //Here we are validating the Length of the Text. 

    //If the text is greater than the provided lenth, we have to ignore the last characters

    if (txtBox.value.length >= maxLength) {

        //Removing the last characters which are more than the length

        txtBox.value = txtBox.value.substring(0, 300);

    }

    //Displaying the Remaining characters



}
function ShowProgress() {

    document.getElementById('overlay').innerHTML = '<b>Verifying, please wait...</b><asp:Image ID="LoadImage" runat="server" ImageUrl="../App_Themes/Default/Images/ajax-loader2.gif" />'


}

function ShowForgotProgress() {
    document.getElementById('overlayForgot').innerHTML = '<b>Please wait....</b><asp:Image ID="LoadForgotImage" runat="server" ImageUrl="../App_Themes/Default/Images/ajax-loader2.gif" />'

}

function ShowForgotPop() {
    $find('popuplogin').hide();
    $find('MyMPE').show();

}
function ShowLoginModelPop() {
    $find('popuplogin').show();
}

var txtEmail;

function pageLoad() {
    // debugger;
    txtEmail = $get("<%=txtEmail.ClientID %>");
    txtPostcode = $get("<%=txtPostcode.ClientID %>");
}
function CheckEmail() {

    //debugger;
    if (txtEmail.value.length > 0) {
        $get("spanEmail").innerHTML = "Checking for duplicate email...<img id=imgWaiting src='App_Themes/Default/Images/ajax-loader.gif' width='28px' height='28px'>";
        // $get("spanEmail").innerHTML = "Checking for duplicate email...<img id=imgWaiting src=/images/ajax-loader_small.gif>";
        $get("spanEmail").style.color = "red";
        $get("spanEmail").style.fontWeight = "bold";
        PageMethods.CheckEmail(txtEmail.value, OnCheckEmail);

    }
    else {
        $get("spanEmail").innerHTML = ""
    }
}
function OnCheckEmail(duplicate) {

    // $get("ctl00_HeaderContent_Registration1_Wizard1_StartNavigationTemplateContainerID_StartNextButton").disabled = false; 
    $get("spanEmail").innerHTML = ""
    if (duplicate == true) {

        $get("spanEmail").innerHTML = "Email address has already been used, please <a href='Javascript:ShowLoginModelPop();'>Click here to login</a>";
        $get("spanEmail").style.color = "red";
        $get("spanEmail").style.fontWeight = "bold";
        $get("<%=btnSave.ClientID %>").disabled = true;
    }
    else if (duplicate != true) {
        $get("spanEmail").innerHTML = "";
        $get("spanEmail").style.color = "green";
        $get("spanEmail").style.fontWeight = "bold";
        $get("<%=btnSave.ClientID %>").disabled = false;

    }
}

//Checking PostCode
function CheckPostCode() {

    //debugger;
    if (txtPostcode.value.length > 0) {
        PageMethods.CheckPostCode(txtPostcode.value, OnCheckPostCode);
    }
}
function OnCheckPostCode(duplicate) {

    //debugger;
 
       
    $get("SpanPostCode").innerHTML = ""
    if (duplicate == false) {
       // $get("<%=btnSave.ClientID%>").disabled = true;
        $get("SpanPostCode").innerHTML = "Please renter postcode or suburb";
        $get("SpanPostCode").style.color = "red";
       // $get("<%=txtPostcode.ClientID%>").val('');
       document.getElementById('ctl00_HeaderContent_Registration1_txtPostcode').value = "";
       //document.getElementById('ctl00_HeaderContent_Registration1_txtPostcode').focus();
    }
    else
        $get("<%=btnSave.ClientID %>").disabled = false;

}
  
function CheckAgreementAction(value) {

    if ($get("<%=chkAgreement.ClientID%>").checked == true)
        $get("<%=btnSave.ClientID %>").disabled = false;
    else {
        $get("<%=btnSave.ClientID %>").disabled = true;
        alert("Please click on  Advertiser Terms and Conditons");
    }

}

/*Page load function for */
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}
 
addLoadEvent(function() 
{
    
      
    var path = location.pathname.substring(1); 
    var splitpath = path.split('/');
    
    
    
    if(splitpath[splitpath.length - 1] == "buy-used-car.aspx")
    {
    $get("li_buy_car").style.fontWeight = "bold";
    }
    else if(splitpath[splitpath.length - 1] == "used-cars-list.aspx" ||
     splitpath[splitpath.length - 1] == "vehicle-search.aspx" ||
     splitpath[splitpath.length - 1] == "details.aspx" || 
     splitpath[splitpath.length - 1] == "buy-dealers-cars.aspx" ||
     splitpath[splitpath.length - 1] == "Dealers-cars-details.aspx" ||
     splitpath[splitpath.length - 1] == "private-used-cars.aspx" ||      
     splitpath[splitpath.length - 1] == "AUDI.aspx" ||
     splitpath[splitpath.length - 1] == "Bentley.aspx" ||
     splitpath[splitpath.length - 1] == "BMW.aspx" ||
     splitpath[splitpath.length - 1] == "Chrysler.aspx" ||
     splitpath[splitpath.length - 1] == "Citroen.aspx" ||
     splitpath[splitpath.length - 1] == "Daewoo.aspx" ||
     splitpath[splitpath.length - 1] == "Daihatsu.aspx" ||
     splitpath[splitpath.length - 1] == "Dodge.aspx" ||
     splitpath[splitpath.length - 1] == "ELFIN.aspx" ||
     splitpath[splitpath.length - 1] == "Toyota.aspx" ||
     splitpath[splitpath.length - 1] == "HOLDEN.aspx" ||
     splitpath[splitpath.length - 1] == "NISSAN.aspx" ||
     splitpath[splitpath.length - 1] == "FORD.aspx" ||
     splitpath[splitpath.length - 1] == "MITSUBISHI.aspx" ||
     splitpath[splitpath.length - 1] == "MAZDA.aspx" ||
     splitpath[splitpath.length - 1] == "HONDA.aspx" ||
     splitpath[splitpath.length - 1] == "FIAT.aspx" ||
     splitpath[splitpath.length - 1] == "HUMMER.aspx" ||
     splitpath[splitpath.length - 1] == "hundai.aspx" ||
     splitpath[splitpath.length - 1] == "isuzu.aspx" ||
      splitpath[splitpath.length - 1] == "jaguar.aspx" ||
       splitpath[splitpath.length - 1] == "kia.aspx" ||
        splitpath[splitpath.length - 1] == "lamborghini.aspx" ||
         splitpath[splitpath.length - 1] == "lexus.aspx"
     )
    {    
        
        if(getQuerystring('Cat') == '1+2+3')
        {
            $get("li_used_car_search").style.fontWeight = "bold";
        }
        else if(getQuerystring('Cat') == '3')
        {
            $get("li_new_car_search").style.fontWeight = "bold";
        }
        
        else
             $get("li_used_car_search").style.fontWeight = "bold";
    
    }
    else if(splitpath[splitpath.length - 1] == "Browse-cars.aspx" || splitpath[splitpath.length - 1] == "Browse-by-car-make.aspx")
    {    
    $get("li_browse").style.fontWeight = "bold";
    $get("li1_browse").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "Find-a-Dealer.aspx" || splitpath[splitpath.length - 1] == "dealer-search.aspx" )
    {   
    $get("li_dealerSearch").style.fontWeight = "bold";
    
    }
     else if(splitpath[splitpath.length - 1] == "Advertise-your-car.aspx")
    {    
    $get("li_dealer_reg").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "sell-your-used-car.aspx" || splitpath[splitpath.length - 1] == "sell-your-used-car.spx")
    {    
    $get("li_sellyourcar").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "car-sale.aspx")
    {    
    $get("li_advancesearch").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "Default.aspx")
    {    
    $get("li_home").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "car-reviews.aspx")
    {    
    $get("li_carreviews").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "latest-future-models.aspx")
    {    
    $get("li_latestfutermodel").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "latest-new-models.aspx")
    {    
    $get("li_latesnewmodel").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "car-news.aspx")
    {    
    $get("li_carnews").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "car-alerts.aspx")
    {    
    $get("li_caralert").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "car-valuations.aspx" || splitpath[splitpath.length - 1] == "values-search.aspx" || splitpath[splitpath.length - 1] == "car-specs-values.aspx")
    {    
    $get("li_value_car_valuation").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "MyShortList.aspx")
    {    
    $get("li_myshortlist").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "ContactUS.aspx" || splitpath[splitpath.length - 1] == "ContactUs.aspx")
    {    
    $get("li_contactus").style.fontWeight = "bold";
    }
      else if(splitpath[splitpath.length - 1] == "Privacy.aspx")
    {    
    $get("li_privacy").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "terms-conditions.aspx")
    {    
    $get("li_termcondition").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "about-cartime.aspx")
    {    
    $get("li_aboutus").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "News-review-bymake.aspx")
    {    
    $get("li_newsandreviewbymake").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "New-cars.aspx")
    {    
    $get("li_new_car_search").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "car-history.aspx")
    {    
    $get("li_carhistory").style.fontWeight = "bold";
    }
      else if(splitpath[splitpath.length - 1] == "Insurance.aspx")
    {    
    $get("li_insurance").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "Finance.aspx")
    {    
    $get("li_finance").style.fontWeight = "bold";
    }
      else if(splitpath[splitpath.length - 1] == "buying-tips.aspx")
    {    
    $get("li_buy_tip").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "selling-tips.aspx")
    {    
    $get("li_selling_tip").style.fontWeight = "bold";
    }
   else if(splitpath[splitpath.length - 1] == "Trustandsecurity.aspx")
    {    
    $get("li_faraud_warning").style.fontWeight = "bold";
    }
   else if(splitpath[splitpath.length - 1] == "ReciprocalLinks.aspx")
    {    
    $get("li_links").style.fontWeight = "bold";
    }
    else if(splitpath[splitpath.length - 1] == "Home.aspx")
    {    
    $get("li_custdetails").style.fontWeight = "bold";
    }
    else if(splitpath[splitpath.length - 1] == "DealersChangePassword.aspx")
    {    
    $get("li_custpassword").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "DealerInvoices.aspx")
    {    
    $get("li_invoices").style.fontWeight = "bold";
    }
    else if(splitpath[splitpath.length - 1] == "DealerAllEnq.aspx" || splitpath[splitpath.length - 1] == "ViewEnquires.aspx" )
    {    
    $get("li_enquires").style.fontWeight = "bold";
    }
    else if(splitpath[splitpath.length - 1] == "DealersCurrentListing.aspx")
    {    
    $get("li_current_listing").style.fontWeight = "bold";
    }
    else if(splitpath[splitpath.length - 1] == "Login.aspx")
    {    
    $get("li_lgoin").style.fontWeight = "bold";
    }
    else if(splitpath[splitpath.length - 1] == "dealers-used-cars.aspx")
    {    
    $get("li_dealerusedcar").style.fontWeight = "bold";
    }
    else if(splitpath[splitpath.length - 1] == "ViewStats.aspx")
    {    
    $get("li_static_report").style.fontWeight = "bold";
    }
     else if(splitpath[splitpath.length - 1] == "dealers.aspx")
    {    
    $get("li_dealer_reg").style.fontWeight = "bold";
    }
})
addLoadEvent(function() {
    //document.body.appendChild(document.createTextNode('Hungry'));;
})
addLoadEvent(function() {
    //document.body.appendChild(document.createTextNode(' monkeys!'));;
})

function getQuerystring(key, default_)
{
  if (default_==null) default_=""; 
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}

//POP-UP DIV
 var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
//document.onclick = mclose; 

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function open_cert(url_add)
   {
   window.open(url_add,'certificate','width=900,height=700,menubar=no,status=yes, location=no,toolbar=no,scrollbars=yes,resizable=yes');
   }
 function removeSpaces(string) {

 return string.split(' ').join('');
 }
