/**
 * @author jleineweber
 */

function OpenEmail(url) {
	emailWind=window.open("/home/email.asp?URLemail="+escape(window.location)+"&Title="+escape(document.title),"Email","status=no,toolbar=no,resizable=yes,location=no,width=350,height=350");
	emailWind.focus();
}


// --- START ROTATING BANNER CODE ---

var siteFeatures = null;
var featureIndex = 0;
var isFocused = 0;
var featureProductDelay = 8000;	

//$(document).ready(function() {
//aigLoadObjects.push(function() {
$(document).ready(function() {
    siteFeatures = $("div.featuredProdList div.prod").hide().size();
    $("div.featuredProdList div.prod:eq(" + featureIndex + ")").show();
    $("div.featuredProdList").hover(function() {
    	isFocused = 1;
    }, function() {
    	isFocused = 0;
    });
    setInterval(updateFeatureProduct, featureProductDelay);
	
});

function updateFeatureProduct() {
	// alert(featureIndex);
	if (isFocused) return;
    $("div.featuredProdList div.prod:eq(" + featureIndex + ")").fadeOut('slow', function() {
    	$(this).hide();
    	featureIndex = (featureIndex + 1) % siteFeatures;
    	$("div.featuredProdList div.prod:eq(" + featureIndex + ")").show().fadeIn('slow');
    });
}

// --- START SHOW DISCLAIMER CODE ---

//aigLoadObjects.push(function() {
$(document).ready(function() {
	$('#disclaimer').hide();
    $('#disclaimerLink').click( function() {
		$('#disclaimer').toggle('normal');
	});
});

// --- END SHOW DISCLAIMER CODE ---

// --- START COUPON ENTRY CODE ---

function toUppercaseNoSpace(formField) {
  formField.value = formField.value.toUpperCase().replace(/([^0-9.\-A-Z])/g,"");
}

var lastFieldValue = null;
var cachedCouponButton = null;
function toUppercaseNoSpaceAndLabelChange(formField) {
  if (formField.value == 'Limit 1 coupon per order') formField.value = '';
  if (formField.value == lastFieldValue) return;
  if (cachedCouponButton == null) cachedCouponButton = $(".applyCoupon");
  
  lastFieldValue = formField.value;
  formField.value = formField.value.toUpperCase().replace(/([^0-9.\-A-Z])/g,"");
  
  if (formField.value == "") {
	cachedCouponButton.val("Clear Coupon");	
  } else {
	cachedCouponButton.val("Apply Coupon");
  }
}

function selectText(formField){
	formField.focus();
	formField.select();
}


function toNumeric(formField) {
  formField.value = formField.value.toUpperCase().replace(/([^0-9])/g,"").substring(0,16);
}

function disallowAngleBrackets(formField) {
  formField.value = formField.value.replace(/[<>]/g,"");
}

// --- END COUPON ENTRY CODE ---


// --- DANIEL'S GET HELP BOX ---

$(document).ready(function() {
   $(".help").click(function() {
     $("#helpBox").toggle('slow');
   });
});
