// Use this function to retrieve a cookie.
function getCookie(name){
var cname = name + "=";               
var dc = document.cookie;  
    if (dc.length > 0) {              
    begin = dc.indexOf(cname);       
        if (begin != -1) {           
        begin += cname.length; 
   
        end = dc.indexOf(";", begin);
            if (end == -1) end = dc.length;
            return unescape(dc.substring(begin, end));
        } 
    }
return null;
}
var i=0;

 function mailMe(form) {       
   i++;
   return true;
  }

 function startTime(){
  if (i != "O") {
   var time=new Date();
   hours=time.getHours();
   mins=time.getMinutes();
   secs=time.getSeconds();
   closeTime=hours*3600+mins*60+secs;
   closeTime+=3;
   Timer();
  }
 }
//Force the system to delay a second and redirect the browser to another page
  function Timer() {
  var time=new Date();
   hours=time.getHours();
   mins=time.getMinutes();
   secs=time.getSeconds();
   curTime=hours*3600+mins*60+secs;
   if (curTime>=closeTime) {
       location="thankyou.html";}
   else { window.setTimeout("Timer()",1000) }
 }

//Validate the email
function validate()
{
x=document.form
at=x.Email.value.indexOf("@")
if (at == -1)
	{
	alert("Not a valid e-mail")
	return false
	}
}

//Determine the browser's version number
var IsOld=0;
var IsNN5=0;
var IsIE5=0;
var brow=0;
function brows()
{
   brow=((navigator.appName)+(parseInt(navigator.appVersion)));
   if (parseInt(navigator.appVersion)<4) {
        IsOld=1;
        msg="Your browser is too old to view this page... Press Ok to install the new version"+brow
        if (confirm(msg))
             if (navigator.appName=="Netscape")
                location.replace("http://www.netscape.com")
 		else location.replace("http://www.microsoft.com")
     }
 }
      
function redirect1()
{
st=	"http://search.yahoo.com/bin/search?p="+escape(window.document.form.keywords.value);
 resultsWindow=window.open();
resultsWindow.document.write(st);
}

function search4(){
  var Yahoo = "http://search.yahoo.com/bin/search?p=";
  var Alta = "http://www.altavista.digital.com/cgi-bin/query?pg=q&what=web&q=";
  var InfoSeek = "http://guide-p.infoseek.com/Titles?qt=";
  var Excite = "http://www.excite.com/search.gw?searchType=Concept&search=";

  var plus=escape(window.document.form.keywords.value);

 var url = new Array(4);
 url[0] = Yahoo + plus;

 url[1] = Alta + plus + "&mode=and";
 url[2]= Excite + plus + "&category=default&mode=relevance&showqbe=1&display=html3,hb";
  url[3] = InfoSeek + plus + "&col=WW";

 resultsWindow=window.open();
 resultsWindow.document.open();
 resultsWindow.document.write("<head><title>Close this window to return to The Book Nook</title></head>");
 resultsWindow.document.write("<FRAMESET ROWS=50%,50%><FRAMESET COLS=50%,50%><FRAME NAME='frame0' SRC='" + url[0] + "'><FRAME NAME='frame1' SRC='" + url[1] + "'></FRAMESET>");
 resultsWindow.document.write("<FRAMESET COLS=50%,50%><FRAME NAME='frame2' SRC='" + url[2] + "'><FRAME NAME='frame3' SRC='" + url[3] + "'></FRAMESET></FRAMESET>");
        resultsWindow.document.close();
        }

function redirect()
{

if (window.document.form.search.value=="www")
   search4();
 else if (window.document.form.search.value=="bn") 
	 location.href="search1.html"                               ;
		
}

//scroll the document down 500px
function scrollit1(){ 
	for (I=1; I<=500; I++){ 	
		parent.scroll(1,I)  
	}
}


function openwindow()
{
window.open("Welcom1.html","my_new_window","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no")
}


function liveclock()
 {
  var curdate=new Date()
  var hours=curdate.getHours()
  var minutes=curdate.getMinutes()
  var seconds=curdate.getSeconds()
  var suffix="AM"
  if (hours>=12)
       {
       suffix="PM"
       if (hours>=13)
       hours-=12
       }
  if (minutes<10)
   minutes="0"+minutes
  if (seconds<10)
   seconds="0"+seconds
  var thetime=hours+":"+minutes+":"+seconds+" "+suffix
  window.status=thetime
  document.time.time2.value=thetime
  setTimeout("liveclock()",1000)
 }
