//****************************************************************************************
//*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 Size=-1>" + s +"</Font></TD>"); }
function tdCol(s)    { return (w("<TD align=center bgcolor=#CEBD7B><Font Color=black Face=Verdana,sans-serif Size=2>" + s+"</Font></TD>")); }
function tdHdr(hdr)  { return (w("<TD align=center colspan=5><FONT color=white>" + hdr +"</Font></TD>")); }

function txtMax(s)   { return ('<td>Text:</td><td colspan="3"><textarea class="fd_max_' + s + '" id="tarea" name="tarea" cols="30" rows="2"></textarea></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 SCTable()   { return(w("</tD></div><!-- end PNG Column --><!-- SCart Table3 --><tD ALIGN=CENTER VALIGN=TOP><TABLE BGCOLOR=000000 BORDER=3 CELLPADDING=+1 CELLSPACING=0 WIDTH=60% COLOR=000000 BORDERCOLOR=CEBD7B BORDERCOLORLIGHT=#996633 BORDERCOLORDARK=#990033>")) ; }
function thisFont()  { return ("<FONT SIZE=2 COLOR=#CEBD7B FACE=Verdana,Arial,Helvetica,sans-serif>"); }
function col(width,s){ return ('<TD VALIGN=TOP HEIGHT=32 WIDTH='+ width +'><NOBR><div style=text-align:LEFT; >' +thisFont() + s + '</Font></TD>'); }

function top()       { return ('<A HREF="#top">&nbsp;&nbsp;<img src="arrow_up.gif" title="Back to Top" border=0 WIDTH=10 HEIGHT=20>&nbsp;&nbsp;</A>'); }
function PopBxPic(s) { return ('+s+');  }





//****************************************************************************************
// Create order form table, line-by-line, from imbedded product list in HTML
//****************************************************************************************

function orderLine(itemno,code,stamp,price,size)
{

       var ckbx  = '<input type="checkbox" value="1" name="qty' ;
            ckbx =  ckbx + itemno + '">' ;
       var prod  = '<input type="hidden" name="product' ;
            prod =  prod + itemno + '" value="' ;
            prod =  prod + code + '-' + stamp +'">' ;
       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 + ' Block: ' + 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("right",price));
 w(tdClose());
 w(txtMax(txtMx));
 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 + '" value="Name on stamp: " size="50">' ;
       var name     = '<br><input type="text" name="product'+prItem + '" size="50">' ;

       var stamp    =   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 + ' Block: ' + 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("right",price));
 w(tdClose());
 // w(txtMax(txtMx));
 w(trClose());
}


//****************************************************************************************
// Create Google-searchable table, line-by-line, from imbedded product list in HTML
//****************************************************************************************

function searchLine(code,stamp,realWords,category,keyWords,size,catPg)
{

    // var number   =  code.substr(3);
    // var WinTitle =  theme + number       //Strip hyphen: Internet Explorer can't handle non-alpha characters in "title" field


/// Create last Col w/Camera icon to view actual stamp
       var quot     = "'";
       var comma    = ',' ;

/// Expand stamp prefix to Theme Collection Names
       var theme  =  code.substr(0,2);
       if (theme == 'AD') { theme = "Art Deco"      ; }
       if (theme == 'AL') { theme = "Art Living"    ; }
       if (theme == 'BP') { theme = "Book Plates"   ; }
       if (theme == 'FF') { theme = "Femme Fatale"  ; }
       if (theme == 'FS') { theme = "Floral Scape"  ; }
       if (theme == 'LD') { theme = "Lucid Dreams"  ; }
       if (theme == 'MA') { theme = "Mail Art"      ; }
       if (theme == 'MM') { theme = "Music Melodies"; }
       if (theme == 'NA') { theme = "Nature"        ; }
       if (theme == 'OA') { theme = "Oriental Aura" ; }
       if (theme == 'PB') { theme = "Pam Bell"      ; }
       if (theme == 'SG') { theme = "Stained Glass" ; }
       if (theme == 'SS') { theme = "Sun n Sea"     ; }
       if (theme == 'TR') { theme = "Tree Scapes"   ; }
       if (theme == 'WW') { theme = "Winter Wonders"; }
       if (theme == 'XP') { theme = "Xpressions"    ; }
       if (theme == 'XS') { theme = "Sympathy"      ; }

       var gifCol   = '<tD VALIGN=TOP WIDTH=46 ALIGN=center bgcolor="CEBD7B"><NOBR><div style=text-align:CENTER;" >' ;
       var gifTD    =  code + ' ' +stamp +'" border="0" width="47" height="30" ALIGN="BOTTOM" HSPACE="0" VSPACE="0">' ;


/// HTML tag for PopBox image -->
      var pTitle = 'title="View '+code+' '+stamp + '"'  ;
      var pic    = 'pix/' + code + '.png' ;
      var camera = ' src="camera.gif" alt="" style="width: 47px; height: 30px;" ' +pTitle ;

      var pbNL   = 'pbSrcNL="'+pic+ '"' ;
      var pbcapt = 'pbCaption="' +realWords+ '"' ;

      var imgSrc = '<img id=' + code + camera + pic ;
          imgSrc =  imgSrc +' pbShowCaption=false popBoxCaptionBelow=true ' +pbNL +pbcapt ;
          imgSrc =  imgSrc +' class="PopBoxImageSmall" onclick=Pop(this,50,"PopBoxImageLarge"); />' ;
      //  imgSrc =  imgSrc +' onmouseout=Revert(this,50,"PopBoxImageSmall"); />' ;

          viewPic  =  gifCol + imgSrc ;




/// Create link to Catalog Page
       var catPg    =  "/catalog/"+catPg+".htm#begincart" ;
       var clikBuy  = '<A HREF=http://www.onyxxpressions.com'+catPg+'>' ;
       var buySrc   = '<img src="shop.gif" align="CENTER"  TITLE="Shop for '+gifTD ;
       var clikBuy  =  gifCol +clikBuy +buySrc ;

       var endTR    = '</FONT></div></NOBR></tD></tR>' ;


/// Generate popup text defining stamp size when hovered over stamp name in cart
       var title    = 'title="' + code +' • ' +realWords + ' • Size: ' + size + '">' ;
     //var realwds  = 'title="' + realWords + '">' ;
       var popup    = '<a class="sub_opt_link" href="JavaScript:void(0)" onclick="return false;"' ;
       var number   =  popup + title + code + '</a>';

 w(trOpen());
 w(col("",theme));
 w(col("",number));
 w(col("180",stamp));
 w(col("180",category));
 w(col("180",keyWords));
 w(clikBuy);
 w(viewPic);
 w(col("",top()));
 w(endTR);

}


//****************************************************************************************
// PopupPic - Centers popup mid-screen & self-calculates graphics width + height
// Requires  ~popup.htm as default popup window name
//****************************************************************************************

//   function PopupPic(sPicURL) {
//       var pix      = "http://www.onyxxpressions.com";
//
//       sPicURL      = "pix/"+sPicURL ;
//       var winTop   = (screen.availHeight/2)-200;
//       var winLeft  = (screen.availWidth/2)-200;
//
//       window.open("~popup.htm?"+sPicURL, "poppis", "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,HEIGHT=300,WIDTH=300,LEFT="+winLeft +",TOP="+winTop  );
//   }



//****************************************************************************************
//* 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;
        }
}

