
/***************************************************************
 * GLOBAL FUNCTION writeFooter
 *
 *   Writes out ARTI footer
 *
 *   returns:
 *     nothing
 *
 *   params:
 *     none
 ***************************************************************/
function writeFooter()
{
  //document.writeln("<TD>");
  document.writeln("<CENTER>");
  document.writeln("  <FONT FACE=\"Arial,Helvetica\" SIZE=\"-1\">Barbara Knupper.</FONT> <BR>");
  document.writeln("  <FONT FACE=\"Arial,Helvetica\" SIZE=\"-1\">The Artful Artisan</FONT><BR>");
  document.writeln("  <FONT FACE=\"Arial,Helvetica\" SIZE=\"-1\">9108 Highway 42  (PO Box 51)</FONT><BR>");
document.writeln("  <FONT FACE=\"Arial,Helvetica\" SIZE=\"-1\">(1 mile south of Fish Creek)</FONT><BR>");
  document.writeln("  <FONT FACE=\"Arial,Helvetica\" SIZE=\"-1\">Fish Creek, WI 54212</FONT><BR>");
  document.writeln("  <FONT FACE=\"Arial,Helvetica\" SIZE=\"-1\">Open 10-5 Daily, except Tuesday</FONT><BR>");
document.writeln("  <FONT FACE=\"Arial,Helvetica\" SIZE=\"-1\">(Contact for Off-Season Hours)</FONT><BR>");
  document.writeln("  <FONT FACE=\"Arial,Helvetica\" SIZE=\"-1\">Phone:(920) 868-9222</FONT><BR>");
  document.writeln("  <FONT FACE=\"Arial,Helvetica\" SIZE=\"-1\">email: talk2barb@artfulartisan.com</FONT><BR><BR>");
  document.writeln("  <B><FONT FACE=\"Arial,Helvetica\" SIZE=\"-3\"><B>Copyright 2006 By The Artful Artisan<BR>All Rights Reserved.</FONT></B>");
  document.writeln("</CENTER>");
  //document.writeln("</TDR>");
} // end writeFooter()





/***************************************************************
 * GLOBAL FUNCTION imgSwitch
 *
 *   Switches imagesWrites the HTML to display an image to the window object passed in
 *
 *   returns:
 *     nothing
 *
 *   params:
 *     which     = the index of the image that needs switched
 *     mouseOver = whether the mouse is over the image or not (boolean)
 ***************************************************************/
function imgSwitch(which, mouseOver)
{
  if (browser==1)
  {
    if(mouseOver)
      eval("document.img" + which + ".src = imgOVER[" + which + "].src");
    else
      eval("document.img" + which + ".src = img[" + which + "].src");
  } // end if
} // end imgSwitch()




/***************************************************************
 * GLOBAL FUNCTION paintScr
 *
 *   Writes the HTML to display an image to the window object passed in
 *
 *   returns:
 *     nothing
 *
 *   params:
 *     thewin = window object to write to
 *     thepic = URL of picture to display
 *     thealt = description of image
 ***************************************************************/
function paintScr(thewin, thepic, thealt)
{
  thewin.document.open();
  thewin.document.writeln("<HTML>");
  thewin.document.writeln("<HEAD>");
  thewin.document.writeln("  <TITLE>Artful Artisan</TITLE>");
  thewin.document.writeln("</HEAD>");
  thewin.document.writeln("<BODY BGCOLOR=\"WHITE\" LINK=\"RED\">");
  thewin.document.writeln("<CENTER>");
  thewin.document.writeln("  <IMG SRC=\""+thepic+"\" BORDER=0 ALT=\""+thealt+"\">");
  thewin.document.writeln("  <BR>");
  thewin.document.writeln("  <FONT FACE=\"arial, helvetica\" SIZE=\"-1\" COLOR=\"RED\"><A HREF=\"javascript:self.close();\">Close</A></FONT>");
  thewin.document.writeln("</CENTER>");
  thewin.document.writeln("</BODY>");
  thewin.document.writeln("</HTML>");
  thewin.document.close();
} // end paintScr()



/***************************************************************
 * GLOBAL FUNCTION productView
 *
 *   Displays large product image on screen in a DIV tag
 *
 *   returns:
 *     nothing
 *
 *   params:
 *     imgURL  = URL of image to display
 *     imgDesc = description of image
 *     thePrice= Price of product
 *     theSize= the Size pf the product 
***************************************************************/

function productView (imgURL, theDesc, theSize, smPrice)
{
  document.images['product'].src=imgURL;
  var i = document.getElementById("myDesc");
  if (theDesc == "")
  {
    toggleBox('itemDesc',0);//hide textarea
  }
  else
  {
  toggleBox('itemDesc',1);//show textarea
   i.value = theDesc + '\r' + theSize + '\r' + smPrice;  
  } // end if
} // end productView ()


// This is the actual html on the page: <div id="productView" style="position:absolute; left:334px; top:181px; width:676px; height:483px; z-index:4"><img src="products/001.jpg" width="624" height="263"></div>
//  helpWin = window.open('','HelpWindow','scrollbars=no,resizable=no,width=620,height=450');
//  paintScr(helpWin, imgURL, imgDesc.replace(/\*/g,"'"));
//  if (helpWin.focus)
//  {
//    helpWin.focus();
//  } // end if



/***************************************************************
 * GLOBAL FUNCTION dualProductView
 *
 *   Displays large product image on screen in a DIV tag
 *
 *   returns:
 *     nothing
 *
 *   params:
 *     imgURL  = URL of image to display
 *     imgDesc = description of image
 *     thePrice= Price of product
 *     theSize= the Size pf the product 
***************************************************************/

function dualProductView (imgURL, theDesc, theSize, smPrice, lgPrice)
{
  document.images['product'].src=imgURL;
  var i = document.getElementById("myDesc");
  if (theDesc == "")
  {
    toggleBox('itemDesc',0);//hide textarea
  }
  else
  {
  toggleBox('itemDesc',1);//show textarea
   i.value = theDesc + '\r' + theSize + '\r' + smPrice + '\r' + lgPrice;  
  } // end if
} // end productView ()







/***************************************************************
 * GLOBAL FUNCTION HelpWindow
 *
 *   Opens a "helper" window to display an image and gives that window focus
 *
 *   returns:
 *     nothing
 *
 *   params:
 *     imgURL  = URL of image to display
 *     imgDesc = description of image
 ***************************************************************/
function HelpWindow (imgURL, imgDesc)
{
  helpWin = window.open('','HelpWindow','scrollbars=no,resizable=no,width=620,height=450');
  paintScr(helpWin, imgURL, imgDesc.replace(/\*/g,"'"));
  if (helpWin.focus)
  {
    helpWin.focus();
  } // end if
} // end HelpWindow()




/***************************************************************
 * GLOBAL FUNCTION gotoPageWithFrom
 *
 *   Redirects to "toPage" attaching a query string parameter (fromPage)
 *   of the current page
 *
 *   returns:
 *     nothing
 *
 *   params:
 *     toPage = page you want to redirect to
 ***************************************************************/
function gotoPageWithFrom(toPage)
{
  // find out what page we're currently on...
  var URL = window.location.pathname;
  var fromPage = URL.substring(URL.lastIndexOf("/")+1, URL.length);

  // create new location URL appending our current page...
  URL = toPage + "?fromPage=" + escape(fromPage);

//alert (URL);


  // move to the new location...
  window.location = URL;

} // end gotoPageWithFrom()




/***************************************************************
 * GLOBAL FUNCTION replaceStr
 *
 *   Replaces a substring w/in a string w/ another substring
 *
 *   returns:
 *     string = String w/ substring replaced w/ other substring.
 *
 *   params:
 *     str      = string to do replacement in
 *     replacee = substring to replace
 *     replacer = substring to replace with
 ***************************************************************/
function replaceStr(str, replacee, replacer)
{
  var i=0
  var j=0;
  var repLen = replacee.length;
  var returnStr = "";

  j = str.indexOf(replacee, i);

  // make sure we have something to do...
  if(repLen==0 || j==-1) return(str);

  while(j != -1)
  {
    returnStr += (str.substring(i, j) + replacer);
    i = j + repLen;
    j = str.indexOf(replacee, i);
  } // end while

  // append remaining string (if any)...
  if(i != str.length)
    returnStr += str.substring(i,str.length);

  return(returnStr);

} // end replaceStr




/***************************************************************
 * GLOBAL FUNCTION getQueryStringParam
 *
 *   Attempts to parse "name" parameter from the *UNESCAPED* "URL" parameter
 *
 *   returns:
 *     string = value of "name" parameter if found, otherwise an empty string ("")
 *
 *   params:
 *     URL  = URL to parse
 *     name = name of query string parameter to find
 ***************************************************************/
function getQueryStringParam(URL, name)
{
  var start;
  var end;
  var param = "?" + name + "="

  // first, find the parameter...
  start = URL.indexOf(param);
  if(start == -1)
  {
    param = "&" + name + "="
    start = URL.indexOf(param); // maybe it wasn't the first parameter
    if(start == -1) return(""); // parameter still wasn't found
  }

  // adjust the starting point (start AFTER the parameter)...
  start = URL.indexOf(param) + param.length;

  // then find the end of the parameter
  end = URL.indexOf('&', start);
  if(end == -1)
    end = URL.length;

  // see if we've got anything to return...
  if(end <= start)
    return("");

  // now return the parameter's value (replacing all '+' w/ ' ')...
  return(replaceStr(URL.substring(start, end), '+', ' '));

} // end getQueryStringParam()




/***************************************************************
 * GLOBAL FUNCTION getFromPage
 *
 *   Attempts to parse "fromPage" parameter from the window's current URL
 *
 *   returns:
 *     string = "fromPage" parameter if found, otherwise "index.html"
 *
 *   params:
 *     none
 ***************************************************************/
function getFromPage()
{
  // call "getQueryStringParam" function to return "fromPage" info...
  var fromPage = getQueryStringParam(unescape(window.location), "fromPage");

  // if the data is invalid, redirect to "index.html"...
  if(fromPage == "")
    return("index.html");
  else
    return(fromPage);

} // end getFromPage()



/***************************************************************
 * GLOBAL FUNCTION calculateShipping
 *
 *   Calculates the shipping & handling charges for an order
 *   with the given parameters
 *
 *   returns:
 *     number - Calculated cost for shipping and handling
 *
 *   params:
 *     subtotal = total cost of items ordered (not including notecards)
 ***************************************************************/
function calculateShipping(subtotal)
{
  if(subtotal > 51)
    return(0);
	//return(15);
  else if(subtotal > 0)
    return(0);
	//return(8);
  else
    return(0);

} // end calculateShipping()



/***************************************************************
 * GLOBAL FUNCTION formatNum
 *
 *   Formats an expression into a specified form
 *
 *   returns:
 *     string - Formatted expression
 *
 *   params:
 *     expr      = expression to format
 *     decplaces = number of places to the right of the decimal to display
 ***************************************************************/
function formatNum(expr, decplaces)
{
  // Raise incoming value by power of 10 times the nuber of decimal places
  // Round to an integer
  // Convert to a string
  var str = "" + Math.round(eval(expr) * Math.pow(10, decplaces));

  // pad small value strings with 0's to the left of rounded number
  while(str.length <= decplaces)
  {
    str = "0" + str;
  } // end while

  // find location of the decimal point
  var decpoint = str.length - decplaces;

  // assemble final result string
  return(str.substring(0,decpoint) + "." + str.substring(decpoint,str.length));

} // end formatNum()



/***************************************************************
 * GLOBAL FUNCTION dollarize
 *
 *   Formats an expression into a dollar value
 *
 *   returns:
 *     string - Dollar value
 *
 *   params:
 *     expr = expression to format
 ***************************************************************/
function dollarize(expr)
{
  return("$" + formatNum(expr,2));

} // end dollarize()




/***************************************************************
 * GLOBAL FUNCTION toggleBox
 *
 *   hides and shows DIV layers
 *
 *   returns:
 *     nothing
 *
 *   params:
 *     szDivID = name of DIV
 *     imgSrc= background image for DIV
 *     iState = 1 visible, 0 hidden
 ***************************************************************/
function toggleBox(szDivID, iState, imgSrc) // 1 visible, 0 hidden

{
    
	if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}


/***************************************************************
 * GLOBAL FUNCTIONS
 * Cross browser Marquee script functions
 * - © Dynamic Drive (www.dynamicdrive.com)
 *
 *   Displays a scrolling marquee across the top of the page
 *   just underneath the navigation tabs 
 *   
 *   returns: nothing
 *     
 *
 *   params: none
 *     
 ***************************************************************/



function populate(){
if (iedom){
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
cross_marquee.innerHTML=marqueecontent
actualwidth=document.all? temp.offsetWidth : document.getElementById("temp").offsetWidth
}
else if (document.layers){
ns_marquee=document.ns_marquee.document.ns_marquee2
ns_marquee.left=parseInt(marqueewidth)+8
ns_marquee.document.write(marqueecontent)
ns_marquee.document.close()
actualwidth=ns_marquee.document.width
}
lefttime=setInterval("scrollmarquee()",20)
}
window.onload=populate

function scrollmarquee(){
if (iedom){
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
else
cross_marquee.style.left=parseInt(marqueewidth)+8+"px"

}
else if (document.layers){
if (ns_marquee.left>(actualwidth*(-1)+8))
ns_marquee.left-=copyspeed
else
ns_marquee.left=parseInt(marqueewidth)+8
}
}
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_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];}
}







/***************************************************************
 * GLOBAL FUNCTION PDFWindow
 *
 *   Opens a window to display a PDF file and gives that window focus
 *
 *   returns:
 *     nothing
 *
 *   params:
 *     theURL  = URL of PDF file to display
 *     theDesc = description of file
 ***************************************************************/

function popPDF(theURL){
   if (popWinHandle != null && !popWinHandle.closed){
     popWinHandle.location.href=theURL;
     popWinHandle.focus();
   }
   else {
	   popWinHandle= open(theURL,"popWindow",'nostatus,scrollbars=1,resizable=1,width=600,height=400,top=0,left=0');
   }
}

