
var td_click=false;
var x=0;
var event_flag=0;
var curr_row=-1;
var curr_id=-1;

function main_load(msg) {
    if (msg!='') {
        last_event(msg);
        setTimeout("last_event_clean()", 5000);
    }
	var obj=document.getElementById('mylogin');
    if (obj!=null) obj.focus();
}

function iframe_load(msg,if_name) {
    last_event(msg);
    iframe_height(if_name);
}

function startClock(){
    if (x!=1) {
        setTimeout("startClock()", 200);
        x=1;
    } else {
        td_click=false;
    }
}

function open_id (href) {
    if (!td_click)
    document.location=href;
}

function del_id (caption,href) {
    td_click=true;
    if (confirm(caption)) document.location=href;
    startClock();
}

function end_loading() {
	var obj=top.document.getElementById('loading');
	if (obj!=null) {obj.innerHTML='';}
}

function last_event(msg) {
    end_loading();
	var obj=top.document.getElementById('last_event');
    if ((msg!=null)&&(obj!=null)) {
        obj.innerHTML=msg;
        setTimeout("last_event_clean()", 5000);
    }
}

function last_event_clean() {
 	var obj=top.document.getElementById('last_event');
    if (obj!=null) obj.innerHTML='';
}

function set_curr(prno,pid) {
    curr_row=prno;
    curr_id=pid;
    var i=0;
    var obj;
	var tbl = document.getElementById('ho');
    if (tbl!=null) {
  		for (i=0;i<tbl.rows.length;i++) {
			if (i & 1) tbl.rows[i].className='odd'; else tbl.rows[i].className='even';
			if (i==prno) tbl.rows[i].className='sel';
        }
    }
	var obj=document.getElementById('curr_id');	if (obj!=null) { obj.value=pid; }
}

function set_curr_id(pid) {
    curr_id=pid;
    var i=0;
    var rno=0;
    var obj;
	var tbl = document.getElementById('ho');
    if (tbl!=null) {
  		for (i=0;i<tbl.rows.length;i++) {
			if (i & 1) tbl.rows[i].className='odd'; else tbl.rows[i].className='even';
            if (tbl.rows[i].id==pid) {
                tbl.rows[i].className='sel';
                curr_row=i;
            }
        }
    }
	var obj=document.getElementById('curr_id');
    if (obj!=null) { obj.value=pid; }
}

function set_rno(prno) {
    var i=0;
	var tbl = document.getElementById('rno');
    if (tbl!=null) {
  		for (i=0;i<tbl.rows.length;i++) {
			tbl.rows[i].className='undefined';
			if (i==prno-1) tbl.rows[i].className='sel';
        }
    }
}

function iframe_height(ifname) {
    var ifr=top.document.getElementById(ifname);
    if (ifr!=null) {
        var innerDoc = (ifr.contentDocument) ? ifr.contentDocument : ifr.contentWindow.document;
        var o=innerDoc.getElementById('last_tag');
        if (o!=null) {
            ifr.height=o.offsetTop+30;
        }
    }
}

var handleFailure_apply = function(o){
    last_event('Ошибка выполнения!');
};


