﻿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>');
    if (document.location.href.indexOf('checkout1') > -1) {
        if ($("input[name=ShippingMethodID]:radio").length) {

            if ($(":radio[value*=Ground]").length > 0) {
                $(":radio[value*=Ground]")[0].nextSibling.textContent = $(":radio[value*=Ground]")[0].nextSibling.textContent.replace('Ground', 'Ground (5-9 business days)');
            }

            if ($(":radio[value*=Parcel Post]").length > 0) {
                $(":radio[value*=Parcel Post]")[0].nextSibling.textContent = $(":radio[value*=Parcel Post]")[0].nextSibling.textContent.replace('Parcel Post<sup>&reg;</sup>', 'Parcel Post (7-8 Business Days)');
                $(":radio[value*=Parcel Post]")[0].value = $(":radio[value*=Parcel Post]")[0].value.replace('Parcel Post<sup>&reg;</sup>', 'Parcel Post');
            }

            if ($(":radio[value*=Priority Mail]").length > 0) {
                $(":radio[value*=Priority Mail]")[0].nextSibling.textContent = $(":radio[value*=Priority Mail]")[0].nextSibling.textContent.replace('Priority Mail<sup>&reg;</sup>', 'Priority Mail (3 Business Days)');
                $(":radio[value*=Priority Mail]")[0].value = $(":radio[value*=Priority Mail]")[0].value.replace('Priority Mail<sup>&reg;</sup>', 'Priority Mail');
            }

            if ($(":radio[value*=Second Day Air]").length > 0) {
                $(":radio[value*=Second Day Air]")[0].nextSibling.textContent = $(":radio[value*=Second Day Air]")[0].nextSibling.textContent.replace('Second Day Air', 'Second Day Air (2 Business Days)');
            }

            if ($(":radio[value*=Next Day Air]").length > 0) {
                $(":radio[value*=Next Day Air]")[0].nextSibling.textContent = $(":radio[value*=Next Day Air]")[0].nextSibling.textContent.replace('Next Day Air', 'Next Day Air (Next Business Day)');
            }

            if ($(":radio[value*=First-Class Mail]").length > 0) {
                $(":radio[value*=First-Class Mail]")[0].nextSibling.textContent = $(":radio[value*=First-Class Mail]")[0].nextSibling.textContent.replace('First-Class Mail<sup>&reg;</sup>', 'First-Class Mail');
                $(":radio[value*=First-Class Mail]")[0].value = $(":radio[value*=First-Class Mail]")[0].value.replace('First-Class Mail<sup>&reg;</sup>', 'First-Class Mail');
            }

            if ($(":radio[value*=Express Mail]").length > 0) {
                $(":radio[value*=Express Mail]")[0].nextSibling.textContent = $(":radio[value*=Express Mail]")[0].nextSibling.textContent.replace('Express Mail<sup>&reg;</sup>', 'Express Mail');
                $(":radio[value*=Express Mail]")[0].value = $(":radio[value*=Express Mail]")[0].value.replace('Express Mail<sup>&reg;</sup>', 'Express Mail');
            }

            if ($(":radio[value*=Media Mail]").length > 0) {
                $(":radio[value*=Media Mail]")[0].nextSibling.textContent = $(":radio[value*=Media Mail]")[0].nextSibling.textContent.replace('Media Mail<sup>&reg;</sup>', 'Media Mail');
                $(":radio[value*=Media Mail]")[0].value = $(":radio[value*=Media Mail]")[0].value.replace('Media Mail<sup>&reg;</sup>', 'Media Mail');
            }
        }
    }
    /*clearbuttontext();*/
    addShoppingCartFullfillerDetail();
    
    $('#SerialCodeText').keyup(function() {
      checkupgrade();
    });
});

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());
}
