/* SIBEX 2009 */
var date_anuale = Array('2010','2009','2008','2007','2006','2005','2004','2003','2002','2001','2000','1999','1998','1997');

function blink_background(target){
	oldcolor = document.getElementById(target).style.bgColor;
	x1 = document.getElementById(target).style.bgColor = "D8EDFF";
	setTimeout("back_background('"+target+"','"+oldcolor+"')",1000);
}

function back_background(target,oldcolor){
	x1 = document.getElementById(target).style.bgColor = oldcolor;
}

function open_detalii(id_div,pozitie){
	divuli = 'intermediar'+id_div;
	x1 = document.getElementById(divuli).style.display;
	if(pozitie=='1'){
  		document.getElementById(divuli).style.display="none";
  		}
	else{
		document.getElementById(divuli).style.display = "block";
   }
}


function scrie_ani(){
		html_text = '<tr>';
		for(i=0;i<date_anuale.length-4;i++){
			html_text += '<td onClick="arata_div('+ i + ','+ date_anuale.length+');" id="td_'+i+'"';
			if(i==0) html_text +='style="background-color:#F1F1EC;cursor:pointer;"';
			  else html_text +='style="cursor:pointer;"';
			html_text += 'align="center"><font class="" id="text_"' + 'i' + '>' + date_anuale[i] + '</font></td>';
		}
		html_text += '</tr>';
		html_text += '<tr>';
		for(i=date_anuale.length-4;i<date_anuale.length;i++){
			html_text += '<td onClick="arata_div('+ i + ','+ date_anuale.length+');" id="td_'+i+'"';
			if(i==0) html_text +='style="background-color:#F1F1EC;cursor:pointer;"';
			  else html_text +='style="cursor:pointer;"';
			html_text += 'align="center"><font class="" id="text_"' + 'i' + '>' + date_anuale[i] + '</font></td>';
		}
		html_text += '</tr>';
		document.write(html_text);
	}

function pic_chng(st_dr,stare){
	if(st_dr=='1'){
		 x = document.getElementById("photo_stanga");
		 if(stare=='1') x.src="docs/despre/imagini/arrow_l_up.png";
		 if(stare=='2') x.src="docs/despre/imagini/arrow_l_dwn.png";
		 if(stare=='3') x.src="docs/despre/imagini/arrow_l.png";
	 }
	if(st_dr=='2'){
		 x = document.getElementById("photo_dreapta");
		 if(stare=='1') x.src="docs/despre/imagini/arrow_r_up.png";
		 if(stare=='2') x.src="docs/despre/imagini/arrow_r_dwn.png";
		 if(stare=='3') x.src="docs/despre/imagini/arrow_r.png";
	}
}

function timeline(an_af,ultim){
  for(i=1994;i<=ultim;i++){
		divul = 'infoan'+i;
		poza = 'pozaan'+i;
		document.getElementById(divul).style.display="none";
		poza1="img/timeline/"+i+".png"
  		document.getElementById(poza).src=poza1;
  }
  divul = 'infoan'+an_af;
  poza = 'pozaan'+an_af;
  document.getElementById(divul).style.display="block";
  poza1="img/timeline/"+an_af+"_a.png"
  document.getElementById(poza).src=poza1;
}

function downdiv(identif){
  divul = 'intermed'+identif;
  poza = 'poza_x'+identif;
  x = document.getElementById(divul).style.display;
  if(x=='block'){
  		document.getElementById(divul).style.display="none";
  		document.getElementById(poza).src="img/div_down.png";
  		}
  else{
   	document.getElementById(divul).style.display = "block";
	document.getElementById(poza).src="img/div_up.png";
   }
}

function enableItem(){
	x= document.getElementById("v10").checked;
	if(x){
	   document.getElementById("v101").readOnly =false;
	   }
	else{
	   document.getElementById("v101").value ='';
	   document.getElementById("v101").readOnly =true;
	  }
}

function update_futures(lang){
	subject_id = "111";
	http.open("GET","read_futures_read.php?lang="+lang,true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
	var date = new Date();
	var hour = date.getHours();
	if((hour>=9)&&(hour<19)) setTimeout("update_futures('"+lang+"')",10500);
}

function update_grafics(){
	subject_id = "grafice_lo";
	http.open("POST","http://www.sibex.ro/grf/qwerty_alex.php",true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
	var date = new Date();
	var hour = date.getHours();
	var minutes = date.getMinutes();
	var seconds = date.getSeconds();
	var timp_de_scris = hour + ":" + minutes + ":" + seconds;
	var content = document.getElementById("list_mo").innerHTML;
	document.getElementById("list_mo").innerHTML = document.getElementById("list_mo").innerHTML + '<br>'+timp_de_scris;
	if((hour>=9)&&(hour<19)) setTimeout("update_grafics()",10500);
}

function update_options(lang){
	subject_id = "112";
	http.open("POST","read_options_read.php?lang="+lang,true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
	var date = new Date();
	var hour = date.getHours();
	if((hour>=9)&&(hour<19)) setTimeout("update_options('"+lang+"')",10500);
}

function update_spot(lang){
	subject_id = "113";
	http.open("POST","read_spot_read.php?lang="+lang,true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
	var date = new Date();
	var hour = date.getHours();
	if((hour>=9)&&(hour<19)) setTimeout("update_spot('"+lang+"')",60000);
}

function update_volume(lang){
	subject_id = "22";
	http.open("POST","update_volume.php?lang="+lang,true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
		var date = new Date();
	var hour = date.getHours();
	if((hour>=9)&&(hour<19)) setTimeout("update_volume('"+lang+"')",9500);
}


function put_title(simbolx){
	var temp = new Array();
	temp = simbolx.split('-');
	contract = temp[0];
	settle = temp[1];
	simboly= simbolx.replace("/", "~");
	filename = 'grf/' + simboly + '.png';
	var y = document.getElementById("chart_image").src = filename;
}

function error_chart(){
	var y = document.getElementById("chart_image").src = 'img/chart/no_image.png';
}
function clock(lang) {
var date = new Date();
var year = date.getYear();
if (year < 1000)
	year+=1900;
var month = date.getMonth();
var day = date.getDate();
var dayo = date.getDay();
var hour = date.getHours();
var minute = date.getMinutes();
var second = date.getSeconds();
var timp = " / ";
	if(lang=='en'){
		months = Array("january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december");
		dayarray = Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	}
	if(lang=='ro'){
		months = Array("ianuarie", "februarie", "martie", "aprilie", "mai", "iunie", "iulie", "august", "septembrie", "octombrie", "noiembrie", "decembrie");
		dayarray = Array("Duminica","Luni","Marti","Miercuri","Joi","Vineri","Sambata");
	}
	if(lang=='de'){
		months = Array("Januar", "Februar", "März", "April", "May", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
		dayarray = Array("Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag");
	}
var monthname = months[month]


if (minute < 10) {
minute = "0" + minute
}

if (second < 10) {
second = "0" + second
}


document.getElementById("theTime").innerHTML = dayarray[dayo] + " " + day + " " + monthname + " " + year + timp + hour + ":" + minute + ":" + second

setTimeout("clock()", 1000)
}

function calling(ind,settle){

	divuri = Array('dea1','dea2','dea3','dea4','dea5','dea6','dea7','dea8','dea9','dea10','dea11','dea12','dea13','dea14','dea15','dea16','dea17','dea18','dea19','dea20','dea21','dea22','dea23','dea24','dea25','dea26','dea27','dea28','dea29','dea30','dea31','dea32','dea33','dea34','dea35','dea36','dea37');
	v1= Array('EUA','CFD','DEC09','IAN10','FEB10','MAR10','APR10','MAI10','IUN10','IUL10','AUG10','SEP10','OCT10','NOV10','DEC10','MAR11','IUN11','SEP11','DEC11');
	v2= Array('scadenta zilnica','nu au scadenta','18 decembrie 2009','15 ianuarie 2010','19 februarie 2010','19 martie 2010','16 aprilie 2010','21 mai 2010','18 iunie 2010','16 iulie 2010','20 august 2010','17 septembrie 2010','15 octombrie 2010','19 noiembrie 2010','17 decembrie 2010','18 martie 2011','18 iunie 2011','17 septembrie 2011','17 decembrie 2011');

	for(j=0;j<37;j++){
		if(v1[j]==settle) data_scadenta = v2[j];
	}

	divul_de_schimbat = ind+'_settle';
	document.getElementById(divul_de_schimbat).innerHTML = data_scadenta;

	for(i=0;i<37;i++){
 		document.getElementById(divuri[i]).style.display = "none";
	}
	if(ind=='DESIF2') ind1='dea1';
	if(ind=='DESIF5') ind1='dea2';
	if(ind=='DESNP') ind1='dea3';
	if(ind=='DETLV') ind1='dea4';
	if(ind=='EUR/RON') ind1='dea5';
	if(ind=='DEBRK') ind1='dea6';
	if(ind=='SIF1') ind1='dea7';
	if(ind=='SIF2') ind1='dea8';
	if(ind=='SIF3') ind1='dea9';
	if(ind=='SIF4') ind1='dea10';
	if(ind=='SIF5') ind1='dea11';
	if(ind=='DESIF1') ind1='dea12';
	if(ind=='DESIF3') ind1='dea13';
	if(ind=='DESIF4') ind1='dea14';
	if(ind=='BCC') ind1='dea15';
	if(ind=='BRD') ind1='dea16';
	if(ind=='BRK') ind1='dea17';
	if(ind=='CHF/RON') ind1='dea18';
	if(ind=='DEBCC') ind1='dea19';
	if(ind=='DECMP') ind1='dea20';
	if(ind=='DEEBS') ind1='dea21';
	if(ind=='DERRC') ind1='dea22';
	if(ind=='DESBX18') ind1='dea23';
	if(ind=='DESBX9') ind1='dea24';
	if(ind=='DETEL') ind1='dea25';
	if(ind=='DETGN') ind1='dea26';
	if(ind=='EUR/RON5') ind1='dea27';
	if(ind=='EUR/USD') ind1='dea28';
	if(ind=='SIBGOLD') ind1='dea29';
	if(ind=='SNP') ind1='dea30';
	if(ind=='TLV') ind1='dea31';
	if(ind=='USD/RON') ind1='dea32';
	if(ind=='DEBRD') ind1='dea33';
	if(ind=='DEDJIA_RON') ind1='dea34';
	if(ind=='CO2_RON') ind1='dea35';
	if(ind=='DESBX') ind1='dea36';
	if(ind=='SIBGOLD_USD') ind1='dea37';
	x = document.getElementById(ind1).style.display = "block";

	TagToTip("deascuns");
}

function calling_a(ind,settle){

	divuri = Array('ded1');

	for(i=0;i<1;i++){
 		document.getElementById(divuri[i]).style.display = "none";
	}
	if(ind=='SBX') ind1='ded1';
	x = document.getElementById(ind1).style.display = "block";

	TagToTip("deascuns1");
}

function do_line(linie,toate){
	for(i=1;i<=toate;i++){
		document.getElementById('td_f'+i).style.textDecoration = "none";
		document.getElementById('tf_f'+i).style.textDecoration = "none";
	}
	document.getElementById('td_f'+linie).style.textDecoration = "underline";
	document.getElementById('tf_f'+linie).style.textDecoration = "underline";
}

function spot_under(linie1,toate1){
	for(i=1;i<=toate1;i++){
		document.getElementById('spot_font'+i).style.textDecoration = "none";
		document.getElementById('spot_font1'+i).style.textDecoration = "none";
	}
	document.getElementById('spot_font'+linie1).style.textDecoration = "underline";
	document.getElementById('spot_font1'+linie1).style.textDecoration = "underline";
}

function on_stat_click(moment,total){
	for(i=1;i<=total;i++){
 		document.getElementById('inside_stat'+i).style.display = "none";
 		document.getElementById('font' + i).style.textDecoration = "none";
	}

	x = document.getElementById('inside_stat'+ moment).style.display = "block";
	y = document.getElementById('font' + moment).style.textDecoration = "underline";
}

function on_com_click(moment,total){
	for(i=1;i<=total;i++){
 		document.getElementById('inside_com'+i).style.display = "none";
 		document.getElementById('fontc' + i).style.textDecoration = "none";
 		document.getElementById('td_comm_' + i).style.background = "url(img/comm_inactiv.png)";
 		document.getElementById('td_comm_c' + i).style.background = "url(img/comm_inactiv_c.png)";
 		document.getElementById('td_comm_r' + i).style.background = "url(img/comm_inactiv_r.png)";
	}

	x = document.getElementById('inside_com'+ moment).style.display = "block";
	y = document.getElementById('fontc' + moment).style.textDecoration = "underline";
 	z1 = document.getElementById('td_comm_' + moment).style.background = "url(img/comm_activ.png)";
 	z2 = document.getElementById('td_comm_c' + moment).style.background = "url(img/comm_activ_c.png)";
 	z3 = document.getElementById('td_comm_r' + moment).style.background = "url(img/comm_activ_r.png)";
}

function arata_div(care,total){
	for(i=0;i<total;i++){
 		document.getElementById('div_an_'+i).style.display = "none";
 		document.getElementById('td_'+i).bgColor  = "#FFFFFF";
 		document.getElementById('td_'+i).style.textDecoration = "none";
	}
	x = document.getElementById('div_an_'+care).style.display = "block";
	y = document.getElementById('td_'+care).bgColor  = "#F1F1EC";
	z = document.getElementById('td_'+care).style.textDecoration = "underline";

}

function open_report(month_n,an){
	if(month_n=='1') pagina = 'ianuarie'+an+'.xls';
	if(month_n=='2') pagina = 'ianuarie'+an+'.xls';
	if(month_n=='3') pagina = 'ianuarie'+an+'.xls';
	if(month_n=='4') pagina = 'ianuarie'+an+'.xls';
	if(month_n=='5') pagina = 'ianuarie'+an+'.xls';
	if(month_n=='6') pagina = 'ianuarie'+an+'.xls';
	if(month_n=='7') pagina = 'ianuarie'+an+'.xls';
	if(month_n=='8') pagina = 'ianuarie'+an+'.xls';
	if(month_n=='9') pagina = 'ianuarie'+an+'.xls';
	if(month_n=='10') pagina = 'ianuarie'+an+'.xls';
	if(month_n=='11') pagina = 'ianuarie'+an+'.xls';
	if(month_n=='12') pagina = 'ianuarie'+an+'.xls';
	window.open ("statistici/zilnice/"+pagina,"Download lunar");
}

function underline_s(linie,pagina){
	for(i=1;i<=12;i++){
 		document.getElementById('tf_'+pagina+i).style.textDecoration = "none";
	}
	document.getElementById('tf_'+pagina+linie).style.textDecoration = "underline";

}
