var upsell = 'false';
var checked = false;

$(document).ready(function() {
    clearbuttontext();
});


function clearbuttontext() {
    
	if ($(".Go") != null) { $(".Go").val(""); }
    if ($("#btnCheckOutNowTop") != null) { $("#btnCheckOutNowTop").val(""); }
    if ($("#btnCheckOutNowBottom") != null) { $("#btnCheckOutNowBottom").val(""); }
    if ($(".AddToCartButton") != null) { $(".AddToCartButton").val(""); }
	if ($("#btnContinueToCheckOut") !=null) { $("#btnContinueToCheckOut").val(""); }
    if ($("#btnContinueCheckout") != null) { $("#btnContinueCheckout").val(""); }
	if ($("#btnContinueCheckout") != null) { $("#btnContinueCheckout").val(""); }
	if ($(".PaymentPageContinueCheckoutButton") != null) { $(".PaymentPageContinueCheckoutButton").val(""); }
	if ($("#btnContinueCheckout1") != null) { $("#btnContinueCheckout1").val(""); }
	if ($("#btnContinueCheckout2") != null) { $("#btnContinueCheckout2").val(""); }
	if ($("#btnCheckOut") != null) { $("#btnCheckOut").val(""); }
	//if ($(".CartDeleteButton") != null) { $(".CartDeleteButton").val(""); }
	
//    if ($("input[name=bt_Delete]") != null) {
//        $("input[name=bt_Delete]").each(function() { $(this).val("Remove"); });
//    }	
	
	
/*	
    if ($("input[name=bt_Delete]") != null) {
        $("input[name=bt_Delete]").each(function() { $(this).val(""); });
    }
*/
	
    $('#btnSearch').bind('click', function() {
        var temp = $('#searchBox')[0].value;
        $('#searchBox')[0].value = temp.replace(/[^a-zA-Z 0-9]+/g, '');
        if ($('#searchBox')[0].value.length == 0) {
            $('#searchBox').focus();
            return false;
        }
        else {
            document.topsearchform.submit();
        }
    });

    $('#searchBox').keypress(function(e) {
        var temp = $('#searchBox')[0].value;
        $('#searchBox')[0].value = temp.replace(/[^a-zA-Z 0-9]+/g, '');
        if ($('#searchBox')[0].value.length == 0) {
            return !(e.keyCode == 13);
        }
    });

    if (upsell == 'True') {
        $('#btnUpdateCart5').val("Upgrade");
    }
    else {
        $('#btnUpdateCart5').val("Add To Cart");
    }

    $('#btnUpdateCart5').bind('click', function() {
        if ($('input[name=UpSell]:checked').length == 0) {
            alert('Please verify selection');
            return false;
        }

        if (upsell == 'True') {
            var UpsellProductRecID = $('input[name^=UpsellProductRecID]').val();
            $('input[name^=Quantity_' + UpsellProductRecID + ']').val("0");
        }
    });

    $('#btnNoThanks').bind('click', function() {
        $("input[type=checkbox]").attr("checked", false);
        $('#pnlUpsellProducts').toggle();
        return false;
    });

}

//Pop-up window code: Richard C. Silverio: 03.02.10
function popAWin(url, wd, ht, windowName, rs, st, scl, loc, mn, tool) {
    try {
        win.close();
    } catch (e) {
    }
    win = window.open(url, windowName, 'height=' + ht + ', width=' + wd + ', resizable=' + rs + ', status= ' + st + ', scrollbars=' + scl + ', location=' + loc + ', menubar=' + mn + ', toolbar= ' + tool + ', left=5, top=5');
    win.focus();
}

// Rules page JQuery code (Unique for Hoyle): Richard C. Silverio: 03.19.10
$(function() {
	$("#leftNavAccMenu ul").hide();
 		$(".leftNavAccMenuHead").click(function(){
		$(this).next("ul").slideToggle()
			$(this).next("ul").siblings("ul:visible").slideUp();
		$(this).toggleClass("selected");
  		$(this).siblings(".leftNavAccMenuHead").removeClass("activeNode");
	return false;
	});
});	

//jQuery on DOM ready
$(function() {
    // Legal notice box
    $('#legal-toggle, #close-legal, #close_legal_top, #close_legal_bottom').click(function() {
        $('#legal-box').animate({ 'opacity': 'toggle', 'height': 'toggle' });
        return false;
    });
});

//jQuery on DOM ready
$(function() {

    // Turn the opacity down on the little screenshots
    //$('#product_images ul a').css("opacity", .8);
	$('#product_images ul a').css("opacity", 1); /*No opacity: Richard C. Silverio: 05.18.10*/
	
    // Thurn the opacity back up when you hover over the little screenshots
    $('#product_images ul a').hover(
    function() {
        $(this).animate({ opacity: 1 }, 300);
    },
    function() {
        //$(this).animate({ opacity: .8 }, 300);
		$('#product_images ul a').css("opacity", 1); /*No opacity: Richard C. Silverio: 05.18.10*/
    }
   );

});

$(document).ready(function() {
    $("ul.category").subMenu({
        animation: { height: 'show' },   // slide-down effect without fade-in 
        delay: 1200               // 1.2 second delay on mouseout 
    });
});


// Upsell box animation: Richard C. Silverio: 04.02.10
$(document).ready(function(){
	$('#pnlUpsellProducts').animate({ 
    	width: "570px",
		opacity: 1.0,
		marginTop: "10px",	
    	marginLeft: "2px",
    	borderWidth: "1px"
  }, 500 );
;
});
$(function() {
    // Upsell box close: Richard C. Silverio: 04.01.10
    $('#btnNoThanks').click(function() {
        
        return false;
    });
}); 

//This is to clear the search form: Richard C. Silverio: 04.12.10
function clearsearch(formfield){
 	if (formfield.defaultValue==formfield.value)
	formfield.value = ""
}