var GLOB_currentHO = null;
var leftnavDelay = 250;
function RemoveHover(elm){}
function CreateHover(elm,path){}

$j(document).ready(function () {		
	$j('#newLeftNav').find('div.SubLink,div.MainLink').each( function(){
		var dom = $j(this).find('div:first');
		$j.get($j(this).attr('rel'), function(data){
			dom.html($j.browser.msie == true && $j.browser.version < 7.0 ? '<iframe class="fixOverlay"></iframe>'+data : data);
			if(dom.find('td.daughterWindow_bottomcol').html() == '')dom.find('td.daughterWindow_bottomcol').remove();
		});
	});

	$j('#newLeftNav').find('div.SubLink,div.MainLink').mousemove(function(e){
		GLOB_currentHO = '#'+$j(this).attr('id');
	}); 

	$j('#newLeftNav').mouseout( function(){ GLOB_currentHO = null; });
	LeftNavInit();
});

function LeftNavInit(){
	HideLN();
	if(GLOB_currentHO)ShowLN(GLOB_currentHO);
	setTimeout("LeftNavInit()",leftnavDelay);
}

function ShowLN(elm){
	$j(elm).find('div:first').css({'top':($j(elm).position().top -1)+'px','left':($j(elm).position().left + $j(elm).width() + 10)+'px'});
	$j(elm).attr('class', NewClass(elm,'','Over','','Hover') );
	$j(elm).find('a:first').css('color','#FFFFFF');
	$j(elm).find('div:first').show();
	OnState(elm);
}

function HideLN(){
	$j('div.daughterWindow').each( function(){
		if('#'+$j(this).parent().attr('id') != GLOB_currentHO){
			var elm = $j(this).parent();
			$j(elm).find('div:first').hide();
			$j(elm).attr('class', NewClass(elm,'Over','','Hover','') );
			if( $j(elm).hasClass('MainLink MainLinkArrow marginBottom') || $j(elm).hasClass('MainLink MainLinkArrowHover marginBottom') )
				$j(elm).find('a:first').css('color','#454545');
			if( $j(elm).hasClass('SubLink') )
				$j(elm).find('a:first').css('color','#0575b9');
			OnState(elm);
		}
	});
}

function OnState(elm){
	var URLpath = location.pathname.split("/");
	var URLlocation = "/"+URLpath[1]+"/"
	if(URLpath[1] == 'trading')URLlocation += URLpath[2]+"/";
//$j('#Header').html(URLlocation);
	if($j(elm).find('a:first').attr('href') == URLlocation){
		if($j(elm).attr('class') == 'SubLink' || $j(elm).attr('class') == 'SubLinkOver'){
			$j(elm).css('background', $j(elm).attr('class') == 'SubLink' ? '#EEEEEE' : '#E78901');
			$j(elm).find('a:first').css({'color': $j(elm).attr('class') == 'SubLink' ? '#cc6600' : '#FFFFFF'});
		}
		if($j(elm).attr('class') == 'MainLink MainLinkArrow marginBottom' || $j(elm).attr('class') == 'MainLink MainLinkArrowHover marginBottom'){
			$j(elm).css('background', $j(elm).attr('class') == 'MainLink MainLinkArrow marginBottom' ? '#FFFFFF' : '#E78901');
			$j(elm).find('a:first').css({'font-weight':'bold','color':$j(elm).attr('class') == 'MainLink MainLinkArrow marginBottom' ? '#cc6600' : '#FFFFFF'});
		}
	}
}

function NewClass(elm,over,newover,hover,newhover){
	if($j(elm).attr('class')  == 'SubLink'+over)
		return 'SubLink'+newover;
	if($j(elm).attr('class')  == 'MainLink MainLinkArrow'+hover+' marginBottom')
		return 'MainLink MainLinkArrow'+newhover+' marginBottom';
}

function getAbsX(elt) { return $j(elt).position().left; }
function getAbsY(elt) { return $j(elt).position().top; }

function DoPrintProdPage(){
	window.print(); 
}
 
function DoEmailProdPage(){
	var myWindow = window.open('/popup/email.html','_blank','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no,width=565,height=350');
}

function AboutThisReportLink(link){
	var myWindow = window.open(link,'_blank','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no,width=565,height=350');
} 