﻿/// <reference path="jquery-1.3.2-vsdoc2.js" />
$(document).ready(function() {
    $("#popupDialog").dialog({
        width: 710,
        height: 580,
        autoOpen: false,
        resizable: false,
        modal: true,
        draggable: false,
        open: function(event, ui) { wthvideo.drawVideo(); },
        close: function(event, ui) { $("#wthvideo").html(""); }
    });
//    var options = { path: '/', expires: 99 };
//    if ($.cookie('hasSeenHomeVideo') == "1") {
//        $.cookie('hasSeenHomeVideo', "2", options);
//        $("#popupDialog").dialog('open');
//    }
//    if (!$.cookie('hasSeenHomeVideo')) {
//        $.cookie('hasSeenHomeVideo', "1", options);
//        $("#popupDialog").dialog('open');
//    }


});
String.prototype.trim = function() {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

function submitHompageContact() {

    var ContactName = $("#ContactName").val().trim();
    var DealershipName = $("#DealershipName").val().trim();
    var EmailAddress = $("#EmailAddress").val().trim();
    var Phone = $("#Phone").val().trim();
    var Comments = $("#Comments").val().trim();

    if (ContactName == "" || DealershipName == "" || EmailAddress == "" || Phone == "") {
        $("#formError").show();
        $("#formError").html("Error!  Please fill out all fields.");
        return false;
    } else {
        $("#formError").hide();
    }

    var data = "";
    data += "ContactName=" + ContactName;
    data += "&DealershipName=" + DealershipName;
    data += "&EmailAddress=" + EmailAddress;
    data += "&Phone=" + Phone;
    data += "&Comments=" + Comments;
    $.ajax({
        type: "POST",
        url: "HomePageFormService.aspx",
        data: data,
        success: function(msg) {
            if (msg == "True") {
                $("#contactForm").html("Thank You");
            } else {
                alert("Error! Please try again.")
            }
        }
    });

}