
//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-5+"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;
			}
		}
	}
}

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*/

function openMailTo(url){
	window.open(url);
}

var banecnt=0;

function scrollSpecialBanner(){
  if( document.getElementById( 'container' ).scrollTop < 140){
    if( banecnt < 70){
      ++banecnt;

  document.getElementById( 'container' ).scrollTop = banecnt * 2;
   setTimeout(scrollSpecialBanner, 5);
   }else{

   banecnt=0;

   }

  }  
}

//this is a special function for scrolling up so we can see all the banner
function scrollSpecialBanner(){
   var gotop = 1050 - screen.height;
   var pageContent = document.getElementById( 'pageContent' );
   if (pageContent){
		if(pageContent.scrollTop < gotop) {  
			while(pageContent.scrollTop < gotop)
				pageContent.scrollTop += 3;
			return true;
		}
	}
    return false;
    onResizeManager();
}
