/*
*************************************************

Cedar Tree Books
Common Javascript

Created by Bob Schwartz
http://www.fotografics.it

*************************************************
*/
// Pop Up Windows
var popupLinkConfig = new Array;
// popupLinkConfig["classname"] = new Array ( "targetname", "width=550,height=350,scrollbars=yes,resizable=yes,status=yes,toolbar=yes,location=yes,menubar=yes");
popupLinkConfig["popup"]  = new Array ( "", "width=600,height=450,resizable=yes,scrollbars=yes,menubar=yes,toolbar=yes");

function initPopupLinks()
{
 if (!document.getElementsByTagName) return true;
 var pageLinks = document.getElementsByTagName("a");
 for (var i = 0; i < pageLinks.length; i++) 
 {
  if (((pageLinks[i].className != null) && 
     (pageLinks[i].className != "")) ||
    ((pageLinks[i].parentNode.className != null) && 
     (pageLinks[i].parentNode.className != "")))
  {
   var linkClass = " " + pageLinks[i].className + " ";
   if ((linkClass == " ") && (pageLinks[i].parentNode.className != ""))
   {
    linkClass = " " + pageLinks[i].parentNode.className + " ";
   }
   for (var theKey in popupLinkConfig) 
   {
    if (linkClass.indexOf(" " + theKey + " ") > -1)
    {
     if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
     {
      pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
     }
     pageLinks[i].settings = popupLinkConfig[theKey][1];
     pageLinks[i].onclick = popUp;
    }
   }
  }
 }
 return true;
}

function popUp()
{
 newWin = window.open(this.href, this.target, this.settings);
 newWin.focus();
 return false;
}
// copyright
function copy() {
	var container = document.getElementById("copy");
	var oldtext = document.getElementById("copy1");
	var text = ("\251 " + (new Date()).getFullYear() + " Cedar Tree Books");
	var p = document.createElement("p");
	container.replaceChild(p, oldtext);
	p.appendChild(document.createTextNode(text));
	document.getElementById("copy").appendChild(p);
}
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;
}
/* p7 menu */
function P7_setNV(){ //v1.3 by PVII
 //set the image over and down name convention
 document.p7NavOver="_over";
 document.p7NavDown="_down";
 var i,k=-1,g,x,gg,tl,ti,tm,tt,tu,args=P7_setNV.arguments,dt=false;
 if(document.getElementsByTagName){dt=true;}if(document.P7NavBar){return;}
 P7NavProp=new Array();for(i=0;i<args.length;i++){P7NavProp[i]=args[i];}
 P7NavIM=new Array();if(dt){tm=document.getElementsByTagName("IMG");
 }else{tm=document.images;}tm=document.images;tt=new Array();tt=tt.concat(tm);
 if(document.layers){for(i=0;i<document.layers.length;i++){
 ti=document.layers[i].document.images;if(ti){tt=tt.concat(ti);}
 for(x=0;x<document.layers[i].document.layers.length;x++){
 ti=document.layers[i].document.layers[x].document.images;if(ti){tt=tt.concat(ti);
 }}}tm=tt;}for(i=0;i<tm.length;i++){tl=tm[i].name;if(dt&&!tl){tl=tm[i].id;}
 if(tl&&tl.indexOf("p7NVim")==0){k++;P7NavIM[k]=tl;}}document.P7_NVswapd=new Array();
 document.P7_NVswapo=new Array();for(i=0;i<P7NavIM.length;i++){g=MM_findObj(P7NavIM[i]);
 gg=g.src;g.p7NVim=g.src;tu=gg.lastIndexOf(".");
 g.p7NVimo=gg.substring(0,tu)+document.p7NavOver+gg.substring(tu,gg.length);
 g.p7NVimd=gg.substring(0,tu)+document.p7NavDown+gg.substring(tu,gg.length);
 if(P7NavProp[1]>1){document.P7_NVswapo[i]=new Image();document.P7_NVswapo[i].src=g.p7NVimo;}
 if(P7NavProp[1]>0){if(P7NavProp[1]==3){g.p7NVimd=g.p7NVimo;}
 document.P7_NVswapd[i]=new Image();document.P7_NVswapd[i].src=g.p7NVimd;}}
 document.P7NavBar=true;
}
function P7_trigNV(bu){ //v1.3 by PVII
 if(!document.P7NavBar){return;}var i,d,dB=-1,tF=false,sF=false;
 for(i=0;i<P7NavIM.length;i++){d=MM_findObj(P7NavIM[i]);
 if(P7NavIM[i]==P7NavProp[0]){dB=i;}if(P7NavIM[i]==bu){tF=true;
 if(P7NavProp[1]>0){if(i==dB){d.src=d.p7NVimd;}else if (P7NavProp[1]>1){
 d.src=d.p7NVimo;}}}else{if(P7NavProp[1]>0){d.src=d.p7NVim;}}}
 if(!tF){if(dB>-1){d=MM_findObj(P7NavIM[dB]);if(P7NavProp[1]>0){d.src=d.p7NVimd;}}}
}
/* random quote */
function random_content(){
var quote=new Array()
quote[1]='<p>There is no frigate like a book to take us lands away nor any coursers like a page of prancing <span class=\"lastword\">poetry.</span></p><p><cite>Emily Dickinson</cite></p>'
quote[2]='<p>The good of a book lies in its being read. A book is made up of signs that speak of other signs, which in their turn speak of things. Without an eye to read them, a book contains signs that produce no concepts; therefore it is <span class=\"lastword\">dumb.</span></p><p><cite>Umberto Eco</cite></p>'
quote[3]='<p>For books are more than books, they are the life The very heart and core of ages past, The reason why men lived and worked and died, The essence and quintessence of their <span class=\"lastword\">lives.</span></p><p><cite>Amy Lowell</cite></p>'
quote[4]='<p>Books constitute capital. A library book lasts as long as a house, for hundreds of years. It is not, then, an article of mere consumption but fairly of capital, and often in the case of professional men, setting out in life, it is their only <span class=\"lastword\">capital.</span></p><p><cite>Thomas Jefferson</cite></p>'
quote[5]='<p>There are books...which take rank in your life with parents and lovers and passionate experiences, so medicinal, so stringent, so revolutionary, so <span class=\"lastword\">authoritative.</span></p><p><cite>Ralph Waldo Emerson</cite></p>'
quote[6]='<p>A good book is the best of friends, the same today and for <span class=\"lastword\">ever.</span></p><p><cite>Martin Tupper</cite></p>'
quote[7]='<p>O, let my books be then the eloquence and dumb presagers of my speaking <span class=\"lastword\">breast.</span></p><p><cite>William Shakespeare</cite></p>'
quote[8]='<p>The oldest books are still only just out to those who have not read <span class=\"lastword\">them.</span></p><p><cite>Samuel Butler</cite></p>'
quote[9]='<p>Books are the bees which carry the quickening pollen from one to another <span class=\"lastword\">mind.</span></p><p><cite>James Russell Lowell</cite></p>'
quote[10]='<p>There are worse crimes than burning books. One of them is not reading <span class=\"lastword\">them.</span></p><p><cite>Joseph Brodsky</cite></p>'
quote[11]='<p>I know every book of mine by its smell, and I have but to put my nose between the pages to be reminded of all sorts of <span class=\"lastword\">things.</span></p><p><cite>George Gissing</cite></p>'
quote[12]='<p>All good books are alike in that they are truer than if they had really happened and after you are finished reading one you will feel that all that happened to you and afterwards it all belongs to you; the good and the bad, the ecstasy, the remorse, and sorrow, the people and the places and how the weather <span class=\"lastword\">was.</span></p><p><cite>Ernest Hemingway</cite></p>'
quote[13]='<p>A book is like a man—clever and dull, brave and cowardly, beautiful and ugly. For every flowering thought there will be a page like a wet and mangy mongrel, and for every looping flight a tap on the wing and a reminder that wax cannot hold the feathers firm too near the <span class=\"lastword\">sun.</span></p><p><cite>John Steinbeck</cite></p>'
quote[14]='<p>A book is a part of life, a manifestation of life, just as much as a tree or a horse or a star. It obeys its own rhythms, its own laws, whether it be a novel, a play, or a diary. The deep, hidden rhythm of life is always there—that of the pulse, the heart <span class=\"lastword\">beat.</span></p><p><cite>Henry Miller</cite></p>'

var ry=Math.floor(Math.random()*quote.length);
if (ry==0)
ry=1;
var container = document.getElementById("quote");
var oldtext = document.getElementById("block");
var bq = document.createElement("blockquote");
container.replaceChild(bq, oldtext);
bq.innerHTML = (quote[ry]);
document.getElementById("quote").appendChild(bq);
}
/* cart form validation */


