﻿var treePTjs = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + treePTjs + "pixel.tree.com/pt.ashx' type='text/javascript'%3E%3C/script%3E"));

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));


$(document).ready(function() {
    if (window._gat) {
        var pageTracker = _gat._getTracker('UA-8160145-3');
        pageTracker._trackPageview();
    }
	
	var tracker = _pt._getTracker({
        visitorNamespace: "autos",
        trackingServer: "tracking.tree.com",
        locationTrackImage: "trk/{0}.gif"
    });
	try {
		tracker._trackPageView();
	} catch (ex) { }
    
    // 1. NewCars/DealerQuote.aspx – add the event to clicking the Submit Quote button
    $("#frmDealerQuote #btnSubmitQuote").click(function(){
        try {
            tracker._trackEvent("Form", "submit-lead", "Auto bytel form submitted", 0);
        } catch (ex) { }
    });
    // 2. widgets/AutoInsuranceWidget.ascx – clicking the Get Quote Now button
    $("#boxAutoInsurance a").click(function(){
        try {
            tracker._trackEvent("Button", "external-lead-transfer", "Auto Insurance Tab", 0);
        } catch (ex) { }
    });
    // 2b usercontrols/ AdBar.ascx – clicking the Get Quote Now for "Search for Auto Insurance Carriers"
    $("#formAutoInsurance .quote2").click(function(){
        try {
            tracker._trackEvent("feature-block", "external-lead-transfer", "Auto Insurance Feature Block Ad", 0);
        } catch (ex) { }
    });
    // 3. widgets/AutoLoanWidget clicking the start request button
    $("#formRequestLoan #btnStartRequest").click(function(){
        try {
            tracker._trackEvent("Button", "external-lead-transfer", "Auto Loan Tab", 0);
        } catch (ex) { }
    });
    // 3b widgets/RequestQuoteWidget.ascx – start request button
    $("#formSuperBoxCarLoan #btnStartRequest").click(function(){
        try {
            tracker._trackEvent("Button", "external-lead-transfer", "Auto Loan Home Page", 0);
        } catch (ex) { }
    });
    // 3c NewCars/CarDetails.aspx– start request button
    $("#formRequestLoan #btnStartRequest").click(function(){
        try {
            tracker._trackEvent("Button", "external-lead-transfer", "Auto Loan Car Details", 0);
        } catch (ex) { }
    });
    // 4. widgets/AutoWarrantyWidget clicking get your free quote
    $("#speakExpert .getfreequote").click(function(){
        try {
            tracker._trackEvent("Button", "external-lead-transfer", "Auto Warranty Tab", 0);
        } catch (ex) { }
    });
    // 4b usercontrols/ AdBar.ascx – clicking the Get Quote Now for "Speak to an Auto Warranty Expert and Save"
    $("#boxAutoWarranty a").click(function(){
        try {
            tracker._trackEvent("feature-block", "external-lead-transfer", "Auto Warranty Feature Block Ad", 0);
        } catch (ex) { }
    });
    // 5. usercontrols/ AdBar.ascx – clicking the Order Report Button
    $("#boxCarFax a").click(function(){
        try {
            tracker._trackEvent("feature-block", "external-lead-transfer", "Carfax Feature Block Ad", 0);
        } catch (ex) { }
    });
    // 6. widgets/CarHistoryWidget.ascx – clicking the check history button
    $("#formCarHistory .check_history").click(function(){
        try {
            tracker._trackEvent("Button", "external-lead-transfer", "CarFax Check History", 0);
        } catch (ex) { }
    });
    // 7. widgets/ UsedCarDetails2Widget.ascx clicking the submit button
    $("#frmUsedCardsDetails .contactSeller #btnSubmit").click(function(){
        try {
            tracker._trackEvent("Form", "submit-lead", "VAST form submitted", 0);
        } catch (ex) { }
    });
    // 8. widgets/RequestQuoteWidget.ascx – clicking Get Quote Now on the hompage
    $("#dealerQuote #formDealerQuote #btnQuote").click(function(){
        try {
            tracker._trackEvent("Form", "requested-offers", "Homepage Autobytel PING requested", 0);
        } catch (ex) { }
    });
    // 9. SearchCarWidget.ascx– clicking submit button
    $("#newDealerQuote #formNewDealerQuote #btnNewSubmit").click(function(){
        try {
            tracker._trackEvent("Form", "requested-offers", "New Car Tab Autobytel PING requested", 0);
        } catch (ex) { }
    });
});

