var lang_hu = new Array("Nyelv", "Frissitési intervallum", "Operációs rendszer információk", "Processzor információk", " - Merevlemez információk", 
	"CD/DVD információk", "Akkumulátor információk", "Hálózati információk", "Memória információk", "Betűszín", "Szöveg árnyék", "Elhelyezkedés", 
	" - Hálózati meghajtó információk", " - Hordozható eszköz információk", "Tárolóeszköz információk", "CPU frissítés", "Uptime információk",
	"Minden információ közvetlenül a desktop-on.", "Csak a fejlécek látszanak a desktop/sidebar-on, a többi információ felbukkanó ablakokban látható, ha a megfelelő szekció ikonjára kattint",
	"Csak egy ikon látszik a desktop/sidebar-on, a többi információ egy felbukkanó ablakban jelenik meg, ha az ikonra kattint.", "Folyamatos uptime óra", 
	"*a gyakori frissítés és a folyamatos uptime óra lelassíthatja a rendszert!", "CPU grafikus kijelző", "Gadget méret", "Font név");

var lang_en = new Array("Language", "Refresh interval", "Operating system information", "Processor information", " - Harddisk information", 
	"CD/DVD information", "Battery information", "Network information", "Memory information", "Font color", "Text shadow", "Orientation", 
	" - Network drive information", " - Removable storage information", "Storage information", "CPU refresh", "Uptime information",
	"All information displayed directly on desktop.", "Only headers displayed on desktop/sidebar, informa-tion of each section can be seen in flyout windows when You click the section's icon.",
	"Only one icon displayed on desktop/sidebar, all infor-mation can be seen in one flyout window when You click the icon.", "Continous uptime clock", 
	"*short refresh intervals and continous uptime clock may cause high CPU utilization!", "CPU line meters", "Gadget size", "Font name");


function onLoadSetup() 
{
var collCPU = System.Machine.CPUs;
var oCPU = collCPU.item(0);  
var strCPUName = oCPU.name;

	System.Gadget.onSettingsClosing = onSetupClose;
	lang_select.selectedIndex = System.Gadget.Settings.read("lang_idx");
	timer_select.selectedIndex = System.Gadget.Settings.read("timer_idx");
	cputimer_select.selectedIndex = System.Gadget.Settings.read("cputimer_idx");	
	orientation_select.selectedIndex = System.Gadget.Settings.read("orientation");
	size_select.value = System.Gadget.Settings.read("size");
	fonttype_select.value = System.Gadget.Settings.read("fonttype");
	var mode = System.Gadget.Settings.read("mode");
	for(i=0;i<ModeRadio.length;i++)
	{
		if(ModeRadio[i].value == mode)
		{
			ModeRadio[i].checked = true;
			if(i > 0)
				enableHorizontal(false);
		}
	}
		
		
	if(System.Gadget.Settings.read("computer"))
		computer_chk.checked = true;
	if(System.Gadget.Settings.read("processor"))
		processor_chk.checked = true;
	if(System.Gadget.Settings.read("uptime"))
		uptime_chk.checked = true;
	if(System.Gadget.Settings.read("ram"))
		ram_chk.checked = true;
	if(System.Gadget.Settings.read("storage"))
		storage_chk.checked = true;
	if(System.Gadget.Settings.read("hdd"))
		hdd_chk.checked = true;
	if(System.Gadget.Settings.read("netdrive"))
		netdrive_chk.checked = true;
	if(System.Gadget.Settings.read("removable"))
		removable_chk.checked = true;
	if(System.Gadget.Settings.read("dvd"))
		dvd_chk.checked = true;
	if(System.Gadget.Settings.read("battery"))
		battery_chk.checked = true;
	if(System.Gadget.Settings.read("network"))
		network_chk.checked = true;		
	if(System.Gadget.Settings.read("shadow"))
		shadow_select.checked = true;
	if(System.Gadget.Settings.read("upcontinous"))
		upcontinous_select.checked = true;
	if(System.Gadget.Settings.read("cpubars"))
		cpubars_select.checked = true;
	if(System.Gadget.Settings.read("color") != "")
		color_select.value = System.Gadget.Settings.read("color");
	else
		color_select.value = "white";
	
	var lang=lang_en;	
	if(lang_select.selectedIndex == 1)
		lang = lang_hu;
		
	lang_label.innerText = lang[0];
	timer_label.innerText = lang[1];
	computer_label.innerText = lang[2];
	processor_label.innerText = lang[3];
	hdd_label.innerText = lang[4];
	dvd_label.innerText = lang[5];
	battery_label.innerText = lang[6];
	network_label.innerText = lang[7];
	ram_label.innerText = lang[8];
	color_label.innerText = lang[9];
	shadow_label.innerText = lang[10];
	orientation_label.innerText = lang[11];
	netdrive_label.innerText = lang[12];
	removable_label.innerText = lang[13];
	storage_label.innerText = lang[14];
	cputimer_label.innerText = lang[15];
	uptime_label.innerText = lang[16];
	normal_info.innerText = lang[17];
	compact_info.innerText = lang[18];
	compressed_info.innerText = lang[19];
	upcontinous_label.innerText = lang[20];
	warning.innerText = lang[21];
	cpubars_label.innerText = lang[22];
	size_label.innerText = lang[23];
	fonttype_label.innerText = lang[24];
	
	changeStorageDisplay()
}

function changeStorageDisplay()
{
	if(storage_chk.checked)
	{
		hdd_label.disabled = true;
		hdd_chk.disabled = true;
		netdrive_label.disabled = true;
		netdrive_chk.disabled = true;
		removable_label.disabled = true;
		removable_chk.disabled = true;		
	}
	else
	{
		hdd_label.disabled = false;
		hdd_chk.disabled = false;
		netdrive_label.disabled = false;
		netdrive_chk.disabled = false;
		removable_label.disabled = false;
		removable_chk.disabled = false;			
	}
}

function enableHorizontal(enable)
{
	if(enable)
	{
		orientation_label.disabled = false;
		orientation_select.disabled = false;
	}
	else
	{
		orientation_label.disabled = true;
		orientation_select.disabled = true;
	}
}

function onSetupClose(event)
{		
	if (event.closeAction == event.Action.commit) 
    {
		System.Gadget.Settings.write("lang_idx", lang_select.selectedIndex);	
		System.Gadget.Settings.write("timer_idx", timer_select.selectedIndex);
		System.Gadget.Settings.write("timer_val", timer_select.value);
		System.Gadget.Settings.write("cputimer_idx", cputimer_select.selectedIndex);
		System.Gadget.Settings.write("cputimer_val", cputimer_select.value);
		System.Gadget.Settings.write("computer", computer_chk.checked);
		System.Gadget.Settings.write("uptime", uptime_chk.checked);
		System.Gadget.Settings.write("processor", processor_chk.checked);
		System.Gadget.Settings.write("ram", ram_chk.checked);
		System.Gadget.Settings.write("storage", storage_chk.checked);
		System.Gadget.Settings.write("hdd", hdd_chk.checked);
		System.Gadget.Settings.write("netdrive", netdrive_chk.checked);
		System.Gadget.Settings.write("removable", removable_chk.checked);
		System.Gadget.Settings.write("dvd", dvd_chk.checked);
		System.Gadget.Settings.write("battery", battery_chk.checked);
		System.Gadget.Settings.write("network", network_chk.checked);
		System.Gadget.Settings.write("color", color_select.value);
		System.Gadget.Settings.write("shadow", shadow_select.checked);
		System.Gadget.Settings.write("orientation", orientation_select.selectedIndex);
		System.Gadget.Settings.write("size", size_select.value);
		System.Gadget.Settings.write("upcontinous", upcontinous_select.checked);
		System.Gadget.Settings.write("cpubars", cpubars_select.checked);
		System.Gadget.Settings.write("fonttype", fonttype_select.value);
		mode = "0";
		for(i=0;i<ModeRadio.length;i++)
		{
			if(ModeRadio[i].checked)
				mode = ModeRadio[i].value;
		}
		System.Gadget.Settings.write("mode", mode);
	}
		
	event.cancel = false;
}