﻿function NavTo(path) {
    $.base64Decode(path);
    var url = $.base64Decode(path);
    location.href = "/" + url;
}
$(function() {
    $('.mainMenuItem').hover(function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hover'));
        $(this).attr('hover', currentImg);
    }, function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hover'));
        $(this).attr('hover', currentImg);
    });
});
//'============================================================================
//'=== Text-Based Menu MouseOver Code'
//'============================================================================

function cellOn(div) {
    if (document.getElementById || (document.all && !(document.getElementById))) {
        div.style.color = "#473a04";
        div.style.display = "block";
        div.style.cursor = "pointer";
        div.style.backgroundImage = "url(/Content/Assets/Images/MenuBG-over.jpg)";
        div.style.textDecoration = "none";
    }
}
function cellOff(div) {
    if (document.getElementById || (document.all && !(document.getElementById))) {
        div.style.color = "#292929";
        div.style.display = "block";
        div.style.cursor = "pointer";
        div.style.backgroundImage = "url(/Content/Assets/Images/MenuBG.jpg)";
        div.style.textDecoration = "none";
    }
}


function cellOnStore(div) {
    if (document.getElementById || (document.all && !(document.getElementById))) {
        div.style.color = "#616161";
        div.style.display = "block";
        div.style.cursor = "pointer";
        div.style.backgroundImage = "url(/Content/Assets/Images/StoreBullet-over.gif)";
        div.style.textDecoration = "none";
    }
}
function cellOffStore(div) {
    if (document.getElementById || (document.all && !(document.getElementById))) {
        div.style.color = "#282828";
        div.style.display = "block";
        div.style.cursor = "pointer";
        div.style.backgroundImage = "url(/Content/Assets/Images/StoreBullet.gif)";
        div.style.textDecoration = "none";
    }
}


function cellOnLG(div) {
    if (document.getElementById || (document.all && !(document.getElementById))) {
        div.style.color = "#616161";
        div.style.display = "block";
        div.style.cursor = "pointer";
        div.style.backgroundImage = "url(/Content/Assets/Images/LeftNavBullet-over.gif)";
        div.style.textDecoration = "none";
    }
}

function cellOffLG(div) {
    if (document.getElementById || (document.all && !(document.getElementById))) {
        div.style.color = "#282828";
        div.style.display = "block";
        div.style.cursor = "pointer";
        div.style.backgroundImage = "url(/Content/Assets/Images/LeftNavBullet.gif)";
        div.style.textDecoration = "none";
    }
}

function cellOnInfo(div) {
    if (document.getElementById || (document.all && !(document.getElementById))) {
        div.style.color = "#616161";
        div.style.display = "block";
        div.style.cursor = "pointer";
        div.style.backgroundImage = "url(/Content/Assets/Images/infoBullet-over.gif)";
        div.style.textDecoration = "none";
    }
}

function cellOffInfo(div) {
    if (document.getElementById || (document.all && !(document.getElementById))) {
        div.style.color = "#282828";
        div.style.display = "block";
        div.style.cursor = "pointer";
        div.style.backgroundImage = "url(/Content/Assets/Images/infoBullet.gif)";
        div.style.textDecoration = "none";
    }
}
///////// ADD TO MOUSEOVER JAVASCRIPT//////////////////////////
function cellOnQL(div) {
    if (document.getElementById || (document.all && !(document.getElementById))) {
        div.style.display = "block";
        div.style.cursor = "pointer";
        div.style.backgroundColor = "#fff200";
        div.style.color = "#000000";
        div.style.textDecoration = "none";
    }
}
function cellOffQL(div) {
    if (document.getElementById || (document.all && !(document.getElementById))) {
        div.style.display = "block";
        div.style.cursor = "pointer";
        div.style.backgroundColor = "#fb471a";
        div.style.color = "#ffffff";
        div.style.textDecoration = "none";
    }
}
function cellOnArrow(div) {
    if (document.getElementById || (document.all && !(document.getElementById))) {
        div.style.color = "#473a04";
        div.style.display = "block";
        div.style.cursor = "pointer";
        div.style.backgroundImage = "url(/Content/Assets/Images/MenuBG-DownArrow-over.jpg)";
        div.style.textDecoration = "none";
    }
}
function cellOffArrow(div) {
    if (document.getElementById || (document.all && !(document.getElementById))) {
        div.style.color = "#292929";
        div.style.display = "block";
        div.style.cursor = "pointer";
        div.style.backgroundImage = "url(/Content/Assets/Images/MenuBG-DownArrow.jpg)";
        div.style.textDecoration = "none";

    }
}
//Used to swap the placement of locator tool and popular products on the vendor page
//This allows locator tool to appear at the bottom of the page in the code-behind :)
$(document).ready(function() {
    //get the position of the top element
    var pos = $("#vendorAppearTop").offset();
    var heightHead = $("#vendorHeadTopContent").height();
    var heightTop = $("#vendorAppearTop").height();
    var heightBottom = $("#vendorAppearBottom").height();
    //show the bottom element just below the top
    $("#vendorAppearBottom").css({ "offset": (pos.top + heightTop) });
    $("#vendorContentWrapper").css({ "height": (heightTop + heightBottom + heightHead) + "px" });
    $("#vendorAppearBottom").show();
});
//Handle vendor selection change for part locator
$(document).ready(function() {
    $("select#VendorId").change(function() {
        var id = $("#VendorId > option:selected").attr("value");
        var controller = $("#ControllerName").attr("value");
        //******* Activate "Loading" Animated GIF
        $(".locatorProgress").css({ "visibility": "visible" });
        $(".gutterLocatorSelect").attr('disabled', true);
        //******************************************
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "/" + controller + "/GetVendorModels?vendorTypeId=" + id,
            data: "{}",
            dataType: "json",
            success: function(data) {
                //Load Series List For Selected Vendor
                if (data.seriesList.length > 0) {
                    var options = '';
                    //options += "<option value=''>&lt;select&gt;</option>";
                    for (p in data.seriesList) {
                        var model = data.seriesList[p];
                        options += "<option value='" + model.Value + "'>" + model.Text + "</option>";
                    }
                    $("#Models").removeAttr('disabled').html("<option value=''>&lt;select&gt;</option>"+options);
                    $("#ModelsHidden").html(options);
                } else {
                    $("#Models").attr('disabled', true).html("<option value=''>&lt;select&gt;</option>");
                }
                //Load Parts List For Selected Vendor
                if (data.partList.length > 0) {
                    var options = '';
                    //options += "<option value=''>&lt;select&gt;</option>";
                    for (p in data.partList) {
                        var model = data.partList[p];
                        options += "<option value='" + model.Value + "'>" + model.Text + "</option>";
                    }
                    $("#Products").removeAttr('disabled').html("<option value=''>&lt;select&gt;</option>" + options);
                    $("#ProductsHidden").html(options);
                } else {
                    $("#Products").attr('disabled', true).html("<option value=''>&lt;select&gt;</option>");
                }
                //******* De-Activate "Loading" Animated GIF
                $(".locatorProgress").css({ "visibility": "hidden" });
            }
        });
    });
}); 
