var pathButtons = "/misc/buttons/";
var maxImageWidth = 640;
var maxImageHeight = 480;
var minImageWidth = 256;
var minImageHeight = 196;

function openWindow(sURL) //Opens a new window to url
{	window.open(sURL);	}

function onTimer(sFunc, iPause)//Run a function after a pause
{	window.setTimeout(sFunc, iPause);	}

function swapImg (sID, i) // Swap an image by changing the integer char - last char of ID filename)
{	document.getElementById(sID).src = pathButtons + sID + "_" + i + ".jpg";	}


function flashB6(){
	var i, sID;
	var	imgSource = "http://" + window.location.hostname + pathButtons + "b6_0.jpg";
	var imgs=document.getElementsByTagName('img');  //get array of all images

	for(i=0; i<imgs.length; i++){
		sID = imgs[i].id;
		if(sID.substring(0,2)=="b6"){
			if (document.getElementById(sID).src == imgSource)
				document.getElementById(sID).src = pathButtons + "b6_2.jpg";	
			else
				document.getElementById(sID).src = imgSource;		
		}
	}

	sFunc = "flashB6();";	// Set timer string
	onTimer (sFunc, 1000);	// Run timer to swap back & forth
}

function rollTicker(message, id, position) {
	var box = document.getElementById(id);
	var i, sFunc, m='';
	var s = String.fromCharCode(183, 32, 183, 32, 183, 32, 183, 32, 183);
	var separator = "     " + s + "     ";
//	var separator = "  -->  ";

	var bSize = box.size;
	
	if (message.length == 0) return;
	
	numCopies = (bSize / message.length) + 1;
	for(i=0; i < numCopies; i++){
		m = m + separator + message; } 
	
	box.value = m.substring(position, bSize + position + 15);
	position++;

	if (position == message.length + separator.length + 1) position = 0;	
	
	sFunc = "rollTicker('" + message + "', '" + id + "', " + position + ");"
	onTimer(sFunc,400); 

}


function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid chars above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         blnResult = false;         
      }
   return blnResult;
   }

function InRange (num, min, max)
// checks that num is in between min and max
{
  if (num < min || num > max) return false;
  return true;
}
