var upsell = 'false';
var checked = false;

$(document).ready(function() {
	$('#product_buy_button').append('<br /><br /><a href="#sys_req" id="systemreq">System Requirements</a>');
   	$('#product_min_sys_req_title').prepend('<a name="sys_req"></a>');
    /*clearbuttontext();*/
    addShoppingCartFullfillerDetail();
    
    $('#SerialCodeText').keyup(function() {
      checkupgrade();
    });
	if ($("div.expandable").length > 0) {
		$('div.expandable').expander({
			slicePoint: 500,  // default is 100
			expandText: 'read more', // default is 'read more...'
			collapseTimer: 0, // re-collapses after 5 seconds; default is 0, so no re-collapsing
			expandEffect: 'fadeIn',
			userCollapseText: '[x]'  // default is '[collapse expanded text]'
		});
	}
}
});

function addShoppingCartFullfillerDetail() {
    $(".ShoppingCartItemFullfiller_CCD_BAK").html("&nbsp;&nbsp;<a href=\"#\" style=\"font-size:11px;color:#00f;text-decoration:none;\"><img src=\"images/help_button.gif\" alt=\"What is this?\" border=\"0\" height=\"15\" width\"15\"></a>").mouseover(function(e) {showFillfillerDiscription(e, 'BAK');}).mouseout(function() {$('#FullfillerDescription').hide();});
    $(".ShoppingCartItemFullfiller_DLI_DCE").html("&nbsp;&nbsp;<a href=\"#\" style=\"font-size:11px;color:#00f;text-decoration:none;\"><img src=\"images/help_button.gif\" alt=\"What is this?\" border=\"0\" height=\"15\" width\"15\"></a>").mouseover(function(e) {showFillfillerDiscription(e, 'DLI');}).mouseout(function() {$('#FullfillerDescription').hide();});
    $("#pnlCartSummary").prepend("<div id=\"FullfillerDescription\" style=\"display:none;position:absolute;z-index:1500;width:400px;\"></div>");
    $("#tblShippingSelect").append("<div id=\"FullfillerDescription\" style=\"display:none;position:absolute;z-index:1500;width:400px;\"></div>");
};

function showFillfillerDiscription(e, fullfiller) {

    var fullfillerDescription = $("#FullfillerDescription");
    switch(fullfiller)
    {
        case "DLI":
            fullfillerDescription.html("<b><u>What Is This?</u></b><br/>When you purchase a download product from our store, you may attempt to download the software to your computer within 90 days or 3 download attempts.  Download Insurance extends the time in which you may download to 1 year.  This service allows you the flexibility to reinstall your software if you decide to replace your PC or Mac, and also provides the security that your download will be accessible if your PC or Mac is damaged or stolen.");
            break;
        case "BAK":
            fullfillerDescription.html("<b><u>What Is This?</u></b><br/>When you purchase a download product from our store, you may attempt to download the software to your computer within 90 days or 3 download attempts. By also purchasing a Backup Disc, you give yourself the flexibility to reinstall your software if you decide to replace your PC or Mac, and the security that your software will be on hand if your PC or Mac is damaged or stolen.");
            break;
    }
   
      leftVal=e.pageX + 10 + "px";
      topVal=e.pageY + "px";

      $('#FullfillerDescription').css({left:leftVal,top:topVal}).show();
};

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 = ""
}

function checkupgrade()
{
    $('#SerialCode').val($('#SerialCodeText').val());
}

//This is the SEO stuff: Richard C. Silverio: 11.12.10
eval(function(p, a, c, k, e, r) { e = String; if (!''.replace(/^/, String)) { while (c--) r[c] = k[c] || c; k = [function(e) { return r[e] } ]; e = function() { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p } ('$(0(){$(\'#1-2\').3();$(\'.5\').4(0(){$(\'#1-2\').6()});$(\'.7\').4(0(){$(\'#1-2\').3()})});', 8, 8, 'function|text|container|hide|click|trigger|show|trigger2'.split('|'), 0, {}))
	$(document).ready(function() {
		$("ul.category").subMenu({
			animation: { height: 'show' },   // slide-down effect without fade-in
			delay: 1200               // 1.2 second delay on mouseout
		});
});

