﻿function DoSearch() {
    var ddlCategory = document.getElementById(ddlCategoryID);
    var selCategory = ddlCategory.options[ddlCategory.selectedIndex].value;

    var ddlPrice = document.getElementById(ddlPriceID);
    var selPrice = ddlPrice.options[ddlPrice.selectedIndex].value;

    var ddlGender = document.getElementById(ddlGenderID);
    var selGender = ddlGender.options[ddlGender.selectedIndex].value;

    var returnURL = selCategory + '?price=' + selPrice + '&gender=' + selGender;

    document.location.href = returnURL;
}

function setShippingButtonClick() {
    SelectedShipping = "";
    if (jQuery('.deliveryitem input:radio[checked=true]').length > 0) {
        SelectedShipping = jQuery('.deliveryitem input:radio[checked=true]').val();
    }
    if (SelectedShipping != "") {
        jQuery(".hdnDateString input").val(SelectedShipping);
        __doPostBack(jQuery(".hdnDateString input").attr("id"), "");
    }
    else {
        jQuery('#shipErrorDiv').html('<p class="error">Please select a shipping method</p>');
    }
}

function validateShipping(oSrc, args) {
    valid = false;
    selectedStr = jQuery(".hdnDateString input").val();
    if (selectedStr != "") {
        if (selectedStr.indexOf("future") != -1) {
            if (jQuery(".hdnFutureDate input").val() != "") {
                valid = true;
            }
        } else {
            valid = true;
        }
    }
    args.IsValid = valid;
}

function ShowDDL(styleid) {
    jQuery("#ddlDiv" + styleid).show();
    jQuery("#hdnDivStyle" + styleid + " input").val(jQuery("#ddl" + styleid).val());
    jQuery("#hdnDivColor" + styleid + " input").val(jQuery("#ddlColor" + styleid).val());
}
function HideDDL(styleid) {
    jQuery("#ddlDiv" + styleid).hide();
}

function changeStyleJS(styleid) {
    newStyle = jQuery("#ddl" + styleid).val();
    oldStyle = jQuery("#hdnDivStyle" + styleid + " input").val();
    newColor = jQuery("#ddlColor" + styleid).val();
    oldColor = jQuery("#hdnDivStyle" + styleid + " input").val();
    jQuery("#hdnDivStyle" + styleid + " input").val(newStyle);
    jQuery("#hdnDivColor" + styleid + " input").val(newColor);
    __doPostBack(jQuery("#hdnDivStyle" + styleid + " input").attr("id"), false);
}

//Show Subnav on Hover
jQuery(document).ready(function () {
    jQuery(".hasSubCat").hover(function () {
        if (jQuery(this).hasClass("hover") == false) {
            jQuery(".subcat").hide();
            jQuery(".hasSubCat").removeClass("hover");
            jQuery(this).addClass("hover").children(".subcat").slideDown(0);
        }
    }, function () {

    });
    if (typeof (startCat) != "undefined") {
        jQuery(".hasSubCat.sub_" + startCat).addClass("hover").children(".subcat").slideDown(0);
    }
});

jQuery(document).ready(function(){	
	jQuery(".subcat li:first-child").addClass("first-child");
	jQuery(".subcat li:last-child").addClass("last-child");
});

var scrollLockHeight = 0;
var scrollHeight = 0;
var isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
jQuery(document).ready(function () {
    if (jQuery(".scrollLockTarget")[0]) {
        offset = jQuery(".scrollLockTarget").offset();
        scrollHeight = jQuery(".scrollLockTarget").height();
        scrollLockHeight = offset.top;

        window.onscroll = function () {
            if (jQuery(document).scrollTop() > scrollLockHeight) {
                if (isIE6 == false) {
                    jQuery(".scrollLockTarget").css({ 'position': 'fixed', 'top': '0' })
                }
                else {
                    jQuery(".scrollLockTarget").css({ 'position': 'absolute', 'top': jQuery(document).scrollTop() })
                }
            }
            else {
                jQuery(".scrollLockTarget").css({ 'position': '', 'top': '0px' })
            }
        }
    }
});

function freeze(jButton) {
    pos = jButton.offset();
    jButton.css("position", "absolute");
    jButton.offset({ top: pos.top, left: pos.left });
}
function unfreeze(jButton) {
    jButton.css("position", "static");
}
