function rp_sendandreplacehlp(resptext) {
			//alert('am primit raspunsul. il scriu in cache si inlocuiesc continutul');
			cachehelpsimbol=resptext;
			document.getElementById('helpsimbol').innerHTML = cachehelpsimbol;
}

function swhlpsim (type){
			
			var lnktxt=document.getElementById("hlplnk").innerHTML;
			if (document.getElementById("helpsimbol").style.display == "block"){

				document.getElementById("helpsimbol").style.display = "none";
				document.getElementById("hlplnk").innerHTML='\u25BC';
				document.getElementById("hlplnk").innerHTML=(lnktxt.substr(0,lnktxt.indexOf("\u25B2"))) + '\u25BC';
			}
			else if(document.getElementById("helpsimbol").style.display == "none"){
				
				if (cachehelpsimbol=='')
				{
					//alert('nu am nimic in cache. fac cerere de continut!');
					sendinput('/js/liveReqHandler.php?xmlraction=' + type + '_helpsimbol&lng='+getPageLng(),'post','rp_sendandreplacehlp');	
				}else
				{
					document.getElementById('helpsimbol').innerHTML = cachehelpsimbol;
				}
				document.getElementById("helpsimbol").style.display = "block";
				document.getElementById("hlplnk").innerHTML='\u25B2';
				document.getElementById("hlplnk").innerHTML=(lnktxt.substr(0,lnktxt.indexOf("\u25BC"))) + '\u25B2';
			

			}
	
}

function wsimb(simbol){
	swhlpsim (simbol);
	document.getElementById("simbol").value=simbol;
	document.setsimbol.submit();
}


//-- live page stats
function rp_sendAndReplacePageStats(resptext) {
		document.getElementById('livePageStats').innerHTML = resptext;
}

function showPageStats(preset,group){
	sendinput('/js/liveReqHandler.php?xmlraction=livePageStats&p=' + preset + '&grp=' + group + '&lng='+getPageLng(),'post','rp_sendAndReplacePageStats');			
}


function rp_sendAndReplaceATImgMap(resptext) {
		document.getElementById('ATImgMapHolder').innerHTML = resptext;
}

function getATImgMap(imgid){
	sendinput('/js/liveReqHandler.php?xmlraction=getATImgMap&imgid=' + imgid + '&lng='+getPageLng(),'post','rp_sendAndReplaceATImgMap');			
}

			
//--functions used to find an object's position
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}



function getPageLng(){
	curloc=document.location + '';
	if (curloc.indexOf('/en/',0)==-1)
	{
		lng='ro';
	}else{
		lng='en';
	}
	return lng;
}


//creates the helpsimbol div near the link
function createHelpSimbolDiv(){
	
	

	if (document.getElementById("hlplnk"))
	{
		
		
		toppos=findPosY(document.getElementById("hlplnk"));
		
		leftpos=findPosX(document.getElementById("hlplnk"));
		
		leftpos=leftpos - (190 - document.getElementById("hlplnk").offsetWidth);
		document.write('<div id="helpsimbol" style="display:none;top:' + toppos + ';left:' + leftpos + ';">Va rugam asteptati pana se incarca datele...<br>Please wait while loading data...</div>');
		
		
	}
	
}


var cachehelpsimbol='';

var useMultipleWinCotatii=false;

function openWinCotatii(simbol,allow_multiple){

	//learn the user habits about new windows for quotes
	if (useMultipleWinCotatii || allow_multiple==1){
		useMultipleWinCotatii=true;
		window.open('msc_cotatiiLiveSingle.php?s=' + simbol ,'Cotatii_real' + simbol ,'height=430,width=400,top=20,left=20,status=no,resizable=yes');
	}else{
		window.open('msc_cotatiiLiveSingle.php?s=' + simbol ,'Cotatii_real','height=430,width=400,top=20,left=20,status=no,resizable=yes');
	}
}
function openWinCotatiiLista(simbol){
	window.open('act_cotatiiLiveAll.php?s=' + simbol ,'Cotatii_real_lista','width=740,height=400,top=20,left=20,status=no,scrollbars=yes,resizable=yes');
}

function openWinExplicatii(url,w,h){
	window.open(url,'pagina','width='+w+',height='+h+',resizable=no, left=20, top=20, scrollbars=yes');
}

function openWinCotatiiBA(simbol,allow_multiple){

	//learn the user habits about new windows for quotes
	if (useMultipleWinCotatii || allow_multiple==1){
		useMultipleWinCotatii=true;
		window.open('msc_cotatiiBA.php?s=' + simbol ,'Cotatii_BA' + simbol ,'height=430,width=400,top=20,left=20,status=no,resizable=yes,scrollbars=yes');
	}else{
		window.open('msc_cotatiiBA.php?s=' + simbol ,'Cotatii_BA','height=430,width=400,top=20,left=20,status=no,resizable=yes,scrollbars=yes');
	}
}

function openWin(url,w,h){
	if (!w){
		w=700;
	}
	if (!h){
		h=400;
	}
	window.open(url,'pagina','width='+w+',height='+h+',resizable=no, left=20, top=20, scrollbars=yes');
}

function focusmyid(elemid){
	if (document.getElementById(elemid)){
		document.getElementById(elemid).focus();
	}
	
}


function showContextSplash(y,refreshAfter){
	if (!document.getElementById('contextSplash')){
		splashDiv=document.createElement('div');
		splashDiv.setAttribute('id','contextSplash');
		
		closeDiv=document.createElement('div');
		closeDiv.setAttribute('id','closeButton');
		if (getPageLng()=='ro'){
			closelabel='inchide'
		}else{
			closelabel='close'
		}
		
		closeDiv.appendChild(document.createTextNode(closelabel));
		splashDiv.appendChild(closeDiv);

		contentDiv=document.createElement('div');
		contentDiv.setAttribute('id','contextSplashContent');
		splashDiv.appendChild(contentDiv);
		
		document.body.appendChild(splashDiv);
		document.getElementById('contextSplash').className='contextSplash';
		
	}
	if (refreshAfter){
		document.getElementById('closeButton').onclick=function() {
			document.getElementById('contextSplash').style.display='none';
			window.location.reload();
			return false;
		}	
	}else{
		document.getElementById('closeButton').onclick=function() {
			document.getElementById('contextSplash').style.display='none';
			return false;
		}
		
	}
	document.getElementById('contextSplash').style.display='block';
	document.getElementById('contextSplash').style.top=y;
}

function splashChart(contextToObj,cat,simbol,tipchart,splashLabel){
	
	var chartTypes=new Array();

	chartTypes['act']=new Array('0d','1m','3m','6m','12m');
	chartTypes['df']=new Array('0d','1m','3m','6m','12m');
	chartTypes['do']=new Array('0d','1m','3m','6m');
	chartTypes['drp']=new Array('0d','1m','3m','6m');
	chartTypes['fnd']=new Array('1m','3m','6m','12m');
	chartTypes['ind']=new Array('0d','1m','3m','6m','12m');
	chartTypes['obl']=new Array('0d','1m','3m','6m','12m');
	chartTypes['rdq']=new Array('0d','1m','3m','6m','12m');
	chartTypes['unl']=new Array('0d','1m','3m','6m','12m');
	chartTypes['dfb']=new Array('0d','1m','3m','6m','12m');
	chartTypes['dcfd']=new Array('0d','1m','3m','6m','12m');
	chartTypes['sibexact']=new Array('0d','1m','3m','6m','12m');
	chartTypes['eua']=new Array('0d','1m','3m','6m','12m');
	
	showContextSplash(findPosY(contextToObj));
	document.getElementById('contextSplashContent').innerHTML='';

	labelDiv=document.createElement('div');
	labelDiv.className='contextSplashLabel';
	if (!splashLabel){
		splashLabel=simbol;
	}
	labelDiv.appendChild(document.createTextNode(splashLabel));
	document.getElementById('contextSplashContent').appendChild(labelDiv);;
	
	chartimg=document.createElement('img');
	chartimg.setAttribute('id','contextSplashChartImg');
	document.getElementById('contextSplashContent').appendChild(chartimg);

	mcont=document.createElement('div');
	mcont.setAttribute('id','contextSplashMenu');
	document.getElementById('contextSplashContent').appendChild(mcont);

	mitem=new Array();

	lng=getPageLng();
	for (i=0; i<chartTypes[cat].length;i++){
		
		cursrc='/inc/grafice/my_grafic.php?tmpl=msc_my_popup&cat=' + cat + '&s='+simbol+'&tipchart=' + chartTypes[cat][i] + '&lng='+getPageLng();
		mlabel=chartTypes[cat][i];
		switch (lng)	{
			case 'ro':
						if (chartTypes[cat][i].charAt(0)<=1 && chartTypes[cat][i].length==2){
							mlabel=mlabel.replace('m',' luna');
							mlabel=mlabel.replace('d',' zi');
						}else{
							mlabel=mlabel.replace('m',' luni');
							mlabel=mlabel.replace('d',' zile');
						}				
						mlabel=mlabel.replace('0 zi','intraday');

				break;
			case 'en':
						if (chartTypes[cat][i].charAt(0)<=1 && chartTypes[cat][i].length==2){
							mlabel=chartTypes[cat][i].replace('m',' month');
							mlabel=chartTypes[cat][i].replace('d',' day');
						}else{
							mlabel=chartTypes[cat][i].replace('m',' months');
							mlabel=chartTypes[cat][i].replace('d',' days');
						}
						mlabel=mlabel.replace('0 day','intraday');

				break;
		}
		
		
		//label.replace('','')
		//label.replace('','')

		mitem[i]=document.createElement('div');
		mitem[i].className='contextSplashMitem';
		mitem[i].innerHTML='<a onClick="document.getElementById(\'contextSplashChartImg\').src=\''+cursrc+'\';">' + mlabel + '</a>';
		
/*
		mitem[i].onclick=function(){
			alert(cursrc);
			
			alert(document.getElementById('contextSplashChartImg').src);
		}
*/

		document.getElementById('contextSplashMenu').appendChild(mitem[i]);
		
		if (chartTypes[cat][i]==tipchart){
			document.getElementById('contextSplashChartImg').src=cursrc;
		}
	}

	//scroll(0,findPosY(document.getElementById('contextSplash'))+document.getElementById('contextSplash').style.height)
	
}



function splashIframe(contextToObj,url,label,reloaOnClose){
	if (reloaOnClose==true)
	{
		showContextSplash(Math.max(findPosY(contextToObj),10),true);
	}else{
		showContextSplash(Math.max(findPosY(contextToObj),10),false);
	}

	document.getElementById('contextSplashContent').innerHTML='<div id="contextSplashContent"><div class="contextSplashLabel">'+label+'</div><iframe src="' + url + '" frameborder="0" scrolling="yes" style="clear:both;"></iframe></div>';

	//scroll(0,findPosY(document.getElementById('contextSplash'))+document.getElementById('contextSplash').style.height)
	
}


function showWinlikeSplash(url,w,h,title,refreshAfter,framescroll){
	if (!document.getElementById('wsp-winFullContainer')){
		splashDiv=document.createElement('div');
		splashDiv.setAttribute('id','wsp-winFullContainer');
		
		contentDiv=document.createElement('div');
			contentDiv.setAttribute('id','wsp-Content');
			contentDiv.setAttribute('style','border-bottom:1px solid #C1C1C1;border-right:1px solid #C1C1C1;border-top:1px solid #F0F0F0;border-left:1px solid #F0F0F0;padding:1px 1px 1px 1px;');
			


		tbarDiv=document.createElement('div');
			tbarDiv.setAttribute('id','wsp-titleBar');
			tbarDiv.setAttribute('style','color:white; background-color:#6A6660; font-family:arial,verdana; font-size:10px; width:100%; height: 12px; border-bottom:1px solid #9E9E9E;');
			
			titleDiv=document.createElement('div');
			titleDiv.setAttribute('style','float:left;text-indent:3px;');
			titleDiv.appendChild(document.createTextNode(title));
			tbarDiv.appendChild(titleDiv);
			contentDiv.appendChild(tbarDiv);

		closeDiv=document.createElement('div');
			closeDiv.setAttribute('id','wsp-closeButton');
			closeDiv.setAttribute('style','float:right; color:black;background-color:#E6E6E6; cursor:pointer; line-height:10px; height:10px; width:10px; border-bottom:1px solid #C1C1C1; border-right:1px solid #C1C1C1; border-top:1px solid #F0F0F0; border-left:1px solid #F0F0F0;');
					
			closeDiv.appendChild(document.createTextNode('X'));
			tbarDiv.appendChild(closeDiv);

		intframe=document.createElement('iframe');
			intframe.setAttribute('id','wsp-iframe');
			intframe.setAttribute('src',url);
			intframe.setAttribute('frameborder','0');
			if (framescroll==true){
				intframe.setAttribute('scrolling','yes');
			}else{
				intframe.setAttribute('scrolling','no');
			}
			
			intframe.setAttribute('style','clear:both;width:100%;height:100%;');
			contentDiv.appendChild(intframe);
				

		splashDiv.appendChild(contentDiv);
	
		document.body.appendChild(splashDiv);
		document.getElementById('wsp-winFullContainer').className='wsp-winFullContainer';

		
		

	}
	if (refreshAfter){
		document.getElementById('wsp-closeButton').onclick=function() {
			document.getElementById('wsp-winFullContainer').style.display='none';
			window.location.reload();
			return false;
		}	
	}else{
		document.getElementById('wsp-closeButton').onclick=function() {
			//document.getElementById('wsp-winFullContainer').style.display='none';
			document.body.removeChild(document.getElementById('wsp-winFullContainer'));
			return false;
		}
		
	}
	document.getElementById('wsp-winFullContainer').style.width='100%';
	document.getElementById('wsp-winFullContainer').style.height='100%';
	document.getElementById('wsp-Content').style.width=w;
	document.getElementById('wsp-Content').style.height=h;
	document.getElementById('wsp-winFullContainer').style.display='block';
	document.getElementById('wsp-winFullContainer').style.textAlign='center';
	document.getElementById('wsp-winFullContainer').style.align='center';
}


function selectQuickFilter(selectid,textFilter){

	
	if (document.getElementById(selectid) && document.getElementById(selectid).nodeName=='SELECT' && document.getElementById(selectid).hasChildNodes())
	{
		sel=document.getElementById(selectid);
		sel.value='';
		//sel.options[sel.selectedIndex].selected=false;
		var selectedToken=false;
		for (i=0;i<sel.options.length;i++ ){
			
			//if (sel.options[i].text.substr(0,textFilter.length).toLowerCase()==textFilter.substr(0,textFilter.length).toLowerCase()){
			if (sel.options[i].text.toLowerCase().indexOf(textFilter.toLowerCase())==0){
					
					if (selectedToken==false){
						sel.options[i].selected=true;
						selectedToken=true;
					}else{
						sel.options[i].selected=false;
						break;
					}
					
			}else{
				//sel.options[i].selected=false;
			}
		}
		
		
		
	}

}

function popEl(sourceid,w,h,cssfile){
	if(document.getElementById(sourceid)) {
		htmlBody=document.getElementById(sourceid).innerHTML;
	}
	if(!cssfile) {
		cssfile='/images/stil_popup.css';
	}
	htmlOpener='<html><head><link href="'+cssfile+'" rel="stylesheet" type="text/css"><style>body{	font-family: Arial, Verdana, sans-serif; font-size: 11px; margin: 5px 5px 5px 5px;}</style></head><body>';
	htmlCloser='</body></html>';

	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	popupWin = window.open("", "puWin",  'width='+w+',height='+h+',scrollbars,dependent,resizable,top='+wint+',left='+winl);
	popupWin.document.open("text/html", "replace"); 
	popupWin.document.write(htmlOpener);
	popupWin.document.write(htmlBody);
	popupWin.document.write(htmlCloser);
	popupWin.document.close();  // close layout stream
	popupWin.focus();  // bring the popup window to the front
}

/*	HorizDynTable(id,viewSize,defaultCol,fixedCol)
	--------------------------------------------------------------------------------------------------
	makes a simple table a horizontaly dinamic one.
	viewSize= the number of columns to view at a time
	defaultCol= the default column from which we show viewSize columns initialy
	fixedCol=the column which should not be modified (this usualy contains horizontal labels)

	example of implementation:

	take special care not to name the object the same as the table id, this will cause an error in IE
	
	<table border="1" id="tableT1">
	<tr>
		<td>h</td>	<td>2</td>	<td>3</td>	<td>4</td>	<td>5</td>	<td>6</td>	<td>7</td>
	</tr>
	<tr>
		<td>e</td>	<td>2</td>	<td>3</td>	<td>4</td>	<td>5</td>	<td>6</td>	<td>7</td>
	</tr>
	<tr>
		<td>a</td>	<td>2</td>	<td>3</td>	<td>4</td>	<td>5</td>	<td>6</td>	<td>7</td>
	</tr>
	<tr>
		<td>d</td>	<td>2</td>	<td>3</td>	<td>4</td>	<td>5</td>	<td>6</td>	<td>7</td>
	</tr>
	</table>

	<script language="JavaScript">
	<!--
		t=new HorizDynTable('tableT1',3,3,1);	
	//-->
	</script>
	
	<a href="javascript:t.strafeLeft();">strafe left</a> 
	<a href="javascript:t.strafeRight();">strafe right</a>
*/
function HorizDynTable(id,viewSize,defaultCol,fixedCol){
		if (document.getElementById(id)){
			this.table=document.getElementById(id);
			
		}
		this.DOMLocations=new Array();
		this.DOMLocations['rows']=new Array();
		this.DOMLocations['cols']=new Array();
		this.DOMLocationsrows=new Array();
		this.colVis=new Array();
		
		this.regenDOMLocations=function (){
			//alert(this.table.firstChild.firstChild.nodeName);
			var curRow=1;
			for (bi=0;bi<this.table.childNodes.length;bi++ ){
				
				if (this.table.childNodes[bi].nodeName=='TBODY'){
					//alert(this.table.childNodes[bi].nodeName);
					this.tbody=this.table.childNodes[bi];
					
					for (ri=0; ri<this.tbody.childNodes.length; ri++ ){
					//cycles through the dom until it reaches the first row to index the column positions
						
						if (this.tbody.childNodes[ri].nodeName=='TR'){
							this.DOMLocations['rows'][curRow]=ri;
							curRow++;
							if (this.DOMLocations['cols'].length<1){
								curCol=1;
								for (ci=0; ci<this.tbody.childNodes[ri].childNodes.length; ci++ )	{
									
									if (this.tbody.childNodes[ri].childNodes[ci].nodeName=='TD' || this.tbody.childNodes[ri].childNodes[ci].nodeName=='TH'){

										this.DOMLocations['cols'][curCol]=ci;
										//alert('mapped column: ' + curCol + '=' +ci + this.tbody.childNodes[ri].childNodes[ci].innerHTML);
										curCol++

									}
									
								}
							}
							

						}
						
						
						//table.childNodes[1].childNodes[i].style.borderWidth=i;
					}
					//alert(this.DOMLocations['cols'])
					
					break;
				}
				
				
			}
			
		}
		
		this.getCell=function (row,col){
			//alert('test r: ' + row + ' c:' + col);
			if (this.DOMLocations['rows'][row]>=0 && this.DOMLocations['cols'][col]>=0 ){
			
				//alert('found mapping: r: ' + row + '=' + this.DOMLocations['rows'][row] + ' c: ' + col + '=' + this.DOMLocations['cols'][col]);
				return this.tbody.childNodes[ this.DOMLocations['rows'][row] ].childNodes[ this.DOMLocations['cols'][col] ];
			
			}else{
				//alert('error searching mapping: r: ' + row + '=' + this.DOMLocations['rows'][row] + ' c: ' + col + '=' + this.DOMLocations['cols'][col]);
				return false;
			}
			
		}

		this.getTotalRows=function(){
			return this.DOMLocations['rows'].length;
		}
		this.getTotalCols=function(){
			return this.DOMLocations['cols'].length;
		}

		this.setColVis=function(col,display){
			for (row=1;row<this.getTotalRows() ; row++){
				//alert('requesting: r:' + row+' c:'+col);
				if (cell=this.getCell(row,col))	{
					if (display==true){
						this.getCell(row,col).style.display='';
					}else{
						this.getCell(row,col).style.display='none';
					}
					this.colVis[col]=display;
				}
				
			}
									
		}

		this.getColVis=function(col){
			if (this.colVis[col]){
				return this.colVis[col];
			}else{
				return false;
			}
		}

		
		this.initTable=function(){
			
			if (!fixedCol){
				fixedCol=false;
			}
			if (!defaultCol){
				defaultCol=1;
			}
			if (!fixedCol){
				fixedCol=false;
			}
			if (!viewSize){
				viewSize=this.getTotalCols();
			}
			
			for (col=1;col<this.getTotalCols() ; col++){
					if ((col>=defaultCol && col<defaultCol+viewSize) || col==fixedCol){
						this.setColVis(col,true);
					}else{
						this.setColVis(col,false);
					}
			}
			

		}


		this.strafeLeft=function (){
			this.strafe('L');
			
		}
		this.strafeRight=function (){
			this.strafe('R');
			
		}

		this.strafe=function(LR){
	
				i=this.getFirstVisibleColumn();
					switch (LR)
					{
					case 'L': 
								for (ts=-1; ts<viewSize-1; ts++){
									//alert('found first visible col: '+i);
									this.setColVis(i+ts,true);
								}
								
								if (i-1>0 && i-1!=fixedCol){
									this.setColVis(i+(viewSize-1),false);
								}
						break;

					case 'R':
								if (i+viewSize < this.getTotalCols() && i!=fixedCol){
									this.setColVis(i,false);
								}
								
								for (ts=1; ts<=viewSize; ts++){
									//alert('found first visible col: '+i);
									if (i+ts < this.getTotalCols()){
									//	alert('set vis true: c'+ (i+ts) );
										this.setColVis(i+ts,true);
									}
									
								}
						break;
					}
					
		
		}

		this.getFirstVisibleColumn=function(){
			for (i=1;i<=this.getTotalCols();i++){
				if (this.getColVis(i) && i!=fixedCol){
					return i;
					break;
				}
			}
			return false;
		}

		
		this.getLastVisibleColumn=function(){
			for (i=this.getTotalCols();i>0;i--){
				if (this.getColVis(i) && i!=fixedCol){
					return i;
					break;
				}
			}
			return false;
		}

/*
		this.autoAttachControls=function(){
			lc=this.getLastVisibleColumn();
			//alert(lc);
			this.getCell(1,lc).style.color='blue';

			fc=this.getFirstVisibleColumn();
			//alert(fc);
			this.getCell(1,fc).style.color='red';

			strfleftctrl=document.createElement('a');
			strfleftctrl.appendChild(document.createTextNode('<'))
			//strfleftctrl.addEventListener('click',this.strafeLeft)


			this.getCell(1,fc).appendChild(strfleftctrl);
		}
*/
		this.regenDOMLocations();

		this.initTable();

		
}