﻿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
        $(".gutterLocatorTitle").css({
            "background-image": "url(/Content/Assets/Images/Loading.gif)",
            "background-repeat": "no-repeat",
            "background-position": "right",
            "width": "100px"
        })
        $(".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(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(options);

                } else {
                $("#Products").attr('disabled', true).html("<option value=''>&lt;select&gt;</option>");

                }

                //******* De-Activate "Loading" Animated GIF
                $(".gutterLocatorTitle").removeAttr("style");
                

            }
        });
    });
});
//Handle model selection change for part locator
$(document).ready(function() {
$("select#Models").change(function() {


//        var seriesId = $("#Models > option:selected").attr("value");       
//        var modelName = $("#Models > option:selected").attr("text");
//        var vendorId = $("#Vendors > option:selected").attr("value");
//        if (vendorId == null) {
//            //Get hidden input from VendorType page
//            vendorId = $("#VendorId").attr("value");
//        }
//        var controller = $("#ControllerName").attr("value");

//        var postURL = "/" + controller + "/LogPartLocatorUsage?queryText=" + modelName + "&vendorTypeId=" + vendorId + "&seriesId=" + seriesId;


//        $.ajax({
//            type: "POST",
//            contentType: "application/json; charset=utf-8",
//            url: postURL,
//            data: "{}",
//            dataType: "json",
//            success: function(data) {

//            $("#btnSuppliesLocator").attr('disabled', true);
//            
//            location.href = "/" + data.navigateTo;
//                
//            }
//        });
    });
});
//Handle Part selection change for part locator
//$(document).ready(function() {
//    $("select#Parts").change(function() {

//        var url = $("#Parts > option:selected").attr("value");
//        var partName = $("#Parts > option:selected").attr("text");

//        var vendorId = $("#Vendors > option:selected").attr("value");
//        if (vendorId == null) {
//            //Get hidden input from VendorType page
//            vendorId = $("#VendorId").attr("value");
//        }
//        var controller = $("#ControllerName").attr("value");

//        var productId = url.substring(url.lastIndexOf("productId=") + 10, url.lastIndexOf("&seriesId"));
//        var seriesId = url.substring(url.lastIndexOf("&seriesId=") + 10, url.length);

//        var postURL = "/" + controller + "/LogPartLocatorUsage?url=#" + partName + "&vendorTypeId=" + vendorId + "&seriesId=" + seriesId + "&productId=" + productId;

//        $.ajax({
//            type: "POST",
//            contentType: "application/json; charset=utf-8",
//            url: postURL,
//            data: "{}",
//            dataType: "json",
//            success: function(data) {

//                $("#btnSuppliesLocator").attr('disabled', true);
//            }
//        });
//        location.href = "/" + url;
//    });
//});

$(document).ready(function() { var qtys = $("input.qtyText"); $("input.qtyText").change(function(objEvent) { var ic = $(this).attr("id").split("#"); var fid = ic[1]; var t = 0; var p = 0; $.each(qtys, function(i, n) { var currId = n.id.split("#"); if (currId[1] == fid) { if (!isNaN(parseInt(n.value))) { t += parseInt(n.value) } else { n.value = "" } } }); $.each(qtys, function(i, n) { var currId = n.id.split("#"); if (currId[1] == fid) { if (!isNaN(parseInt(n.value))) { if (t == 1) { var priceSpan = $(".price" + fid + currId[0] + "_1"); var spanId = priceSpan.attr("id").split("#"); p += parseFloat(spanId[2]) * parseFloat(n.value) } else if (t >= 2 && t <= 3) { var priceSpan = $(".price" + fid + currId[0] + "_2"); var spanId = priceSpan.attr("id").split("#"); p += parseFloat(spanId[2]) * parseFloat(n.value) } else if (t >= 4 && t <= 7) { var priceSpan = $(".price" + fid + currId[0] + "_4"); var spanId = priceSpan.attr("id").split("#"); p += parseFloat(spanId[2]) * parseFloat(n.value) } else if (t >= 8) { var priceSpan = $(".price" + fid + currId[0] + "_8"); var spanId = priceSpan.attr("id").split("#"); p += parseFloat(spanId[2]) * parseFloat(n.value) } } } }); $(".totalQty" + fid).text(t); $(".totalPrice" + fid).text(p); $(".totalPrice" + fid).formatCurrency(); if (p >= 75) { $(".imgFreeGround").css("display", "block") } else { $(".imgFreeGround").css("display", "none") } if (t == 1) { $(".hl1" + fid).css("background-color", "#fff766"); $(".hl2" + fid).css("background-color", "#ffffff"); $(".hl4" + fid).css("background-color", "#ffffff"); $(".hl8" + fid).css("background-color", "#ffffff") } else if (t >= 2 && t <= 3) { $(".hl1" + fid).css("background-color", "#ffffff"); $(".hl2" + fid).css("background-color", "#fff766"); $(".hl4" + fid).css("background-color", "#ffffff"); $(".hl8" + fid).css("background-color", "#ffffff") } else if (t >= 4 && t <= 7) { $(".hl1" + fid).css("background-color", "#ffffff"); $(".hl2" + fid).css("background-color", "#ffffff"); $(".hl4" + fid).css("background-color", "#fff766"); $(".hl8" + fid).css("background-color", "#ffffff") } else if (t >= 8) { $(".hl1" + fid).css("background-color", "#ffffff"); $(".hl2" + fid).css("background-color", "#ffffff"); $(".hl4" + fid).css("background-color", "#ffffff"); $(".hl8" + fid).css("background-color", "#fff766") } else { $(".hl1" + fid).css("background-color", "#ffffff"); $(".hl2" + fid).css("background-color", "#ffffff"); $(".hl4" + fid).css("background-color", "#ffffff"); $(".hl8" + fid).css("background-color", "#ffffff") } }); $("input.qtyText").trigger("change") });
