function sameAsBilling() {

    if (document.form1.same.checked) {

	    document.form1.shipCompany.value = document.form1.company.value;
		document.form1.shipFirstName.value = document.form1.first_name.value;
		document.form1.shipLastName.value = document.form1.last_name.value;
		document.form1.shipAddress1.value = document.form1.address1.value;
		document.form1.shipAddress2.value = document.form1.address2.value;
		document.form1.shipAddress3.value = document.form1.address3.value;
		document.form1.shipCity.value = document.form1.city.value;
		document.form1.shipState.value = document.form1.state.value;
		document.form1.shipZip.value = document.form1.zip.value;
		document.form1.shipCountry.value = document.form1.country.value;
		document.form1.shipPhone.value = document.form1.phone.value;
	}
}

function cvv2() {

    options="toolbar=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500,height=300";
	window.open("cvv2.html", "Help", options);
}

function maxGangs() {

    options="toolbar=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=550";
	window.open("maxGangs.html", "Help", options);
}

function preview(item_number) {

    options="toolbar=0,status=0,menubar=0,scrollbars=0,resizable=0,width=600,height=300";
	window.open("http://www.homenetworksupply.com/products/" + item_number, "Preview", options);
}

function writeReview(product_id) {

    options="toolbar=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500,height=550";
	window.open("/review.aspx?product_id=" + product_id, "Review", options);
}

var clickmessage="Image Download Prohibited"

function disableclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
alert(clickmessage);
return false;
}
}
}
else if (document.layers) {
if (e.which == 3) {
alert(clickmessage);
return false;
}
}
else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
alert(clickmessage)
return false
}
}
}

function associateimages(){
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown=disableclick;
}

if (document.all)
document.onmousedown=disableclick
else if (document.getElementById)
document.onmouseup=disableclick
else if (document.layers)
associateimages()

function checkQty(field, desc) {

	var chars = "0123456789";
	var field_val = eval('document.form1.' + field + '.value');
    var alertNow = false;
    
	if (field_val == "0")
	  	eval('document.form1.' + field).value = ""; 
	for (var i = 0; i < field_val.length; i++) { 
		if (chars.indexOf(field_val.charAt(i)) == -1) { 
			alertNow = true;
    	  	eval('document.form1.' + field).value = "";
   		} 
	}
	
	if (alertNow == true)
	    alert("Only numbers (0-9) are allowed for the " + desc + " quantity.\n");
}

function updateSubtotal() {

	var chars = "0123456789";
	var qty = document.form1.quantity.value;
    var alertNow = false;
    
	if (qty == "0")
	  	document.form1.quantity.value = "1"; 
	
	for (var i = 0; i < qty.length; i++) { 
		if (chars.indexOf(qty.charAt(i)) == -1) { 
			document.form1.quantity.value = "1";
   		} 
	}
	
	var total = document.form1.quantity.value * document.form1.subtotal_orig.value;
	document.form1.subtotal.value = '$' + total.toFixed(2);
}

function showBilling(copyBilling) { 

    if (document.getElementById && document.getElementById("div_ship")!= null) 
	    node = document.getElementById("div_ship").style.display=''; 
    else if (document.layers && document.layers["div_ship"]!= null) 
	    document.layers["div_ship"].display = ''; 
    else if (document.all) 
	    document.all["div_ship"].style.display = ''; 
	    
	if (copyBilling == 'True') {
	    document.form1.shipCompany.value = document.form1.company.value;
		document.form1.shipFirstName.value = document.form1.first_name.value;
		document.form1.shipLastName.value = document.form1.last_name.value;
		document.form1.shipAddress1.value = document.form1.address1.value;
		document.form1.shipAddress2.value = document.form1.address2.value;
		document.form1.shipCity.value = document.form1.city.value;
		document.form1.shipState.value = document.form1.state.value;
		document.form1.shipZip.value = document.form1.zip.value;
		document.form1.shipCountry.value = document.form1.country.value;
		document.form1.shipPhone.value = document.form1.phone.value;
	}     
	else {
	    document.form1.shipCompany.value = '';
		document.form1.shipFirstName.value = '';
		document.form1.shipLastName.value = '';
		document.form1.shipAddress1.value = '';
		document.form1.shipAddress2.value = '';
		document.form1.shipCity.value = '';
		document.form1.shipState.value = '';
		document.form1.shipZip.value = '';
		document.form1.shipCountry.value = '';
		document.form1.shipPhone.value = '';
	}          
} 

function show(c) { 

    if (document.getElementById && document.getElementById(c)!= null) 
	    node = document.getElementById(c).style.display=''; 
    else if (document.layers && document.layers[c]!= null) 
	    document.layers[c].display = ''; 
    else if (document.all) 
	    document.all[c].style.display = ''; 
} 

function hide(c) { 

    if (document.getElementById && document.getElementById(c)!= null) 
	    node = document.getElementById(c).style.display='none'; 
    else if (document.layers && document.layers[c]!= null) 
	    document.layers[c].display = 'none'; 
    else if (document.all) 
	    document.all[c].style.display = 'none'; 
} 
