﻿$(document).ready(function() {
    $(document).pngFix();
    // Main Menu Hover Function
    $(".Btn").hover(function() {
        $(this).removeClass("Btn").addClass("BtnSelected");
    }, function() {
        $(this).removeClass("BtnSelected").addClass("Btn");
    })
    // Sub Menu Hover Function
    $(".SideBtn").hover(function() {
        $(this).removeClass("SideBtn").addClass("SideBtnSelected");
    }, function() {
        $(this).removeClass("SideBtnSelected").addClass("SideBtn");
    })
    // Select Box Initialization
    $('#MM, #DD, #YY, #TYPE1, #typeOfMove, #timeToCall').sSelect({ ddMaxHeight: '300px' });
    // Allow only numbers function -- add the class InputNum to the field 
    $(".InputNum").keypress(function(e) {
        if (e.whice != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) return false;
    })
    $(".QuoteBox").click(function() {
         window.location = 'http://www.northern-american.com/About_Us/?subId=28';
    })
    $(".QuoteBoxHigh").click(function() {
         window.location = 'http://www.northern-american.com/About_Us/?subId=28';
    })
})
// Locate Zip Function
function locatezip() {
    window.open('http://www.hellomoving.biz/wc.dll?mputil~zipwc~NEW','EANITHING','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes,width=550,height=500');
self.name="main"}
// Main Menu Tab Change
function ChangeTab(idToChange)
{
    $("#" + idToChange).removeClass("Btn").addClass("BtnSelectedConst");
}

// Request a Quote Form Validation
function Validation(action) {
    var flag = true;
    $(".CheckField").each(function(i) {
        if (typeof $(this).attr("regex") != 'undefined') {
            var regex = new RegExp($(this).attr("regex"));
            if ($(this).attr("class").indexOf("required") != -1) {
                if (!(regex).test($(this).val())) {
                    $(this).addClass("RedBorder");
                    flag = false;
                }
                else $(this).removeClass("RedBorder");
                //else $("#" + ($(this).attr("ErrMsg"))).css("display","none"); 
            }
            else // IF IT NOT A REQUIRED FIELD
            {
                if ($(this).val().length > 0) {
                    if (!(regex).test($(this).val())) {
                        $(this).addClass("RedBorder");
                        flag = false;
                    }
                    else $(this).removeClass("RedBorder");
                }
            }
        }
    })
    if (flag) {
        if (action == 'form')
        {
            $("#ContinueBtn").unbind("click");
            $(".ErrMsg").css("display", "none");
		    document.QuoteForm.action="http://www.hellomoving.biz/wc.dll?mpdir~moduleret~AMAZON~N";
		    document.QuoteForm.submit();  
        }
        else if (action == 'contact')
        {
            $.post("handlers/SendMail.ashx", 
                                {
                                 fullName : $("#fullName").val(),
                                 email : $("#email").val(),
                                 phone: $("#phone").val(),
                                 secondPhone: $("#otherPhone").val(),
                                 comments : $("#comments").val()},
              function(data) {
                  $("#ContactTitle").html("Thank You!!")
                  $("#ContactCont").html("<p class='F14'><b>Thank You for contacting Northern American Van Lines<br/>We will be happy to get back with you within  2 business days.</b></p>")
              });
        }
        else if (action == 'trackYourShipment') {
            $.post("handlers/trackShipment.ashx",
                                {
                                    fullName: $("#fullName").val(),
                                    email: $("#email").val(),
                                    phone: $("#phone").val(),
                                    jobNumber: $("#jobNumber").val()
                                },
              function(data) {
                  $("#ContactTitle").html("Thank You!!")
                  $("#trackYourShipment").html("<p class='F14'><b>Thank You for contacting Northern American Van Lines<br/>We will get back to you soon with your shipment details</b></p>")
              });
        }
    }
    else $("#ErrorMsg").css("visibility", "visible");
}

