var W3CDOM;
W3CDOM = (document.getElementById) ? true : false;
function hideMenu(id) {
	if (W3CDOM) {
		document.getElementById(id).style.visibility="hidden";
	}
}

function showMenu(id) {
	if (W3CDOM) {
		document.getElementById(id).style.visibility="visible";
	}
}

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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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 no_order() {
  alert("We're sorry, but we do not have online ordering at this time.\n\nYou may fill out and print our 'Blank Order Form' using the option on the menu at the left.  It is suitable for mailing or faxing.  Thank you!");
  return false;
}
function sold_out() {
  alert("We're sorry, but we are sold out of this item, at this time.  Check back, as we may have more in stock soon.");
  return false;
}
function open_enlarge(inImg,inOrient) {
  var NewURL = "/CatPages/enlarge_view.asp?dir=" + inOrient + "&img=" + URLEncode(inImg);
  if (inOrient == 'P') {
    window.open(NewURL,'EnlargedView','width=380,height=550,left=50,top=15'); }
  else {
    window.open(NewURL,'EnlargedView','width=500,height=450,left=50,top=15'); }
  return true;
}
function add_order(sid,newItm,newDesc,qtyNum,newPrc) {
  var qtyNam = "document.form1.qty" + qtyNum;
  var qtyObj = eval(qtyNam);
  var qtyVal = qtyObj.value;
  if (qtyVal == "" || qtyVal == "0") {
	alert("You must enter a Quantity.  To delete an Item use 'View Cart/Checkout'.");
	return false;
  }
  var outDesc = URLEncode(newDesc);
  var newURL = "/CatPages/BuildOrder.asp?sid=" + sid + "&newItem=" + newItm + "&newDesc=" + outDesc + "&newQty=" + qtyVal + "&newPrc=" + newPrc;
  qtyObj.value = "";
  //alert(newURL);
  window.open(newURL,'ShoppingCart','scrollbars=yes,width=600,height=400,left=50,top=15');
  //window.location = newURL;
  return true;
}
function show_cart(sid) {
  var newURL = "/CatPages/BuildOrder.asp?sid=" + sid + "&newItem=&newDesc=&newQty=&newPrc=";
  //alert(newURL);
  window.open(newURL,'ShoppingCart','scrollbars=yes,width=600,height=400,left=50,top=15');
  //window.location = newURL;
  return true;
}
function URLEncode(str)
	{
		var ms = "%25#23 20?3F<3C>3E{7B}7D[5B]5D|7C^5E~7E`60"
		var msi = 0
		var i,c,rs,ts 
		while (msi < ms.length)
	{
	c = ms.charAt(msi)
	rs = ms.substring(++msi, msi +2)
	msi += 2
	i = 0
	while (true)
	{ 
		i = str.indexOf(c, i)
		if (i == -1) break
		ts = str.substring(0, i)
		str = ts + "%" + rs + str.substring(++i, str.length)
	}
	}
	return str
	}		
function blank_order() {
  alert("The PDF document you are about to open is a Form.  You can fill out part or all of the form, if you wish, before actually printing the document.");
  return true;
}
function post_chg(sid,frmIdx) {
  var itmNam = "document.dumyFrm.itm" + frmIdx;
  var itmObj = eval(itmNam);
  var itmVal = itmObj.value;
  var dscNam = "document.dumyFrm.dsc" + frmIdx;
  var dscObj = eval(dscNam);
  var dscVal = URLEncode(dscObj.value);
  var qtyNam = "document.dumyFrm.qty" + frmIdx;
  var qtyObj = eval(qtyNam);
  var qtyVal = qtyObj.value;
  var prcNam = "document.dumyFrm.prc" + frmIdx;
  var prcObj = eval(prcNam);
  var prcVal = prcObj.value;
  var newURL = "/CatPages/BuildOrder.asp?sid=" + sid + "&newItem=" + itmVal + "&newDesc=" + dscVal + "&newQty=" + qtyVal + "&newPrc=" + prcVal;
  //alert(newURL);
  window.location = newURL;
}
function notify(sid) {
  var opt = confirm("You are about to open a PDF version of our Order Form.  If you do not have PDF Reader software, press CANCEL, close the shopping cart window, and click the Adobe button on the menu to download the latest Acrobat Reader.\n\nThe items in your shopping cart will already be filled in.  You can complete the entry of all other information before printing for mailing or faxing to us.  Click OK to continue (this will clear your cart) or CANCEL to continue shopping");
  if (opt != true) {
    return false;
  }
   //window.location = "homepage.asp";
   newURL = "/checkout.asp?sid=" + sid;
   window.open(newURL,'Checkout');
   window.close();
}
function notify2(sid) {
  var opt = confirm("You are about to remove all items from your Shopping Cart.  If this is what you want to do, Click OK.  Otherwise, Click CANCEL.");
  if (opt == true) {
   newURL = "/CatPages/BuildOrder.asp?sid=" + sid + "&act=empty";
   window.location = newURL; }
  else {
   return false
  }
}
function notify3(sid,frmIdx,qtyName) {
  var qtyNam = "document.dumyFrm." + qtyName;
  var qtyObj = eval(qtyNam);
  var qtyVal = qtyObj.value;
 if (qtyVal == "0") {
  var opt = confirm("You are about to remove this item from your Shopping Cart.  If this is what you want to do, Click OK.  Otherwise, Click CANCEL.");
  if (opt != true) {
    return false; }
  else {
	post_chg(sid,frmIdx);
  }
 }
 else {
    post_chg(sid,frmIdx);
 }
}
function PrivacyMsg() {
  var opt = confirm("PRIVACY INFORMATION:   Please be aware that email is not a 'secure' means \nfor transmitting credit card information.\n\nAppalachian Nurseries, Inc. does not encourage the use of this method for\ncommunicating any private or credit related information to us.");
  if (opt != true) {
    return false; }
}
