function GetXmlHttpObject() {
	
	var xmlHttp=null;
	
	try {
		
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		
	}
	
	catch (e) {
	//Internet Explorer
	
		try {
	
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		
		catch (e) {
			
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	return xmlHttp;

}

function colorRoll(a) {
	document.getElementById('color_name').innerHTML = a;
}
function colorRollOut() {
	document.getElementById('color_name').innerHTML = "&nbsp;";
}

function selectColor(a,b,c) {
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url="ajax/product_select_quantity.php"
	url=url+"?check="+b
	url=url+"&upc="+c
	url=url+"&sid="+Math.random()
	
	document.getElementById("color_select").value = a 
	
	document.getElementById("add_to_cart_div").innerHTML="&nbsp;"
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		
			document.getElementById("select_quantity").innerHTML=xmlHttp.responseText
			document.getElementById("select_quantity").style.display="block"
				var mytext = document.getElementById("quantity");
				mytext.focus(); 
				mytext.select()
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function selectColorFromDrop() {
	
	if (document.getElementById('color_select').value != 0) {
	
		xmlHttp=GetXmlHttpObject()
		
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		}
		
		var upc_info = document.getElementById('color_select').value
		var upc_array = upc_info.split("_")
		
		var upc_code = upc_array[0]
		var check = upc_array[2]
		
		var url="ajax/product_select_quantity.php"
		url=url+"?check="+check
		url=url+"&upc="+upc_code
		url=url+"&sid="+Math.random()
	
		document.getElementById("add_to_cart_div").innerHTML="&nbsp;"
		
		xmlHttp.onreadystatechange=function() {
	
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			
				document.getElementById("select_quantity").innerHTML=xmlHttp.responseText 
				document.getElementById("select_quantity").style.display="block"
				var mytext = document.getElementById("quantity");
				mytext.focus(); 
				mytext.select()
			
			}
		
		}
			
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	
	} else {
		
		//document.getElementById("add_to_cart_btn").disabled = true
	//	document.getElementById("quantity").disabled = true
		
		document.getElementById("select_quantity").style.display="none"
		
	}
	
}

function selectLevel(a,b,c,d) {

	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url="ajax/product_select_size.php"
	url=url+"?level_id="+a
	url=url+"&product_id="+b
	url=url+"&check_stock="+d
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		
			document.getElementById("select_size").innerHTML=xmlHttp.responseText 
			selectSize(b,a,c,d)
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function initialSize(a,b,c,d) {
	
	

	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url="ajax/product_select_size.php"
	url=url+"?level_id="+a
	url=url+"&product_id="+b
	url=url+"&check_stock="+c
	url=url+"&sid="+Math.random()
	
	document.getElementById("add_to_cart_div").innerHTML="&nbsp;"
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	
			document.getElementById("select_size").innerHTML=xmlHttp.responseText 
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function selectSize(a,b,c,d) {
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	document.getElementById('size_select_box').value = c
	
	//if (c == 0) {
		
		//document.getElementById("quantity").disabled = true
		//document.getElementById("add_to_cart_btn").disabled = true
		
	//}
	
	document.getElementById("select_quantity").style.display="none"
	
	var url="ajax/product_select_color.php"
	url=url+"?size_id="+c
	url=url+"&product_id="+a
	url=url+"&level_id="+b
	url=url+"&check_stock="+d
	url=url+"&sid="+Math.random()
	
	document.getElementById("add_to_cart_div").innerHTML="&nbsp;"
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	
			document.getElementById("select_color").innerHTML=xmlHttp.responseText 
			
			
			
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function showMenu(a) {

	document.getElementById(a+"_sub").style.display = 'block';
	//document.getElementById("cart").style.display = 'none';
	
}
function hideMenu(a) {
	document.getElementById(a+"_sub").style.display = 'none';
	//document.getElementById("cart").style.display = 'block';
}
function selectBrandFromCat(a,b,c,d,e) {
	this.location.href = "category.php?bid="+a+"&stid="+b+"&did="+c+"&lid="+d+"&sid="+e
}
function selectSizeFromCat(a,b,c,d,e,f) {
	this.location.href = "category_"+f+"-"+a+"-"+b+"-"+d+"-"+c+"-"+e+"-0.html"
	//this.location.href = "category.php?bid="+a+"&stid="+b+"&did="+c+"&lid="+d+"&sid="+e
}

function clearSearchBox() {
	if (document.getElementById("search_box").value == " Search Dungarees.net") {
		document.getElementById("search_box").value = "";
		document.getElementById("search_box").style.color = "#333"
	}	
}
function popSearchBox() {
	if (document.getElementById("search_box").value == "") {
		document.getElementById("search_box").style.color = "#666"
		document.getElementById("search_box").value = " Search Dungarees.net";
	}
}

function clearSearchBox2() {
	if (document.getElementById("search_box2").value == " Search Dungarees.net") {
		document.getElementById("search_box2").value = "";
		document.getElementById("search_box2").style.color = "#333"
	}	
}
function popSearchBox2() {
	if (document.getElementById("search_box2").value == "") {
		document.getElementById("search_box2").style.color = "#666"
		document.getElementById("search_box2").value = " Search Dungarees.net";
	}
}
function clearEmailBox() {
	if (document.getElementById("email_list_address").value == " Your Email") {
		document.getElementById("email_list_address").value = "";
		document.getElementById("email_list_address").style.color = "#333"
	}	
}
function popEmailBox() {
	if (document.getElementById("email_list_address").value == "") {
		document.getElementById("email_list_address").style.color = "#666"
		document.getElementById("email_list_address").value = " Your Email";
	}
}
function sizeSearch(a) {
	
	if (a != 0) {
	
		document.forms['size_form'].submit();
	
	}
	
}

function sizeSearchFromPage(a) {
	
	if (a != 0) {
	
		document.forms['size_form_from_page'].submit();
	
	}
	
}


function largerImage(a) {

	//mywindow = window.open (a,"mywindow","location=0,status=0,scrollbars=0,width=500,height=500");
	 mywindow = window.open(a,
'FirstWin','location=0,status=0,scrollbars=0,width=520,height=520')
   
} 
function showColorName(a) {
	document.getElementById("color_name").innerHTML = a
}
function hideColorName() {
	document.getElementById("color_name").innerHTML = "&nbsp;"
}

//CART FUNCTIONS//

function addToCart(a) {
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var upc_info = document.getElementById('color_select').value
	var upc_array = upc_info.split("_")
	
	
	var upc_code = upc_array[0]
	var upc_id = upc_array[1]
	var quantity = document.getElementById('quantity').value
	
	if (quantity > a) {
		var answer = confirm ("We only have "+a+" available.  Would you still like to add "+a+" to your cart?");	
		if (answer){
			quantity = a;
		}
		else{
			document.getElementById('quantity').value = 1
			return false
		}
	}
	
	var url="ajax/add_to_cart.php"
	url=url+"?upc_id="+upc_id
	url=url+"&upc_code="+upc_code
	url=url+"&quantity="+quantity
	url=url+"&qx="+Math.random()
	
	document.getElementById("select_quantity").style.display="none"
	
	document.getElementById("add_to_cart_div").innerHTML="<br>Adding to Cart..."
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	
			document.getElementById("add_to_cart_div").innerHTML=xmlHttp.responseText 
			document.getElementById("color_select").value=0
			updateCart(upc_id, upc_code, quantity);
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function updateCart(a,b,c) {
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url="ajax/cart.php"
	url=url+"?upc_id="+a
	url=url+"&upc_code="+b
	url=url+"&quantity="+c
	url=url+"&qx="+Math.random()
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	
			document.getElementById("cart").innerHTML=xmlHttp.responseText 
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function cartShowBilling() {
	
	if (document.getElementById("billing_info").style.display == 'block') {
		
		document.getElementById("billing_info").style.display = 'none';
		
	} else {
		
		document.getElementById("billing_info").style.display = 'block';
		
	}
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	if (document.getElementById("international_ship").checked==true) {
		
		var usa = 0;
		document.getElementById("international_bill").checked=true
		
	} else {
		
		var usa = 1;
		document.getElementById("international_bill").checked=false
		
	}
	
	var url="ajax/cart_billing_info.php"
	url=url+"?usa="+usa
	url=url+"&qx="+Math.random()
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	
			document.getElementById("billing_info_div").innerHTML=xmlHttp.responseText 
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function validateShippingBilling() {
	
	var err = 0;
	
	form = document.shipping_billing_information
	
	if (form.ship_first_name.value == "") {		
		form.ship_first_name.style.backgroundColor  = '#99FF99'
		err=1	
	} else {	
		form.ship_first_name.style.backgroundColor  = '#FFFFFF'	
	}
	
	if (form.ship_last_name.value == "") {
		form.ship_last_name.style.backgroundColor  = '#99FF99'
		err=1		
	} else {
		form.ship_last_name.style.backgroundColor  = '#FFFFFF'
	}
	
	if (form.ship_address_1.value == "") {
		form.ship_address_1.style.backgroundColor  = '#99FF99'
		err=1		
	} else {
		form.ship_address_1.style.backgroundColor  = '#FFFFFF'
	}
	
	if (form.ship_city.value == "") {
		form.ship_city.style.backgroundColor  = '#99FF99'
		err=1		
	} else {
		form.ship_city.style.backgroundColor  = '#FFFFFF'
	}
	
	if (form.ship_state.value == 0) {
		form.ship_state.style.backgroundColor  = '#99FF99'
		err=1		
	} else {
		form.ship_state.style.backgroundColor  = '#FFFFFF'
	}
	
	if (form.ship_zip.value == "") {
		form.ship_zip.style.backgroundColor  = '#99FF99'
		err=1		
	} else {
		form.ship_zip.style.backgroundColor  = '#FFFFFF'
	}
	
	re = /\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.biz)|(\.coop)|(\..{2,2}))$)\b/gi;
	
	if(!form.email_address.value.match(re) || form.email_address.value == ""){
		form.email_address.style.backgroundColor  = '#99FF99'
		err=1		
	} else {
		form.email_address.style.backgroundColor  = '#FFFFFF'
	} 
	var phoneRE = /[0-9()+.-]$/; 
	var phone_number_1 = form.phone_number_1.value
	
	if (phone_number_1 == "" || !phone_number_1.match(phoneRE)) {
		form.phone_number_1.style.backgroundColor  = '#99FF99'
		err=1		
	} else {
		form.phone_number_1.style.backgroundColor  = '#FFFFFF'
	}
	
	var phone_number_2 = form.phone_number_2.value
	if (phone_number_2 != "" && !phone_number_2.match(phoneRE)) {
		form.phone_number_2.style.backgroundColor  = '#99FF99'
		err=1		
	} else {
		form.phone_number_2.style.backgroundColor  = '#FFFFFF'
	}
	
	var fax_number = form.fax_number.value
	if (fax_number != "" && !fax_number.match(phoneRE)) {
		form.fax_number.style.backgroundColor  = '#99FF99'
		err=1		
	} else {
		form.fax_number.style.backgroundColor  = '#FFFFFF'
	}
		
	if (document.getElementById("international_ship").checked==true) {
		
		if (form.ship_country.value == "") {
			form.ship_country.style.backgroundColor  = '#99FF99'
			err=1		
		} else {
			form.ship_country.style.backgroundColor  = '#FFFFFF'
		}
		
	}
	
	//////	
	
	if (document.getElementById("value_the_same").checked==false) {
	
		if (form.bill_first_name.value == "") {		
			form.bill_first_name.style.backgroundColor  = '#99FF99'
			err=1	
		} else {	
			form.bill_first_name.style.backgroundColor  = '#FFFFFF'	
		}
		
		if (form.bill_last_name.value == "") {
			form.bill_last_name.style.backgroundColor  = '#99FF99'
			err=1		
		} else {
			form.bill_last_name.style.backgroundColor  = '#FFFFFF'
		}
		
		if (form.bill_address_1.value == "") {
			form.bill_address_1.style.backgroundColor  = '#99FF99'
			err=1		
		} else {
			form.bill_address_1.style.backgroundColor  = '#FFFFFF'
		}
		
		if (form.bill_city.value == "") {
			form.bill_city.style.backgroundColor  = '#99FF99'
			err=1		
		} else {
			form.bill_city.style.backgroundColor  = '#FFFFFF'
		}
		
		if (form.bill_state.value == 0) {
			form.bill_state.style.backgroundColor  = '#99FF99'
			err=1		
		} else {
			form.bill_state.style.backgroundColor  = '#FFFFFF'
		}
		
		if (form.bill_zip.value == "") {
			form.bill_zip.style.backgroundColor  = '#99FF99'
			err=1		
		} else {
			form.bill_zip.style.backgroundColor  = '#FFFFFF'
		}
		
		if (document.getElementById("international_bill").checked==true) {
		
		
			if (form.bill_country.value == "") {
				form.bill_country.style.backgroundColor  = '#99FF99'
				err=1		
			} else {
				form.bill_country.style.backgroundColor  = '#FFFFFF'
			}
		
		}
	
	}
	
	if (err == 0) {
	
		document.forms["shipping_billing_information"].submit();
	
	} else {
		
		document.getElementById("error").style.display="block"
		document.getElementById("error").style.backgroundColor = "#99FF99"
		document.getElementById("error").style.padding = "3px"
		return false;
	
	}
		
}

function cartShowGiftMessage() {
	
	if (document.getElementById("gift_message_div").style.display == 'block') {
		
		document.getElementById("gift_message_div").style.display = 'none';
		
	} else {
		
		document.getElementById("gift_message_div").style.display = 'block';
		
	}
	
}

function isValidCreditCard(type, ccnum) {
	
   if (type == "Visa") {
      // Visa: length 16, prefix 4, dashes optional.
      var re = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "Mastercard") {
      // Mastercard: length 16, prefix 51-55, dashes optional.
      var re = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "Discover") {
      // Discover: length 16, prefix 6011, dashes optional.
      var re = /^6011-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "American Express") {
      // American Express: length 15, prefix 34 or 37.
      var re = /^3[4,7]\d{13}$/;
   }
   
   if (!re.test(ccnum)) return false;
   // Remove all dashes for the checksum checks to eliminate negative numbers
   ccnum = ccnum.split("-").join("");
   ccnum = ccnum.split(' ').join('');
   
   // Checksum ("Mod 10")
   // Add even digits in even length strings or odd digits in odd length strings.
   var checksum = 0;
   for (var i=(2-(ccnum.length % 2)); i<=ccnum.length; i+=2) {
      checksum += parseInt(ccnum.charAt(i-1));
   }
   // Analyze odd digits in even length strings or even digits in odd length strings.
   for (var i=(ccnum.length % 2) + 1; i<ccnum.length; i+=2) {
      var digit = parseInt(ccnum.charAt(i-1)) * 2;
      if (digit < 10) { checksum += digit; } else { checksum += (digit-9); }
   }
   if ((checksum % 10) == 0) return true; else return false;
   
}

function cartDisplayPassword() {
	
	if (document.getElementById("password_info").style.display == 'block') {
		
		document.getElementById("password_info").style.display = 'none';
		
	} else {
		
		document.getElementById("password_info").style.display = 'block';
		
	}
	
}

function cartExistingCustomer() {
	
	if (document.getElementById("existing_customer_div").style.display == 'block') {
		
		document.getElementById("existing_customer_div").style.display = 'none';
		
	} else {
		
		document.getElementById("existing_customer_div").style.display = 'block';
		
	}
	
}

function cartSwitchShipInternational() {
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	if (document.getElementById("international_ship").checked==true) {
		
		var usa = 0;
		
	} else {
		
		var usa = 1;
		
	}
	
	var url="ajax/cart_shipping_info.php"
	url=url+"?usa="+usa
	url=url+"&qx="+Math.random()
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	
			document.getElementById("shipping_info_div").innerHTML=xmlHttp.responseText 
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function cartSwitchBillInternational() {
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	if (document.getElementById("international_bill").checked==true) {
		
		var usa = 0;
		
	} else {
		
		var usa = 1;
		
	}
	
	var url="ajax/cart_billing_info.php"
	url=url+"?usa="+usa
	url=url+"&qx="+Math.random()
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	
			document.getElementById("billing_info_div").innerHTML=xmlHttp.responseText 
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function topSellersRecommend(a,b,c) {
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url="ajax/rec_box.php"
	url=url+"?stid="+a
	url=url+"&display="+b
	url=url+"&pid="+c
	url=url+"&qx="+Math.random()
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	
			document.getElementById("rec_holder").innerHTML=xmlHttp.responseText 
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
	
}

function sortCat(a,b,c,d,e,f,g) {
	
	window.location = "category_"+g+"-"+a+"-"+b+"-"+d+"-"+c+"-"+e+"-"+f+".html";
	
}

function validateCreateAccount() {
	
	var err = 0;
	var err2 = 0;
	
	form = document.create_account
	
	if (form.first_name.value == "") {		
		form.first_name.style.backgroundColor  = '#99FF99'
		err=1	
	} else {	
		form.first_name.style.backgroundColor  = '#FFFFFF'	
	}
	
	if (form.last_name.value == "") {		
		form.last_name.style.backgroundColor  = '#99FF99'
		err=1	
	} else {	
		form.last_name.style.backgroundColor  = '#FFFFFF'	
	}
	
	re = /\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.biz)|(\.coop)|(\..{2,2}))$)\b/gi;
	
	if(!form.email_address.value.match(re) || form.email_address.value == ""){
		form.email_address.style.backgroundColor  = '#99FF99'
		err=1		
	} else {
		form.email_address.style.backgroundColor  = '#FFFFFF'
	} 
	
	var pass_re = /[a-zA-Z0-9]$/;
	var pass = form.account_pass_verify.value
	
	if (form.account_pass.value == "" || form.account_pass_verify.value == "" || (form.account_pass.value != form.account_pass_verify.value) || !pass.match(pass_re) || pass.length < 6 || pass.length > 12) {	
		form.account_pass.style.backgroundColor  = '#99FF99'
		form.account_pass_verify.style.backgroundColor  = '#99FF99'
		err2=1	
	} else {
		form.account_pass.style.backgroundColor  = '#FFFFFF'
		form.account_pass_verify.style.backgroundColor  = '#FFFFFF'
	}
	
	if (err == 1) {
		
		document.getElementById("error").style.display="block"
		document.getElementById("error").style.backgroundColor = "#99FF99"
		document.getElementById("error").style.padding = "3px"
	
	} else {
		
		document.getElementById("error").style.display="none"
		
	}
	
	if (err2 == 1) {
		
		document.getElementById("error2").style.display="block"
		document.getElementById("error2").style.backgroundColor = "#99FF99"
		document.getElementById("error2").style.padding = "3px"
	
	} else {
		
		document.getElementById("error2").style.display="none"
		
	}
	
	if (err == 0 && err2 == 0) {
	
		document.forms["create_account"].submit();
	
	} else {
	
		return false;
		
	}
	
}

function emailListSignUp() {
	
	var err=0
	
	form = document.side_email_list
	
	re = /\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.biz)|(\.coop)|(\..{2,2}))$)\b/gi;
	
	if(!form.email_list_address.value.match(re) || form.email_list_address.value == ""){
		err=1		
	}
	
	if (err == 0) {
		
		document.forms["side_email_list"].submit();
	
	} else {
		
		document.getElementById("email_list_error").style.display="block"
		document.getElementById("email_list_error").style.backgroundColor = "#99FF99"
		document.getElementById("email_list_error").style.padding = "3px"
		return false;
	
	}
	
}

function validateLogin() {
	
	var err=0
	
	form = document.login_information
	
	re = /\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.biz)|(\.coop)|(\..{2,2}))$)\b/gi;
	
	if(!form.sign_in_email.value.match(re) || form.sign_in_email.value == ""){
		err=1		
	}
	
	if(form.sign_in_pass.value == "" || form.sign_in_pass.length < 6){
		err=1		
	}
	
	if (err == 0) {
	
		document.forms["login_information"].submit();
	
	} else {
		
		document.getElementById("login_error").style.display="block"
		document.getElementById("login_error").style.backgroundColor = "#99FF99"
		document.getElementById("login_error").style.padding = "3px"
		return false;
	
	}
	
}

function validateCartLogin() {
	
	var err=0
	
	form = document.cart_sign_in
	
	re = /\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.biz)|(\.coop)|(\..{2,2}))$)\b/gi;
	
	if(!form.sign_in_email.value.match(re) || form.sign_in_email.value == ""){
		err=1		
	}
	
	if(form.sign_in_pass.value == "" || form.sign_in_pass.length < 6){
		err=1		
	}
	
	if (err == 0) {
	
		document.forms["cart_sign_in"].submit();
	
	} else {
		
		document.getElementById("cart_login_error").style.display="block"
		document.getElementById("cart_login_error").style.backgroundColor = "#99FF99"
		document.getElementById("cart_login_error").style.padding = "3px"
		return false;
	
	}
	
}

function validateOrderTrack() {
	
	var err=0
	
	form = document.track_order
	
	re = /\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.biz)|(\.coop)|(\..{2,2}))$)\b/gi;
	
	if(!form.email_address.value.match(re) || form.email_address.value == ""){
		err=1		
	}
	
	if(form.order_number.value == "") {
		err=1		
	}
	
	if (err == 0) {
	
		document.forms["track_order"].submit();
	
	} else {
		
		document.getElementById("track_error").style.display="block"
		document.getElementById("track_error").style.backgroundColor = "#99FF99"
		document.getElementById("track_error").style.padding = "3px"
		return false;
	
	}
	
}

function footwearFunction(a,b,c,d,e,f,g,h) {
	
	window.location = "footwear_"+e+"_"+h+"_"+f+"-"+a+"-"+b+"-"+c+"-"+d+"-"+g+".html";
	
}

function dealsFunction(a,b,c,d,e) {
	
	window.location = "deals_"+a+"-"+b+"-"+c+"-"+d+"-"+e+".html";
	
}

function dealsDept(a,b,c,d,e) {
	
	window.location = "deals_"+a+"-"+b+"-"+c+"-"+d+"-"+e+".html";
	
}

function dealsSort(a,b,d,e,f,g,h) {
	
	if (b != 0) {
		
		var myarray = b.split("_")
		
		b = myarray[0]
		c = myarray[1]
	
		window.location = "deals_"+f+"_"+g+"_"+h+"-"+a+"-"+b+"-"+c+"-"+d+"-"+e+".html";
	
	}
	
}

function productMoreColorsSizes(a,b) {
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url="ajax/more_colors_sizes.php"
	url=url+"?pid="+a
	url=url+"&lid="+b
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		
			if (document.getElementById("more_colors_sizes").style.display=="block") {
			
				document.getElementById("more_colors_sizes").style.display="none"
				document.getElementById("more_colors_sizes").style.margin="auto"
				document.getElementById("more_colors_sizes").innerHTML="" 
				
			} else {
			
				document.getElementById("more_colors_sizes").style.display="block"
				document.getElementById("more_colors_sizes").style.margin="5px 0 0 0"
				document.getElementById("more_colors_sizes").innerHTML=xmlHttp.responseText 
			
			}
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function showPasswordReminder() {
	
	document.getElementById("password_reminder").style.display = "block"
	
}

function validatePasswordReminderEmail() {
	
	var err = 0;
	
	form = document.reminder
	
	re = /\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.biz)|(\.coop)|(\..{2,2}))$)\b/gi;
	
	if(!form.email_address.value.match(re) || form.email_address.value == ""){
		
		form.email_address.style.backgroundColor  = '#99FF99'
		err=1	
	}
	
	if (err == 0) {
	
		document.forms["reminder"].submit();
	
	} else {
		
		document.getElementById("remind_error").style.display="block"
		document.getElementById("remind_error").style.backgroundColor = "#99FF99"
		document.getElementById("remind_error").style.padding = "3px"
		document.getElementById("remind_error").style.margin = "0 0 5px 0"
		return false;
	
	}
	
}

function openCCV() {
	strURL="images/ccv.jpg"
	rs = window.open(strURL,"Pin","height=270,width=235, resizable=no, scrollbars=no")
}

function createSearch() {
	
	function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}
	
	var searchfield = document.getElementById("search_box").value
	
	searchfield = trim(searchfield)
	
	if (searchfield != '' && searchfield != "Search Dungarees.net") {
		
		document.search_form.submit();
		
	} else {
	
		return false
	
	}
	
}

function createSearchFromPage() {
	
	function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}
	
	var searchfield = document.getElementById("search_box2").value
	
	searchfield = trim(searchfield)
	
	if (searchfield != '' && searchfield != "Search Dungarees.net") {
		
		document.search_form2.submit();
		
	} else {
	
		return false
	
	}
	
}

function payByCheck() {
	
	if (document.getElementById("pay_by_check").checked==true) {
		
		document.getElementById("cc_info").style.display="none"
		document.getElementById("check_info").style.display="block"
		
	} else {
		
		document.getElementById("cc_info").style.display="block"
		document.getElementById("check_info").style.display="none"
		
	}
	
}


function rushProcessingInfo(a) {

	 mywindow = window.open("http://dungarees.net/rush_processing_info.html",
'FirstWin','location=0,status=0,scrollbars=1,width=500,height=350')
   
}

function cartStockingStuffers() {
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url="ajax/cart_stocking_stuffers.php"
	url=url+"?did=did"
	url=url+"&qx="+Math.random()
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	
			document.getElementById("stocking_stuffers").innerHTML=xmlHttp.responseText 
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
	
}

function cartAuthorizeOrder() {
	
	document.getElementById("submit_message").innerHTML = "Your order is being submitted...."
	document.getElementById("submit_button").style.display = "none"
	
	var err = 0;
	var err3 = 0;
	
	form = document.cart_review
	
	if (document.getElementById("pay_by_check").checked==false) {
	
		if (form.bill_cc_type.value == 0) {	
			form.bill_cc_type.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
			form.bill_cc_type.style.backgroundColor  = '#FFFFFF'
		}
			
		if (form.bill_cc_num.value == "") {	
			form.bill_cc_num.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
	
			ccnum = form.bill_cc_num.value;
			ccnum = ccnum.split("-").join("");
    		ccnum = ccnum.split(' ').join('');
			
			if (!isValidCreditCard(form.bill_cc_type.value, ccnum)) {
				
				form.bill_cc_num.style.backgroundColor  = '#99FF99'
				err3=1	
				
			} else {
				
				form.bill_cc_num.style.backgroundColor  = '#FFFFFF'
				
			}
		}
		
		if (form.bill_cc_exp_month.value == 0) {	
			form.bill_cc_exp_month.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
			form.bill_cc_exp_month.style.backgroundColor  = '#FFFFFF'
		}
		
		if (form.bill_cc_exp_year.value == 0) {	
			form.bill_cc_exp_year.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
			form.bill_cc_exp_year.style.backgroundColor  = '#FFFFFF'
		}
			
		if (form.bill_cc_ccv.value == "") {	
			form.bill_cc_ccv.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
			form.bill_cc_ccv.style.backgroundColor  = '#FFFFFF'
		}
	
	}
	
	var err2=0
	
	if (document.getElementById("create_account").value != 0) {
	
		if (document.getElementById("create_account").checked==true) {
				
			if (form.account_password.value == "" || form.account_password_verify.value == "" || (form.account_password.value != form.account_password_verify.value)) {	
				form.account_password.style.backgroundColor  = '#99FF99'
				form.account_password_verify.style.backgroundColor  = '#99FF99'
				err2=1	
			} else {
				form.account_password.style.backgroundColor  = '#FFFFFF'
				form.account_password_verify.style.backgroundColor  = '#FFFFFF'
			}
			
		}
	
	}
	
	if (err==1) {
		
		document.getElementById("error_invalid_decline").style.display="none"
		
		document.getElementById("error").style.display="block"
		document.getElementById("error").style.backgroundColor = "#99FF99"
		document.getElementById("error").style.padding = "3px"
		document.getElementById("error").style.margin = "10px 0 0 0"
		
		document.getElementById("error_bottom").style.display="block"
		document.getElementById("error_bottom").style.backgroundColor = "#99FF99"
		document.getElementById("error_bottom").style.padding = "3px"
		document.getElementById("error_bottom").style.margin = "10px 0 0 0"
	
	} else {
		
		document.getElementById("error").style.display="none"
		
	}
	
	if (document.getElementById("create_account").value != 0) {
	
		if (err2==1) {
			
			document.getElementById("error_invalid_decline").style.display="none"
			
			document.getElementById("error_pass").style.display="block"
			document.getElementById("error_pass").style.backgroundColor = "#99FF99"
			document.getElementById("error_pass").style.padding = "3px"
			document.getElementById("error_pass").style.margin = "10px 0 10px 0"
		
			document.getElementById("error_bottom").style.display="block"
			document.getElementById("error_bottom").style.backgroundColor = "#99FF99"
			document.getElementById("error_bottom").style.padding = "3px"
			document.getElementById("error_bottom").style.margin = "10px 0 0 0"
		
		} else {
			
			document.getElementById("error_pass").style.display="none"
			
		}
	
	}
	
	if (err3==1) {
		
		document.getElementById("error_invalid_decline").style.display="none"
		
		document.getElementById("error_invalid").style.display="block"
		document.getElementById("error_invalid").style.backgroundColor = "#99FF99"
		document.getElementById("error_invalid").style.padding = "3px"
		document.getElementById("error_invalid").style.margin = "10px 0 0 0"
		
		document.getElementById("error_bottom").style.display="block"
		document.getElementById("error_bottom").style.backgroundColor = "#99FF99"
		document.getElementById("error_bottom").style.padding = "3px"
		document.getElementById("error_bottom").style.margin = "10px 0 0 0"
		
	} else {
			
		document.getElementById("error_invalid").style.display="none"
			
	}
	
	if (err == 0 && err2 == 0 && err3 == 0) {
	
		if (document.getElementById("pay_by_check").checked==true) {
			document.forms["cart_review"].action = "scripts/cart/authorize_order_check.php"
		} else {
			document.forms["cart_review"].action = "scripts/cart/authorize_order.php"
		}
		document.forms["cart_review"].submit();
	
	} else {
		
		document.getElementById("submit_message").innerHTML = "(Please only click once)"
		document.getElementById("submit_button").style.display = "block"
		return false;
		
	}
	
}

function cartAuthorizeOrderBronto() {
	
	document.getElementById("submit_message").innerHTML = "Your order is being submitted...."
	document.getElementById("submit_button").style.display = "none"
	
	var err = 0;
	var err3 = 0;
	
	form = document.cart_review
	
	if (document.getElementById("pay_by_check").checked==false) {
	
		if (form.bill_cc_type.value == 0) {	
			form.bill_cc_type.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
			form.bill_cc_type.style.backgroundColor  = '#FFFFFF'
		}
			
		if (form.bill_cc_num.value == "") {	
			form.bill_cc_num.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
	
			ccnum = form.bill_cc_num.value;
			ccnum = ccnum.split("-").join("");
    		ccnum = ccnum.split(' ').join('');
			
			if (!isValidCreditCard(form.bill_cc_type.value, ccnum)) {
				
				form.bill_cc_num.style.backgroundColor  = '#99FF99'
				err3=1	
				
			} else {
				
				form.bill_cc_num.style.backgroundColor  = '#FFFFFF'
				
			}
		}
		
		if (form.bill_cc_exp_month.value == 0) {	
			form.bill_cc_exp_month.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
			form.bill_cc_exp_month.style.backgroundColor  = '#FFFFFF'
		}
		
		if (form.bill_cc_exp_year.value == 0) {	
			form.bill_cc_exp_year.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
			form.bill_cc_exp_year.style.backgroundColor  = '#FFFFFF'
		}
			
		if (form.bill_cc_ccv.value == "") {	
			form.bill_cc_ccv.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
			form.bill_cc_ccv.style.backgroundColor  = '#FFFFFF'
		}
	
	}
	
	var err2=0
	
	if (document.getElementById("create_account").value != 0) {
	
		if (document.getElementById("create_account").checked==true) {
				
			if (form.account_password.value == "" || form.account_password_verify.value == "" || (form.account_password.value != form.account_password_verify.value)) {	
				form.account_password.style.backgroundColor  = '#99FF99'
				form.account_password_verify.style.backgroundColor  = '#99FF99'
				err2=1	
			} else {
				form.account_password.style.backgroundColor  = '#FFFFFF'
				form.account_password_verify.style.backgroundColor  = '#FFFFFF'
			}
			
		}
	
	}
	
	if (err==1) {
		
		document.getElementById("error_invalid_decline").style.display="none"
		
		document.getElementById("error").style.display="block"
		document.getElementById("error").style.backgroundColor = "#99FF99"
		document.getElementById("error").style.padding = "3px"
		document.getElementById("error").style.margin = "10px 0 0 0"
		
		document.getElementById("error_bottom").style.display="block"
		document.getElementById("error_bottom").style.backgroundColor = "#99FF99"
		document.getElementById("error_bottom").style.padding = "3px"
		document.getElementById("error_bottom").style.margin = "10px 0 0 0"
	
	} else {
		
		document.getElementById("error").style.display="none"
		
	}
	
	if (document.getElementById("create_account").value != 0) {
	
		if (err2==1) {
			
			document.getElementById("error_invalid_decline").style.display="none"
			
			document.getElementById("error_pass").style.display="block"
			document.getElementById("error_pass").style.backgroundColor = "#99FF99"
			document.getElementById("error_pass").style.padding = "3px"
			document.getElementById("error_pass").style.margin = "10px 0 10px 0"
		
			document.getElementById("error_bottom").style.display="block"
			document.getElementById("error_bottom").style.backgroundColor = "#99FF99"
			document.getElementById("error_bottom").style.padding = "3px"
			document.getElementById("error_bottom").style.margin = "10px 0 0 0"
		
		} else {
			
			document.getElementById("error_pass").style.display="none"
			
		}
	
	}
	
	if (err3==1) {
		
		document.getElementById("error_invalid_decline").style.display="none"
		
		document.getElementById("error_invalid").style.display="block"
		document.getElementById("error_invalid").style.backgroundColor = "#99FF99"
		document.getElementById("error_invalid").style.padding = "3px"
		document.getElementById("error_invalid").style.margin = "10px 0 0 0"
		
		document.getElementById("error_bottom").style.display="block"
		document.getElementById("error_bottom").style.backgroundColor = "#99FF99"
		document.getElementById("error_bottom").style.padding = "3px"
		document.getElementById("error_bottom").style.margin = "10px 0 0 0"
		
	} else {
			
		document.getElementById("error_invalid").style.display="none"
			
	}
	
	if (err == 0 && err2 == 0 && err3 == 0) {
	
		if (document.getElementById("pay_by_check").checked==true) {
			document.forms["cart_review"].action = "scripts/cart/authorize_order_check.php"
		} else {
			document.forms["cart_review"].action = "scripts/cart/authorize_order_bronto.php"
		}
		document.forms["cart_review"].submit();
	
	} else {
		
		document.getElementById("submit_message").innerHTML = "(Please only click once)"
		document.getElementById("submit_button").style.display = "block"
		return false;
		
	}
	
}

function cartAuthorizeOrderPaypal() {
	/*NOT USING YET - 07-06-09*/
	document.getElementById("submit_message").innerHTML = "Your order is being submitted...."
	document.getElementById("submit_button").style.display = "none"
	
	var err = 0;
	var err3 = 0;
	
	form = document.cart_review
	
	if (document.getElementById("pay_by_check").checked==false) {
	
		if (form.bill_cc_type.value == 0) {	
			form.bill_cc_type.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
			form.bill_cc_type.style.backgroundColor  = '#FFFFFF'
		}
			
		if (form.bill_cc_num.value == "") {	
			form.bill_cc_num.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
	
			ccnum = form.bill_cc_num.value;
			ccnum = ccnum.split("-").join("");
    		ccnum = ccnum.split(' ').join('');
			
			if (!isValidCreditCard(form.bill_cc_type.value, ccnum)) {
				
				form.bill_cc_num.style.backgroundColor  = '#99FF99'
				err3=1	
				
			} else {
				
				form.bill_cc_num.style.backgroundColor  = '#FFFFFF'
				
			}
		}
		
		if (form.bill_cc_exp_month.value == 0) {	
			form.bill_cc_exp_month.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
			form.bill_cc_exp_month.style.backgroundColor  = '#FFFFFF'
		}
		
		if (form.bill_cc_exp_year.value == 0) {	
			form.bill_cc_exp_year.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
			form.bill_cc_exp_year.style.backgroundColor  = '#FFFFFF'
		}
			
		if (form.bill_cc_ccv.value == "") {	
			form.bill_cc_ccv.style.backgroundColor  = '#99FF99'
			err=1	
		} else {
			form.bill_cc_ccv.style.backgroundColor  = '#FFFFFF'
		}
	
	}
	
	var err2=0
	
	if (document.getElementById("create_account").value != 0) {
	
		if (document.getElementById("create_account").checked==true) {
				
			if (form.account_password.value == "" || form.account_password_verify.value == "" || (form.account_password.value != form.account_password_verify.value)) {	
				form.account_password.style.backgroundColor  = '#99FF99'
				form.account_password_verify.style.backgroundColor  = '#99FF99'
				err2=1	
			} else {
				form.account_password.style.backgroundColor  = '#FFFFFF'
				form.account_password_verify.style.backgroundColor  = '#FFFFFF'
			}
			
		}
	
	}
	
	if (err==1) {
		
		document.getElementById("error_invalid_decline").style.display="none"
		
		document.getElementById("error").style.display="block"
		document.getElementById("error").style.backgroundColor = "#99FF99"
		document.getElementById("error").style.padding = "3px"
		document.getElementById("error").style.margin = "10px 0 0 0"
		
		document.getElementById("error_bottom").style.display="block"
		document.getElementById("error_bottom").style.backgroundColor = "#99FF99"
		document.getElementById("error_bottom").style.padding = "3px"
		document.getElementById("error_bottom").style.margin = "10px 0 0 0"
	
	} else {
		
		document.getElementById("error").style.display="none"
		
	}
	
	if (document.getElementById("create_account").value != 0) {
	
		if (err2==1) {
			
			document.getElementById("error_invalid_decline").style.display="none"
			
			document.getElementById("error_pass").style.display="block"
			document.getElementById("error_pass").style.backgroundColor = "#99FF99"
			document.getElementById("error_pass").style.padding = "3px"
			document.getElementById("error_pass").style.margin = "10px 0 10px 0"
		
			document.getElementById("error_bottom").style.display="block"
			document.getElementById("error_bottom").style.backgroundColor = "#99FF99"
			document.getElementById("error_bottom").style.padding = "3px"
			document.getElementById("error_bottom").style.margin = "10px 0 0 0"
		
		} else {
			
			document.getElementById("error_pass").style.display="none"
			
		}
	
	}
	
	if (err3==1) {
		
		document.getElementById("error_invalid_decline").style.display="none"
		
		document.getElementById("error_invalid").style.display="block"
		document.getElementById("error_invalid").style.backgroundColor = "#99FF99"
		document.getElementById("error_invalid").style.padding = "3px"
		document.getElementById("error_invalid").style.margin = "10px 0 0 0"
		
		document.getElementById("error_bottom").style.display="block"
		document.getElementById("error_bottom").style.backgroundColor = "#99FF99"
		document.getElementById("error_bottom").style.padding = "3px"
		document.getElementById("error_bottom").style.margin = "10px 0 0 0"
		
	} else {
			
		document.getElementById("error_invalid").style.display="none"
			
	}
	
	if (err == 0 && err2 == 0 && err3 == 0) {
	
		if (document.getElementById("pay_by_check").checked==true) {
			document.forms["cart_review"].action = "scripts/cart/authorize_order_check.php"
		} else {
			document.forms["cart_review"].action = "scripts/cart/authorize_order_paypal.php"
		}
		document.forms["cart_review"].submit();
	
	} else {
		
		document.getElementById("submit_message").innerHTML = "(Please only click once)"
		document.getElementById("submit_button").style.display = "block"
		return false;
		
	}
	
}

function displayFeatures(a,b) {
	
	if (document.feature_selection.feature_0) {
		var val1 = 0;
		for( i = 0; i < document.feature_selection.feature_0.length; i++ ) {
			
			if( document.feature_selection.feature_0[i].checked == true ) {
				
				val1 = document.feature_selection.feature_0[i].value;
				break;
			}
		}
	}
	
	var val0 = 0;
	
	if (document.feature_selection.feature_0) {
		
		for( i = 0; i < document.feature_selection.feature_0.length; i++ ) {
			
			if( document.feature_selection.feature_0[i].checked == true ) {
				
				val0 = document.feature_selection.feature_0[i].value;
				break;
			}
		}
	}
		
	var val1 = 0;
	
	if (document.feature_selection.feature_1) {
		
		for( i = 0; i < document.feature_selection.feature_1.length; i++ ) {
			
			if( document.feature_selection.feature_1[i].checked == true ) {
				
				val1 = document.feature_selection.feature_1[i].value;
				break;
			}
		}
	}
	
	var val2 = 0;
	
	if (document.feature_selection.feature_2) {
		
		for( i = 0; i < document.feature_selection.feature_2.length; i++ ) {
			
			if( document.feature_selection.feature_2[i].checked == true ) {
				
				val2 = document.feature_selection.feature_2[i].value;
				break;
			}
		}
	}
	
	var val3 = 0;
	
	if (document.feature_selection.feature_3) {
		
		for( i = 0; i < document.feature_selection.feature_3.length; i++ ) {
			
			if( document.feature_selection.feature_3[i].checked == true ) {
				
				val3 = document.feature_selection.feature_3[i].value;
				break;
			}
		}
	}
	
	var val4 = 0;
	
	if (document.feature_selection.feature_4) {
		
		for( i = 0; i < document.feature_selection.feature_4.length; i++ ) {
			
			if( document.feature_selection.feature_4[i].checked == true ) {
				
				val4 = document.feature_selection.feature_4[i].value;
				break;
			}
		}
	}
	
	//alert(val0 + " " + val1 + " " + val2 + " " + val3)
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url="ajax/feature_app.php"
	url=url+"?stid="+a
	url=url+"&did="+b
	url=url+"&val0="+val0+"&val1="+val1+"&val2="+val2+"&val3="+val3+"&val4="+val4
	url=url+"&qx="+Math.random()
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	
			document.getElementById("feature_div").innerHTML=xmlHttp.responseText 
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
	
}

////////image feature//



function selectLevel2(a,b,c,d) {

	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url="ajax/product_select_size2.php"
	url=url+"?level_id="+a
	url=url+"&product_id="+b
	url=url+"&check_stock="+d
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		
			document.getElementById("select_size").innerHTML=xmlHttp.responseText 
			selectSize2(b,a,c,d)
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}



function selectSize2(a,b,c,d) {
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	document.getElementById('size_select_box').value = c
	
	//if (c == 0) {
		
		//document.getElementById("quantity").disabled = true
		//document.getElementById("add_to_cart_btn").disabled = true
		
	//}
	
	document.getElementById("select_quantity").style.display="none"
	
	var url="ajax/product_select_color2.php"
	url=url+"?size_id="+c
	url=url+"&product_id="+a
	url=url+"&level_id="+b
	url=url+"&check_stock="+d
	url=url+"&sid="+Math.random()
	
	document.getElementById("add_to_cart_div").innerHTML="&nbsp;"
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	
			document.getElementById("select_color").innerHTML=xmlHttp.responseText 
			
			
			
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}
var productCurrentImage = "";
var colorTimer = "";
var imageTimer = "";

function showColorName2(a,b) {
	
	clearTimeout(colorTimer);
	clearTimeout(imageTimer);
	
	if ( typeof( window['colorTimer'] ) != "undefined" ) {

		//clearTimeout(colorTimer);
		//clearTimeout(imageTimer);
	
	}
	document.getElementById("color_name").innerHTML = a
	document.getElementById("product_image").innerHTML = "<a href='javascript: largerImage(\"images/products/"+b+"\")'><img src='display_image.php?img=/"+b+"&mw=300&mh=300' border='0' style='margin-top: 5px' width='300' height='300'/></a>";
	document.getElementById("color_name").style.color = "#333"
	
}

document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) {
		var classes = elem[i].className;
		if (myclass.test(classes)) retnode.push(elem[i]);
	}
	return retnode;
}; 

function selectColor2(a,b,c,d,e) {
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url="ajax/product_select_quantity2.php"
	url=url+"?check="+b
	url=url+"&upc="+c
	url=url+"&sid="+Math.random()
	
	document.getElementById("color_select").value = c+"_"+a+"_"+e 
	
	productCurrentImage = e;
	
	 var imgs;
	 imgs=document.getElementsByClassName('product_color');
	 //alert(imgs.length)
	 for(i=0; i<imgs.length; i++) {
	 	imgs[i].style.borderStyle="solid";
	 }


	document.getElementById("product_color_"+d).style.borderStyle = "dashed" 
	
	document.getElementById("add_to_cart_div").innerHTML="&nbsp;"
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		
			document.getElementById("select_quantity").innerHTML=xmlHttp.responseText
			document.getElementById("select_quantity").style.display="block"
				var mytext = document.getElementById("quantity");
				mytext.focus(); 
				mytext.select()
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function hideColorName2() {
	
	document.getElementById("color_name").innerHTML = "&nbsp;"
	colorTimer = setTimeout ( "resetColor()", 500 );
	//alert(productCurrentImage)
	
	if (productCurrentImage != "") {
		imageTimer = setTimeout ( "resetImage()", 500 );
	}
	
}

function clearImgVar() {
	productCurrentImage = "";
}
	

function resetColor() {
	document.getElementById("color_name").innerHTML = "Rollover to view color"
	document.getElementById("color_name").style.color = "#999"
}

function resetImage() {
	document.getElementById("product_image").innerHTML = "<a href='javascript: largerImage(\"images/products/"+productCurrentImage+"\")'><img src='display_image.php?img=/"+productCurrentImage+"&mw=300&mh=300' border='0' style='margin-top: 5px' width='300' height='300'/></a>";
	//productCurrentImage = "";
}

function selectColorFromDrop2() {
	
	if (document.getElementById('color_select').value != 0) {
	
		xmlHttp=GetXmlHttpObject()
		
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		}
		
		var upc_info = document.getElementById('color_select').value
		var upc_array = upc_info.split("_")
		
		var upc_code = upc_array[0]
		var check = upc_array[2]
		
		var url="ajax/product_select_quantity2.php"
		url=url+"?check="+check
		url=url+"&upc="+upc_code
		url=url+"&sid="+Math.random()
		
		var img = upc_array[5]
		var d = upc_array[4]
		
		productCurrentImage = img;
	
		 var imgs;
		 imgs=document.getElementsByClassName('product_color');
		 //alert(imgs.length)
		 for(i=0; i<imgs.length; i++) {
			imgs[i].style.borderStyle="solid";
		 }
	
	
		document.getElementById("product_color_"+d).style.borderStyle = "dashed" 
		
		document.getElementById("product_image").innerHTML = "<a href='javascript: largerImage(\"images/products/"+img+"\")'><img src='display_image.php?img=/"+img+"&mw=300&mh=300' border='0' style='margin-top: 5px' width='300' height='300'/></a>";
	
		document.getElementById("add_to_cart_div").innerHTML="&nbsp;"
		
		xmlHttp.onreadystatechange=function() {
	
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			
				document.getElementById("select_quantity").innerHTML=xmlHttp.responseText 
				document.getElementById("select_quantity").style.display="block"
				var mytext = document.getElementById("quantity");
				mytext.focus(); 
				mytext.select()
			
			}
		
		}
			
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	
	} else {
		
		//document.getElementById("add_to_cart_btn").disabled = true
	//	document.getElementById("quantity").disabled = true
		
		document.getElementById("select_quantity").style.display="none"
		
	}
	
}

function addToCart2(a) {
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var upc_info = document.getElementById('color_select').value
	var upc_array = upc_info.split("_")
	
	
	var upc_code = upc_array[0]
	var upc_id = upc_array[1]
	var quantity = document.getElementById('quantity').value
	
	if (quantity > a) {
		var answer = confirm ("We only have "+a+" available.  Would you still like to add "+a+" to your cart?");	
		if (answer){
			quantity = a;
		}
		else{
			document.getElementById('quantity').value = 1
			return false
		}
	}
	clearImage = setTimeout ( "clearImgVar()", 500 );
	//productCurrentImage = "";
	var imgs;
	 imgs=document.getElementsByClassName('product_color');
	 //alert(imgs.length)
	 for(i=0; i<imgs.length; i++) {
	 	imgs[i].style.borderStyle="solid";
	 }
	
	var url="ajax/add_to_cart.php"
	url=url+"?upc_id="+upc_id
	url=url+"&upc_code="+upc_code
	url=url+"&quantity="+quantity
	url=url+"&qx="+Math.random()
	
	document.getElementById("select_quantity").style.display="none"
	
	document.getElementById("add_to_cart_div").innerHTML="<br>Adding to Cart..."
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	
			document.getElementById("add_to_cart_div").innerHTML=xmlHttp.responseText 
			document.getElementById("color_select").value=0
			updateCart(upc_id, upc_code, quantity);
		
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function validateCatalogRequest() {
	
	var err = 0;
	
	form = document.catalog_request
	
	if (form.ship_name.value == "") {		
		form.ship_name.style.backgroundColor  = '#99FF99'
		err=1	
	} else {	
		form.ship_name.style.backgroundColor  = '#FFFFFF'	
	}
	
	if (form.address_1.value == "") {		
		form.address_1.style.backgroundColor  = '#99FF99'
		err=1	
	} else {	
		form.address_1.style.backgroundColor  = '#FFFFFF'	
	}
	
	if (form.city.value == "") {		
		form.city.style.backgroundColor  = '#99FF99'
		err=1	
	} else {	
		form.city.style.backgroundColor  = '#FFFFFF'	
	}
	
	if (form.state.value == "" || form.state.value == 0) {		
		form.state.style.backgroundColor  = '#99FF99'
		err=1	
	} else {	
		form.state.style.backgroundColor  = '#FFFFFF'	
	}
	
	if (form.zip.value == "") {		
		form.zip.style.backgroundColor  = '#99FF99'
		err=1	
	} else {	
		form.zip.style.backgroundColor  = '#FFFFFF'	
	}
	
	if (err == 0) {
	
		document.forms["create_account"].submit();
	
	} else {
	
		return false;
		
	}
	
}

function loadCatColors(a,b) {
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url="ajax/category_colors.php"
	url=url+"?pid="+a
	url=url+"&lid="+b
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=function() {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		
			alert("product_"+a+"_"+b)
	
			document.getElementById("product_"+a+"_"+b).innerHTML=xmlHttp.responseText 
			
			
			
		}
	
	}
		
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function openSizeChart(a,w,h) {
	
	
	
	//var str = "menubar=1,resizable=1,scrollbars=1,width="+(w+25)+",height="+(h+25);
	
	window.open ("size_chart_window.php?chart="+a,"SizeChart","menubar=1,resizable=1,scrollbars=1,width="+(w+25)+",height="+(h+25)); 

}