
function switchTab(tabName) {

	document.forms[0].lastTab.value=tabName;
	document.all.tabWelcome.style.visibility='hidden';
	
	if(tabName=='tabGeneral') {
		document.all.tabAvailability.style.visibility='hidden';
		document.all.tabImages.style.visibility='hidden';
		document.all.tabGeneral.style.visibility='visible';
	} else if(tabName=='tabAvailability') {
		document.all.tabGeneral.style.visibility='hidden';
		document.all.tabImages.style.visibility='hidden';
		document.all.tabAvailability.style.visibility='visible';
	} else if(tabName=='tabImages') {
		document.all.tabGeneral.style.visibility='hidden';
		document.all.tabAvailability.style.visibility='hidden';
		document.all.tabImages.style.visibility='visible';
	}
  	return;
}

function removeItem(pid,sName){
	var loc = 'cart_remove.php?remove='+pid;

	if (confirm('you\'re about to remove '+sName+' from your shopping cart.\nare you sure?'))
		window.location=loc;
	
	return;
}

function validateOrder(){
	alert('validateOrder()');
	return;
}

function checkZipCode(flag){

	var f = document.frmVeriSign;
	var zip;

	if (flag == 'bill')
		zip = f.ZIP.value;
	else
		zip = f.ZIPTOSHIP.value;

	zip = zip.substr(0,5);
	zip = parseInt(zip);

	if(zip > 0 && zip < 99999) {
		if (flag == 'bill'){
	    	f.COUNTRY.value = 'USA';
	    	f.EMAIL.focus();
	    } else {
	    	f.COUNTRYTOSHIP.value = 'USA';
	    	f.EMAILTOSHIP.focus();
	    }
	} else {
		if (flag == 'bill')
	    	f.COUNTRY.value = '';
	    else
	    	f.COUNTRYTOSHIP.value = '';
    }

    return;
}

function copyAddress() {
	var f = document.frmVeriSign;

	f.NAMETOSHIP.value = f.NAME.value;
	f.ADDRESSTOSHIP.value = f.ADDRESS.value;  
	f.CITYTOSHIP.value = f.CITY.value;  
	f.STATETOSHIP.value = f.STATE.value;  
	f.ZIPTOSHIP.value = f.ZIP.value;  
	f.COUNTRYTOSHIP.value = f.COUNTRY.value;  
	f.EMAILTOSHIP.value = f.EMAIL.value;  
	f.PHONETOSHIP.value = f.PHONE.value;  

	return;
}


function checkForm(){

var f = document.frmVeriSign;

	$msg = "please fill out all fields";
	if(f.NAMETOSHIP.value =='') {
		f.NAMETOSHIP.select();
		alert($msg);
		return;
	}
	else if(f.ADDRESSTOSHIP.value =='') {
		f.ADDRESSTOSHIP.select();
		alert($msg);
		return;
	}
	else if(f.CITYTOSHIP.value =='') {
		f.CITYTOSHIP.select();
		alert($msg);
		return;
	}
	else if(f.STATETOSHIP.value =='') {
		f.STATETOSHIP.select();
		alert($msg);
		return;
	}
	else if(f.ZIPTOSHIP.value =='') {
		f.ZIPTOSHIP.select();
		alert($msg);
		return;
	}
	else if(f.EMAILTOSHIP.value =='') {
		f.EMAILTOSHIP.select();
		alert($msg);
		return;
	} 
	else if(f.PHONE.value =='') {
		f.PHONE.select();
		alert($msg);
		return;
	} else {
		if(confirm('are you sure this information is correct?')) 
			f.submit();
		return;
	}
}


/* 
 * name: openWindow(url, width, height)
 * purpose: open a child window with a given url, width, and height.
 * 	    no toolbars, scrollbars, menubar, location bar, etc.
 */
var winChild;

function openWin(url, name, width, height) {
 
 var features = 'width='+width+',height='+height+','+
                'resizable=no,scrollbars=no,toolbar=no,'+
                'location=no,menubar=no,directories=no';
                
 if (document.all) 
 	features = features + ',left=350,top=150';
 else if (document.layers)            
 	features = features + ',screenX=350,screenY=150';
 else 
 	features = features + ',left=350,top=150';

 winChild = window.top.open(url, name, features);
 return;
}

function openScrollingWin(url, name, width, height) {

 if (winChild!=null) { winChild.close();}

 var features = 'width='+width+',height='+height+','+
                'resizable=no,scrollbars=yes,toolbar=no,'+
                'location=no,menubar=no,directories=no';
                
 if (document.all) 
 	features = features + ',left=350,top=150';
 else if (document.layers)            
 	features = features + ',screenX=350,screenY=150';
 else 
 	features = features + ',left=350,top=150';

 winChild = window.top.open(url, name, features);
 return;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function addItem(pid) {
    
  eval("var hasMultiple = document.frmProduct.size_"+pid+"!=null;");
    
  eval("if (hasMultiple) { document.frmProduct.avail_id_"+pid+".value=document.frmProduct.size_"+pid+"[document.frmProduct.size_"+pid+".selectedIndex].value; }");
  
  eval("var sz=document.frmProduct.avail_id_"+pid+".value");
     
  if (sz!='')
  {
	document.frmProduct.pid.value = pid;
	document.frmProduct.avail_id.value = sz;
	document.frmProduct.qty.value = 1;
	
  	document.frmProduct.submit();
  }
  else
    alert('Please choose a size or color.');
  
  return;
}
