var d=document;
function load_ajax(todo,param1,param2,param3,param4){
hform.todo.value=todo;

hform.param1.value=param1;
hform.param2.value=param2;
hform.param3.value=param3;
hform.param4.value=param4;
hform.submit();
}

function show_progs(opt_ar,prog){
var selel = d.getElementById('programm_select');
while (selel.options.length) selel.options[0] = null;
for(i=0;i<opt_ar.length/3;i++){
selel.options[i]=new Option(opt_ar[i*3+1],opt_ar[i*3]);
selel.options[i].setAttribute('value1',opt_ar[i*3+2]);
if (prog==opt_ar[i*3+2]) selel.options[i].selected='selected';
}
}

function show_countries(opt_ar,country){
var selel = d.getElementById('country_select');
while (selel.options.length) selel.options[0] = null;
for(i=0;i<opt_ar.length/2;i++){
selel.options[i]=new Option(opt_ar[i*2+1],opt_ar[i*2]);
if (country==opt_ar[i*2]) selel.options[i].selected='selected';
}
}

function quick_click(){
	var selel = d.getElementById('programm_select');
	var cel = d.getElementById('country_select');
	var url = selel.options[selel.selectedIndex].value;
	if ((url!='')&&(url!=0)) {
		ar = url.split(';');
		if (cel.selectedIndex==0) window.location.href =  url;
		else if (ar[cel.selectedIndex-1]) window.location.href = url;
	}
}

function country_selected(){
var cel = d.getElementById('country_select');
var cel_p = d.getElementById('programm_select');
load_ajax('load_progs',cel.options[cel.selectedIndex].value,lang,cel_p.options[cel_p.selectedIndex].getAttribute('value1'));
}

function programm_selected(){
var cel = d.getElementById('programm_select');
var cel_c = d.getElementById('country_select');
load_ajax('load_countries',cel.options[cel.selectedIndex].getAttribute('value1'),lang,cel_c.options[cel_c.selectedIndex].value);
}

function pop(n,w,h) {
var t=(document.layers) ? "" : "title";
var a=t ? "закрыть окно" : "''";
win=window.open('','','width='+w+',height='+h+',toolbar=0,scrollbars=0,resizable=1');
var d = win.document;
d.open();
d.writeln("<html><head><title>"+t+"</title><meta http-equiv=Content-Type content='text/html; charset=windows-1251'></head>");
d.writeln("<body bgcolor=white marginwidth=0 marginheight=0 topmargin=0 leftmargin=0><table width="+w+" border=0 cellspacing=0 cellpadding=0><tr><td align=center valign=middle height="+h+"><a href=# onclick=window.close()><img src="+n+" width="+w+" border=0 alt="+a+"></a></td></tr></table></body></html>");
d.close();
win.focus();
}
