function openWindow(theURL,winName,features) { //v2.0
  window.open(theURL,'',features);
}
function swap_bg(status,button) {
	if (status=="on") {
		style=button+"_over";
		document.getElementById(button).className=style;
	} else {
		style=button;
		document.getElementById(button).className=style;
	}
}
function preloadImages() {
  var d=document;
  if(d.images){
    if(!d.p) d.p=new Array();
      var i,j=d.p.length,a=preloadImages.arguments;
    for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){
      d.p[j]=new Image;
      d.p[j++].src=a[i];
    }
  }
}
function preLoader() {
  preloadImages(
    '/images/btn1R.jpg',
    '/images/btn2R.jpg',
    '/images/btn3R.jpg',
    '/images/btn4R.jpg',
    '/images/btn5R.jpg',
    '/images/btn6R.jpg'
  );
}
window.addEventListener?window.addEventListener("load",preLoader,false):window.attachEvent("onload",preLoader);



var last_div = "";
function show_div(which) {
	if (document.getElementById(which).style.display == "inline") {
		document.getElementById(which).style.display = "none";
	} else {
		document.getElementById(which).style.display = "inline";
	}
	if (last_div != which) {
		if (last_div) {
			document.getElementById(last_div).style.display = "none";
		}
	}
	last_div = which;
}

function update_sub(which,fin) {
	sub = "sub["+which+"]";
	sub_field = document.forms[0][sub];

	qty = "qty["+which+"]";
	qty_field = document.forms[0][qty];

	cost = "cost["+which+"]";
	cost_field = document.forms[0][cost];
	
	if ((qty_field.value-0)>20) {
		cost_value = (cost_field.value-0)*.85;
		sub_total = (qty_field.value-0)*(cost_value.toFixed(2));
	}
	else if ((qty_field.value-0)>12) {
		cost_value = (cost_field.value-0)*.90;
		sub_total = (qty_field.value-0)*(cost_value.toFixed(2));
	}
	else if ((qty_field.value-0)>5) {
		cost_value = (cost_field.value-0)*.95;
		sub_total = (qty_field.value-0)*(cost_value.toFixed(2));
	}
	else {
		cost_value = (cost_field.value-0);
		sub_total = (qty_field.value-0)*(cost_value.toFixed(2));
	}
	sub_field.value = sub_total.toFixed(2);
	
	price=0;
	for (i=0;i<fin;i++) {
		sub = "sub["+(i+1)+"]";
		sub_field = document.forms[0][sub];
		price = (price-0)+(sub_field.value-0);
	}
	document.forms[0].total.value=price.toFixed(2);
	
	handling = price*.10;
	document.forms[0].handling.value = handling.toFixed(2);
	
	salestax = price*.0775;
	document.forms[0].salestax.value = salestax.toFixed(2);
	
	gtotal = handling+salestax+price;
	document.forms[0].gtotal.value = gtotal.toFixed(2);
	
}
function show_vol(which) {
	if (document.getElementById(which).style.display == "inline") {
		document.getElementById(which).style.display = "none";
	} else {
		document.getElementById(which).style.display = "inline";
	}
}
function update_sub_withweight(which,fin) {
	sub = "sub["+which+"]";
	sub_field = document.forms[0][sub];

	qty = "qty["+which+"]";
	qty_field = document.forms[0][qty];

	cost = "cost["+which+"]";
	cost_field = document.forms[0][cost];

	weight = "weight["+which+"]";
	weight_field = document.forms[0][weight];
	sub_weight = (qty_field.value * weight_field.value);

	item_weight = "item_weight["+which+"]";
	item_weight_field = document.forms[0][item_weight];
	item_weight_field.value = sub_weight.toFixed(2);
	
	if ((qty_field.value-0)>20) {
		cost_value = (cost_field.value-0)*.85;
		sub_total = (qty_field.value-0)*(cost_value.toFixed(2));
	}
	else if ((qty_field.value-0)>12) {
		cost_value = (cost_field.value-0)*.90;
		sub_total = (qty_field.value-0)*(cost_value.toFixed(2));
	}
	else if ((qty_field.value-0)>5) {
		cost_value = (cost_field.value-0)*.95;
		sub_total = (qty_field.value-0)*(cost_value.toFixed(2));
	}
	else {
		cost_value = (cost_field.value-0);
		sub_total = (qty_field.value-0)*(cost_value.toFixed(2));
	}
	sub_field.value = sub_total.toFixed(2);
	
	price=0;
	total_weight=0;
	for (i=0;i<fin;i++) {
		sub = "sub["+(i+1)+"]";
		sub_field = document.forms[0][sub];
		price = (price-0)+(sub_field.value-0);

		item_weight = "item_weight["+(i+1)+"]";
		item_weight_field = document.forms[0][item_weight];
		total_weight = (total_weight-0)+(item_weight_field.value-0);
	}
	document.forms[0].total.value=price.toFixed(2);
	document.forms[0].total_weight.value=total_weight.toFixed(2);
	
	handling = price*.10;
	//document.forms[0].handling.value = handling.toFixed(2);
	
	salestax = price*.0775;
	document.forms[0].salestax.value = salestax.toFixed(2);
	
	gtotal = handling+salestax+price;
	document.forms[0].gtotal.value = gtotal.toFixed(2);
	
}
