﻿$(document).ready(function() {

    // Image Rotator on the homepage
    $('#slider').nivoSlider({
        effect: 'fade',
        pauseTime: 4000,
        controlNav: false
    });

    // Contact Form Popup
    $("#contact-directions").dialog({
        resizable: false,
        autoOpen: false,
        width: 620,
        height: 620,
        open: function(type, data) {
            $(this).parent().appendTo("form");
        }
    });
    $('[rel="contact"]').click(function() {
        $("#contact-directions").dialog('open');
        return false; // So it doesn't reload the page
    });

    $("#ServiceContact").dialog({
        resizable: false,
        autoOpen: false,
        width: 420,
        height: 500,
        open: function(type, data) {
            $(this).parent().appendTo("form");
        }
    });

    $("#ctl00_ScheduleContactDate").datepicker();
    
    $("#ScheduleContact").dialog({
        resizable: false,
        autoOpen: false,
        width: 420,
        height: 600,
        open: function(type, data) {
            $(this).parent().appendTo("form");
        }
    });

    
    // Mission Statement Popup
    $("#mission-statement").dialog({
        resizable: false,
        autoOpen: false,
        width: 650,
        height: 380,
        open: function(type, data) {
            $(this).parent().appendTo("form");
        }
    });
    $("#mission-link").click(function() {
        $("#mission-statement").dialog('open');
        return false;
    });

    // New Inventory Dropdown
    $('.drop-1 ul li').mouseenter(function() {
        $('.drop-2').show();
    });
    $('.drop-1').mouseleave(function() {
        $('.drop-2').hide();
    });
    $('#dd-c, #dd-c-sedan').hover(function() {
        $('#e-class-selector').hide();
        $('#c-class-selector').show();
        $('#vehicle-class').text('C-Class');
        $('#vehicle-style').css({ width: '200px' }).text('The C-Class Sedan');
        $('#vehicle-detail').css({ width: '200px' }).text('Equal parts race and refinement in a mid-size sedan that delivers full-size luxury, safety and performance. Starting at $33,990.');
        $('#vehicle-image').attr('src', '/Resources/Images/c-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/C-Class-Sedan.aspx');
    });
    $('#dd-c-coupe').hover(function() {
        $('#vehicle-style').text('The C-Class Coupe');
        $('#vehicle-detail').text('Like every Mercedes-Benz coupe, The C-Class wraps four sport seats and passion for the road in sleek style. Starting at $37,220.');
        $('#vehicle-image').attr('src', '/Resources/Images/c-coupe-thumb.png');
        $('.drop-2 a').attr('href', '/Models/C-Class-Coupe.aspx')
    });
    $('#dd-e, #dd-e-sedan').hover(function() {
        $('#c-class-selector').hide();
        $('#e-class-selector').show();
        $('#vehicle-class').text('E-Class');
        $('#vehicle-style').css({ width: '200px' }).text('The E-Class Sedan');
        $('#vehicle-detail').css({ width: '200px' }).text('Bold new styling, class-leading safety and technology in a full-size sedan. Starting at $49,400.');
        $('#vehicle-image').attr('src', '/Resources/Images/e-sedan-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/E-Class-Sedan.aspx');
    });
    $('#dd-e-wagon').hover(function() {
        $('#vehicle-style').text('The E-Class Wagon');
        $('#vehicle-detail').text('Bold new styling, class-leading safety and trailblazing technology in a full-size wagon with a history of defining the future. Starting at $56,200.');
        $('#vehicle-image').attr('src', '/Resources/Images/e-wagon-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/E-Class-Wagon.aspx')
    });
    $('#dd-e-coupe').hover(function() {
        $('#vehicle-style').text('The E-Class Coupe');
        $('#vehicle-detail').text('An aggressively styled coupe offering a signature blend of performance-oriented luxury, technology and power for four. Starting at $48,850.');
        $('#vehicle-image').attr('src', '/Resources/Images/e-coupe-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/E-Class-Coupe.aspx')
    });
    $('#dd-e-cabriolet').hover(function() {
        $('#vehicle-style').text('The E-Class Cabriolet');
        $('#vehicle-detail').text('Designed for true year-round enjoyment, a seductive, soft-top convertible for four with legendary E-Class comfort and safety. Starting at $56,850.');
        $('#vehicle-image').attr('src', '/Resources/Images/e-cab-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/E-Class-Cabriolet.aspx')
    });
    $('#dd-cl').hover(function() {
        $('#c-class-selector').hide();
        $('#e-class-selector').hide();
        $('#vehicle-class').text('CL-Class');
        $('#vehicle-style').css({ width: '320px' }).text('The CL-Class Coupe');
        $('#vehicle-detail').css({ width: '320px' }).text('Exclusive in audience and extraordinary in every way, the flagship Mercedes-Benz coupe defies constraints and compromise alike. Starting at $113,150.');
        $('#vehicle-image').attr('src', '/Resources/Images/cl-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/CL-Class.aspx');
    });
    $('#dd-cls').hover(function() {
        $('#e-class-selector').hide();
        $('#c-class-selector').hide();
        $('#vehicle-class').text('CLS-Class');
        $('#vehicle-style').css({ width: '320px' }).text('The CLS-Class Coupe');
        $('#vehicle-detail').css({ width: '320px' }).text("A powerful expression of individuality in a visionary four-door coupe whose beauty runs far deeper than its alluring profile. Starting at $74,000.");
        $('#vehicle-image').attr('src', '/Resources/Images/cls-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/CLS-Class.aspx');
    });
    $('#dd-s').hover(function() {
        $('#e-class-selector').hide();
        $('#c-class-selector').hide();
        $('#vehicle-class').text('S-Class');
        $('#vehicle-style').css({ width: '320px' }).text('The S-Class Sedan');
        $('#vehicle-detail').css({ width: '320px' }).text("With pioneering performance, luxury and safety, one sedan remains<br>not just the flagship of a brand, but the beacon for an industry. Starting at $91,000.");
        $('#vehicle-image').attr('src', '/Resources/Images/s-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/S-Class.aspx');
    });
    $('#dd-glk').hover(function() {
        $('#e-class-selector').hide();
        $('#c-class-selector').hide();
        $('#vehicle-class').text('GLK-Class');
        $('#vehicle-style').css({ width: '320px' }).text('The GLK-Class SUV');
        $('#vehicle-detail').css({ width: '320px' }).text("A compact twist on the DNA of an award-winning family of SUVs, with a style all its own and an aptitude for adventure. Starting at $35,500.");
        $('#vehicle-image').attr('src', '/Resources/Images/glk-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/GLK-Class.aspx');
    });
    $('#dd-gl').hover(function() {
        $('#e-class-selector').hide();
        $('#c-class-selector').hide();
        $('#vehicle-class').text('GL-Class');
        $('#vehicle-style').css({ width: '320px' }).text('The GL-Class SUV');
        $('#vehicle-detail').css({ width: '320px' }).text("Exceptional luxury and seating for seven in a full-size SUV engineered to come up big on every conceivable measure. Starting at $60,950.");
        $('#vehicle-image').attr('src', '/Resources/Images/gl-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/GL-Class.aspx');
    });
    $('#dd-m').hover(function() {
        $('#e-class-selector').hide();
        $('#c-class-selector').hide();
        $('#vehicle-class').text('M-Class');
        $('#vehicle-style').css({ width: '320px' }).text('The M-Class SUV');
        $('#vehicle-detail').css({ width: '320px' }).text('Five-star safety and five-star comfort meet in a mid-size luxury SUV that redefines every word in "sport utility vehicle." Starting at $46,490.');
        $('#vehicle-image').attr('src', '/Resources/Images/m-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/M-Class.aspx');
    });
    $('#dd-r').hover(function() {
        $('#e-class-selector').hide();
        $('#c-class-selector').hide();
        $('#vehicle-class').text('R-Class');
        $('#vehicle-style').css({ width: '320px' }).text('The R-Class SUV');
        $('#vehicle-detail').css({ width: '320px' }).text("Award-winning safety, versatility and luxury for up to seven take shape in a crossover that performs with poise and precision. Starting at $50,240.");
        $('#vehicle-image').attr('src', '/Resources/Images/r-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/R-Class.aspx');
    });
    $('#dd-g').hover(function() {
        $('#e-class-selector').hide();
        $('#c-class-selector').hide();
        $('#vehicle-class').text('G-Class');
        $('#vehicle-style').css({ width: '320px' }).text('The G-Class SUV');
        $('#vehicle-detail').css({ width: '320px' }).text("Superior craftsmanship and serious off-road capability in an exclusive SUV that pulls no punches in asserting its icon status. Starting at $105,750.");
        $('#vehicle-image').attr('src', '/Resources/Images/g-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/G-Class.aspx');
    });
    $('#dd-slk').hover(function() {
        $('#e-class-selector').hide();
        $('#c-class-selector').hide();
        $('#vehicle-class').text('SLK-Class');
        $('#vehicle-style').css({ width: '320px' }).text('The SLK-Class Roadster');
        $('#vehicle-detail').css({ width: '320px' }).text("Formula 1-inspired looks and race-inspired performance converge in a compact, two-seat roadster with retractable hardtop. Starting at $47,650.");
        $('#vehicle-image').attr('src', '/Resources/Images/slk-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/SLK-Class.aspx');
    });
    $('#dd-sl').hover(function() {
        $('#e-class-selector').hide();
        $('#c-class-selector').hide();
        $('#vehicle-class').text('SL-Class');
        $('#vehicle-style').css({ width: '320px' }).text('The SL-Class Roadster');
        $('#vehicle-detail').css({ width: '320px' }).text("The quintessential two-seat roadster, endowed with a retractable hardtop, unparalleled elegance and effortless performance. Starting at $102,600.");
        $('#vehicle-image').attr('src', '/Resources/Images/sl-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/SL-Class.aspx');
    });
    $('#dd-sls').hover(function() {
        $('#e-class-selector').hide();
        $('#c-class-selector').hide();
        $('#vehicle-class').text('SLS AMG');
        $('#vehicle-style').css({ width: '320px' }).text('The SLS AMG Roadster');
        $('#vehicle-detail').css({ width: '320px' }).text("Breathtaking performance and craftsmanship take flight in a gullwing coupe that nods to the past while rocketing into the future.");
        $('#vehicle-image').attr('src', '/Resources/Images/sls-thumb.jpg');
        $('.drop-2 a').attr('href', '/Models/SLS-Class.aspx');
    });
});

function DropDownChanged() {
    $("#<%= ddlYear.ClientID %>").attr("disabled", "disabled");
    $("#<%= ddlMake.ClientID %>").attr("disabled", "disabled");
    $("#<%= ddlModel.ClientID %>").attr("disabled", "disabled");
    $("#<%= ddlTrim.ClientID %>").attr("disabled", "disabled");
    $("#<%= ddlColor.ClientID %>").attr("disabled", "disabled");
}

function ShowSubPanel(panel) {
    document.getElementById('contactUs').style.display = 'none';
    document.getElementById('vehicleOptions').style.display = 'none';
    document.getElementById('windowSticker').style.display = 'none';
    document.getElementById('safetyResults').style.display = 'none';
    document.getElementById(panel).style.display = '';
}

function ShowEmailForm() {
    var div = document.getElementById('divEmailForm');
    if (div) {
        if (div.style.display == '')
            div.style.display = 'none';
        else
            div.style.display = '';
    }
}
function ShowWindowSticker() {
    $("#WindowSticker").show();
    $("#sticker").addClass("selected");
    $("#SafetyResults").hide();
    $("#safety").removeClass("selected");
    $("#VehicleOptions").hide();
    $("#equipemtn").removeClass("selected");
    $("#ContactUs").hide();
    $("#contact").removeClass("selected");
}

function ShowContactUs() {
    $("#WindowSticker").hide();
    $("#sticker").removeClass("selected");
    $("#SafetyResults").hide();
    $("#safety").removeClass("selected");
    $("#VehicleOptions").hide();
    $("#equipment").removeClass("selected");
    $("#ContactUs").show();
    $("#contact").addClass("selected");
}
function ShowStandardEquipment() {
    $("#WindowSticker").hide();
    $("#sticker").removeClass("selected");
    $("#SafetyResults").hide();
    $("#safety").removeClass("selected");
    $("#VehicleOptions").show();
    $("#equipment").addClass("selected");
    $("#ContactUs").hide();
    $("#contact").removeClass("selected");
}
function ShowSafetyResults() {
    $("#WindowSticker").hide();
    $("#sticker").removeClass("selected");
    $("#SafetyResults").show();
    $("#safety").addClass("selected");
    $("#VehicleOptions").hide();
    $("#equipment").removeClass("selected");
    $("#ContactUs").hide();
    $("#contact").removeClass("selected");
}

// $("#<%=testDate.ClientID %>").datepicker();
$("#WindowSticker").hide();
$("#SafetyResults").hide();
$("#VehicleOptions").hide();

function ShowBrochure(id) {
    window.open('/Brochure/' + id + '.aspx', 'Brochure', 'height=600,width=750,toolbar=no,status=yes,scrollbars=yes');
}

$(function() { $("#dvPhotoLarger").dialog({ autoOpen: false, width: 790, height: 530 }); });

function ShowZoomImages() {
    $("#dvPhotoLarger").dialog('open');
}

//function ShowLargeImages(large, larger) {
//    document.getElementById('photoLarger').src = '<%=(WebSite.Global.IsDevelopment() ? "http://demo.DealerDNA.com/" : "") %>' + larger;
//}

function ShowLargeImages(larger) {
    $('#photoLarger').attr('src', larger);
}

function showDetails() {
    $("#offer-details").dialog("open");
}

$(function() {
    $("#offer-details").dialog({
        resizable: false,
        autoOpen: false,
        width: 420,
        height: 320
    });
});

function showDisclaimer() {
    $("#offer-disclaimer").slideDown();
    $("#show-disclaimer").hide();
}
function hideDisclaimer() {
    $("#offer-disclaimer").slideUp();
    $("#show-disclaimer").show();
}
