//Scripts for Wimbledon Books & Music
//Written by, and copyright M.Ruttley, Mohiga Media 2007

var delay = 3000; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=50; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(255,255,255); // start color (red, green, blue)
var endcolor=new Array(0,0,0); // end color (red, green, blue)

var fcontent=new Array();
begintag='<div style="font: normal 14px Arial; padding: 5px; align: center;" align="center" z-index:1;>'; //set opening tag, such as font declarations
fcontent[0]="<img src=\"images/booktable200.gif\" height=150 width=200>&nbsp;&nbsp;&nbsp;<img height=100 width=141 src=\"images/rathan-with-books.gif\">&nbsp;&nbsp;&nbsp;<img height=135 width=150 src=\"images/shop-exterior.gif\">";
fcontent[1]="<table border=\"0\" ><tr><td width=\"120\"><img border=\"0\" src=\"images/oathbreaker.jpg\" height=\"150\" /></td><td width=\"350\"><font face=\"Verdana\"><b>FEATURED BOOK</b><p>Michelle Paver will be signing copies of her new book 'OATH BREAKER'<br />on Saturday 6th September at 11.30</font><p>&nbsp;</td><td><img src=\"http://194.68.4.204/semic/c/20451C.jpg\" height=\"150\" /></td></tr>";
// fcontent[2]="<table border=\"0\" width=\"488\" height=\"115\"><tr><td height=\"115\" width=\"96\"><font face=\"Verdana\"><img border=\"0\" src=\"images/9815_new_ayres.jpg\"></font></td><td height=\"115\" width=\"316\"><p><font face=\"Verdana\">We also sell rocking horses such as this faithful reproduction of the 19th century F.A. Ayres original, in medium size.</font><p><a href=\"index.php?page=rockinghorses\">Rocking Horses</a></td></tr>";
closetag='</div>';

var fwidth='660px'; //set scroller width
var fheight='170px'; //set scroller height

var fadelinks=1;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.
///No need to edit below this line/////////////////


var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=0;

function cycleImages()
{


if (ie4||DOM2)
  document.write('<div id="fscroller" style="border:1px solid black;width:'+fwidth+';height:'+fheight+'"></div>');

if (window.addEventListener)
window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent)
else if (document.getElementById)
window.onload=changecontent

}

/*Rafael Raposo edited function*/
//function to change content
function changecontent(){
  if (index>=fcontent.length)
    index=0
  if (DOM2){
    document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
    document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
    if (fadelinks)
      linkcolorchange(1);
    colorfade(1, 15);
  }
  else if (ie4)
    document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
  index++
}

// colorfade() partially by Marcio Galli for Netscape Communications.  ////////////
// Modified by Dynamicdrive.com

function linkcolorchange(step){
  var obj=document.getElementById("fscroller").getElementsByTagName("A");
  if (obj.length>0){
    for (i=0;i<obj.length;i++)
      obj[i].style.color=getstepcolor(step);
  }
}

/*Rafael Raposo edited function*/
var fadecounter;
function colorfade(step) {
  if(step<=maxsteps) {	
    document.getElementById("fscroller").style.color=getstepcolor(step);
    if (fadelinks)
      linkcolorchange(step);
    step++;
    fadecounter=setTimeout("colorfade("+step+")",stepdelay);
  }else{
    clearTimeout(fadecounter);
    document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
    setTimeout("changecontent()", delay);
	
  }   
}

/*Rafael Raposo's new function*/
function getstepcolor(step) {
  var diff
  var newcolor=new Array(3);
  for(var i=0;i<3;i++) {
    diff = (startcolor[i]-endcolor[i]);
    if(diff > 0) {
      newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
    } else {
      newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
    }
  }
  return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}



function openR(areaname)
{
var openup = document.getElementById(areaname)
openup.innerHTML = book1review
}

function delayer()
{
var texta = document.getElementByID("text1a")
texta.innerHTML = "HTML"
}

function buybutton()
{
	var conf = confirm( "Wimbledon Books website is currently under development, and the payment system is not yet fully functional. \n \nIf you would like to order this book, please telephone us or send us an email - click OK to proceed to the contact information page, or cancel to stay here. \n\nMany Thanks,\nWimbledon Books 2007")
	 
	 if(conf)
	 {
	 	location.href = "index.php?page=howtofindus"
	 }
}

function closeWin()
{
var fArea = document.getElementById("flyer")
fArea.style.visibility="hidden"
}
function openWin()
{
var fArea = document.getElementById("flyer")
fArea.style.visibility="visible"
}

function openReview(isbn,title,author)
{
	var w=window.open("", "Information", "width=550 height=450 status=yes resizeable=yes location=no");
	var d=w.document;
	d.open();
	d.write('<font face="Arial">');
	d.write('<h1>' + title + '</h1>');
	d.write('<h3>' + author + '</h3>');
	d.write('<table border="0" width="500" height="299" cellpadding="2">');
	d.write('<tr>');
	d.write('<td bgcolor="#84FFFF">');
	d.write('<img height="197" width="128" src="http://images.bertrams.com/Multimedia/GetImages?imageSource=BERT&quality=WEB&component=FRONTCOVER&ean13=' +isbn+ '" />'); 
	d.write('</td>');
	d.write('<td align="left" valign="top" bgcolor="#84FFFF">');
	d.write('<p>Paperback<br>&pound;7.99</p>');
	d.write('<p>Supremely authentic account of the Arthurian legend. Cornwell takes us into the heart of fifth century Britain, an island of fractious kingdoms struggling to repel Saxon invaders, accommodate an aggressive Middle Eastern sect and cope with Roman withdrawal from empire.<br />');
	d.write("Excellent characterisation, unrivalled descriptive skills and a gripping narrative make this the best of Cornwell's work.</p>");
	d.write('</td>');
	d.write('</tr>');
	d.write('</table>');
	d.write('</font>');

	d.close();
}



