/* finance graph */
/*
var selectedNavigationMenuId = "indicesNavigationTabs";

var selectedFinTabTitleId = "TaTabTitle";
var selectedFinTabId = "TaTab";

var selectedIndicesTab = new Array();
selectedIndicesTab["TaTab"] = "TaTabIndex";
	
var selectedIndicesTabTitle = new Array();
selectedIndicesTabTitle["TaTab"] = "Index";

var iframeLinks = new Array();
iframeLinks["TaTabActiveIFrame"] = "/ibo/financeTools/hp/leadingStocks/10TaStocks.jhtml?subview=byPeriodIdent&period=5&secIdent=100&frameId=TaTabActiveIFrame";
iframeLinks["TaTabDownIFrame"] = "/ibo/financeTools/hp/leadingStocks/10TaStocks.jhtml?subview=byMonitorTypeAsc&period=5&secIdent=100&monitor=2&frameId=TaTabDownIFrame";
iframeLinks["TaTabUpIFrame"] = "/ibo/financeTools/hp/leadingStocks/10TaStocks.jhtml?subview=byMonitorTypeMon1Desc&period=5&secIdent=100&monitor=1&frameId=TaTabUpIFrame";
iframeLinks["TaTabIndexIFrame"] = "/ibo/financeTools/hp/indicesGraph.jhtml?rviewName=stockRates&subviewName=getStockes&indice0=1171&indice1=1230&indiceGraph=TaTabGrafImage&IndType=1&frameId=TaTabIndexIFrame";

function showIndicesTab(indicesTabTypeId){
//alert("indicesTabTypeId: " + indicesTabTypeId + " | " + selectedIndicesTabTitle[selectedFinTabId]);
	selectedIndicesTab[selectedFinTabId] = switchTabs(selectedFinTabId + indicesTabTypeId, selectedIndicesTab[selectedFinTabId]);
	selectedIndicesTabTitle[selectedFinTabId] = switchTabTitles(indicesTabTypeId, selectedIndicesTabTitle[selectedFinTabId], "indices");
}

function switchTabs(currTab, prevTab){
//alert("switchTabs : " + currTab + " | " + prevTab);
	var prevTabObj = document.getElementById(prevTab);
	var currTabObj = document.getElementById(currTab);
	
	var currTabIframe = document.getElementById(currTab + "IFrame");
//alert(currTab + "IFrame | " +   currTabIframe);
	if (!currTabIframe){		
		currTabIframe = document.getElementById(selectedIndicesTab[currTab] + "IFrame");
//alert(selectedIndicesTab[currTab] + "IFrame | " +   currTabIframe);
	}
	if (currTabIframe){
		currTabIframe.src = iframeLinks[currTabIframe.id];
		
	}
	
	if (prevTabObj && currTabObj){
		prevTabObj.style.display = "none";
		currTabObj.style.display = "block";
	}
	return currTab;
}

function switchTabTitles(currTitle, prevTitle, titleType){
//alert("switchTabTitles : " + currTitle + " | " + prevTitle + " | " + titleType);
	var prevTitleObj = document.getElementById(prevTitle);
	var currTitleObj = document.getElementById(currTitle);
	if (prevTitleObj){
		prevTitleObj.className = prevTitleObj.className.replace(titleType+"SelectedTab",titleType+"UnSelectedTab");
	}
	if (currTitleObj){
		currTitleObj.className = currTitleObj.className.replace(titleType+"UnSelectedTab",titleType+"SelectedTab");
	}	
	return currTitle;	
}

function makeMeVisible(objId){
	var currTabIframe = document.getElementById(objId);
	//alert(objId + " | " + currTabIframe);
	if (currTabIframe){
		currTabIframe.style.display = "block";
	}
}

function changeSrcForTmcGraphImg()
{
	var grafImg = document.getElementById(selectedFinTabId + "GrafImage");
	if (!grafImg){
		grafImg = getElementByIdFromSelectedIFrame(selectedFinTabId + "GrafImage");
	}
	if(grafImg){	
		var gifPath = "/tmc/i/g/mg" + selectedFinTabId + "GrafImage.gif";
		grafImg.src = gifPath + "?"+ getUrlExtra();
	}
}

function getElementByIdFromSelectedIFrame(elementId)
{
	var iframeName = selectedIndicesTab[selectedFinTabId] + "IFrame";
	//alert("iframeName: " + iframeName + " | " + elementId);
	var iframeWindow = window.frames[iframeName];
	//alert("iframeWindow: " + iframeWindow);
	if (iframeWindow){
		//alert("iframeWindow : " + iframeWindow.document.getElementById(elementId).id);
		return iframeWindow.document.getElementById(elementId);
	}else{
		return "undefined";
	}
}

var intervalID;
var loadGifInterval;
function startFinanceDataUpdate(functionName, loadUpdatePeriod)
{
	stopTmcFinanceDataUpdate();
	if (!loadUpdatePeriod){
		loadUpdatePeriod = 30000;
	}
	intervalID = window.setInterval(functionName, loadUpdatePeriod);
}

function stopTmcFinanceDataUpdate()
{
	if(intervalID != null){
		window.clearInterval (intervalID);
	}
}
*/

/* End finance graph graph */

//window.onresize = onResizeManager;//removing this row will remove the horizontall scroll on tmc homepage as long as it contains the finance bar.

function onResizeManager(){
	fixScroll();
}

function fixScroll()
{
	 if ((navigator.userAgent.indexOf("MSIE") > -1))
	{
		var contentHeight=document.body.offsetHeight-44+"px";
		var contentWidth=document.body.offsetWidth+"px";
		document.getElementById("container").style.height=contentHeight;
		document.getElementById("container").style.width=contentWidth;
		document.getElementById("container").style.overflowX='auto';
		document.getElementById("container").style.overflowY='scroll';
	}
	else
	{
		var contentHeight=document.body.offsetHeight-40+"px";
		document.getElementById("container").style.height=contentHeight;
		document.getElementById("container").style.overflow='auto';
	}
}
function setPhotoNameAndCredit(creditId, imgId, imgData){
//alert(imgId + " : " + imgData)
	var photo_credit = 0;
	var photo_name = 1;
	var photo_text = 2;
	var params = imgData.split("^");
	var imgObject = document.getElementById(imgId);
	
	if (imgObject){
		if ((params[photo_credit] != null) && (params[photo_credit] != "")){
			imgObject.alt = params[photo_credit];
			imgObject.title = params[photo_credit];
		}else{
			if (params[photo_name]){
				imgObject.alt = params[photo_name];
				imgObject.title = params[photo_name];
			}
		}
	}
	if (creditId){
		var creditObj = document.getElementById(creditId);
		if (creditObj){
			if ((params[photo_name] != null) && (params[photo_text] != null) && (params[photo_name] != "") && (params[photo_text] != "")){
				creditObj.innerHTML = params[photo_name] + ", " + params[photo_text] + "&nbsp;&nbsp;";
			}	
		}
	}
}

function resizeIframe(iframeId){
	var iframe = document.getElementById(iframeId);
	if (iframe){
		if(iframe.contentDocument){
			iframe.style.height = iframe.contentDocument.body.scrollHeight; 
		}
		else{
			var height = iframe.contentWindow.document.body.scrollHeight;;
			if (height > 0){
				iframe.style.height = iframe.contentWindow.document.body.scrollHeight;
			}			
		}
	}
	//alert(iframeId +  " | " + iframe.style.height + " | " + iframe.contentWindow.document.body.scrollHeight);
}

function buildURLNew(fld)
{
	if (fld == "") return false;
	var encodedField = "";
	var s = fld;
	if (typeof encodeURIComponent == "function")
	{
		// Use JavaScript built-in function
		// IE 5.5+ and Netscape 6+ and Mozilla
		encodedField = encodeURIComponent(s);
	}
	else 
	{
		// Need to mimic the JavaScript version
		// Netscape 4 and IE 4 and IE 5.0
		encodedField = encodeURIComponentNew(s);
	}	
	return encodedField;
}
/*start dynamic tags functions*/
var timerHideTagDiv;
function replaceSpecialChars(str)
{		
	while (str.indexOf("&quot;")!=-1)
		str = str.replace("&quot;",'~');
	
	while (str.indexOf("'")!=-1)
		str = str.replace("'",'*');	
		
	while (str.indexOf("&amp;")!=-1)
		str = str.replace("&amp;",'^');	
		
	while (str.indexOf("&")!=-1)
		str = str.replace("&",'^');	
			
	return str;
}
function replaceSpecialCharsBack(str)
{	
	while (str.indexOf('~')!=-1)
		str = str.replace('~',"&quot;");
	
	while (str.indexOf('*')!=-1)
		str = str.replace('*',"'");	
		
	while (str.indexOf('^')!=-1)
		str = str.replace('^',"&");	
	
	while (str.indexOf('+')!=-1)
		str = str.replace('+'," ");	
		
	return str;
}
function replaceSpace(str)
{	
	re = new RegExp(' ','g');
	return str.replace(re, '%20');	
}
function showTagsDiv(loadevt,x, slug, startPlace)
{	
	var val,obj;
	var crossevt=(window.event)? event : loadevt;		
	hideTagsDivNow();
	
	if (startPlace == null)
		startPlace = 1;
	
	var countTags = 0;
	var tableInDiv = '<table style="width:83px;" cellpadding="0" cellspacing="0" border="0" width="100%" dir="rtl">';
				
	for (var cnt = startPlace; cnt < 4; cnt++){
		val = eval("valArr"+slug+"["+cnt+"]");	
		if (val && val != ""){
			countTags = countTags + 1;		
			tableInDiv = tableInDiv + "<tr><td nowrap id=tag"+cnt+" style='padding-right:7px;padding-left:7px; height:17px;' onmouseover=onmouseOverTagLine(true,"+cnt+"); onmouseout=onmouseOverTagLine(false,"+cnt+");><a target='_top' id=tagText"+cnt+" class=tagLineTxt href='/web2/tags.jhtml?tag="+replaceSpace(val)+"'>"+replaceSpecialCharsBack(val)+"</a></td></tr>";		
		}
	}	
	tableInDiv = tableInDiv + "</table>";
	obj = document.getElementById("tagsDiv");	
	if (obj){				
		obj.innerHTML = tableInDiv;		
		obj.style.height = countTags*17+2;		
		
		obj.style.left = getAbsolute(x)[0]-80;
		
		if (crossevt.clientY < 400)			
		 	obj.style.top = getAbsolute(x)[1]-20;
		else
		 	obj.style.top = getAbsolute(x)[1]-62+(3-countTags)*17;
		//alert(obj.style.left + " | " + obj.style.top);
		obj.style.display = 'block';
	}		
}
function hideTagsDivNow()
{	
	isShow = true;
	var obj = document.getElementById("tagsDiv");
	if (obj)
		obj.style.display = 'none';
}

function hideTagsDiv()
{
	window.clearInterval(timerHideTagDiv);
	timerHideTagDiv = "";		
	isShow = false;
	timerHideTagDiv = setTimeout("hideTagsDivAfterWaiting()", 2000); 
}

function hideTagsDivAfterWaiting()
{		
	if (isShow == false)
	{
		window.clearInterval(timerHideTagDiv);
		timerHideTagDiv = "";			
		hideTagsDivNow();		
	}
}
function getAbsolute(oNode){
	var k = new Array(2);
 	var oCurrentNode=oNode;
	xpos=-19;
	ypos=0;
	while(oCurrentNode.tagName!="BODY"){
		xpos+=oCurrentNode.offsetLeft;
		ypos+=oCurrentNode.offsetTop;
   		oCurrentNode=oCurrentNode.offsetParent;
	}
	ypos = ypos + 20;
	xpos = xpos + 19;
	k[0] = xpos;
	k[1] = ypos;			
  	return k;
}
function keepShowingTagsDiv()
{		
	isShow = true;
	var obj = document.getElementById("tagsDiv");
	if (obj)
		obj.style.display = 'block';
}
function onmouseOverTagLine(isIn,cnt)
{	
	var obj = document.getElementById("tag"+cnt);
	var objA = document.getElementById("tagText"+cnt);
	if (obj)	
	{
		if (isIn == true)//in
			obj.className = 'tagBack';
		else//out
			obj.className='';
	}
	if (objA)	
	{
		if (isIn == true)//in
			objA.className = 'tagLineTxtOver';
		else//out
			objA.className = 'tagLineTxt';
	}
}
/*end dynamic tags functions*/