function checkone(id){
	var pid = "pid_" + id;
	var p = document.getElementById(pid);
	var qty = p.value;
	if(qty == ''){
		p.value = 1;
	}
}

function updateCounter(num, id){
	document.getElementById(id).innerHTML = num;	
}

function textBoxEdit(sid,textval){
	var tbox = document.getElementById(sid);
	if(tbox.value!=textval)	tbox.value = textval;
}

function checknewsletterForm()
{
  var theForm = document.getElementById("newsform");

  for(i=0; i<theForm.elements.length; i++){
  	 if((theForm.elements[i].type == "password" || theForm.elements[i].type == "text" || theForm.elements[i].type == "textarea") && theForm.elements[i].getAttribute('id') != "nr" ){
         	var elname = theForm.elements[i].name;
      	 	if(theForm.elements[i].value == "" || theForm.elements[i].value == "Enter Email Address"){
      	 	theForm.elements[i].style.background = "#FFCCCC";
      	 	theForm.elements[i].focus();
      	 	theForm.elements[i].value = "";
      	 	document.getElementById("erralert2").innerHTML = "Enter Email Address";
      	 	document.getElementById("erralert2").className = "newsalerton";
      	 	document.getElementById("erralert2").style.fontSize = "12px";
           document.getElementById("erralert2").style.margin = "0";
  
      	 	t=1;
      	 	return false;
      	 	}else {
      	 		theForm.elements[i].style.background = "#FFFFFF";
      	 		document.getElementById("erralert2").className = "erralertoff";
      	 		}

      }
  }
   return true;
}

/*Handle Size Click img change*/
function sizeClick(sid,hiddenval)
{
	sizeimg  = document.getElementById(sid);

	document.getElementById(hiddenval).value=sid.toUpperCase();


	navRoot = document.getElementById("sizenav");
	for (i=0; i<navRoot.childNodes.length; i++) {
	node = navRoot.childNodes[i];
	if (node.nodeName=="LI") {
		nname = node.getAttribute('name');
		if(nname!=sid){
		document.getElementById(nname).src = "./images/buttons/"+nname+".jpg";
		}else
		{document.getElementById(nname).src = "./images/buttons/"+sid+"-selected.jpg";
		  document.getElementById('sizeselected').innerHTML =  "&nbsp;&nbsp;"+sid.toUpperCase();
		}
	   }
	  }



	return true;
}

function confirmAction(url, text){
	if (confirm(text)){
		document.location = url;
	}
}

function confirmSubmit(elem, text){
	if (confirm(text)){
		alert(elem.form.name);
		elem.form.submit();
	}
}

function showCustom(){
	var allTR = document.getElementsByTagName('tr');
	if(document.getElementById('changeDate').checked==true){ 
		for (i=0; i<allTR.length; i++) { 
			if (allTR[i].className=='hide') { 
				allTR[i].className='show'; 
			}else if (allTR[i].className=='show') { 
				allTR[i].className='hide'; 
			}
		}
	}else{ 
		for (i=0; i<allTR.length; i++) { 
			if (allTR[i].className=='show') { 
				allTR[i].className='hide'; 
			}else if (allTR[i].className=='hide') { 
				allTR[i].className='show'; 
			}
		}
	}
}

function setShipName(name){
	document.getElementById('shipName').value = name;
}

function checkzip(){
	//var zip = document.getElementById('zip');
	var zip = document.getElementById('zip');
	if(zip.value!=''){
		//document.location="/windshield-repair-kits/confirm/";
		return true;
	}else{
		zip.style.border="1px solid red";
		alert("Please submit your zip code to determine availability in your area.");
		//document.location="/windshield-repair-kits/confirm/";
		return false;
	}
}

function chooseshipping(){
	var ship = document.getElementById('shipoptions');
	ship.style.border="1px solid red";
	alert("Please choose a shipping option.");

}

function next() {
	if(checkzip()) { 
		document.itemSubmitForm.submit();
		document.getElementById('message').innerHTML='<img src="images/loading.gif" />'; 
	}
}

function checkRegExp() {
	var zip = document.getElementById('zip');
	var reZip = /^((\d{5}([- ])\d{4})|(\d{5})|([AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvXxYy]\d[A-Za-z]\s?\d[A-Za-z]\d))$/

	if(zip.value.search(reZip)==-1){
		zip.style.border="1px solid red";
		alert("Please submit your zip code to determine availability in your area.");
		return false;
	}else{
		return true;
	}

}

function enterZip() {
	if(checkRegExp()) { 
		document.itemSubmitForm.submit();
		document.getElementById('message').innerHTML='<img src="images/loading.gif" />'; 
	}
}
