//SWAP IMAGE
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function swapImage() {
	strImage = (arguments[1]=='on')?'style/images/leftmenu_r.gif':'style/images/leftmenu.gif';
	MM_swapImage(arguments[0],'',strImage,1)
}

function MM_homeMenu(targ,selObj,restore){ //v3.0
	if (selObj.selectedIndex == 4 || selObj.selectedIndex == 0 ) {
			eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		}
		else {
			window.open(selObj.options[selObj.selectedIndex].value,'new')
		}
  if (restore) selObj.selectedIndex=0;
	return false;
}



// Exit disclaimer
var popupWidth;
var popupHeight;

// check type size
function textSizeDetect() {
	var intTextSize = (document.layers)?document.layers["textsizedetect"]:(document.all)?document.all["textsizedetect"]:(document.getElementById)?document.getElementById("textsizedetect"):"";

	if (intTextSize) {
		 intTextSize = intTextSize.offsetHeight
	}
	if (intTextSize>14){
		//set the height and width of the popup
		popupWidth=220;
		popupHeight=240;
	} else if (intTextSize>12){
		//set the height and width of the popup
		popupWidth=220;
		popupHeight=220;
	} else{
		popupWidth=220;
		popupHeight=200;
	
	}
}


// get all links with the class name disclaimer and add to them
// an onclick event going to the disclaimer, and an onKeyPress event 
// going to the onClick event
function doPopups() {
  if (!document.getElementsByTagName) return false;
  var links = document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("disclaimer")) {
      links[i].onclick = function() {
		textSizeDetect()
		window.open(this.href,'disclaimer','width='+popupWidth+',height='+popupHeight+',scrollbars=auto,resizable');
        return false;
      }
	  links[i].onkeypress = function(){
	  	verifyKey(this,'this.onclick();');
	  }
    }
  }
}
// Called in on index.asp
// window.onload = doPopups;

/*opens links in a new window*/
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if(anchor.getAttribute("href")&&anchor.getAttribute("rel") == "external"){
			anchor.target = "_blank";
			var strTitle = anchor.getAttribute("title");
			if((strTitle=="")||(strTitle==null)){
				anchor.title = "Opens in a new browser window.";
			} else {
				if(strTitle.indexOf("browser window")<0){
					anchor.title = strTitle+". Opens in a new browser window.";
				}
			}
			var strTitle = "";
		}
	}
}
window.onload=externalLinks;


// Keypress checker
function verifyKey(oElement,oEvent){
  if(oEvent.keyCode==13 && oElement.onclick){
     oEvent();
  }
}



// -----------------------------
// --- form button rollovers ---
// -----------------------------
function highlight(element) {
 element.className = 'button_f2';
}
function restore(element) {
 element.className = 'button';
}




// -----------------------------
// --- Print Page
// -----------------------------


function printpage() {
	window.print();  
}

// -----------------------------
// --- SET COOKIE FOR FONT SIZE
// -----------------------------


function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}


function setfontsize(multiplier) 
{
	if (document.body.style.fontSize == "") { 
		document.body.style.fontSize = "1em";  
	}  
   
	//Set fontsize without refreshing page
	if (multiplier == 'small') { document.body.style.fontSize = "0.7em"; size="0.7em"; }
	if (multiplier == 'medium') { document.body.style.fontSize = "0.8em"; size="0.8em"; }
	if (multiplier == 'large') { document.body.style.fontSize = "0.9em"; size="0.9em"; }

	document.cookie="fontsize="+size
}


function checkfontsize() {
	var x = getCookie('fontsize');
	document.body.style.fontSize = x;
}

//Table rollover


function tableruler()
{
	if (document.getElementById && document.createTextNode)
	{
		var tables=document.getElementsByTagName('table');
		for (var i=0;i<tables.length;i++)
		{
			if(tables[i].className=='financial')
			{
				var trs=tables[i].getElementsByTagName('tr');
				
				for(var j=0;j<trs.length;j++)
				{
					

					if(trs[j].parentNode.nodeName=='TBODY')
					{

						var orginalClass = trs[j].className;
	
						if (orginalClass=="line") 
						{
							trs[j].onmouseover=function(){this.className='line row_highlight';return false}
							trs[j].onmouseout=function(){this.className='line';return false}
						}
						else if (orginalClass=="line2x") 
						{
							trs[j].onmouseover=function(){this.className='line2x row_highlight';return false}
							trs[j].onmouseout=function(){this.className='line2x';return false}
						}
						else if (orginalClass=="padtop")
						{
							trs[j].onmouseover=function(){this.className='padtop row_highlight';return false}
							trs[j].onmouseout=function(){this.className='padtop';return false}
						}
						else if (orginalClass=="padtop2x")
						{
							trs[j].onmouseover=function(){this.className='padtop2x row_highlight';return false}
							trs[j].onmouseout=function(){this.className='padtop2x';return false}
						}
						else 
						{
						
							trs[j].onmouseover=function(){this.className='row_highlight';return false}
							trs[j].onmouseout=function(){this.className='';return false}
						}
					}
				}
			}
		}
	}
}



function onloadtrigger(){
	externalLinks();
	checkfontsize();
}

window.onload = onloadtrigger;
