jQuery(document).ready(function ()
{
		
		//jQuery("<img>").attr("src", "/checkout/img/loadingAnimation.gif");
		
		//alert(.attr('class'));
		//$("#checkoutform").parent().css({'background' : 'none'})
		//$("#checkoutForm").parent().css({'background' : 'none'})
		//$(".cart-block .table li:last").css({'border-bottom' : 'none'})
		//$(".shipping").parent().css({'position' : 'absolute', 'top' : '0', 'left' : '430px'})
		//$(".shipping").parent().children().css({'display' : 'block'})
		//$(".all-page").css({'background' : '#fff'})
		
		//jQuery("#click-to-redeem-link").click(function()
		//{
		//	jQuery("div#click-to-redeem").hide();
		//	jQuery("div#promo-entry").show();
		//});
		
		jQuery("a#redeem-link").click(function()
		{
			jQuery("#anything").attr("name", "promo");
			jQuery("#checkoutForm").submit();
			
			jQuery("#targetPlaceholder").each(function()
			{
				this.name = "_target3"
			});
			
		});
	
	
		//jQuery("a#change-promo-link").click(function()
		//{
		//	jQuery("div#promo-selected").hide();
		//	jQuery("div#click-to-redeem").hide();
		//	jQuery("div#promo-entry").show();
		//	
		//});

		/*
		jQuery("input").each(function()
		{
			
			if (this.checked)
			{
				if (this.id == 'no')
				{
					jQuery(".btn-plan2-displ").text("You've selected to register for Peek service later. Click here to register your Peek now!");
					jQuery("div.promo-form p").css("font-size", "105%");
					
				}
				else if (this.id.indexOf("default") >= 0)
				{
					jQuery(".btn-plan2-displ").text("We'll set you up for standard Peek service at $" + this.alt + "/month. Click here for more options!");
					jQuery("div.promo-form p").css("font-size", "95%");
				}
				else
				{
					jQuery(".btn-plan2-displ").text(this.alt);
					jQuery("div.promo-form p").css("font-size", "120%");
					
				}
			}
	
		});
		
		$('.shipping-form .col2 .billing-btn :checkbox').click(function()
		{
			$('.shipping-form .col2 .plan1').toggle();
		});

		*/
	});
	

/**
*   Checks for alphanumeric key codes based on ASCII values.
*       48 to 57 (ASCII) = 0 to 9
*       45 to 90 (ASCII) = A to Z
*       97 to 122 (ASCII) = a to z
*       8 (ASCII) = backspace
*       37 (ASCII) = left arrow
*       39 (ASCII) = right arrow
*       13 (ASCII) = enter
*
*       Delete Key
*       - The ASCII table specifies DEL as 127
*       - Firefox & Netscape map DEL to 46, same as . (dot), which means you cannot block . without blocking DEL as well
*       - IE doesn't consider DEL as a key event
*
*   @params:
*       event - key press event
**/
function isNumeric(event) {
    var allowed = false;



    var keyCode = (event.keyCode ? event.keyCode :
                    (event.charCode ? event.charCode :
                        (event.which ? event.which : 0)));

   //9 is tab in Firefox
    //46 is Delete in Firefox
    


    if ( ((keyCode >=48) && (keyCode <= 57)) ||
      (keyCode == 8) || (keyCode == 9))
    {
        allowed = true;
    }

	if (! allowed)
	{
		//alert("This field allows only numeric values.");
	}

    return allowed;
}

function updateQty()
{
	document.getElementById("anything").name = "update";
	document.cart.submit();
}

function deleteCartItem(qtyField)
{
	document.getElementById("anything").name = "update";
	document.getElementById(qtyField).value = 0;
	document.cart.submit();
}

function checkout()
{
	document.getElementById("anything").name = "checkout";
	document.cart.submit();
}


function paymentPageNext()
{
	jQuery("#targetPlaceholder").each(function()
	{
		this.name = "_target3"
	});
	jQuery("#checkoutForm").submit();
}

function paymentPagePrevious()
{
	jQuery("#targetPlaceholder").each(function()
	{
		this.name = "_target0"
	});
	
	jQuery("#checkoutForm").submit();
}


function submitOrder()
{
	/* Must have higher z-index then the blockUi (>1001) */
	/*
	<div style="background:url(/checkout/img/loadingAnimation.gif) no-repeat 0 0;height: 15px;margin-left: 100px;margin-top:10px;margin-bottom: 10px"></div>
    <div>Processing order...</div>
	*/
	var h3 = document.createElement("h3");
	var txt = document.createElement("div");
	$(txt).text("Processing order...");

	$('<img />')
		.attr('src','/checkout/img/loadingAnimation.gif')
		.attr('style','z-index:1002;height: 15px;margin-top:10px;margin-bottom: 10px')
		.load(function(){
			$(h3).append($(this));
			$(h3).append($(txt));
		
	});
	
	jQuery.blockUI({message:$(h3)})
	setTimeout('jQuery("#checkoutForm").submit()',1000);
}





//rechanging radios
/*
function rechangeRadios(who) {
	
	if(!radios[who].checked) {
		for(var q = 0; q < radios.length; q++) {
			if(radios[q].name == radios[who].name)	{
				radios[q].checked = false;
				radios[q].parentNode.className = radios[q].parentNode.className.replace('selected','');
			} 
		
			if (radios[who].parentNode.className.indexOf('selected') == -1)
				radios[who].parentNode.className += ' selected';
			
			radios[who].checked = true; 
			checkRadios(who);
			
			
		}
	}
	
	selectPlan(radios[who]);
}
*/
	
	
	
function selectPlan(who)
{
	if (who.id == "no")
	{
		jQuery(".btn-plan2-displ").text("You've selected to register for Peek service later. Click here to register your Peek now!");
		jQuery("div.promo-form p").css("font-size", "105%");
	}
	else if (who.id.indexOf("default") >= 0)
	{
		var msg = "We'll set you up for standard Peek service at $" + who.alt + " month. Click here for more options!";
		
		jQuery(".btn-plan2-displ").text(msg);
		jQuery("div.promo-form p").css("font-size", "95%");
		
		jQuery("#recurring").each(function()
		{
			this.value = true;
		});
	}
	else
	{
		jQuery(".btn-plan2-displ").text(who.alt);
		
		jQuery("div.promo-form p").css("font-size", "95%");
		
		jQuery("#recurring").each(function()
		{
			this.value = false;
		});
	}
	
	$('.cart-holder2 .plan2').css('display','none');
	$('.cart-holder2 .service-holder').css('display','block');
	
}