var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
function hidelayer(lay) {
if (ie4) {document.all[lay].style.visibility = "hidden";}
if (ns4) {document.layers[lay].visibility = "hide";}
if (ns6) {document.getElementById([lay]).style.display = "none";}
}
function showlayer(lay) {
if (ie4) {document.all[lay].style.visibility = "visible";}
if (ns4) {document.layers[lay].visibility = "show";}
if (ns6) {document.getElementById([lay]).style.display = "block";}
}
function writetolayer(lay,txt) {
if (ie4) {
document.all[lay].innerHTML = txt;
}
if (ns4) {
document[lay].document.write(txt);
document[lay].document.close();
}
if (ns6) {
over = document.getElementById([lay]);
range = document.createRange();
range.setStartBefore(over);
domfrag = range.createContextualFragment(txt);
while (over.hasChildNodes()) {
over.removeChild(over.lastChild);
}
over.appendChild(domfrag);
}
}

function colorcheck(odx, nm, name) {
	document.frm.coloroptions.value ="";
	document.frm.coloroptions.value = odx;
	document.all.colorname.innerHTML = 'You chose <b>"'+name+'"</b>';
}

function checkform(nb) {
var f = document.frm;
var checkcolor = "";
var chk = "";
var tmpoption = '';

if (nb=='buy') {
	f.action='/cart/buynow_checkout_process.asp?paymethod=1';
}
else if (nb=='liq') {
	f.action ='/liquidation/buynow_checkout_process.asp';
}
else if (nb=='paypal') {
	f.action ='/cart/buynow_checkout_process.asp?paymethod=2';
}
else {
	f.action='/cart/cartprocess.asp';
}
//alert(nb);
//return false;

f.ops.value = '';
if(isNaN(f.p_sum.value)) {
	alert("Quantity Should be Number. If you have more than one item in your shopping cart and are trying to use PayPal, please return to your shopping cart (by clicking on My Order) and remove all but one item. You may still have multiple quantities of the one item. If you would like to order multiple items with PayPal, simply place a seperate order for each item type.");
	return;
}
else {
	if (f.p_sum.value <=0 ) {
	alert("Check Quantity again");
	return;
	}
	if (f.p_sum.value < f.minimum_qty.value) {
	alert("Minimum Quintity is "+ f.minimum_qty.value+" ea");
	f.p_sum.reset;
	return;
	}
}
if(f.optionname) {
	if(f.optionname.length) {
		for(var i = 0; i <f.optionname.length; i++) {
			if(f.optionname[i].value=='color') {
				if(f.color) {
					if(!f.color.value) {
						alert("Please choose your color");
						return;
					}
					else{
						f.coloroptions.value = f.color.value;
					}

				}
				else {
					if(!document.frm.coloroptions.value) {
						alert("Please click your color");
						return;
					}
				}
			}
			else {
				tmpoption = eval("f."+f.optionname[i].value);
				if(!tmpoption.value) {
					alert("Please choose your "+f.optionname[i].value);
					return;
				}
				else {
					if(f.ops.value) {
						f.ops.value =tmpoption.value+","+f.ops.value ;
					}
					else {
						f.ops.value = tmpoption.value;
					}
				}
			}
		}
	}
	else {
		if(f.optionname.value == 'color') {
			if(f.color) {
				if(!f.color.value) {
					alert("Please choose your color");
					return;
				}
				else{
					document.frm.coloroptions.value = f.color.value;
				}
			}
			else {
				if(!document.frm.coloroptions.value) {
					alert("Please click your color");
					return;
				}
			}
		}
		else {
			tmpoption = eval("f."+f.optionname.value);
			if(!tmpoption.value) {
				alert("Please click your");
				return;
			}
			else {
				f.ops.value =tmpoption.value;
			}
		}
	}
}
	document.frm.submit();
}
function reviewon(nm) {
	if (document.all.userreview.style.display == '') {
//		document.all.information1.style.display = '';
		if(document.all.information1) {	document.all.information1.style.display = '';}
		if(document.all.information2) {	document.all.information2.style.display = 'none';}
		if(document.all.information3) {	document.all.information3.style.display = 'none';}
		if(document.all.information4) {	document.all.information4.style.display = 'none';} 
		if(document.all.information5) {	document.all.information5.style.display = 'none';}
		document.all.userreview.style.display = 'none';
		document.images['reviewbutton'].src = "/images/common/reviews.gif";
		document.location.href="#top";
	}
	else 
	{
//		document.all.information1.style.display = 'none';
		if(document.all.information1) {	document.all.information1.style.display = 'none';}
		if(document.all.information2) {	document.all.information2.style.display = 'none';}
		if(document.all.information3) {	document.all.information3.style.display = 'none';}
		if(document.all.information4) {	document.all.information4.style.display = 'none';}
		if(document.all.information5) {	document.all.information5.style.display = 'none';}
		document.all.userreview.style.display = '';
		document.images['reviewbutton'].src = "/images/common/reviews2.gif";
		document.location.href="#reviewlist";
	}
}
function openemailbox(idx, spt) {
	var win; 
	var gsc1 = "";
	if (spt =="liquidation") {
		gsc1 = "liquidation";
	}
	else {
		gsc1 = "product";
	}
	win = window.open("/"+gsc1+"/email.asp?idx="+idx, "emailwindow", "width=400, height=300,status=no, scrollbars=yes, toolbars=no");
	if(!win) {
		alert("Please allow popup window");
	}
}
function savereview() {
var ch = document.reviewbox;
	if(!ch.username.value) {
		alert("Please type your name");
		return;
	}
	else if(!ch.content.value) {
		alert("Please type your review");
		return;
	}
	else if(ch.content.value.length > 500) {
		alert("Content shoul not be over 500 letters");
		ch.content.value = ch.content.value.substring(0,499);
		return;
	}
	else {
		ch.submit();
	}
}
function deletereview(idx,step1) {
	var win; 
	var gsc1;
	if (step1 =="liquidation") {
		gsc1 = "liquidation";
	}
	else {
		gsc1 = "product";
	}
	win = window.open("/"+gsc1+"/deletereview.asp?idx="+idx, "deletereview", "width=100, height=100, status=no, scrollbars=no, toolbars=no");
	if(!win) {
		alert("Please allow popup window");
	}
}

