//   Change next line for your text msg.

var hD="0123456789ABCDEF";
function d2h(d) {
var h = hD.substr(d&15,1);
while(d>15) {d>>=4;h=hD.substr(d&15,1)+h;}
return h;
}
function h2d(h) {return parseInt(h,16);} 
function right(str, num) {return str.substring(str.length-num);} // pull out right num

var msg = ''
var colorTimer = null;
var c = new Array();

function cnext(i){
  if (i>ml+steps) return;
  for (j=-steps;j<=steps;j++) {
    if ((i>=-j)&&(i<ml-j)) document.getElementById('colorizer' + (i+j)).style.backgroundColor = c[j];
  }
  colorTimer = window.setTimeout('cnext('+(i+1)+')',10);
}

function buildc(){
  ml=msg.length;
  c1='#ffe500';
  c2='#0101cc';
  steps=8;
  dec11=h2d(c1.substring(1,3)); dec12=h2d(c1.substring(3,5)); dec13=h2d(c1.substring(5,7));
  dec21=h2d(c2.substring(1,3)); dec22=h2d(c2.substring(3,5)); dec23=h2d(c2.substring(5,7));
  dif1=(dec21-dec11)/steps; dif2=(dec22-dec12)/steps; dif3=(dec23-dec13)/steps;
  c[0]=c1;
  for (j=1;j<=steps;j++) {
    dec11=dec11+dif1; dec12=dec12+dif2;	dec13=dec13+dif3;
	hex1=d2h(dec11); hex2=d2h(dec12); hex3=d2h(dec13);
	hexcolor="#"+right(('0'+hex1),2)+right(('0'+hex2),2)+right(('0'+hex3),2);
	c[-j]=hexcolor;
	c[j]=hexcolor;
  }
}

function colorize(){
  if (!document.getElementById) return;
  buildc();
  cnext(-3);
}

//function changeImage(btn, bOver, bCurrent) {
//  if (bOver){
//    newImage = "url('images/btn/btnHov"; 
//  } else {
//    if (bCurrent){
//      newImage = "url('images/btn/btnCur";
//    } else {
//      newImage = "url('images/btn/btnOth";
//    }
//  }
//  document.getElementById(btn+'a').style.backgroundImage = newImage+"0.gif')";
//  document.getElementById(btn+'b').style.backgroundImage = newImage+"1.gif')";
//  document.getElementById(btn+'c').style.backgroundImage = newImage+"2.gif')";
//}
function changeImage(btn, bOver, bCurrent) {
  // btn = button id
  // bOver = true if hover color
  // bCurrent = true if this is the current button
  if (bOver){
    newImage = "url('images/btn/btnHov"; 
  } else {
	if (bCurrent){
      newImage = "url('images/btn/btnCur";
    } else {
      newImage = "url('images/btn/btnOth";
	}
  }
  document.getElementById(btn+'a').style.backgroundImage = newImage+"0.gif')";
  document.getElementById(btn+'b').style.backgroundImage = newImage+"1.gif')";
  document.getElementById(btn+'c').style.backgroundImage = newImage+"2.gif')";
  if (bOver){
	document.getElementById(btn+'d').style.textDecoration = 'underline';
	document.getElementById(btn+'d').style.color= "#0000CC";
	document.getElementById(btn+'b').style.cursor= "pointer";
  } else {
	document.getElementById(btn+'d').style.textDecoration = 'none';
    document.getElementById(btn+'d').style.color= "#ffffff";
    document.getElementById(btn+'b').style.cursor= "normal";
  }
}


var flashMenuTimer = null;
var menuCt=0;
var curBtnId=-1;
function flashMenu(menuId, bOn) {
  if (curBtnId!=0) return;
  if (!document.getElementById) return;
  if (menuId>=menuCt) return;
  bCurrent=(menuId==curBtnId);
  changeImage('MenuBtn'+menuId, bOn, bCurrent);
  if (bOn){
    flashMenuTimer = window.setTimeout('flashMenu('+(menuId)+', false)',100);
  }else{
    flashMenuTimer = window.setTimeout('flashMenu('+(menuId+1)+', true)',10);
  }
}

function beginFlashMenu(menuId, bOn) {
  if (curBtnId!=0) return;
 //   flashMenuTimer = window.setTimeout('flashMenu('+(menuId)+', true)',1000);
}

function beginPhotoChange() {
  if (curBtnId!=0) return;
	timeimgs('photo1', 1, 3, 5000);
	timeimgs('photo2', 1, 1, 7500);
	timeimgs('photo3', 1, 2, 10000);
	timeimgs('photo4', 1, 2, 12500);
}

function timeimgs(imgname, numb, imgmax, delay) { // Reusable timer
	thetimer = window.setTimeout("imgturn('" +imgname+ "', '" +numb+ "', '" +imgmax+ "')", delay);
	//numb=numb+1;
}

//if (document.images) { // Preloaded images
//demo1 = mew Image();
//demo2 = mew Image();
//demo3 = mew Image();
//demo4 = mew Image();
//}

function imgturn(imgname, numb, imgmax) { // Reusable image turner
	mydelay=10000;
	if (document.images) {
		document[imgname].src = 'images/index/'+imgname+'/Photo'+numb+'.gif';
		if (numb == imgmax) { // This will loop the image
			//document[imgname].src = eval("demo3.src");
			timeimgs(imgname, '1', imgmax, mydelay);
		} else { 
			//document[imgname].src = eval("demo" + numb + ".src");
			timeimgs(imgname, numb = ++numb, imgmax, mydelay);
		}
	}
}
