var so, currenttab, currentsubtab, current, tempsrc, tempobj, tempvar, i, obj, fromselecturl;
currenttab=1;
currentsubtab=1;
currentselect=1;

// which - ktory wlaczyc
// sidemenu - 0 jesli wlaczamy flasha 1 jesli wlaczamy sidemenu
// id - pomocnicze dla zmiany obrazka / pogrubienia

function wlacz(which, sidemenu, id, nselect) {
	if (nselect!=currentselect && groups==true) {
		document.getElementById('groupselect'+currenttab+'-'+currentselect).style.display="none";
		document.getElementById('groupselect'+currenttab+'-'+nselect).style.display="inline";
		currentselect=nselect;
	}
	current = (sidemenu!=0) ? currenttab : currentsubtab;
	if (sidemenu!=0) {
		currenttab = which;
		tempobj = document.getElementById(id+current);
		tempobj.className="normal";
		tempobj = document.getElementById(id+which);
		tempobj.className="chosen";
		
		tempobj = document.getElementById("submenu"+current);
		if (showsubtabs==1) {tempobj.className="tab_submenu submenu_ukryte";}
		tempobj = document.getElementById("submenu"+which);
		if (showsubtabs==1) {tempobj.className="tab_submenu submenu_odkryte";}
			
		
		for (i=0; i<tempobj.childNodes.length; i++) {
			if (tempobj.childNodes[i].nodeName=="LI") {
				if (tempobj.childNodes[i].className!="select_item") {
					tempobj.childNodes[i].className="normal";
				}
			}
		}
		for (i=0; i<tempobj.childNodes.length; i++) {
			if (tempobj.childNodes[i].nodeName=="LI") {
				tempobj.childNodes[i].className="chosen";
				window.open(tempobj.childNodes[i].firstChild.href,"_self");
				break;
			}
		}
	}
	else {
		if (groups) {
			tempobj = document.getElementById(id+current).parentNode;
			tempobj.className="normal";
			tempobj = document.getElementById(id+which).parentNode;
			tempobj.className="chosen";
		}
		else {
			tempobj = document.getElementById(id+current);
			tempobj.className="normal";
			tempobj = document.getElementById(id+which);
			tempobj.className="chosen";
		}
		currentsubtab = which;
		obj = document.getElementById('groupselect'+currenttab+'-'+currentselect);
		if (groups) fromselecturl = obj.options[obj.selectedIndex].value; else fromselecturl = "";
		print_new_flash(which,fromselecturl);
		
		//document.getElementById("wykres_numer").innerHTML = "Wykres "+opis_numer[currentgroup[currenttab]][which];
		document.getElementById("wykres_opis_tekst").innerHTML = opis_tekst[which];
	}
}

// obj - select, ktorym zmieniamy grupe
// tab - w zakresie ktorego taba zmieniamy grupe

function zmien_grupe(obj,tab) {
	fromselecturl = obj.options[obj.selectedIndex].value;
	print_new_flash(currentsubtab,fromselecturl);
}

function print_new_flash(which,fromselecturl) {
	//alert(which);
	xml=data_file_path+data_file[which]+'|'+fromselecturl;
	xml_url=location.protocol+"//"+location.hostname+xml+"|"+Math.random();
	//prompt("xml","https://devv.telarena.pl"+xml);
	
	settings_file_path=settings_file_path+"|r="+Math.random()
	
	//document.getElementById("wykres_debug").innerHTML = "<input type=\"text\" size=\"55\" value=\""+xml_url+"\">";
	
	
	so = new SWFObject("/wykresy/ampie.swf", "graphflash", flashwidth, flashheight, "8", "#FFFFFF");
	so.addParam("wmode","opaque");
	so.addVariable('path',path);
	so.addVariable('settings_file',settings_file_path);
	so.addVariable('data_file',xml);
	so.addVariable('preloader_color',"#424242");
	so.addVariable("loading_settings", "Ładowanie ustawień");
	so.addVariable("loading_data", "Ładowanie danych");
	so.write("graphflashholder");
	

}