// JavaScript Document

	function windowPop(url) {
		shipWindow = window.open(url, "ShipHazmatNet", "width=800,height=600,left=0,top=0,toolbar=no,location=no,scrollbars=yes,resizable=yes");
		if (window.focus) {
			shipWindow.focus();
		}
	}

	 function changeOptions(obj, obj2) {
	  	var tmpHTML = document.getElementById(obj).innerHTML;
	  	document.getElementById(obj2).innerHTML = tmpHTML;
	  	document.getElementById(obj2).style.visibility = "visible";
	}
	
	function onChange(dropdown) {
		var sindex = dropdown.selectedIndex;
		var svalue = dropdown.options[sindex].value;
		if (svalue == "perclick") {
			changeOptions("pi_click", "planinfo");
			changeOptions("option_click", "planoptions");
			doCalc(0,14.95);
		} else {
			changeOptions("pi_annual", "planinfo");
			changeOptions("option_annual", "planoptions");
		}
	}
	
	function toCurrency(n, c, g) {
			var s = (0 > n) ? '-' : ''; n = Math.abs(n);
			var m = String(Math.round(n));
			var j, i = '', f; c = c || ''; g = g || '';
			
			while(m.length < 3) {m = '0' + m;}
				f = m.substring((j = m.length - 2));
			while(j > 3) {
				i = g + m.substring(j - 3, j) + i;
				j -= 3;
				}
				i = m.substring(0, j) + i;
			return s + c + i + '.' + f;
		}
		
	function doCalc(inum, icreditprice) {
			var iCount = parseInt(inum)+1;
			var iPrice = icreditprice;
			var tmpprice = iCount*iPrice;
			if (tmpprice.toFixed) {
				tmpprice1 = tmpprice.toFixed(2);
				tmpprice2 = tmpprice1.toString();
				document.getElementById("creditPrice").innerHTML = 'Purchase Total: <strong>$'+tmpprice2+'</strong>';
				document.pform.typeprice.value = tmpprice2;
			} else {
				tmpprice1 = tmpprice*100;
				document.getElementById("creditPrice").innerHTML = toCurrency(tmpprice1,'$',',');
				document.pform.typeprice.value = tmpprice1;
			}
		}
