﻿function Privacy() {
    window.location = '/dealership/Privacy';
}

function openHideFooter() {  
    var isHidden = $.cookie('mycookie');
    if (isHidden != null && isHidden != '' && isHidden != 'undefined') {
        if (isHidden == 'true') {
            $("#mc").slideUp("slow", function () {
                $(".mainfooter").css("padding-bottom", "0");
            });
        }
    }
}

$(document).ready(function () {
    $("input, textarea").each(function () {
        if (!$(this).attr("title") == "") {
            $(this).val($(this).attr("title"));
        }
    }).bind("focus", function () {
        if (!$(this).attr("readonly") && $.trim($(this).val()) == $(this).attr("title")) {
            $(this).val("");
        }
    }).bind("blur", function () {
        if ($.trim($(this).val()) == "" || $.trim($(this).val()) == $(this).attr("title")) {
            $(this).val($(this).attr("title"));
        }
    });

    $("#mcplus").bind("click", function () {
        SetCookie();
    });
});

function SetCookie() {   
    $.cookie('mycookie', 'true', { expires: null, path: '/', domain: '', secure: false });
    openHideFooter();
}


function contactUsSubmit() {
    var ContactUs = {};
    ContactUs.FirstName = $('#txtCFirstName').val();
    ContactUs.LastName = $('#txtCLastName').val();
    ContactUs.Email = $('#txtCEmail').val();
    ContactUs.Comments = $('#txtCComments').val();

    $.ajax({
        type: "POST",
        url: "/Home/ContactUsSubmit",
        data: ContactUs,
        dataType: "json",
        success: function (data) {
            $("#spnContactError").hide();
            if (data == true) {
                $("#spnContactError").html('Contact Detail Submitted Successfully');
            }
            else {
                $("#spnContactError").html('Error in Sending Contact Detail');
            }
            $("#spnContactError").show();
        }
    });

}

function FinacingSubmit() {
    var Finance = {};
    Finance.FirstName = $('#txtFFirstName').val();
    Finance.LastName = $('#txtFLastName').val();
    Finance.Apartment = $('#txtFApartment').val();
    Finance.Address = $('#txtFAddress').val();
    Finance.City = $('#txtFCity').val();
    Finance.ZipCode = $('#txtFZipCode').val();
    Finance.Comments = $('#txtFComments').val();

    $.ajax({
        type: "POST",
        url: "/Home/FinancingSubmit",
        data: Finance,
        dataType: "json",
        success: function (data) {
            $("#spnFinanceError").hide();
            if (data == true) {
                $("#spnFinanceError").html('Finance Detail Submitted Successfully');
            }
            else {
                $("#spnFinanceError").html('Error in Sending Finance Detail');
            }
            $("#spnFinanceError").show();
        }
    });
}
