
// Prints the main table layout for the site
function printOpenLayout(editdate)
{
   document.writeln("<TABLE CLASS='layout' CELLPADDING=0 CELLSPACING=0>");
   document.writeln("<TR CLASS='armlayout'>");
   document.writeln("<TD CLASS='leftcolumn'><A HREF='/?p=home'><IMG SRC='/images/home.gif' BORDER=0></A></TD>");
   document.writeln("<TD CLASS='arm'><IMG SRC='/images/title.gif'></TD>");
   document.writeln("<TD CLASS='rightcolumn'><IMG SRC='/images/head-top.gif'></TD>");
   document.writeln("</TR><TR VALIGN='top'>");
   document.writeln("<TD>");
   printNav();
   document.writeln("<BR><FONT CLASS='lastedit'> ...last update: " + editdate + "</FONT></TD>");
   document.writeln("<TD CLASS='content'>");
}

// Prints the closing elements for the site
function printCloseLayout()
{
  document.writeln("</TD><TD ALIGN='center'><IMG SRC='/images/head-bottom.gif'><BR><BR>");
  document.writeln("</TR><TR>");
  document.writeln("<TD CLASS='stdlinks' COLSPAN=3><A HREF='/?p=aboutus'>about us</A> | <A HREF='/?p=contactus'>contact us</A> | <A HREF=\"javascript:popout('terms');\">terms/conditions</A> | <A HREF=\"javascript:popout('privacy');\">privacy policy</A></TD>");
  document.writeln("</TR><TR>");
  document.writeln("<TD CLASS='copyright' COLSPAN=3>Copyright &copy; 2008. 2007. Happy-O Quilting. All Rights Reserved.</TD>");
  document.writeln("</TR>");
  document.writeln("</TABLE>");
}

// Prints the navigation buttons down the machine
function printNav() {
  var options = new Array(9);
  options[0] = 'faq';
  options[1] = 'forsale';
  options[2] = 'gallery';
  options[3] = 'materials';
  options[4] = 'order';
  options[5] = 'patterns';
  options[6] = 'pricing';
  options[7] = 'services';
  options[8] = 'shipping';

  printPanel(options);

  var preLoad = new Array();
  preLoadImages(preLoad,options);
}

function printPanel(obj)
{
  var objLen = obj.length;

  document.writeln("<IMG SRC='/images/startpanel.gif' BORDER=0><br>");
  for (var i = 0; i < objLen; i++)
    document.writeln("<A HREF='/?p="+obj[i]+"' TITLE='"+obj[i]+"' onMouseOver=\"javascript:document."+obj[i]+".src='/images/"+obj[i]+"-d.gif'\" onMouseOut=\"javascript:document."+obj[i]+".src='/images/"+obj[i]+"-u.gif'\"><IMG BORDER=0 SRC='/images/"+obj[i]+"-u.gif' NAME='"+obj[i]+"'></A><BR>");
  document.writeln("<IMG SRC='/images/endpanel.gif' BORDER=0>");
}

// Preload images for faster and more smooth rollover effect
function preLoadImages(preImages,myImages)
{
  var myLen = myImages.length;
  for (var i = 0; i < myLen; i++)
  {
    preImages[i] = new Image();
    preImages[i].src = "/images/"+myImages[i]+"-d.gif";
  }
}

function popout(location)
{
  var url = "/popout.php?p="+location;
  var newwindow = window.open(url,'happyowin','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=600,width=650');
  if (window.focus) newwindow.focus;
}

function newInstance(location)
{
  var newwindow = window.open(location,'happyowin','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=600,width=650');
  if (window.focus) newwindow.focus;
}

function todayDate(element,format)
{
  var now = new Date();
  var d = now.getDate();
  var dd = (d < 10) ? '0'+d : d;
  var m = now.getMonth()+1;
  var mm = (m < 10) ? '0'+m : m;
  var yyyy = now.getFullYear();
  var y = yyyy%100;
  var yy = (y < 10) ? '0'+y : y;

  format = format.replace(/dd/,dd);
  format = format.replace(/mm/,mm);
  format = format.replace(/yyyy/,yyyy);
  format = format.replace(/yy/,yy);

  format = format.replace(/DD/,dd);
  format = format.replace(/MM/,mm);
  format = format.replace(/YYYY/,yyyy);
  format = format.replace(/YY/,yy);

  element.value = format;
}

