var clicked = '';



function set_kraj(kraj) {
    var t = '';
    if(location.href.indexOf('?')!=-1) t = '&kraj='+kraj;
    else t = '?kraj='+kraj;
    location.href = location.href + t;
}

function switch_submenu(submenu) {
   document.getElementById('submenu').innerHTML = $('submenu_'+submenu).get('html');
}


function menu_onover(el, color) {
    el.style.background=color;
}

function menu_onout(el, color) {
    if(clicked != el.id)
    el.style.background=color;
}

function submenu_click(el, color, name) {
    if(clicked!='' && clicked!=el.id) {
        $(clicked).style.background = prev_color;
        $(clicked).style.borderBottomWidth = '4px';
    }
    switch_submenu(name);
    el.style.background=color;
    el.style.borderBottomWidth=0;
    clicked = el.id;
}


function show_hide_elm(div) {
    if(document.getElementById(div).style.display=='none' || document.getElementById(div).style.display=='') {
        document.getElementById(div).style.display='block';
		return true;
    }
    else {
        document.getElementById(div).style.display='none';
		return false;
    }
}

function invert_checkboxes(form) {
    form = document.forms[form];
    
    for(i=0; i< form.elements.length; i++) {
        if(form.elements[i].type=='checkbox' && form.elements[i].disabled==false) {
            if(form.elements[i].checked == true)
            form.elements[i].checked = false;
            else
            form.elements[i].checked = true;
        }
    }
}

function invert_checkboxes_name(form, name) {
    form = document.forms[form];
    
    for(i=0; i< form.elements.length; i++) {
        if(form.elements[i].type=='checkbox' && form.elements[i].disabled==false && form.elements[i].name.indexOf(name)!=-1) {
            if(form.elements[i].checked == true)
            form.elements[i].checked = false;
            else
            form.elements[i].checked = true;
        }
    }
}


function code2utf(num){
  if(num<128)return String.fromCharCode(num);
  if(num<1024)return String.fromCharCode((num>>6)+192)+String.fromCharCode((num&63)+128);
  if(num<32768)return String.fromCharCode((num>>12)+224)+String.fromCharCode(((num>>6)&63)+128)+String.fromCharCode((num&63)+128);
  if(num<2097152)return String.fromCharCode(num>>18+240)+String.fromCharCode(((num>>12)&63)+128)+String.fromCharCode((num>>6)&63+128)+String.fromCharCode(num&63+128);
  return '';
 }
 
 window.addEvent('domready', function() {
	$$('.help_link').each( function(elm) {
		elm.setStyle('cursor', 'pointer');
		elm.addEvent('click', function() {
			window.open('/xl/help/'+elm.get('rel'), 'help', 'toolbar=no,menubar=no,status=no,location=yes,directories=no,copyhistory=no,scrollbars,height=700,width=900');
			//return false;
		});
	});
 });