function fnSelectTshirtSize()
{
	var strSelectedSize = jQuery('#slSize').val();
	objElement = jQuery('input[name=CouponCode]');
	objElement.val(strSelectedSize);
	jQuery('#divWinner').hide('slow');
	objElement.focus();
	//jQuery(objElement).parent("form").submit();
	document.forms['OnePageCheckoutForm'].submit();
}
var flgFound = false;
var totalPrice = 0.0;
var couponAdded = false;
function fnChangeState()
{
	jQuery("#BillingState_dropdown").change(function() {
		fnCheckAndShowCouponWindow();
	});
}
function fnCheckAndShowCouponWindow()
{
	jQuery('#span_Shopping_Cart_UnEditable td').each(function(i, objEle){
		if(objEle.innerHTML.match(/Free T-Shirt/i))
		{
			couponAdded = true;
			return;
		}
	});
	jQuery('b').each(function(i, objEle){
		if(!(totalPrice > 0))
		{
			if(flgFound)
			{
				totalPrice = jQuery.trim(objEle.innerHTML);;
				totalPrice = parseFloat(totalPrice.replace(/[\$,]/g,""));
				if(totalPrice > 0)
				{
					return;
				}
			}
			if(objEle.innerHTML.match(/Total.*:/i))
			{
				flgFound = true;
			}
		}
	});
	if(!couponAdded)
	{
	  var strLocation = ""+window.location+"";
	  if(strLocation.match(/one-page-checkout/i))
	  {
		  
		  if(totalPrice >= 1000)
		  {
			//show winner window for United States users only
			if("United States" == jQuery("#BillingCountry").val())
			{
				jQuery('#divWinner').show('slow');
				jQuery("#divWinner").load("/v/vspfiles/templates/alternatives/winner_window.html");
				window.location = "#";
			}
		  }
	  }
	}
}
jQuery(document).ready(function(){
	jQuery("#BillingCountry").change(function() {
			fnChangeState();
			fnCheckAndShowCouponWindow();
		});
	fnChangeState();
});
