function swap(){
	this.className="msieFix";
}
function swapBack(){
	this.className="trigger";
}
function reveal(){
	this.parentNode.parentNode.parentNode.className="msieFix";
}
function setupdropmenus(){
	var LI = document.getElementById('mainmenu').getElementsByTagName("li");
	var zLI= LI.length;
	for(var k=0;k<zLI;k++){
		if(LI[k].id){
			LI[k].className="trigger";
			LI[k].onmouseover=swap;
			LI[k].onmouseout=swapBack;
		}
	}
}

/* Rollover functions */
function rollOn() { this.src = this.ovrsrc; }
function rollOff(){ this.src = this.orgsrc; }
function iamOn() {
  if(! document.getElementById ) return;
	var maxheight = document.getElementById("offers").clientHeight + "px";
	this.style.height = maxheight;
	this.style.backgroundImage = "url(/s/pix/bg-iam-y.png)";
}
function iamOff() {
	this.style.height = "auto";
	this.style.backgroundImage = "none";
}
function oskOn() {
  if(! document.getElementById ) return;
	var maxheight = document.getElementById("offers").clientHeight + "px";
	this.style.height = maxheight;
	this.style.backgroundImage = "url(/s/pix/bg-osk-y.png)";
}
function oskOff() {
	this.style.height = "auto";
	this.style.backgroundImage = "none";
}
function shineOn() {
  if(! document.getElementById ) return;
	var maxheight = document.getElementById("offers").clientHeight + "px";
	var bgbox     = this.parentNode.parentNode.parentNode;
	bgbox.style.height = maxheight;
	bgbox.style.backgroundImage = "url(/s/pix/bg-offers-v.png)";
}
function shineOff() {
  if(! document.getElementById ) return;
	var maxheight = document.getElementById("offers").offsetHeight + "px";
	var bgbox     = this.parentNode.parentNode.parentNode;
	bgbox.style.height = "auto";
	bgbox.style.backgroundImage = "none";
}
function setUpRoll(el) {
	if(el.src.lastIndexOf("-n.") != el.src.length - 6) return false;
  var temp       = el.src.replace(/\-n\.(gif|png|jpg)/, "-y.$1"); // Set rollover image
  // if(temp == el.src) return false; // No roll if image is already "active"
	el.orgsrc      = el.src;  // Remember original image
	el.ovrsrc      = temp;  // Remember original image
	el.onmouseover = rollOn;
	el.onmouseout  = rollOff;
  return true;
}
function usebglink() {
	document.location.href = this.bglink;
}
function setupactiveboxes(){
	// alert("Setting up active boxes");
	activeboxes = new Array("boxexpert", "boxsector", "boxclients", "boxwebsem", "boxkeynote");
	for (n=0;n<activeboxes.length; n++) {
		elid = activeboxes[n];
		// alert("Looking for element " + elid);
		if (el = document.getElementById(elid)) {
			// alert("Found it: " + elid);
			var elinks = el.getElementsByTagName("A");
			if (elinks.length > 0) {
				el.bglink = elinks[0].href;
				el.onclick = usebglink;
			}
		}
	}
}
function miniSrch(){
	// alert("Run minisearch");
  document.getElementById("searchform").submit();
  return false;
}

function primeSearchbox(){
	// On first keypress in a searchbox, clear the "search" value and activate the text link to send the form
	// alert("Key pressed");
	if(this.className == "used") return true;
	this.value = "";
  document.getElementById("minisearch").onclick = miniSrch;
	this.className = "used";
  return true;
}
function setUpRolls() { // Sets rollovers for all rollable images
  if(! document.getElementById ) return;

// Set up rollovers on all images marked as rollovers (filename ends in -n)
  var els = document.getElementsByTagName("IMG"); // Main menu links
  for (var i=0; i<els.length; i++){ setUpRoll(els[i]); }  

	// Set up rollovers on offer boxes 
	var offerbox;
	if( offerbox = document.getElementById("offers") ) { // Only present on home pages
	  document.getElementById("boxsso").onmouseover = iamOn;
	  document.getElementById("boxsso").onmouseout  = iamOff;
	  document.getElementById("boxidm").onmouseover = iamOn;
	  document.getElementById("boxidm").onmouseout  = iamOff;
	  document.getElementById("boxrm").onmouseover  = iamOn;
	  document.getElementById("boxrm").onmouseout   = iamOff;
	  document.getElementById("boxom").onmouseover  = oskOn;
	  document.getElementById("boxom").onmouseout   = oskOff;
	  document.getElementById("boxsk").onmouseover  = oskOn;
	  document.getElementById("boxsk").onmouseout   = oskOff;
	}

  // Set up minisearch
	if(document.getElementById("sbox") ) document.getElementById("sbox").onkeydown  = primeSearchbox; // Trigger search on entry

	setupactiveboxes();
	setupdropmenus();
}
