/**/

var ftxmlHttp = createXmlHttpRequestObject();
var cur_chartbox;

function toggleChartTab(item, act) {
	if(item.className == 'NavHigh') return;
	if(act=='off') item.className = 'NavPassiv';
	else item.className = 'NavAktiv';
	
	
}

function deactivateme(item) {
	item.className = 'NavPassiv';	
}

function ch_chart(symbol, range, chdom) {

	var item; 
	var feed = '';
	
	t = new Array("intra", 1, 3, 12, 36, 60);
	while(r = t.shift()) {
		dom = chdom+"_"+r;
		//alert(document.getElementById(dom));
		item = document.getElementById(dom);
		if(!item || dom==chdom+'_'+range) continue;
		if(item.className == "NavHigh") {
			item.className = 'NavPassiv';
		}
	}
	
	
	dom = chdom+"_"+range;
	item = document.getElementById(dom); 
	item.className = "NavHigh";
	
	/*feed = feed + '---------- \n';
	
	t = new Array("intra", 1, 3, 12, 36, 60);
	while(r = t.shift()) {
		dom = chdom+"_"+r;
		item = document.getElementById(dom);
		if(!item) continue;
		feed = feed + item.id + ' - ' + item.getAttribute('onmouseover')+'\n';
	}
	alert(feed);
	*/
	ajaxGetChart(symbol, range, chdom);
}

function ajaxGetChart(symbol, range, chdom) {
	if(!ftxmlHttp || (ftxmlHttp.readyState!=0 && ftxmlHttp.readyState!=4)) {
		alert('Nicht bereit zur Verbindung.');
		return;
	}
	cur_chartbox = chdom;
	var charturl = "/ajaxchart.php";
	try {
		ftxmlHttp.open("POST", charturl, true);
		ftxmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ftxmlHttp.onreadystatechange = ajaxGetChartState;		
		ftxmlHttp.send("item="+symbol+"&hist="+range+"&size=mid");
	} catch(e) { alert("Can't connect to server:\n"+e.toString());}
	
	//alert(cur_chartbox);
}

function ajaxGetChartState() {
	
	dom = cur_chartbox+"_img";	
	
	if(ftxmlHttp.readyState==1) {
		 document.getElementById(dom).src = "/img/wait-1.gif"; 	
		 document.getElementById(dom).style.margin = "50px 0px 0px 140px";
		 return;
	} 
	else if(ftxmlHttp.readyState==4) {
		if(ftxmlHttp.status!=200) {	alert("There was a problem retrieving the data.\n"+ftxmlHttp.statusText);	return;	} 
		try {	
			setTimeout("setChart(ftxmlHttp.responseText, dom)", 100);
			
		}
		catch(e) {alert("Error reading the response:\n"+e.toString());}
	}
}

function setChart(img, dom) {
	document.getElementById(dom).style.margin = "0px";
	document.getElementById(dom).src = img;
}

function notin() {}


