/*
  ------------------------------------
  Changes document element to suit browser
  ------------------------------------
*/
function brwsEle(element){
	if (document.all){ // Opera and IE
		docElement = document.all[element];
	}else if (document.getElementById && !document.all){ // Firefox, Mozilla, and Netscape
		docElement = document.getElementById(element);
	}else{  // if (document.layers) Very early Netscape, like 4.8 early!
		docElement = document.layers[element];
	}
}
/*
  ------------------------------------
  Changes style display to suit browser - hidden or none
  ------------------------------------
*/
function brwsDsply(display){
	if (display=="show" && !document.layers){
		styleDsply = "block";
	}else if (display=="show" && document.layers){ 
		styleDsply = "visible";
	}else if (display=="hide" && !document.layers){ 
		styleDsply = "none";
	}else{  // if (display=="hide" && document.layers)
		styleDsply = "hidden";
	}
}

// Flexible pop-up window function
function XENewWindow(mypage, myname, w, h, scroll,amountFrom,to,template) {
	if (amountFrom != void 0 || to != void 0){
		  splitArray = amountFrom.split(' ');
		  if (template != void 0 ){
		  	convertPage = 'Amount=' + splitArray[0] + '&From=' + splitArray[1] + '&To=' + to + '&template=' + template;
		  }else{
			convertPage = 'Amount=' + splitArray[0] + '&From=' + splitArray[1] + '&To=' + to;
		  }
	  } else {
		  convertPage='';
	  }
	mypage = mypage + convertPage;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
}

// Pop-up window function to get around Firefox tabs... so not meant to really be a popup, keep address bar, etc.
function XEOpen(mypage) {
	winprops = 'scrollbars=1,menubar=1,resizable=1,location=1,toolbar=1,status=1'
	win = window.open(mypage, 'XEtradeNew', winprops)
}

// Alternate row colours of table
function alternate()
{
	var idTag = "alternateRows";
	var tableArray = document.getElementsByTagName("table");
	
	for (var tableIndex = 0; tableIndex < tableArray.length; tableIndex++) 
	{
		var table = tableArray[tableIndex];
		
		if(table.id != null && table.id.indexOf(idTag) == 0) 
		{
			var rowArray = table.getElementsByTagName("tr");
			
   			for(var rowIndex = 0; rowIndex < rowArray.length; rowIndex++)
			{
				var columnArray =  rowArray[rowIndex].getElementsByTagName("td");
				
				for(columnIndex = 0; columnIndex < columnArray.length; columnIndex++)
				{
					var column = columnArray[columnIndex];
					var className = column.className;
					
					if(className == null || !(className == "dh" || className == "dhBlue"))
					{
						if(rowIndex % 2 == 0)
						{
							column.className = "d0";
						}
						else
						{
							column.className = "d1";
						}
	   				}
				}
			}
		} // end if
	}
}