var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
var isFirefox = (navigator.userAgent.indexOf("Firefox") != -1);
function getel(id)
{
return document.getElementById(id);
}
function _GetElementById(id)
{
	return document.all[id];
}
if (document.getElementById == null)
{	document.getElementById = _GetElementById;}

function is_array(x) {
    return ((typeof x == "object") && (x.constructor == Array));
} 
function in_array(a,val)
{
i=0;alen=a.length;
while(i<alen){if(a[i]==val)return true;i++;}
return false;
}
function array_serch(a,val)
{
i=0;alen=a.length;
while(i<alen){if(a[i]==val)return i;i++;}
return null;
}
function showmenu(show)
{
var bt=document.getElementById("menu_hs");
if(bt==null)return;
var obj=window.parent.document.getElementById("lfs1");
if(obj!=null)
{
        if(show=="show"){obj.cols="30%,*";bt.href="javascript:showmenu('show_all');";}
        else if(show=="show_all"){obj.cols="90%,*";bt.href="javascript:showmenu('hide');";}
        else {obj.cols="0,*";bt.href="javascript:showmenu('show');";}
}
}
flag_onload=false;
function addonload(fn)
{
onload_handlers[onload_handlers.length]=fn;
}

function popup(URL)
{
return newwin(URL,600,500);
}
function newwin(URL,w,h,scroll,resize)
{
if(scroll==null)scroll='yes';
if(resize==null)resize='yes';

if(isOpera)
{
        x=mouse_page_x;
        y=mouse_page_y;        
        x=x-w/2;
        y=y-h/3;
}
else
{
        x=mouse_scr_x;
        y=mouse_scr_y;        
        x=x-w/2;
        y=y-h/2;
        if(x<0)x=0;
        if(y<0)y=0;
        if((x+w)>screen.availWidth)x=screen.availWidth-w;
        if((y+h)>screen.availHeight)y=screen.availHeight-h;
}
reg_win=window.open(URL, '','left='+x+',top='+y+',width='+w+',height='+h+',scrollbars='+scroll+',resizable='+resize+',status=no');
}

function FitPopupSize()
{
mt_obj=document.all['main_table'];
if(typeof(mt_obj)!='object')return;
if(isOpera)_h=50;
else if(isMSIE)_h=40;
else if(isFirefox)_h=70;
else _h=0;
min_heigth=300;
min_width=150;

max_heigth=600;
//max_width=800;
max_width=3000;
mt_width=mt_obj.width;
mt_obj.width="";
if(mt_obj.clientWidth!="")
{
window.resizeBy(15,15);
__h=mt_obj.clientHeight;
__w=mt_obj.clientWidth+10
if(__h>max_heigth)__h=max_heigth;
if(__w>max_width)__w=max_width;
if(__h<min_heigth)__h=min_heigth;
if(__w<min_width)__w=min_width;

window.resizeTo(__w+10,__h+_h);
window.resizeBy(15,15);
}
else if(mt_obj.innerWidth!="")
{
alert('innerWidth');
window.resizeTo(mt_obj.innerWidth+30,mt_obj.innerHeight+50);
}
mt_obj.width=mt_width;           
}
function CheckTab(obj) {
  if ((9==event.keyCode)) {
    obj.selection=document.selection.createRange();
    setTimeout("ITAB('"+obj.id+"')",0)
  }
}
function CheckENT(obj) {
if(typeof(event)!='object')return;
if (13==event.keyCode) 
{
        if(typeof(obj) =='object')obj.blur();
}
return true;
}
function ITAB(id) {
  document.all[id].selection.text=String.fromCharCode(9)
  document.all[id].focus()
}
mouse_scr_x=-1;
mouse_scr_y=-1;
mouse_page_x=-1;
mouse_page_y=-1;
function _onmousemove(e)
{
window.event? mouse_page_x=window.event.x : mouse_page_x=e.pageX;
window.event? mouse_page_y=window.event.y : mouse_page_y=e.pageY;
window.event? mouse_scr_x=window.event.screenX : mouse_scr_x=e.screenX;
window.event? mouse_scr_y=window.event.screenY : mouse_scr_y=e.screenY;
}
document.onmousemove=_onmousemove;



//TIMESTAMP FUNCTIONS
function TS2Date(TS) {
	var re_date_ts = /^(\d+)\-(\d+)\-(\d+) (\d+):(\d+):(\d+)$/;
    if(re_date_ts.exec(TS)){return (new Date (RegExp.$1, RegExp.$2-1, RegExp.$3, RegExp.$4, RegExp.$5, RegExp.$6));}
    return null;
}
function DT2Date(DT) {
    var re_date = /^(\d+):(\d+) (\d+)\.(\d+)\.(\d+)$/;
    if(re_date.exec(DT)){year=RegExp.$5;if(year<100)if(year<30)year=year*1+2000;else year=year*1+1900;return (new Date (year, RegExp.$4-1, RegExp.$3, RegExp.$1, RegExp.$2, 0));}
    return null;
}

function TS2DT (TS)
{
	var re_date_ts = /^(\d+)\-(\d+)\-(\d+) (\d+):(\d+):(\d+)$/;
    if(re_date_ts.exec(TS)){year=RegExp.$1%100;if(year<10)year="0"+year;return RegExp.$4+":"+RegExp.$5+" "+RegExp.$3+"."+(RegExp.$2)+"."+year}
    return null;
}
function DT2TS (DT)
{
    var re_date = /^(\d+):(\d+) (\d+)\.(\d+)\.(\d+)$/;
    if(re_date.exec(DT)){year=RegExp.$5;if(year<100)if(year<30)year=year*1+2000;else year=year*1+1900; return year+"-"+(RegExp.$4)+"-"+RegExp.$3+" "+RegExp.$1+":"+RegExp.$2+":00";}
    return null;
}
function NowTS()
{
d=new Date();
return d.getFullYear()+"-"+c0t(d.getMonth()+1)+"-"+c0t(d.getDate())+" "+c0t(d.getHours())+":"+c0t(d.getMinutes())+":"+c0t(d.getSeconds());
}
function c0t(v)
{
if(v>=0&&v<10)return "0"+v;
else return v;
}
