//****************************************************************************************
//*Routine to create/display list in table format on the fly
// Called from catalog_order.html files
//****************************************************************************************


// Setting up HTML table formats

function tr(s)       { return ("<TR>" + s + "</TR>"); }
function trCol(bgc)  { return (w("<TR bgcolor=" + bgc + ">")); }

function td(align,s) { return ("<TD align=" + align + "><Font color=#CEBD7B Face=Verdana, Arial, Helvetica>" + s +"</Font></TD>"); }
function tdCol(s)    { return (w("<TD align=center>  <Font Color=black Face=Verdana,sans-serif>" + s+"</Font></TD>")); }
function tdHdr(hdr)  { return (w("<TD align=center colspan=5><FONT color=white>" + hdr +"</Font></TD>")); }

function Table()     { return (w("<div style=text-align:CENTER; ><div ALIGN=CENTER><TABLE class=sortable id=searchtable BGCOLOR=000000 BORDER=3 CELLPADDING=+1 CELLSPACING=1 WIDTH=768 COLOR=#000000 BORDERCOLOR=#CEBD7B BORDERCOLORLIGHT=#CC9933 BORDERCOLORDARK=#999933>")) ; }
function w(s)        { document.write(s); }               // Shorthand for building table
function tdOpen()    { return("<TD>"); }
function tdClose()   { return("</TD>"); }
function trOpen()    { return("<TR>"); }
function trClose()   { return("</TR>"); }

function hrule()     { return(w('<hr color=#CEBD7B>')); }
function top()       { return ('&nbsp;&nbsp;<A HREF="#top"><img src="_arrow_up.gif" title="Back to Top" border=0 WIDTH=10 HEIGHT=20></A>&nbsp;&nbsp;'); }
function copyFont()  { return ('<CENTER><FONT COLOR="#999933" SIZE="1" FACE="Comic Sans MS">'); }

function SCTable()   { return(w("</tD></div><!-- end PNG Column --><!-- SCart Table3 --><tD ALIGN=CENTER VALIGN=TOP><TABLE BGCOLOR=000000 BORDER=3 CELLPADDING=+4 CELLSPACING=0 WIDTH=60% COLOR=#000000 BORDERCOLOR=#CEBD7B BORDERCOLORLIGHT=#CC9933 BORDERCOLORDARK=#999933>")) ; }
function ckBox(s,txt){ return(w('</td></tr><tD ALIGN=LEFT VALIGN=TOP><Font color=#CEBD7B Face=Verdana, Arial, Helvetica Size=-1><input type="hidden"><input type="checkbox" value="1" name="qty' + s + '">' + txt + '<br>')) ; }
function Hdr(s)                      { return(w('<Center><Font color=#CEBD7B Face=Comic Sans MS,Verdana,sans-serif Size=4>' + s +'</Font>')); }
function MultiHdr(itemno)            { return (w('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select Style from dropdown: <select name="product' + itemno + '">')) ; }
function MultiProd(code,stamp,price) { return (w('<option value="' + code + ' ' + stamp+ '&nbsp;—&nbsp;:' + price + '">' + code + ' ' + stamp + '— $' + price + '</option>')) ; }
function newSelect(hdr,s)            { return (w('<br>' + hdr + '&nbsp;<select name="product' + s + '">')) ; }
function optValue(s,sht)             { return (w('<option value="' + s +' '+ sht + '">' + s + '</option>')) ; }
function endSelect()                 { return (w('</select><br>')) ; }
function typeName(s)                 { return (w('• Type Name • Proofread • Add To Cart <input type="text" name="product' + s + '" size="45">')) ; }



//****************************************************************************************
// Create string to view actual stamp when stamp-number is clicked in shopping cart.
//****************************************************************************************

function findCAT(cat,code,stamp) {

      var catButton = '<A href=http://www.onyxxpressions.com/catalog/' +cat+ '.htm#begincart>' +stamp+ '</a>';
      var gifCol    = '<tD VALIGN=MIDDLE WIDTH=46 ALIGN=center bgcolor="white"><NOBR><div style=text-align:CENTER;" >' ;

/// HTML tag for PopBox image -->
      var pTitle = 'title="Click to View|Close &bull; ' +code+ ' &bull;" '  ;
      var pic    = ' ../pix/' + code + '.png' ;
      var camera = ' src="_camera.gif" alt="" style="width: 38px; height: 24px;" ' +pTitle ;

      var pbNL   = 'pbSrcNL="'+pic+ '"' ;
      var pbcapt = 'pbCaption="' +code+ '"' ;

      var imgSrc = '<img id=' + code + camera + pic ;
          imgSrc =  imgSrc +' pbShowCaption=false popBoxCaptionBelow=true ' +pbNL +pbcapt ;
          imgSrc =  imgSrc +' class="PopBoxImageSmall" onclick=Pop(this,50,"PopBoxImageLarge"); />' ;

          viewPng  =  gifCol + imgSrc ;

 w(trOpen());
 w(td("left",cat));
 w(td("left",code));
 w(td("left",catButton));
 w(viewPng);
 w(td("",top()));
 w(tdClose());
 w(trClose());
}

//****************************************************************************************
// Create order form table, line-by-line, from imbedded product list in HTML
//****************************************************************************************

function orderLine(itemno,code,stamp,price,size)
{
      var descr  =   code +" "+ stamp
      var ckbx   = '<input type="checkbox" value="1" name="qty' + itemno + '">' ;
      var scod   = '<input type="hidden" name="scode'   + itemno + '" value="' + code  + '">' ;
      var prod   = '<input type="hidden" name="product' + itemno + '" value="' + descr + '">' ;
      var cost   = '<input type="hidden" name="price'   + itemno + '" value="' + price + '">' ;
      cartline   =   ckbx + prod + cost + scod ;

      var gifCol = '<tD VALIGN=MIDDLE WIDTH=46 ALIGN=center bgcolor="white"><NOBR><div style=text-align:CENTER;" >' ;

/// HTML tag for PopBox image -->
      var pTitle = 'title="Click to View|Close &bull; '+code+' '+stamp+' &bull;" '  ;
      var pic    = ' ../pix/' + code + '.png' ;
      var camera = ' src="_camera.gif" alt="" style="width: 47px; height: 30px;" ' +pTitle ;

      var pbNL   = 'pbSrcNL="'+pic+ '"' ;
      var pbcapt = 'pbCaption="' +code+stamp+ '"' ;

      var imgSrc = '<img id=' + code + camera + pic ;
          imgSrc =  imgSrc +' pbShowCaption=false popBoxCaptionBelow=true ' +pbNL +pbcapt ;
          imgSrc =  imgSrc +' class="PopBoxImageSmall" onclick=Pop(this,50,"PopBoxImageLarge"); />' ;

         viewPic =  gifCol + imgSrc ;

// Generate popup text defining stamp size when hovered over stamp name in cart
       var title = 'title="' + code + ' Size: ' + size + '">' ;
       var popup = '<a class="sub_opt_link" href="JavaScript:void(0)" onclick="return false;"' ;
       var stamp =  popup + title + stamp + '</a>';

 w(trOpen());
 w(td("left",cartline));
 w(td("left",code));
 w(td("left",stamp));
 w(td("center",price));
 w(viewPic);
 w(tdClose());
 w(trClose());

}

//****************************************************************************************
// Create custom name order form table, line-by-line, from imbedded product list in HTML
//****************************************************************************************

function customLine(itemno,code,stamp,price,size,txtMx)
{

var ckbx = '<input type="checkbox" value="1" name="qty' + itemno + '">' ;

var prItem =  itemno + '[]' ;
var prod   = '<input type="hidden"   name="product'+prItem + '" value="' + code + ' ' + stamp + '">' ;
var name   = '<br><input type="text" name="product'+prItem + '" size="50">' ;

var stampX =  stamp + name

var cost = '<input type="hidden" name="price' ;
    cost = cost + itemno + '" value="' ;
    cost = cost + price +'">' ;

cartline = ckbx + prod + cost ;

// Generate popup text defining stamp size when hovered over stamp name in cart
var title = 'title="' + code + ' Size: ' + size + '">' ;
var popup = '<a class="sub_opt_link" href="JavaScript:void(0)" onclick="return false;"' ;
var stamp = popup + title + stampX + '</a>';

    //Create fifth column for Celtic Customs to offer font choices
    //Modify trClose() to append the fifth column -- just in Celtics.
  //  function trClose() {return (w(tdCol("Select Font") +"</TR>")) };


 w(trOpen());
 w(td("left",cartline));
 w(td("left",code));
 w(td("left",stamp));
 w(td("right",price));
    thisDIR=location.pathname.indexOf("celtic");
    if (thisDIR >= 1) {
        function fontCol() {(w('<tD VALIGN=MIDDLE ALIGN=center bgcolor="black"><NOBR><div style=text-align:CENTER>')); }
        fontCol();
        newSelect("",itemno+"[]");
        optValue("Antiqua" ,"Font");
        optValue("Edifice" ,"Font");
        optValue("Gothic"  ,"Font");
        optValue("Minuet"  ,"Font");
        optValue("StoneAge","Font");
        endSelect();
    }
 w(tdClose());
 w(trClose());
}



//***********************************************
//* Ajax Includes script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
//* This notice MUST stay intact for legal use
//* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
//* http://www.javascriptkit.com/dhtmltutors/ajaxincludes.shtml
//***********************************************/

//To include a page, invoke ajaxinclude("afile.htm") in the BODY of page
//Included file MUST be from the same domain as the page displaying it.

var rootdomain="http://"+window.location.hostname

function ajaxinclude(url) {
    var page_request = false
        if (window.XMLHttpRequest) // if Mozilla, Safari etc
            page_request = new XMLHttpRequest()
        else if (window.ActiveXObject){ // if IE
            try {
                  page_request = new ActiveXObject("Msxml2.XMLHTTP")
                }
        catch (e){
                  try{
                      page_request = new ActiveXObject("Microsoft.XMLHTTP")
                     }
        catch (e){}
                 }
        }
    else
        return false
        page_request.open('GET', url, false) //get page synchronously
        page_request.send(null)
        writecontent(page_request)
}

function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText)
}


//***********************************************
// Copyright SimplytheBest Inc. http://simplythebest.net.
// This script may only be used with the copyright notices intact.
// For use on commercial web sites please contact email@simplythebest.net.
// Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/
//***********************************************
function ShowMenu(URL, WinTitle, WinWidth, WinHeight, WinLeft, WinTop){
        attr = "scrollbars=yes,resizable=no,width=" + WinWidth + ",height=" + WinHeight + ",screenX=" + WinLeft + ",screenY=" + WinTop + ",left=" + WinLeft + ",top=" + WinTop + "";
        msgWindow=open(URL, WinTitle, attr);
        if (msgWindow.opener == null) msgWindow.opener = self;
}


//****************************************************************************************
// Re-direct the browser to the url value
//****************************************************************************************
function radio_input(url) {
      window.location.href = "http://" + url
}


//***********************************************
function limitText(limitField, limitCount, limitNum) {
        if (limitField.value.length > limitNum) {
                limitField.value = limitField.value.substring(0, limitNum);
        } else {
                limitCount.value = limitNum - limitField.value.length;
        }
}


//***********************************************
//My top Javascripts for Designers
//See http://www.blakems.com/archives/000087.html for more info.
//***********************************************

//expandCollapse
function expandCollapse() {
        for (var i=0; i<expandCollapse.arguments.length; i++) {
                var element = document.getElementById(expandCollapse.arguments[i]);
                element.style.display = (element.style.display == "none") ? "block" : "none";
        }
}


//***********************************************
// eMail URL page to friend....
// Author: http://www.tne.co.uk/2006/mals/send-web-page.html
//***********************************************

   var good;
function checkEmailAddress(field){
   var goodEmail=field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
       if (goodEmail)
          {good = true}else{alert('Please enter a valid e-mail address.');
           field.focus();field.select();good=false;}
   }

   u=window.location;
   m="I thought you might like these OnyxXpressions stamps ...";
function mailThisUrl(){

   good=false;
   checkEmailAddress(document.eMailer.address);
      if (good){window.location="mailto:"+document.eMailer.address.value+"?subject="+m+"&body="+u;}
   }
   var nn=(navigator.appName.indexOf("Netscape")!=-1);
   var dD=document,dH=dD.html,dB=dD.body,px=dD.layers?'':'px';



//***********************************************
//Obtained at http://BontragerConnection.com/
//Auto-Copyright Year Updater • Copyright 2007 Bontrager Connection, LLC
//***********************************************
function copyright(company) {
   var CopyrightLine = "Original Images Copyright© [[YEAR]] " +company;
   // No edits required below this point.
      y = new Date();
      year = y.getFullYear();
      re = new RegExp("\\[\\[YEAR\\]\\]");
      CopyrightLine = CopyrightLine.replace(re,year);
      document.write(copyFont());
      document.write(CopyrightLine);
}

