﻿function GetAssociate() {
    var today = new Date()
    var thisDay = today.getDay()
    thisDay = thisDay % 5;

    $('#Associate1').hide();
    $('#Associate2').hide();
    $('#Associate3').hide();
    $('#Associate4').hide();
    $('#Associate5').hide();

    if (thisDay == 0) {
        $('#Associate1').show();
    }

    if (thisDay == 1) {
        $('#Associate2').show();
    }

    if (thisDay == 2) {
        $('#Associate3').show();
    }

    if (thisDay == 3) {
        $('#Associate4').show();
    }

    if (thisDay == 4) {
        $('#Associate5').show();
    }
    GetQuestion();
}

function GetQuestion() {
    var today = new Date()
    var thisDay = today.getDay()
    $('#Question1').hide();
    $('#Question2').hide();
    $('#Question3').hide();
    $('#Question4').hide();
    $('#Question5').hide();
    $('#Question6').hide();
    $('#Question7').hide();

    if (thisDay == 0) {
        $('#Question1').show();
    }

    if (thisDay == 1) {
        $('#Question2').show();
    }

    if (thisDay == 2) {
        $('#Question3').show();
    }

    if (thisDay == 3) {
        $('#Question4').show();
    }

    if (thisDay == 4) {
        $('#Question5').show();
    }

    if (thisDay == 5) {
        $('#Question6').show();
    }

    if (thisDay == 6) {
        $('#Question7').show();
    }

}

$(document).ready(function () {
    $('#ContentPopup').dialog({
        autoOpen: false,
        height: 500,
        modal: true,
        resizable: true,
        width: 600
    });
});

function popContent(nodeId, field, title, pageLocation) {
    var url = '/usercontrols/Navigation/ContentPop.aspx?nodeId=' + nodeId + '&field=' + field;

    if (pageLocation)
        url += '#' + pageLocation;

    $('#ContentPopup iframe').attr('src', url);
    $('#ContentPopup').dialog('open');
    $('#ContentPopup').dialog('option', 'title', title);
}

function setProductMedLrgImg(li, medUrl) {
    $('#medBox>img').attr('src', medUrl);

    $('#firstImg').removeClass('sel');
    $('#secondImg').removeClass('sel');
    $('#thirdImg').removeClass('sel');
    $('#fourthImg').removeClass('sel');

    $(li).addClass('sel');
}
function OpenBoldChat() {
    window.open('https://livechat.boldchat.com/aid/7638420296462874948/bc.chat?cwdid=421226952161662919&amp;rdid=2541069682483712013&amp;url=' + escape(document.location.href), 'Chat5519953050893287054', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=480');
    return false;
}

function fixReviewHeights() {
    var prodListingUL = document.getElementById("prodListingUL");
    var prodListingLIs = new Array();
    prodListingLIs = prodListingUL.getElementsByTagName("li")
    for (var i = 0; i < prodListingLIs.length; i++) {
        //check the chold node count
        //if its greater than 15, make the height 160
        var prodListingdivs = new Array();
        var divCount = prodListingLIs[i].getElementsByTagName("div").length;
        if (divCount >= 15) {
            //set the height to something larger, like 160px to accomidate for the ratings that popped up.
            prodListingLIs[i].style.height = 160 + 'px';
        }
    }
}

$(function () {
    //only need to auto set zindex for first 50 or so divs (header, minicart, and topnavs)
    var zIndexNumber = 50;
    $('div').each(function () {
        if (($(this).hasClass('CCPopupContainer'))) {
            //make sure all the custom cable popups have a higher zindex than everything else
            $(this).css('zIndex', 12000);
        }
        else {
            if (zIndexNumber > 0)
                $(this).css('zIndex', zIndexNumber);
        }
        zIndexNumber -= 1;
    });

});

function ShowLargeImage(elementID) {
    document.getElementById(elementID).style.display = 'inline';
    if (document.getElementById('questionBox') != null)
        document.getElementById('questionBox').style.display = 'none';


}
function HideLargeImage(elementID) {
    document.getElementById(elementID).style.display = 'none';
    if (document.getElementById('questionBox') != null)
        document.getElementById('questionBox').style.display = 'inline';
}

function ShowLargeImageListing(elementID) {
    document.getElementById(elementID).style.display = 'inline';

}
function HideLargeImageListing(elementID) {
    document.getElementById(elementID).style.display = 'none';
    if (document.getElementById('questionBox') != null)
        document.getElementById('questionBox').style.display = 'inline';
}

function ShowFacetFilterUpdate() {
    var opaque = $("<div id='opaque'></div>");
    $("body").append(opaque);
    var opaqueContent = $("<div id='opaqueContent' class='shadow'>Updating...<br/><br/><img src='/images/spinner.gif' alt='Please Wait' /></div>");
    $("body").append(opaqueContent);

}


$.extend({
    getParamValue: function (paramName) {
        /// <summary>
        ///     Get the value of input parameter from the querystring
        /// </summary>
        /// <param name="paramName" type="String">The input parameter whose value is to be extracted</param>
        /// <returns type="String">The value of input parameter from the querystring</returns>
        parName = paramName.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]');
        var pattern = '[\\?&]' + paramName + '=([^&#]*)';
        var regex = new RegExp(pattern);
        var matches = regex.exec(window.location.href);
        if (matches == null) return '';
        else return decodeURIComponent(matches[1].replace(/\+/g, ' '));
    }
});

