﻿var rootUrl = location.protocol + "//" + location.hostname + (location.port.length > 0 ? ":" + location.port : "") + (location.hostname.indexOf("localhost") >= 0 ? "/searshomepro5/" : "/");
$(document).ready(function() {
    loadProductPageGallery();
    loadTaxRebateInfo();
    loadOfferDisclaimer();
    loadCashForAppliance();
});
function loadProductPageGallery() {
    try {
        $("div.product div.inline_pic a").nyroModal();
        $("div.product div.thumbnails img").click(function(e) {
            var Index = $("div.product div.thumbnails img").index(e.target);
            $("div.product div.inline_pic a:eq(" + Index + ")").removeClass("hide");
            $("div.product div.inline_pic a:eq(" + Index + ")").siblings().addClass("hide");
        });
    } catch (ex) { }
}
function loadTaxRebateInfo() {
    try {
        $("a.taxRebateLightbox").nyroModal({
            type: 'iframe',
            forceType: 'iframe',
            minWidth: 1,
            minHeight: 1,
            width: 320,
            height: 350,
            processHandler: function() { $("#flash").css("visibility", "hidden"); },
            endRemove: function() { $("#flash").css("visibility", "visible"); }
        });
    } catch (ex) { }
}
function loadCashForAppliance() {
    try {
        $("a.appLightbox").nyroModal({
            type: 'iframe',
            forceType: 'iframe',
            minWidth: 1,
            minHeight: 1,
            width: 700,
            height: 800,
            processHandler: function() { $("#flash").css("visibility", "hidden"); },
            endRemove: function() { $("#flash").css("visibility", "visible"); }
        });
    } catch (ex) { }
}
function loadOfferDisclaimer() {
    try {
        $("a.nonoLightbox").nyroModal({
            type: 'iframe',
            forceType: 'iframe',
            minWidth: 1,
            minHeight: 1,
            width: 515,
            height: 475,
            processHandler: function() { $("#flash").css("visibility", "hidden"); },
            endRemove: function() { $("#flash").css("visibility", "visible"); }
        });
    } catch (ex) { }
}
function popupOfferDisclaimer(popupUrl) {
    try {
        $.nyroModalManual({
            type: 'iframe',
            forceType: 'iframe',
            url: popupUrl,
            minWidth: 1,
            minHeight: 1,
            width: 515,
            height: 475,
            processHandler: function() { $("#flash").css("visibility", "hidden"); },
            endRemove: function() { $("#flash").css("visibility", "visible"); }
        });
    } catch (ex) { }
}
function beforeAndAfterGallery(popupId) {
    try {
        $(popupId + " a:first-child").nyroModalManual();
    } catch (ex) { }
}
function SearchSite() {
    var DefaultSearchValue = $("input[id$='hidDefaultSearch']").val();
    var CurrentSearchValue = $("input[id$='txtSearch']").val();
    if (jQuery.trim(CurrentSearchValue) == jQuery.trim(DefaultSearchValue)
        || jQuery.trim(CurrentSearchValue).length <= 0) {
        alert("Please enter a search term.");
        return false;
    } else {
        try {
            var s = s_gi(s_account);
            s.linkTrackVars = 'eVar1';
            s.eVar1 = CurrentSearchValue;
            s.tl(this, 'o', ' intSearch');
        } catch (ex) { }
        document.location.href =
            rootUrl
            + "searchresults.aspx?cx=005668391240130570544:gfrqjlqigf8&cof=FORID:11;NB:1&ie=UTF-8&q="
            + encodeURIComponent(CurrentSearchValue)
            + "&sa=Search";
        return true;
    }
}
function TabClick(tabName) {
    tabName = tabName.toLowerCase();
    try {
        var s = s_gi(s_account);
        s.linkTrackVars = 'prop1,prop2';
        s.prop1 = s.prop1;
        s.pageName = s.prop1 + ": " + tabName;
        s.prop2 = s.prop1 + ": " + tabName;
        s.tl(this, 'o', 'TABS');
    } catch (ex) { }
}
function NewsletterSubmitted(zipCode) {
    try {
        var s = s_gi(s_account);
        s.linkTrackVars = 'events,eVar10,eVar11';
        s.linkTrackEvents = 'event4';
        s.events = "event4";
        s.eVar10 = zipCode;
        s.eVar11 = "newsletter";
        s.tl(this, 'o', 'intNewsletter');
    } catch (ex) { }
}
function FeedbackEmailSent() {
    try {
        var s = s_gi(s_account);
        s.linkTrackVars = 'events,eVar11';
        s.linkTrackEvents = 'event4';
        s.events = "event4";
        s.eVar11 = "email";
        s.tl(this, 'o', 'intEmail');
    } catch (ex) { }
}
function SchedulerCall() {
    try {
        setTimeout(function() {
            if (Page_IsValid != null && Page_IsValid == true) {
                s.events = "event9";
                s.t();
            }
        }, 1);
    } catch (ex) { }
}
function SchedulerApptOpen() {
    try {
        s.events = "event10";
        s.t();
    } catch (ex) { }
}
function SchedulerAppt() {
    try {
        if ($("input[id$='SelectedApptTime']").val().length > 0) {
            s.events = "event12";
            s.t();
        }
    } catch (ex) { }
}

