// JavaScript Document
var lastid;
var lastid1;
function formatNumber(myNum, numOfDec)
   {
      var decimal = 1
      for(i=1; i<=numOfDec;i++)
         decimal = decimal *10

      var myFormattedNum = (Math.round(myNum * decimal)/decimal).toFixed(numOfDec)
      return myFormattedNum;
   }

function disp_subcat(id,id1){
	//alert (id);
	document.getElementById("cat"+id).style.display='';
	document.getElementById("cata"+id).style.display='none';
	document.getElementById("catb"+id).style.display='';
	//alert(lastid);
	lastid1=id;
	hide_subcat(id);
		
	
}

function hide_subcat(id){
	
	if(lastid!=null){
	document.getElementById('cat'+lastid).style.display='none';
	document.getElementById("cata"+lastid).style.display='';
	document.getElementById("catb"+lastid).style.display='none';}
	lastid=id;
	//alert(lastid);
}

function disp_tab(obj,id){
	
	for(i=1;i<=5;i++){
		if(i==id){
			document.getElementById('tab'+i).style.display='';
			document.getElementById("tab1"+i).className="TabActive";
			
		}else{
			document.getElementById('tab'+i).style.display='none';
			document.getElementById("tab1"+i).className="Tab";
		}
	}		
}

function disp_tab1(obj,id){
	
	for(i=1;i<=6;i++){
		if(i==id){
			document.getElementById('tab'+i).style.display='';
			document.getElementById("tab1"+i).className="Tab1Active";
			
		}else{
			document.getElementById('tab'+i).style.display='none';
			document.getElementById("tab1"+i).className="Tab1";
		}
	}		
}

function chg_prog(id,id1){
	document.getElementById('product').selectedIndex = id;
	fine_size(id1);
}


function validEmailAddress(email){
		invalidChars = " /:,;~"
		if (email == ""){
			return (false);
		}
		for (i=0; i<invalidChars.length; i++){
			badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar,0) != -1){
				return (false);
			}
		}
		atPos = email.indexOf("@",1)
		if (atPos == -1){
			return (false);
		}
		if (email.indexOf("@",atPos+1) != -1){
			return (false);
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1){
			return (false);
		}
		
		return (true);
}

function validForm(obj)
{
	if(obj.firstName.value == ''){
		alert("Please enter first name.");
		obj.firstName.focus();
		return false;
	}
	if(obj.company.value == ''){
		alert("Please enter company name.");
		obj.company.focus();
		return false;
	}
	if(obj.phone1.value == ''){
		alert("Please enter phone number.");
		obj.phone1.focus();
		return false;
	}
	else if(obj.phone1.value.length < 7){
		alert("Please enter valid phone number.");	
		obj.phone1.focus();
		return false;
	}
	if(obj.email.value == ''){
		alert("Please enter email address.");
		obj.email.focus();
		return false;
	}
	else if(!validEmailAddress(obj.email.value)){
		alert("Please enter valid e-mail address.");
		obj.email.focus();
		return false;
	}
	if(obj.pwd.value == ''){
		alert("Please enter password.");
		obj.pwd.focus();
		return false;
	}
	if(obj.pwd.value != obj.cpwd.value){
		alert("Please enter same password for confirmation.");
		obj.pwd.focus();
		return false;
	}
	
	
}

function samecustomeraddress(){
	if(document.quickcheckout.address[0].checked==true){
		document.quickcheckout.chaddress.value=document.quickcheckout.bill_address.value;
	}
}
function sameshippingaddress(){
	if(document.quickcheckout.address[1].checked==true){
		document.quickcheckout.chaddress.value=document.quickcheckout.ship_address.value;
	}
}
