var downloadspage = false;

//UTILITY
function isIE() {
	return document.all && !window.opera ? true : false;
}
function isIE7() {
	return isIE() && document.documentElement && typeof document.documentElement.style.maxHeight != "undefined" ? true : false;
}
function islteIE6() {
	return (document.all && !window.opera) && !(document.documentElement && typeof document.documentElement.style.maxHeight != "undefined") ? true : false;
}
function up(srcEl, tag) {
	var _el = srcEl;
	while(_el.tagName != tag.toUpperCase()) { _el = _el.parentNode; }	
	return _el;
}


//TABS
function activateTabs() {
	if(document.getElementById('tabs') == null) {
		return;
	}
	var _src = document.getElementById('tabs');
	var _tabs =	_src.getElementsByTagName('a');
	for (var i = 0; i < _tabs.length; i++) {
		var _tab = _tabs[i];
		_tab.onclick = function() {
		
		document.getElementById('body').className = this.className + 'Active_';


		//force a sifr replace by removing classname ...
		var _activeTab = document.getElementById(this.className);
		var _objs = _activeTab.getElementsByTagName('object');
		for(var i = 0; i < _objs.length; i++) {
			var _obj = _objs[i];
			if(_obj.parentNode.className.indexOf('sIFR-replaced') != -1) {
				_obj.parentNode.className = _obj.parentNode.className.replace('sIFR-replaced','');
			}
		}

		
		//do again since the hidden tab intros don't get replaced
		sIFR.replace(GE_Inspira_Medium, { 
			selector: 'p.intro,p.sm-intro,p.tab-intro', 
			css: [ '.sIFR-root { color: #3b73b9 }','em { font-style: normal; color: #000000; }' ],
			wmode: 'transparent'
		});
		sIFR.replace(GE_Inspira_Medium, { 
			selector: '.aside h4', 
			css: [ '.sIFR-root { color: #3b73b9 }' ],
			wmode: 'transparent'
		});
		//sIFR.replace(GE_Inspira_Medium, { 
			//selector: 'p.tab-intro', 
			//css: [ '.sIFR-root { color: #666666 }' ],
			//tuneHeight: isIE7() ? 0 : -4, 
			//offsetTop: -1, 
			//wmode: 'transparent'
		//});	

			return false;
		}
	}
	//set default to first tab
	document.getElementById('body').className = 'tab1Active_';
}




//HOVERS
function attachTableHovers(){
	if(!document.getElementById(CONTENT_CONTAINER)) {
		return;
	}
	//handle table data cells
	var _tablecells = document.getElementById(CONTENT_CONTAINER).getElementsByTagName('td');
	var _isFinTable = true;
	for (var i = 0; i < _tablecells.length; i++) {
		var _cell = _tablecells[i];
		if(_cell._col == null) {
			//get the table (only need financial tables)	
			var _table = up(_cell, 'table');
			if(_table.className.indexOf('financials') == -1) {
				_isFinTable = false;
			} else {
				//get the col ... will be same index as the cell
				var _col = _table.getElementsByTagName('col')[_cell.cellIndex];
				//store orig class strings for col and cell
				if(_col._className == null) {
					_col._className = _col.className;
				}
				_cell._className = _cell.className;
				//store ref to col on table cell
				_cell._col = _col;
			}
		}
		if(_isFinTable) {
			//attach events	
			_cell.onmouseover = function() {
				//do hover on the cell (lte IE6 only)
				if(islteIE6()) {
					this.className = this._className + ' hover_';					
				}
				this._col.className = this._col._className + ' hover_';
			}
			_cell.onmouseout = function() {
				//remove hover on the cell (lte IE6 only)
				if(islteIE6()) {
					this.className = this._className;
				}
				this._col.className = this._col._className;
			}			
		}
	}
	//handle table rows (lte IE6 only)
	if(_isFinTable && islteIE6()) {
		var _tablerows = document.getElementById(CONTENT_CONTAINER).getElementsByTagName('tr');
		for (var i = 0; i < _tablerows.length; i++) {
			var _row = _tablerows[i];
			//store orig class strings for row
			_row._className = _row.className;
			//attach events	
			_row.onmouseover = function() {
				this.className = this._className + ' hover_';					
			}
			_row.onmouseout = function() {
				this.className = this._className;
			}			
		}		
	}
}


function attachNavHover() {
	if(!islteIE6() || !document.getElementById(MENU_CONTAINER)) {
		return;
	}
	var _menuitems = document.getElementById(MENU_CONTAINER).getElementsByTagName('li');
	for (var i = 0; i < _menuitems.length; i++) {
		var _item = _menuitems[i];
		//store orig class
		if(_item._className == null) {
			_item._className = _item.className;
		}
		_item.onmouseover = function(){
			this.className = this._className + ' hover_';
			if(downloadspage==true && this.id == 'nav-financials'){
				e = document.getElementById('country')
				e.style.display = 'none';
			}
		}
		_item.onmouseout = function(){
			this.className = this._className;
			if(downloadspage==true){
				e = document.getElementById('country')
				e.style.display = 'block';
			}
		}	
	}
	if(!document.getElementById(NAVIGATION_CONTAINER)) {
		return;
	}
	var _sectionitems = document.getElementById(NAVIGATION_CONTAINER).getElementsByTagName('li');
	for (var i = 0; i < _sectionitems.length; i++) {
		var _item = _sectionitems[i];
		//can only be attached to items with subnav
		if (_item.className.indexOf('parent-nav') != -1) {
			//store orig class
			if(_item._className == null) {
				_item._className = _item.className;
			}
			_item.onmouseover = function(){
				this.className = this._className + ' hover_';
			}
			_item.onmouseout = function(){
				this.className = this._className;
			}
		}
	}
}


