function doBubble() {
	/* Requires jQuery (http://jquery.com/) */
	$(document).ready(function() {
	
		/* show lists */
		$(".bubbleBox").hide();

		/*BubblePopUp*/
		$(".openBubble").click(jsfOpenBubble);
		$(".bubbleBox").mouseout(jsfCloseBubbleTrigger);
		$(".bubbleBox").mouseover(jsfCancelCloseBubble);
		
	});
}

try{ doBubble(); } catch(e){}

toolTipTimer = null;

/*Bubble Box */
var strEurope = '<li><a class="nl" href="http://www.abnamromarkets.nl">abnamromarkets.nl</a></li><li><a class="es" href="http://www.abnamromarkets.es">abnamromarkets.es</a></li><li><a class="fr" href="http://www.abnamromarkets.fr">abnamromarkets.fr</a></li><li><a class="be" href="http://www.abnamromarkets.be">abnamromarkets.be</a></li><li><a class="pt" href="http://www.abnamromarkets.pt">abnamromarkets.pt</a></li><li><a class="se" href="http://www.abnamromarkets.se">abnamromarkets.se</a></li><li><a class="fi" href="http://www.abnamromarkets.fi">abnamromarkets.fi</a></li><li><a class="ch" href="http://www.abnamromarkets.ch">abnamromarkets.ch</a></li><li><a class="de" href="http://www.abnamromarkets.de">abnamromarkets.de</a></li><li><a class="it" href="http://www.abnamromarkets.it">abnamromarkets.it</a></li>'

var strWorld = '<li><a class="nl" href="http://www.abnamromarkets.nl">abnamromarkets.nl</a></li><li><a class="es" href="http://www.abnamromarkets.es">abnamromarkets.es</a></li><li><a class="fr" href="http://www.abnamromarkets.fr">abnamromarkets.fr</a></li><li><a class="be" href="http://www.abnamromarkets.be">abnamromarkets.be</a></li><li><a class="pt" href="http://www.abnamromarkets.pt">abnamromarkets.pt</a></li><li><a class="se" href="http://www.abnamromarkets.se">abnamromarkets.se</a></li><li><a class="fi" href="http://www.abnamromarkets.fi">abnamromarkets.fi</a></li><li><a class="ch" href="http://www.abnamromarkets.ch">abnamromarkets.ch</a></li><li><a class="de" href="http://www.abnamromarkets.de">abnamromarkets.de</a></li><li><a class="it" href="http://www.abnamromarkets.it">abnamromarkets.it</a></li><li><a class="us" href="http://www.us.abnamromarkets.com">us.abnamromarkets.com</a></li>'

var strNAmercia = '<li><a class="us" href="http://www.us.abnamromarkets.com">us.abnamromarkets.com</a></li>'

var jsfOpenBubble = function()
	{	
		$(".bubbleBox").find("h4").html("World:")
		switch(this.id)
		{
		case "Europe":
			{
			$(".bubbleBox").find("ul").html(strEurope)
			var topCoord = -16
			var leftCoord = -90
			break;
			}
		case "NAmerica":
			{
			$(".bubbleBox").find("ul").html(strNAmercia)
			var topCoord = -16
			var leftCoord = -150
			break;
			}
		case "World":
			{
			$(".bubbleBox").find("ul").html(strWorld)
			var topCoord = -239
			var leftCoord = -187
			break;
			}
		default:
		}

		var arrCoords = this.coords.split(",")	
		$(".bubbleBox").changeCss("top",topCoord + "px")
		$(".bubbleBox").changeCss("left",leftCoord + "px")
		$(".bubbleBox").show()
		return false;
	}

var myTimeout;

var jsfCloseBubbleTrigger = function()
	{
		myTimeout = setTimeout("jsfCloseBubble()", 1000)	
	}
	
var jsfCloseBubble = function()
	{
		$(".bubbleBox").hide()
	}
	
var jsfCancelCloseBubble = function()
	{
		clearTimeout(myTimeout)
	}
	
function initializeBubbleBox()
	{
		$(".openBubble").click(jsfOpenBubble);
		$(".bubbleBox").mouseout(jsfCloseBubbleTrigger);
		$(".bubbleBox").mouseover(jsfCancelCloseBubble);
	}

//divAdjust
function adjustDiv(e){var df=document.getElementById('ctl00_updateProgress');if (df != null){var dfs = df.style;dfs.zIndex = "999";dfs.position = "absolute";var x,y;if (self.innerHeight){x = self.innerWidth;y = self.innerHeight;}else if (document.documentElement && document.documentElement.clientHeight){x = document.documentElement.clientWidth;y = document.documentElement.clientHeight;}else if (document.body){x = document.body.clientWidth;y = document.body.clientHeight;}x = (x - df.offsetWidth) / 2;y = (y - df.offsetHeight) / 2;if (self.pageXOffset || self.pageYOffset){x += self.pageXOffset;y += self.pageYOffset;}else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)){x += document.documentElement.scrollLeft;y += document.documentElement.scrollTop;}else if (document.body){x += document.body.scrollLeft;y += document.body.scrollTop;}dfs.left = (x + 170) + "px";dfs.top = (y - 50) + "px";}}function conditionalEventBind(e){var check=document.getElementById('ctl00_updateProgress');if (check){window.onload=adjustDiv;window.onresize=adjustDiv;window.onscroll=adjustDiv;adjustDiv(e);}}if (Sys.WebForms != null){var pageRequestManager = Sys.WebForms.PageRequestManager.getInstance();if (pageRequestManager)pageRequestManager.add_beginRequest(BeginRequestHandler);}function BeginRequestHandler() {conditionalEventBind();}

//functions
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
function IsOldFlash()
{
	if (isIE && isWin && !isOpera)
	{
		try {
			
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.8");
		} catch (e) {
			return true;
		}
		return false;
	}
	
	else if (navigator.plugins != null && navigator.plugins.length > 0) 
	{
		var flash = navigator.plugins["Shockwave Flash 2.0"]
		if (!flash)
		{
			flash = navigator.plugins["Shockwave Flash"]
			if (!flash)
			{
				return false;
			}
		}
		
		if (flash.description.split(" ")[2].split(".")[0] > 7)
		{
			return true;
		}
	}
	
	return false;
}
var enterTargetControlID = '';
function setEnterEvent(targetControlUniqueID)
{
	document.onkeydown = doEnterClick;
	enterTargetControlID = targetControlUniqueID;
}
function doEnterClick(evnt)
{
	if (enterTargetControlID  != '')
	{
		if (!evnt) {
			evnt = window.event;
		}
		if (evnt.which || evnt.keyCode) {
			if ((evnt.which == 13) || (evnt.keyCode == 13)) {
				var submitButton = document.getElementById(enterTargetControlID);
				if (submitButton != null)
				{
					if (submitButton.style.display != 'none')
					{
						submitButton.focus();
					}
					submitButton.click();
				}
			}
		}
	}
}

function disableEnter(evnt)
{
	if (!evnt) {
		evnt = window.event;
	}
	if (evnt.which || evnt.keyCode) {
		if ((evnt.which == 13) || (evnt.keyCode == 13)) {
			return false;
		}
	}
	return true;
}
function doPostBackOnEnter(event, eventTarget, eventArgument, validationGroup)
{
	if (event.which || event.keyCode) {
		if ((event.which == 13) || (event.keyCode == 13)) {
			if (validationGroup != null)
			{
				WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(eventTarget, eventArgument, true, validationGroup, '', false, true));
			}
			else
			{
				WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(eventTarget, eventArgument, false, '', '', false, true));
			}
		}
	}
}
function doClickOnEnter(event, targetControlUniqueID, eventTarget, eventArgument, validationGroup)
{
	if (event.which || event.keyCode) {
		if ((event.which == 13) || (event.keyCode == 13)) {
			setEnterEvent('');
			
			var validationResult = true;
			if (validationGroup != '')
			{
				if (typeof(Page_ClientValidate) == 'function') {
					validationResult = Page_ClientValidate(validationGroup);
				}
			}
			if (validationResult)
			{
				__customPostBack(eventTarget, eventArgument, targetControlUniqueID);
			}
		}
	}
	return false;
}
function __customPostBack(eventTarget, eventArgument, submitButtonId) 
{
	if (!theForm.onsubmit || (theForm.onsubmit() != false)) 
	{
		theForm.__EVENTTARGET.value = eventTarget;
		theForm.__EVENTARGUMENT.value = eventArgument;
		var submitButton = document.getElementById(submitButtonId);
		if (submitButton != null)
		{
			
			if (submitButton.style.display != 'none')
			{
				submitButton.focus();
			}
			submitButton.click();
		}
	}
}
function centerWindow(){
	self.moveTo(screen.height?(screen.width - document.documentElement.clientWidth)/2:300,screen.height?(screen.height - document.documentElement.clientHeight)/2:200);
}
function show_object(strObjectId) {
	var objDiv = document.getElementById(strObjectId);
	if (objDiv.style.visibility == "hidden") {
		objDiv.style.visibility = "visible";
	} else {
		objDiv.style.visibility = "hidden";
	}
}
function compareProducts(link, checkboxName, tooFew, tooMuch)
{
	var isinString = GetISINArray(checkboxName,2,3);
	var openWindow = true;
	if (isinString == -1)
	{
		alert(tooFew);
		openWindow = false;
	}
	if (isinString == -2)
	{
		alert(tooMuch);
		openWindow = false;
	}

	if (openWindow)
	{
		var now = new Date();
		window.open(link + '&isins=' + isinString, 'CompareProducts'+now.getTime(), 'width=830, height=790, location=no, menubar=no, resizeable=no, scrollbars=no, status=no, toolbar=no');
	}
	return false;
}

function sendProducts(link, checkboxName, tooFew, tooMuch, min, max)
{
	var isinString = GetISINArray(checkboxName,min,max);
	var openWindow = true;
	if (isinString == -1)
	{
		alert(tooFew);
		openWindow = false;
	}
	if (isinString == -2)
	{
		alert(tooMuch);
		openWindow = false;
	}

	if (openWindow)
	{
		var now = new Date();
		window.open(link + '&isin=' + isinString, 'CompareProducts'+now.getTime(), 'width=630, height=590, location=no, menubar=no, resizeable=no, scrollbars=no, status=no, toolbar=no');
	}
	return false;
}

function GetISINArray(checkboxID, min, max)
{
	var isinString = "";
	var checked = 0;
	checkboxes = document.getElementsByName(checkboxID);
	for (var i = 0; i < checkboxes.length; i++)
	{
		if (checkboxes[i].checked == true)
		{
			if (isinString.length > 0)
			{
				isinString += ",";
			}
			isinString += checkboxes[i].value;
			checked++;
		}
	}
	if (min > -1 && checked < min)
	{
		return -1;
	}
	
	if (max > -1 && checked > max)
	{
		return -2;
	}

	return isinString;
}
function switchFrame(kat, id, frameCount)
{
	for(i=0;i<frameCount;i++)
	{
		document.getElementById(kat + '_' + i).style.display = 'none';
	}
	document.getElementById(kat + '_' + id).style.display = 'block';
}
function setTab(id, item, count){
	for(i=0;i<count;i++){
		if ((document.getElementById(id + '_' + i + '_tab')) && (document.getElementById(id + '_' + i + '_div')))
		{ 
			document.getElementById(id + '_' + i + '_tab').className = '';
			document.getElementById(id + '_' + i + '_div').style.display = 'none';
		}
	}
	if ((document.getElementById(id + '_' + item + '_tab')) && (document.getElementById(id + '_' + item + '_div')))
	{
		document.getElementById(id + '_' + item + '_tab').className = 'selected';
		document.getElementById(id + '_' + item + '_div').style.display = 'block';
	}
}
function toggle(newDiv, openDiv)
{
	if (openDiv.length > 0)
	{
		document.getElementById(openDiv).style.display = 'none';
	}
	if (document.getElementById(newDiv).style.display != 'none') 
	{
		document.getElementById(newDiv).style.display = 'none';
	}
	else 
	{
		document.getElementById(newDiv).style.display = '';
	}
	return newDiv;
}
function setHiddenValue(elementId, value, buttonId) {
	var submit = false;
	if (value.length > 2)
	{
		var element1 = document.getElementById(elementId);
		
		if (element1 != null)
		{
			element1.value = value;
			
			var submitButton = document.getElementById(buttonId);
			if (submitButton != null) {
				if (submitButton.style.display != 'none')
				{
					submitButton.focus();
				}
				submitButton.click();
			}
		}
	}
}
function createFlashChart(chartName, importer, xmlCreatorPath, isin, type)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="458" height="400" title="Graph">');
	document.write('<param name="movie" value="Flash/' + chartName + '?path=' + importer + '?target=' + xmlCreatorPath + '|' + isin+  '|' + type + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<embed src="Flash/' + chartName + '?path=' + importer + '?target=' + xmlCreatorPath + '|' + isin + '|' + type + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="458" height="400"></embed>');
	document.write('</object>');
}
function writeFlash(htmlString)
{
	document.write(htmlString);
}
function toggleCharts(newDiv, openDiv, clickedTab, nameArray)
{
	for (var i = 0; i < nameArray.length; i++)
	{
		if(nameArray[i] == clickedTab)
		{
			document.getElementById(nameArray[i]).className = 'selected';						
		}
		else
		{
			var foundElement = document.getElementById(nameArray[i]);
			
			if(foundElement)
				foundElement.className = '';
		}
	}
  
	if (openDiv.length > 0)
	{
		document.getElementById(openDiv).style.display = 'none';
	}
	if (document.getElementById(newDiv).style.display != 'none') 
	{
		document.getElementById(newDiv).style.display = 'none';
	}
	else 
	{
		document.getElementById(newDiv).style.display = '';
	}
	return newDiv;
}
function MoveListElement(from, to, isMultiple)
{
	listFrom = document.getElementById(from);
	listTo = document.getElementById(to);
	
	if (isMultiple)
	{
		for (i = 0; i < listFrom.length; ++i) 
		{
			if (listFrom.options[i].selected == true) 
			{
				newElmt = new Option(listFrom.options[i].text, listFrom.options[i].value, false, false);
				listTo.options[listTo.length] = newElmt;
				listFrom.options[i] = null;
				i--;
			}
		}
	}
	else
	{
		newElmt = new Option(listFrom.options[listFrom.options.selectedIndex].text, listFrom.options[listFrom.options.selectedIndex].value, false, false);
		listTo.options[listTo.length] = newElmt;
		listFrom.options[listFrom.options.selectedIndex] = null;
	}
	return false;
}
function SelectAll(dropdownID)
{
	var dropdown = document.getElementById(dropdownID);
	if (dropdown != null)
	{
		for(i = 0; i < dropdown.length; i++)
		{
			dropdown[i].selected = true;
		}
	}	
}
function toggleProductDetailData(partID, startIndex, count, labelId, lblText){
	var displayPart = 'none';
	if(document.getElementById(partID + '_' + startIndex).style.display == 'none')
	{
			displayPart = '';
			document.getElementById(labelId).innerHTML = lblText.split(",")[1];
	}
	else
	{
		document.getElementById(labelId).innerHTML = lblText.split(",")[0];
	}
	for(i = startIndex; i < count; i++){
		document.getElementById(partID + '_' + i).style.display = displayPart;
	}
}
function toggleVideoDivOn (homeDivID, videoDivID, moviename)
{
	var homeDiv = document.getElementById(homeDivID);
	var videoDiv = document.getElementById(videoDivID);
	var htmlStr;
	
	videoDiv.style.display = '';
	homeDiv.style.display = 'none';
	htmlStr = '<table style="float:right;"><tr>';
	if(videoDivID == 'comlp_eco')
		htmlStr += '<td style="padding-right: 5px;"><a class="greenButton" href="http://www.abnamroecomarkets.com" target="_blank"><span>Visit our eco site</span></a></td>';
	if(videoDivID == 'comlp_commodity')
		htmlStr += '<td style="padding-right: 5px;"><a class="greenButton" href="http://www.abnamromarkets.com/commodities/" target="_blank"><span>Visit our commodities site</span></a></td>';
	
	if(videoDivID == 'comlp_emerging')
		htmlStr += '<td style="padding-right: 5px;"><a class="greenButton" href="http://www.abnamromarkets.com/emerging/" target="_blank"><span>Visit our emerging markets site</span></a></td>';	
	htmlStr += '<td><a class="greenButton" href="javascript:void(0);" onclick="javascript:toggleVideoDivOff(\'' + homeDivID + '\', \'' + videoDivID + '\');"><span>Close video</span></a></td>';
	
	htmlStr += '</tr></table><div class="extFloatFix"></div><br/>';
	if (videoDivID == 'comlp_products')
	{
		var playerPath = "Flash/videoplayer.swf";
		if ( isIE && isWin && !isOpera ) 
		{
			htmlStr += '<object id="site_content_flash" align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" height="367" name="site_content_flash" width="622">';
			htmlStr += '<param name="movie" value="'+playerPath+'"/>'; 
			htmlStr += '<param name="quality" value="best"/>'; 
			htmlStr += '<param name="wmode" value="window"/>'; 
			htmlStr += '<param name="devicefont" value="false"/>'; 
			htmlStr += '<param name="bgcolor" value="#FFFFFF"/>'; 
			htmlStr += '<param name="menu" value="false"/>'; 
			htmlStr += '<param name="allowFullScreen" value="true"/>'; 
			htmlStr += '<param name="allowScriptAccess" value="always"/>'; 
			htmlStr += '<param name="salign" value="TL"/>'; 
			htmlStr += '</object>'; 
		}
		else
		{
			htmlStr += '<embed src="' + playerPath + '" quality="best" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" wmode="window" devicefont="false" bgcolor="#FFFFFF" name="site_content_flash" menu="false" allowfullscreen="true" allowscriptaccess="always" salign="TL" type="application/x-shockwave-flash" align="middle" height="367" width="662"></embed>';
		}
	}
	else
	{
		var playerPath = "/Flash/flvplayer.swf";
		var moviePath;
		if (IsOldFlash())
		{
			moviePath = "/Flash/movies/flash7/" + moviename;
		}
		else
		{
			moviePath = "/Flash/movies/flash8/" + moviename;
		}
		
		if ( isIE && isWin && !isOpera ) 
		{
			htmlStr += '<object id=player codeBase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab height=390 width=662 align=middle classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>';
			htmlStr += '<param NAME="movie" VALUE="' + playerPath + '">';
			htmlStr += '<param NAME="quality" VALUE="high">';
			htmlStr += '<param NAME="alowfullscreen" VALUE="true">';
			htmlStr += '<param NAME="flashVars" VALUE="autoplay=false&file=' + moviePath + '">';
			htmlStr += '<param NAME="allowScriptAccess" VALUE="sameDomain">';
			htmlStr += '</object>';
		}
		else
		{
			htmlStr += '<embed src="' + playerPath + '" loop="false" quality="high" bgcolor="#cccccc" width="662" height="390" name="player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="autoplay=false&file=' + moviePath + '"/>';
		}
	}

	videoDiv.innerHTML = htmlStr + '<div class="extFloatFix"></div>';
}
function toggleVideoDivOff (homeDivID, videoDivID)
{
	var homeDiv = document.getElementById(homeDivID);
	var videoDiv = document.getElementById(videoDivID);
	
	videoDiv.style.display = 'none';
	homeDiv.style.display = '';
	videoDiv.innerHTML = '';
}
function getElementsByClassName(oElm, strTagName, oClassNames)
{
	var arrElements = (strTagName == "*" && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();

	if (typeof oClassNames == "object")
	{
		for(var i=0; i<oClassNames.length; i++)
			arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames[i].replace(/-/g, "\-") + "(\s|$)"));
	}
	else
		arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames.replace(/-/g, "\-") + "(\s|$)"));

	var oElement;
	var bMatchesAll;

	for (var j=0; j<arrElements.length; j++)
	{
		oElement = arrElements[j];
		bMatchesAll = true;
		for (var k=0; k<arrRegExpClassNames.length; k++)
		{
			if (!arrRegExpClassNames[k].test(oElement.className))
			{
				bMatchesAll = false;
				break;
			}
		}

		if (bMatchesAll)
			arrReturnElements.push(oElement);
	}

	return (arrReturnElements)
}
function FormatNumber(strValue, lngPrecision, strGroupSeparator, strDecimalSeparator)
{
	var arrParts;
	var intI;
	var strPart;
	var strTemp;
	
	// number_format(number, decimals, comma, formatSeparator)
	strValue = parseFloat(strValue).toFixed(lngPrecision);
	strValue = strValue + '';
	arrParts = strValue.split('.');
	if(!arrParts[0]) arrParts[0] = '0';
	if(!arrParts[1]) arrParts[1] = '';

	if(strDecimalSeparator != '' && arrParts[0].length > 3)
	{
		strPart = arrParts[0];
		arrParts[0] = '';
		for(intI = 3; intI < strPart.length; intI += 3)
		{
			strTemp = strPart.slice(strPart.length - intI, strPart.length - intI + 3);
			arrParts[0] = strGroupSeparator + strTemp +  arrParts[0] + '';
		}
		strTemp = strPart.substr(0, (strPart.length % 3 == 0) ? 3 : (strPart.length % 3));
		arrParts[0] = strTemp + arrParts[0];
	}
	
	strDecimalSeparator = (lngPrecision <= 0) ? '': strDecimalSeparator;
	return arrParts[0] + strDecimalSeparator + arrParts[1];
}


function toggleTFBCharts(idToShow,chartClassName,chartsrc,defaultTab)
{
	if(timeOutObject!=null) 
		window.clearTimeout(timeOutObject);
	timeOutObject=window.setTimeout('showWithDelay(\'' + idToShow + '\',\'' + chartClassName + '\',\'' + chartsrc + '\',\'' + defaultTab + '\')',500);
}

function showWithDelay(idToShow,chartClassName,chartsrc,defaultTab)
{
	$(chartClassName).hide();
	document.getElementById('chart_'+idToShow).src = chartsrc;
	//var displayType = (navigator.userAgent.toLowerCase().indexOf('msie')<0 ? 'table-row':'block');
	document.getElementById(idToShow).style.display = navigator.userAgent.toLowerCase().indexOf('msie')<0 ? 'table-row':'block';
	toggleTabs(idToShow,defaultTab,6);
}

function switchGraph(id,item,count,selectedtab,tabcount)
{
	toggleTabs(id + '_' + item,selectedtab,tabcount);
	toggleTopFlopCharts(id,item,count);
}

function toggleTabs(id, item, count){
	for(i=0;i<count;i++){
		var element = document.getElementById(id + '_' + i + '_tab');
		if (i == item)
		{ 
			if(element != null)
				element.className = 'selected';
		}
		else
		{
			if(element != null)
				element.className = '';
		}
	}
}

function toggleTopFlopCharts(divName, selectedItem, maxItems)
{
	var displayType = (navigator.userAgent.toLowerCase().indexOf('msie')<0 ? 'table-row':'block');
	for(var i=0; i<maxItems; i++){
		if(i != selectedItem)
		{ 
			if (document.getElementById(divName + '_' + i))
			{
				if(document.getElementById(divName + '_' + i).style.display != 'none')
				{
					document.getElementById(divName + '_' + selectedItem).style.display=displayType;
					document.getElementById(divName + '_' + i).style.display = 'none'
					return;
				}
			}
		}
	}
}

function toggleLastViewed(listName, maxItems, textReduced, textOpened)
{
	for(var i=3; i<maxItems; i++){
		if(document.getElementById(listName + '_' + i).style.display != 'none')
		{
			document.getElementById(listName + '_' + i).style.display = 'none';
			document.getElementById('linkLastViewed').className = 'grayButton extGrayButton';
			document.getElementById('linkLastViewed').innerHTML = textOpened;
		}
		
		else
		{
			document.getElementById(listName + '_' + i).style.display = 'block';
			document.getElementById('linkLastViewed').className = 'grayButton extGrayButton';
			document.getElementById('linkLastViewed').innerHTML = textReduced ;
			
		}
	}
}

// Tooltip main function; requires jquery 
function showTooltip(baseObj,text)
{
	if (document.readyState == "complete")
	{
		var showDelay = 500;
		window.clearTimeout(toolTipTimer);
		$(".tooltip").remove();
		$("body").append("<div id='tooltip' class='tooltip' onmouseover='window.clearTimeout(toolTipTimer);' onmouseout='hideTooltip()'><div id='tooltipText'></div></div>");
		$("#tooltipText").html(text);
		if(baseObj != null && text != '' && text.indexOf('ColumnTooltipTranslation_') < 0)
		{
			baseObj.onmouseout = hideTooltip;
			setTooltipPosition(baseObj,"tooltip");
			toolTipTimer = window.setTimeout("setTooltip('show')",showDelay);
		}
	}
}

//Tooltip helper function
function hideTooltip()
{
	var hideDelay = 1000;
	window.clearTimeout(toolTipTimer);
	toolTipTimer = window.setTimeout("setTooltip('hide')",hideDelay);
}

//Tooltip helper function
function setTooltip(action)
{
	switch(action)
	{
		case 'show':
		$("#tooltip").fadeIn("fast");
		break;
		
		case 'hide':
		$("#tooltip").fadeOut("fast",function(){ $("#tooltip").remove(); });
		break;
		
	}
}

//Tooltip helper function
function setTooltipPosition(baseObj,toolTipId)
{
	var coors = findPosition(baseObj);
	var x = document.getElementById(toolTipId);
	x.style.top = (coors[1] + baseObj.offsetHeight) + 'px';
	x.style.left =(coors[0] - 65) + 'px';
}

function findPosition(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	else if (obj.parentElement.offsetParent)
	{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj.parentElement.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function stopBubble(evt)
{
	if (evt.cancelBubble != null)
		evt.cancelBubble = true;
	if (evt.stopPropagation)
		evt.stopPropagation();
	if (evt.preventDefault)
		evt.preventDefault();
	if (window.event)
		evt.returnValue = false;
	if (evt.cancel != null)
		evt.cancel = true;
}
 // Adjust the height of the iframe according its content; used in MarketMap
function adjustFrameHeight(containerName, frameName)
{
	var divFrame = document.getElementById(containerName);
	if(null == divFrame)
		return;
  
	// Reading the height of the surrounding div tag
	var height  = divFrame.offsetHeight;
	// fetching the iframe	
	var frame = parent.document.getElementById(frameName);
	
	frame.height = height + 100;
}
function clearTextBox(textBox)
{
	textBox.value="";
}

var isLSInitialized = false;
function setLightstreamerStatus(status)
{
	if (status != "DISCONNECTED")
	{
		initLS();
		setIsinGroup(group);
		pushTableInit(tableSetting);
	}
		
	var pairs = document.cookie.split(";");
	var namevalue;
	var newCookieString;
	var	now = new Date();
	now = new Date(now.getTime() + (24*60*60*1000));
	newCookieString = "lightstreamerStatus=" + status + ";expires=" + now.toGMTString() + ";";
	document.cookie = newCookieString;

	myEngine.changeStatus(status);
}

function hideMoreLess(strObjectId)
{
	if(document.getElementById(strObjectId).style.display != 'none')
	{
		document.getElementById(strObjectId).style.display = 'inline';
	}
		
	else
		document.getElementById(strObjectId).style.display = 'none';
}


var addBookmark = function(url, title){

  // user agent sniffing is bad in general, but this is one of the times 
  // when it's really necessary
  var ua=navigator.userAgent.toLowerCase();
  var isKonq=(ua.indexOf('konqueror')!=-1);
  var isSafari=(ua.indexOf('webkit')!=-1);
  var isMac=(ua.indexOf('mac')!=-1);
  var buttonStr=isMac?'Command/Cmd':'CTRL';

  if(window.external && (!document.createTextNode || (typeof(window.external.AddFavorite)=='unknown'))) {
  	// IE4/Win generates an error when you
    // execute "typeof(window.external.AddFavorite)"
    // In IE7 the page must be from a web server, not directly from a local 
    // file system, otherwise, you will get a permission denied error.
    window.external.AddFavorite(url, title); // IE/Win
  } else if(isKonq) {
    alert('You need to press CTRL + B to bookmark our site.');
  } else if(window.opera) {
  	alert('You need to press CTRL + D to bookmark our site.');
  } else if (window.sidebar) {
  	// firefox
  	window.sidebar.addPanel(title,url, "");
  }
    else if(window.home || isSafari) { // Firefox, Netscape, Safari, iCab
    alert('You need to press '+buttonStr+' + D to bookmark our site.');
  } else if(!window.print || isMac) { // IE5/Mac and Safari 1.0
    alert('You need to press Command/Cmd + D to bookmark our site.');    
  } else {
    alert('In order to bookmark this site you need to do so manually through your browser.');
  }
}

function addCheckBoxValue(checkBox, valueContainerId, value)
{
	var valueContainer = document.getElementById(valueContainerId);
	if (checkBox == null || valueContainer == null)
		return;
		
	if (checkBox.checked == true)
	{
		if (valueContainer.value.indexOf(value) < 0)
		{
			valueContainer.value = valueContainer.value + value;
		}
	}
	else
	{
		 valueContainer.value = valueContainer.value.replace(value, "");
	}
}
