// Please leave URLs as relative!


// Set up & Populate array
var dropDownArray = new Array ("moreeLooker", "moreFeedback");
// Check browser
var ddArrayLength = 2;
var scriptWorks = false;
var scriptActive = false;
var currentMenu = "";
var agent=navigator.userAgent.toLowerCase();
var loaded = false;

if (((agent.indexOf("msie 6")>-1)||(agent.indexOf("msie 5")>-1)||(agent.indexOf("msie 4")>-1))&&(agent.indexOf("mac")==-1)) {
    scriptWorks = true;
}

// Monitor mouse
    
var mouseX = 0;
var mouseY = 0;

// Set up event capturing.
if (document.layers)
{
document.captureEvents(Event.MOUSEMOVE);
}

document.onmousemove = navBarGetMousePosition;

function navBarGetMousePosition(e) {
  // Save mouse pointer position.

  if (window.event) {
    mouseX = window.event.clientX + document.body.scrollLeft;
    mouseY = window.event.clientY + document.body.scrollTop;
	checkMouse();
  }
  else {
	mouseX = e.pageX;
	mouseY = e.pageY;
	checkMouse();
  }
}
// Initiate Variables

var shiftRate=60;
var brightest=153;

// Routines

function colourShift(item) {
if (scriptWorks) {
    item.style.color='#4d4d4d';
    var colorCode='';
    for (var i=0;(i*20)<=brightest;i++) {
        colorCode=i*20;
        eval("setTimeout('changeColour(\""+item.name+"\",\""+colorCode+"\")', shiftRate*i)");
        }
    }
}
    
function changeColour(item, colour) {
    var colourTemp = hexToDec(document.all[item].style.color.substring(1,3));
    if (colourTemp <= colour) {
        colour = decToHex(colour);
        document.all[item].style.color = "#"+ colour + colour + colour;
        }
    }
    
function randomShift() {
    var howMany = parseInt(5*Math.random());
    var done = new Array(10);
    var which;
    for (var i = 0; i < howMany; i++) {
        which = parseInt(10*Math.random());
        if (done[which]!=true) {
            eval("colourShift(a"+which+")");
            done[which] = true;
            }
        }
    }
    
function letsGo() {
if (scriptWorks) {
    timer=setInterval("randomShift();",800);
    }
}

// Conversion functions
		
var hexbase="0123456789ABCDEF";

// take a decimal integer, return 2-digit hex string
function decToHex(number) {
  return hexbase.charAt((number>> 4)& 0xf)+ hexbase.charAt(number& 0xf);
}

// take a hex string, return decimal integer
function hexToDec(number) {
  return parseInt(number.toUpperCase(), 16);
}

// Menu swapper

function colourChange(item,colour) {
if (document.all||document.getElementById) {
		item.style.color = "#"+ colour;
		}
	}
	
// Set up variables
var window_width;
var menu_start;
var old_menu;
var currentMenu;
var do_it = "no";


// Get width of client browser window
function getInsideWindowWidth() {
	scriptActive = true;
	if (document.all) {
		window_width = document.body.clientWidth;
	}
	else {
	window_width = window.innerWidth;
	}
	whereToStart();
}

// Find where the menu starts
function whereToStart() {
		window_width = window_width - 730;
		window_width = window_width / 2;
		menu_start = window_width + 176;
		setPositioning();
	}


// Set positioning for sub menus
function setPositioning() {

if (document.all&&(agent.indexOf("mac")==-1)) {

	for (i=0;i<ddArrayLength;i++) {
	menuRef = eval("document.all."+dropDownArray[i]+".style");
	menuRef.top = 131;
	}
	document.all.moreeLooker.style.left = (menu_start + 33);
	document.all.moreFeedback.style.left = (menu_start + 78);
	
		}
else if (document.getElementById&&(agent.indexOf("mac")==-1)) {

	for (i=0;i<ddArrayLength;i++) {
	menuRef = eval("document.getElementById('"+dropDownArray[i]+"').style");
	menuRef.top = 150;
	}
	document.getElementById('moreeLooker').style.left = (menu_start - 149);
	document.getElementById('moreFeedback').style.left = (menu_start - 90);
	
	}
else if (document.layers) {
for (i=0;i<ddArrayLength;i++) {
	menuRef = eval("document."+dropDownArray[i]);
	menuRef.top = 131;
	}
	document.moreeLooker.left = (menu_start + 18);
	document.moreFeedback.left = (menu_start + 63);
	
	}
	//this is for mac ie (bit screwed)
else if ((agent.indexOf("mac")!=-1))
	{
	//alert(menu_start);
	document.getElementById('moreeLooker').style.left = (menu_start - 493);
	document.getElementById('moreFeedback').style.left = (menu_start - 420);
	
	}
}

// Hide all sub menus
function hide() {
if (loaded) {
	if (document.all&&(agent.indexOf("mac")==-1)) {
		
			for(count = 0; count <= ddArrayLength; count++)
			{
				theMenu = document.all(dropDownArray[count]);
				//alert(theMenu.style.display)
		  		if (theMenu.style.display == 'block') {
		   	 	theMenu.style.display = 'none';
		  		}
		}
		scriptActive = false;
	}
	else if (document.getElementById) {
	
			for(count=0;count<ddArrayLength;count++)
			{
				theMenu = eval("document.getElementById('"+dropDownArray[count]+"')");
		  		if (theMenu.style.display == 'block') {
		   	 	theMenu.style.display = 'none';
		  		}
		}
		scriptActive = false;	
	}
	
	else if (document.layers) {
	for(count=0;count<ddArrayLength;count++)
				{
				theMenu = eval("document."+dropDownArray[count]);
		  		if (theMenu.visibility == 'show') {
		   	 	theMenu.visibility = 'hide';
		  		}
		}
	}
	scriptActive = false;
}
}
// Display sub menus
function reveal(menu) {
if (loaded) {
old_menu = dropDownArray[menu];
			hide();
	if (document.all&&(agent.indexOf("mac")==-1)) {
		
		//if (currentMenu != old_menu) {
		  	theMenu = eval("document.all."+old_menu+".style");
		  //	if (theMenu.display == 'block') {
		  // 	 theMenu.display = 'none';
		  		//} 
			//else {
		  	  theMenu.display = 'block';
		 	//	}
			//currentMenu = old_menu
			//}
			
		}
		// this is for netscape 6
		else if (document.getElementById){
		//alert("show wiv get element");
			//if (currentMenu != old_menu) {
			  	theMenu = eval("document.getElementById('"+old_menu+"').style");
			  //	if (theMenu.display == 'block') {
			  // 	 theMenu.display = 'none';
			  //		} 
				//else {
			  	  theMenu.display = 'block';
			 	//	}
			//	currentMenu = old_menu
			//	}
			}

		
		// this is for netscape 4
		else if (document.layers){
			//if (currentMenu != old_menu) {
			  	theMenu = eval("document."+old_menu);
			  	if (theMenu.visibility == 'show') {
			   	 theMenu.visibility = 'hide';
			  		} 
				else {
			  	  theMenu.visibility = 'show';
			 		}
				//currentMenu = old_menu
				//}
				
			}
			scriptActive = true;
		}
		
	}

// hide menus if mouse out
function checkMouse() {
	if (scriptActive) {
		//if (currentMenu != "") {
		//window.status = "Y : " + mouseY + "X : " + mouseX;
			if (mouseY < 117 || mouseY > 376 || mouseX < menu_start || mouseX >menu_start+560) {
				hide();
				//currentMenu="";
				}
			//}
		}
	}

// email a friend function	
function emailfriends ()
{ 
	myWindow = window.open('/emailafriend.asp', 'emailafriend','resizable=no,toolbar=no,location=no,scrollbars=yes,width=500,height=420') 
	myWindow.window.focus() 
} 

function setClearer()
{
document.onmousemove=navBarGetMousePosition;
}

function on(st) {
	st.style.backgroundColor="#ccccff";
	}

function off(st) {
	st.style.backgroundColor="#ffffff";
	}	
	
// pop-up functions for reuters

function pop(url) {
	window.open(url,'welcome','width=620, height=420, resizable=no, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0');

}

function popa(url) {
	window.open(url,'welcome','width=300, height=300, resizable=no, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0');

}

