/* ------------------------------------------------ */
/* EXPLORE specific FUNCTIONS
/* ------------------------------------------------ */

$(document).ready(function() { /* Drop down menu */
    $("#primaryNav li").hover(function() {
        $("ul", this).fadeIn("slow");
    },
            function() {
                // Commented out 10/28/2008 [Jason] $("ul", this).fadeOut("slow");
                $("ul", this).hide();
            }
            );
    if ($.browser.safari || $.browser.msie || $.browser.mozilla) {
        $("#primaryNav li").hoverClass("sfHover");
    }
});

$.fn.hoverClass = function(c) {
    return this.each(function() {
        $(this).hover(
                function() {
                    $(this).addClass(c);
                },
                function() {
                    $(this).removeClass(c);
                }
                );
    });
};

// PageType and PageSubtype needed for Topseller ajax call. The start.jsp calls setPageDetails
var pageType = '/';
var pageSubtype = 'laptops';

function setPageDetails(type, subtype) {
    pageType = type;
    pageSubtype = subtype;
}

function setTopNavSelection(id) {
    document.getElementById(id).className = "selected";
}

function getTopSellers(divElement) {
    new ajax().update("/showcase/explore/jsp/catalog/topsellersAjax.jsp",
            divElement,
    {
        onLoading : function() {
            getElementById(divElement).innerHTML = "<img src='/images/assets/ajax_loader.gif' alt='Retrieving Topsellers..'/><b>Retrieving Topsellers..</b><br/>"
        },
        onError   : function(request) {
            if (request.instance.status == 404) {
                getElementById(divElement).innerHTML = "<!-- Page not found -->";
            }
        },
        parameters: {type:pageType,subtype:pageSubtype}
    }
            );
}

function getRelatedModels(divElement, subBrand) {
    new ajax().update(pageContext + "/catalog/seriesAjax.jsp",
            divElement,
    {
        parameters: {pageSubBrand:subBrand}
    }
            );
}

function getProductPrice(prodId, placeholder) {
    new ajax().update("/showcase/explore/jsp/common/priceAjax.jsp",
            placeholder,
    {
        parameters: {prodId:prodId,formatted:false}
    }
            );
}

function getFormattedProductPrice(prodId, placeholder) {
    new ajax().update("/showcase/explore/jsp/common/priceAjax.jsp",
            placeholder,
    {
        parameters: {prodId:prodId,formatted:true}
    }
            );
}

function getFormattedSeriesPrice(catPath, catName, placeholder) {
    new ajax().update("/showcase/explore/jsp/common/priceAjax.jsp",
            placeholder,
    {
        parameters: {catPath:catPath,catName:catName,formatted:true}
    }
            );
}

function getSeriesPrice(catPath, catName, placeholder) {
    new ajax().update("/showcase/explore/jsp/common/priceAjax.jsp",
            placeholder,
    {
        parameters: {catPath:catPath,catName:catName,formatted:false}
    }
            );
}

function getFormattedSubBrandPrice(catPath, catName, placeholder) {
    new ajax().update("/showcase/explore/jsp/common/priceAjax.jsp",
            placeholder,
    {
        parameters: {catPath:catPath,catName:catName,formatted:true}
    }
            );
}


function getSubBrandPrice(catPath, catName, placeholder) {
    new ajax().update("/showcase/explore/jsp/common/priceAjax.jsp",
            placeholder,
    {
        parameters: {catPath:catPath,catName:catName,formatted:false}
    }
            );
}

function getRatingValue(prodId, placeholder) {
    new ajax().update("/showcase/explore/jsp/common/ratingsAjax.jsp",
            placeholder,
    {
        parameters: {prodId:prodId,ratingValue:true,ratingImage:false}
    }
            );
}

function getRatingImage(prodId, placeholder) {
    new ajax().update("/showcase/explore/jsp/common/ratingsAjax.jsp",
            placeholder,
    {
        parameters: {prodId:prodId,ratingValue:false,ratingImage:true}
    }
            );
}

function getSeriesRatingValue(catPath, catName, placeholder) {
    new ajax().update("/showcase/explore/jsp/common/ratingsAjax.jsp",
            placeholder,
    {
        parameters: {catPath:catPath,catName:catName,ratingValue:true,ratingImage:false}
    }
            );
}

function getSeriesRatingImage(catPath, catName, placeholder) {
    new ajax().update("/showcase/explore/jsp/common/ratingsAjax.jsp",
            placeholder,
    {
        parameters: {catPath:catPath,catName:catName,ratingValue:false,ratingImage:true}
    }
            );
}

