
function swap(imgName) 
{ if (document.images) { var test = document.images[imgName].src; if (test.indexOf("off")!=-1) { document.images[imgName].src = "/images/nav/"+imgName+"-on.gif"; } else { document.images[imgName].src = "/images/nav/"+imgName+"-off.gif"; } } } 

function swap2(imgName) 
{ if (document.images) { var test = document.images[imgName].src; if (test.indexOf("off")!=-1) { document.images[imgName].src = "/images/"+imgName+"-on.gif"; } else { document.images[imgName].src = "/images/"+imgName+"-off.gif"; } } } 

function cookietest(form) {
	var cookieEnabled=(navigator.cookieEnabled)? true : false;
	if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){
		document.cookie="testcookie";
		cookieEnabled=(document.cookie.indexOf("testcookie")!=-1)? true : false;
	}
	if (!cookieEnabled) {
        	alert ("Your cookies are set to the off position. Click the OK button for instructions on how to turn your cookies settings 'on' so that you may shop at BettyMills.");
	        window.location ='http://www.bettymills.com/shop/page/cookies.html';
        	return false;
	}
	else {
	        return validate(form)
	}
}

function validate_zipcode(form){
	var num = form.zip.value;
	if(num.length == 0){
	alert("Zipcode is not set");
	return false;
	}
	if(num == 0){
	alert("Zipcode cannot be zero");
	return false;
	}
	var validchars = "0123456789";
	for (var i=0; i < num.length; i++) {
		var letter = num.charAt(i).toLowerCase();
		if (validchars.indexOf(letter) == -1) {
			alert("Invalid value for Zipcode");
			return false;
		}
	}
}

function add_when_zipcode(form){
	if(document.form1.zip.value){
		alert("Submit Your Zipcode to Add Product!");
		return false;
	}
	else{
		alert("Submit Your Zipcode to Add Product!");
		return false;
	}
}

function validate(form){
	var num = form.count.value;
	if(num.length == 0){
		alert("Quantity is not set");
		return false;
	}
	if(num == 0){
		alert("Quantity cannot be zero");
		return false;
	}
	var validchars = "0123456789";
	for (var i=0; i < num.length; i++) {
		var letter = num.charAt(i).toLowerCase();
		if (validchars.indexOf(letter) == -1) {
			alert("Invalid value for Quantity");
			return false;
		}
	}
	return true;
}

