moz=document.getElementById&&!document.all;
isIE6 = /msie|MSIE 6/.test(navigator.userAgent); 
var clona_zapnuta=false;
if (!document.getComputedStyle){
  if(!document.defaultView){
    document.getComputedStyle = function(el, pseudo) {
    this.el = el;
    this.getPropertyValue = function(prop) {
    var re = /(\-([a-z]){1})/g;
    if (prop == 'float') prop = 'styleFloat';
    if (re.test(prop)) {
      prop = prop.replace(re,function(){return arguments[2].toUpperCase();});
      };
      return el.currentStyle[prop] ? el.currentStyle[prop] : null;
    };
    return this;
    };
  }else{
    if(!document.defaultView.getComputedStyle){
    }else{
      document.getComputedStyle = function(el, pseudo){ return document.defaultView.getComputedStyle(el, pseudo);  }
    };
  };
};

function dumbcm(){
  this.pi=function(){
    return 0;
  }
}

var cm=new dumbcm();

function stripix(s){if(s==null)return 0;var re=/px/gi;var c=s.replace(re,'');return Number(c);};

function e(o){return document.getElementById(o)}
function el(o){return document.getElementById(o)}
function goNewWindow(url){var newWindow = window.open(url, '_blank');newWindow.focus();}
function go(url){location.href=url;}
function go(url,e){if (url) location.href=url;if (!e) var e = window.event;e.cancelBubble = true;if (e.stopPropagation) e.stopPropagation();return false;}
function show_element(name){e(name).style.display='block';return false;}
function hide_element(name){
  e(name).style.display='none';
  var o = document.getElementById('clona_'+name);if(o)hide_new_popup(name);
  return false;
}
function hide_current_row(t)
{
    while ((t) && (t.parentNode))
    {
        if (t.nodeName.toLowerCase() == 'tr')
        {
            t.style.display = 'none';
            return;
        }
        t=t.parentNode;
    }
    alert(t.nodeName);
}
function switchVisibility(what)
{
    if (typeof(what) == "object")
    {
        if ((what.style.display == 'none') || (what.style.display == ''))
        {
            what.style.display = 'block';
        } else {
            what.style.display = 'none';
        }
    } else {
        if ((el(what).style.display == '') || (el(what).style.display == 'none'))
        {
            el(what).style.display = 'block';
        } else {
            el(what).style.display = 'none';
        }
    }
}
            function switchXBTN(elId){
			  var a=document.getElementById('xbox_'+elId);
			  if(!a)return false;
              if ((a.style.display=='block')||(a.style.display==''))a.style.display='none';
              else a.style.display='block';

			  var b=document.getElementById('xbtn_'+elId);
			  if(!b)return false;
              if ((a.style.display=='block'))b.src='/img/agency/icon_group_hide.gif';
              else b.src='/img/agency/icon_group_show.gif';
            }

function mini_modal_message(t,text,color,auto_close)
{
var p = t;
x = 0;
y = 0;
while(p && p.offsetParent)
{
    x += p.offsetLeft;
    y += p.offsetTop;
    p = p.offsetParent;
}
dx = t.offsetWidth;
dy = t.offsetHeight;
if (!color) color = 'red';
e('mini_message_div_bg').style.display = 'block';
e('mini_message_div_bg').style.backgroundImage = 'url(\'/img/bg_'+color+'_mini_modal_dialog.png\')';
e('mini_message_div_bg').style.left = x + dx - t.offsetWidth-200;
e('mini_message_div_bg').style.top = y + dy - t.offsetHeight-80;
e('mini_message_div_text').innerHTML = text;
if (auto_close)
    setTimeout('close_mini_modal_message()',auto_close);

}
function modal_message(text,color,auto_close)
{
if (!color) color = 'red';
e('modal_div').style.width = '100%';
e('modal_div').style.height = '100%';
e('modal_div').style.display = 'block';
e('modal_div_text_bg').style.backgroundImage = 'url(\'/img/bg_'+color+'_modal_dialog.png\')';
e('modal_div_text_bg').style.left = (document.width-500)/2;
e('modal_div_text_bg').style.top = (document.height-193)/2;
e('modal_div_text').innerHTML = text;
if (auto_close)
    setTimeout('close_modal_message()',auto_close);
}
function close_modal_message()
{
e('modal_div').style.display = 'none';
}
function close_mini_modal_message()
{
e('mini_message_div_bg').style.display = 'none';
}

function getX(id)
{
    var abs_pos;
    abs_pos = 0;
    el = document.getElementById(id);
    while(el.offsetParent != null)
    {
        el = el.offsetParent;
        if (el.offsetLeft != null) abs_pos += el.offsetLeft;
    }
    return abs_pos;    
}

function getY(id)
{
    var abs_pos;
    abs_pos = 0; 
    el = document.getElementById(id);
    while(el.offsetParent != null)
    {
        el = el.offsetParent;
        if (el.offsetLeft != null) abs_pos += el.offsetTop;
    }
    return abs_pos;    
}
function getXbyID(id)
{
    var abs_pos;
    abs_pos = 0;
    el = id;
    while(el.offsetParent != null)
    {
        el = el.offsetParent;
        if (el.offsetLeft != null) abs_pos += el.offsetLeft;
    }
    return abs_pos;    
}

function getYbyID(id)
{
    var abs_pos;
    abs_pos = 0; 
    el = id;
    while(el.offsetParent != null)
    {
        el = el.offsetParent;
        if (el.offsetLeft != null) abs_pos += el.offsetTop;
    }
    return abs_pos;    
}

function showOnScreen(id_element)
{
    var p;
    var y;
    p = document.body;
    
    document.getElementById(id_element).style.left = (p.clientWidth - Number(document.getElementById(id_element).style.width.replace('px', ''))) / 2;
    document.getElementById(id_element).style.top = document.body.scrollTop + 60;
    
    document.getElementById(id_element).style.position = 'absolute';
    document.getElementById(id_element).style.display = 'block';
    document.getElementById(id_element).style.zIndex = '200';

    return false;                    
}


function showElementAtItem(id_element, id_item, args)
{
    var p;
    var x = 0;
    var y = 0;
    var parent;
    p = document.getElementById(id_item);
    while(p && p.offsetParent)
    {
        x += p.offsetLeft;
        y += p.offsetTop;
        if (p.parentNode.scrollTop != undefined)
        {
            y -= p.parentNode.scrollTop;
        }
        p = p.offsetParent;
    }
    

    document.getElementById(id_element).style.left = (x - args);
    document.getElementById(id_element).style.top = y + 21;
    document.getElementById(id_element).style.position = 'absolute';
    document.getElementById(id_element).style.display = 'block';
    document.getElementById(id_element).style.zIndex = '200';
    width = document.getElementById(id_element).clientWidth;

    if (document.getElementById('elementBody') != undefined)
    {
        if (window.innerWidth <= (x+width)+25) 
            args = (x+width+25) - window.innerWidth;
        document.getElementById(id_element).style.left = (x - args);
    } 
    
    return false;                    
}
function showElementAtItem2(id_element, id_item, args)
{
    var p;
    var x = 0;
    var y = 0;
    var parent;
    p = document.getElementById(id_item);
    while(p && p.offsetParent)
    {
        x += p.offsetLeft;
        y += p.offsetTop;
        if (p.parentNode.scrollTop != undefined)
        {
            //y -= p.parentNode.scrollTop;
        }
        p = p.offsetParent;
    }
    

    document.getElementById(id_element).style.left = (x - args);
    document.getElementById(id_element).style.top = y + 21;
    document.getElementById(id_element).style.position = 'absolute';
    document.getElementById(id_element).style.display = 'block';
    width = document.getElementById(id_element).clientWidth;

    if (document.getElementById('adminBody') != undefined)
    {
        if (window.innerWidth <= (x+width)+25) 
            args = (x+width+25) - window.innerWidth;
        document.getElementById(id_element).style.left = (x - args);
    } 
    
    return false;                    
}   
function showElementAtItemExactly(id_element, id_item)
{
    var p;
    var x = 0;
    var y = 0;
    var parent;
    p = document.getElementById(id_item);
    while(p && p.offsetParent)
    {
        x += p.offsetLeft;
        y += p.offsetTop;
        if (p.parentNode.scrollTop != undefined)
        {
            //y -= p.parentNode.scrollTop;
        }
        p = p.offsetParent;
    }
    

    document.getElementById(id_element).style.left = x + 'px';
    document.getElementById(id_element).style.top = y + 'px';
    document.getElementById(id_element).style.position = 'absolute';//absolute
    document.getElementById(id_element).style.display = 'block';
    
    return false;                    
}
function showElementAtItemWithOffset(id_element, id_item,l,t)
{
    //alert('S'+id_element);
    var p;
    var x = 0;
    var y = 0;
    var parent;
    if (typeof(id_item) == "string")
    {
        p = document.getElementById(id_item);
    } else {
        p = id_item;
    }
    while(p && p.offsetParent)
    {
        x += p.offsetLeft;
        y += p.offsetTop;
        if (p.parentNode.scrollTop != undefined)
        {
            //y -= p.parentNode.scrollTop;
        }
        p = p.offsetParent;
    }
    
    
    document.getElementById(id_element).style.left = Number(x)+Number(l)+'px';
    document.getElementById(id_element).style.top = Number(y)+Number(t)+'px';
    document.getElementById(id_element).style.position = 'absolute';//absolute
    document.getElementById(id_element).style.display = 'block';
    document.getElementById(id_element).style.zIndex = '200';
    return false;                    
}

function showElementAtItemWithOffsetOnY(id_element, id_item,l,y)
{
    //alert('S'+id_element);
    var p;
    var x = 0;    
    var parent;
    if (typeof(id_item) == "string")
    {
        p = document.getElementById(id_item);
    } else {
        p = id_item;
    }
    while(p && p.offsetParent)
    {
        x += p.offsetLeft;        
        if (p.parentNode.scrollTop != undefined)
        {
            //y -= p.parentNode.scrollTop;
        }
        p = p.offsetParent;
    }
    
    
    document.getElementById(id_element).style.left = Number(x)+Number(l)+'px';
    document.getElementById(id_element).style.top = Number(y)+'px';
    document.getElementById(id_element).style.position = 'absolute';//absolute
    document.getElementById(id_element).style.display = 'block';
    document.getElementById(id_element).style.zIndex = '1200';
    return false;                    
}

function showElementOnXY(id_element,x,y)
{    
    document.getElementById(id_element).style.left = Number(x)+'px';
    document.getElementById(id_element).style.top = Number(y)+'px';
    document.getElementById(id_element).style.position = 'absolute';//absolute
    document.getElementById(id_element).style.display = 'block';
    document.getElementById(id_element).style.zIndex = '1200';
    return false;                    
}

function hideElement(id_element)
{
    //alert('H'+id_element);
    if(document.getElementById(id_element))
        document.getElementById(id_element).style.display = 'none';
    return false;
}

function addDynamicContent(id_element, from_url)
{
    document.getElementById(id_element).innerHTML = '';
    appendDynamicContent(id_element, from_url)    
}

function appendDynamicContent(id_element, from_url)
{
    script = document.createElement('script');
    script.src = from_url; 
    
    // (script musi byt vo formate document.getElementById(id_element).innerHTML = ...
    document.getElementById(id_element).appendChild(script); 
    return false;    
}


function drag_element(e,element_id, max_height)
{
    id = element_id;
    document.getElementById(id).onmouseup = element_mouse_up;
    cursor_position_x=(!moz ? window.event.clientX : e.clientX); 
    cursor_position_y=(!moz ? window.event.clientY : e.clientY);
    object_position_x=document.getElementById(id).offsetLeft; 
    object_position_y=document.getElementById(id).offsetTop;
    cursor_top = (cursor_position_y - object_position_y);
    if (cursor_top < max_height || max_height == null)
    {
        moving=true;
        document.onmousemove=move_element;
        document.getElementById(id).style.cursor= "move";
    } else {
        moving = false;
        document.getElementById(id).style.cursor="auto";
    }
}

function move_element(e)
{
    current_cursor_pos_x=(!moz ? window.event.clientX : e.clientX); 
    current_cursor_pos_y=(!moz ? window.event.clientY : e.clientY);
    if (moving==true)
    {
        document.getElementById(id).style.left=Math.max(current_cursor_pos_x-(cursor_position_x-object_position_x), 0); // Objectx Current Position
        document.getElementById(id).style.top=Math.max(current_cursor_pos_y-(cursor_position_y-object_position_y), 0); //Objecty Current Position
        return false;
    }
}

function element_mouse_up()
{
    document.onmouseup=new Function("moving=false");
    document.getElementById(id).style.cursor="auto";
}



function fadeIn(where, endColor, which) 
{
    Color= new Array();
    Color[1] = "ff";
    Color[2] = "ee";
    Color[3] = "dd";
    Color[4] = "cc";
    Color[5] = "bb";
    Color[6] = "aa";
    Color[7] = "99";
    if(!document.getElementById(which))return false;
    if (where >= 1)
    {
        document.getElementById(which).style.backgroundColor = "#ffff" + Color[where];

        if (where == 7)
        {
            iWait = 600;
        } else {
            iWait = 300-(where*20);
        }

        if (where > 1)
        {
            where -= 1;
            setTimeout("fadeIn("+where+",'" + endColor + "','" + which + "')", iWait);
        } else {
            where -= 1;
            setTimeout("fadeIn("+where+",'" + endColor + "','" + which + "')", iWait);
            document.getElementById(which).style.backgroundColor = endColor;
        }
    }
} 

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
      {
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start!=-1)
        { 
        c_start=c_start + c_name.length+1; 
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
        return unescape(document.cookie.substring(c_start,c_end));
        } 
      }
    return "";
}

function setOpac(o,t) {
  t=(t==100)?99.999:t;
  if(typeof o.style.opacity !== 'undefined'){
// W3C
    o.style.opacity=t/100;
  }else if (typeof o.style.MozOpacity !== 'undefined') {
// Older Mozilla
    o.style.MozOpacity=t/100;
  }else if (typeof o.style.filter != 'undefined') {
// IE 
    o.style.filter='alpha(opacity:'+t+')';
  }else if (typeof o.style.KHTMLOpacity != 'undefined') {
// Older KHTML Based Browsers 
    o.style.KHTMLOpacity=t/100;
  }
};

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
};
function getPageWH() {
  this.Screen={w:0,h:0};
  if( typeof(window.innerWidth ) == 'number' )
    {  this.Screen.w   = window.innerWidth;  this.Screen.h   = window.innerHeight; }
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    { this.Screen.w    = document.documentElement.clientWidth; this.Screen.h   = document.documentElement.clientHeight; } 
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
    { this.Screen.w    = document.body.clientWidth; this.Screen.h   = document.body.clientHeight; }
  return [ this.Screen.w, this.Screen.h ];
};


 

function getObjectWH(o) {
  if (o)
  {  
      var ow = o.style.width;
      var oh = o.style.height;
      return [ stripix(ow), stripix(oh) ];
  } else {
      return [0, 0]
  }
};


  
 

function hide_new_popup(el_name){
document.getElementById(el_name).style.display='none';
document.getElementById('clona_'+el_name).style.display='none';
  document.body.style.overflow='auto';
  document.body.style.height='auto';
  document.body.style.width='auto';
  clona_zapnuta=false;
  window.onscroll = null;
  window.onresize = null;
  
  if(typeof(rememberScroll)!='undefined')
    if(rememberScroll!=null)
      window.scrollTo(rememberScroll[0],rememberScroll[1]);
  rememberScroll=null;
return false;
}
/*
function show_new_popup(el_name)
{
  var curtain=document.getElementById('clona_'+el_name);
  var wgbox  = document.getElementById(el_name);
  wgbox.style.position = 'absolute';
  wgbox.style.zIndex=1000;
  wgbox.style.display='block';
  viewport.measure();
  viewport.centerOnScreen(wgbox);
  return false;
  var oxy=new xyPos(document.body);
  curtain.style.display='block';
  curtain.style.width=(oxy.w+50)+'px';
  curtain.style.height=oxy.w+'px';
  viewport.setOpac(curtain,75);
  document.body.style.overflow='hidden';
  document.body.style.height=viewport.hScreen+'px';
  document.body.style.width=viewport.wScreen+'px';
}
*/

function show_new_popup(el_name)
{
    
    var wh = getPageWH();
    var xy = getScrollXY();
    
    var wgbox = document.getElementById(el_name);
    var wgwh = getObjectWH(wgbox);
    wgbox.style.position = 'absolute';
    wgbox.style.zIndex=1000;
    var need_scrolling = false;
    if ((wh[1]-wgwh[1])>0)
    {
        wgbox.style.top = Math.floor(xy[1]+Math.floor((wh[1]-wgwh[1])/2))+'px';
    }else{     
        wgbox.style.top = '0px';
        need_scrolling = true;
    }
    if ((wh[0]-wgwh[0])>0)    
        wgbox.style.left = Math.floor(xy[0]+Math.floor((wh[0]-wgwh[0])/2))+'px';
    else{     
        wgbox.style.left = '0px';
        need_scrolling = true;
    }
    wgbox.style.width = Math.floor(wgwh[0])+'px';
    wgbox.style.height = Math.floor(wgwh[1])+'px';
    wgbox.style.display = 'block';
    wgbox.style.overflow='hidden';
    if(el_name.substr(0,5)=='ulkas') wgbox.style.overflow='scroll';

  var o = document.getElementById('clona_'+el_name);
  //if(!o)return false;
  o.style.position = 'absolute';
  o.style.zIndex=900;
  o.style.display = 'block';
  o.style.top = Math.floor(xy[1]-25)+'px';
  o.style.left = Math.floor(xy[0]-25)+'px';    
  o.style.width = Math.floor(wh[0]+35)+'px';
  o.style.height = Math.floor(wh[1]+35)+'px';
  if ((need_scrolling) && (typeof document.getElementById('sidemenuBox2')!="undefined"))
  {
    if (document.getElementById('sidemenuBox2') != null)
    {   
        var temp = document.getElementById('sidemenuBox2').style.height;
        temp = temp.substring(0,temp.length-2); 
        o.style.height = (eval(temp) + 400) + 'px';
    } else {
        o.style.height = '400px';
    }  
    o.style.top = '0px';
    o.style.left = '0px';    
      rememberScroll=xy;
      window.scrollTo(0,0);  
    
    if ((Math.floor(wh[0]+35))<900)    
        o.style.width = Math.floor(955)+'px';             
  }
  o.style.backgroundColor = '#404040';
  o.onmousedown = function(){return false;};
  o.onmousemove = function(){return false;};
  setOpac(o,75);    
  if (!need_scrolling){
    document.body.style.overflow='hidden';
    document.body.style.height=viewport.hScreen+'px';
    document.body.style.width=viewport.wScreen+'px';
    clona_zapnuta=true;
  
  }
/*  
    document.body.style.overflow='hidden';
  document.body.style.height=wh[1]+'px';
  document.body.style.width=wh[0]+'px';
  if (!need_scrolling)
    window.onscroll = function(){window.scrollTo(xy[0],xy[1]);};
*/
  window.onresize = function(){hide_new_popup(el_name); show_new_popup(el_name);};
}

function show_new_popup_at_item(el_name,id_item,l,t){
    if(window.outerHeight==undefined){
    var wh = document.body.clientHeight;
    var ww = document.body.clientWidth;
    }else{
    var wh = window.innerHeight;
    var ww = window.innerWidth;
    }
    
    var p;
    var x = 0;
    var y = 0;
    var parent;
    p = document.getElementById(id_item);
    while(p && p.offsetParent)
    {
        x += p.offsetLeft;
        y += p.offsetTop;
        if (p.parentNode.scrollTop != undefined)
        {
            //y -= p.parentNode.scrollTop;
        }
        p = p.offsetParent;
    }
    
    var wgbox = document.getElementById(el_name);
    wgbox.style.position = 'absolute';
    if (l == 'center')
    {
        var xy = getScrollXY();
        var wgwh = getObjectWH(wgbox);
        wgbox.style.position = 'absolute';
        wgbox.style.zIndex=1000;

        wgbox.style.left = Math.floor(xy[0]+Math.floor((ww-wgwh[0])/2))+'px';
    } else wgbox.style.left = x+l+'px';
    wgbox.style.top = y+t+'px';
    
    //wgbox.style.width = Math.floor(wgw)+'px';
    //wgbox.style.height = Math.floor(wgh)+'px';
    wgbox.style.display = 'block';
    wgbox.style.overflow='hidden';

  var o = document.getElementById('clona_'+el_name);
  //if(!o)return false;
  o.style.position = 'absolute';
  o.style.display = 'block';
  o.style.top = '0px';
  o.style.left = '0px';    
  o.style.width = ww+'px';
  o.style.height = Math.floor(wh+y)+'px';
  o.style.backgroundColor = '#404040';
  setOpac(o,75);
  /*  
  document.body.style.overflow='hidden';
  document.body.style.height=wh+'px';
  document.body.style.width=ww+'px';
  */
  document.body.style.overflow='hidden';
  document.body.style.height=viewport.hScreen+'px';
  document.body.style.width=viewport.wScreen+'px';
  clona_zapnuta=true;
  //window.onscroll = function(){window.scrollTo(0,0);};
}
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    }
    else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}
 
function dont_post(event, sender, alternate)
{
    if (event.which)
        key = event.which;
    else key = event.keyCode;

    if (key == 13)
    {
        if (sender.form != null)
        {
            sender.form.onsubmit = function() {return false;};
            if (typeof(alternate) == 'string')
            {
                alternate_url = alternate.replace('#SENDER_VALUE#', String(sender.value));
                document.location.href = alternate_url;
            }
            if (typeof(alternate) == 'function')
            {
                alternate();   
            }
        }
        return false;
    }
    if (key == 27)
    {
        sender.blur();
    }    
}

function was_escape_pressed(event, sender)
{
    if (event.which)
        key = event.which;
    else key = event.keyCode;
    
    if (key == 27)
    {
        return true;
    } else {
        return false;
    }    
}

// zavola php skript v pozadi, a zobrazi ho v body
function call_external_url(url)
{
    script = document.createElement('script');
    script.src = url; 
    
    if (document.getElementById('body') != null) 
        document.getElementById('body').appendChild(script); 
    return false;    
} 


function admin_call_external_url(url)
{
    script = document.createElement('script');
    script.src = url; 
    
    document.getElementById('etargetBody').appendChild(script); 
    return false;    
} 


function get_help(url, event, id)
{
    // download
    script = document.createElement('script');
    script.src = url;
    
    // generate popup div
    var div;
    div = document.getElementById('help_div_'+id);
    if (div != null && div.innerHTML != '<img src="/img/loading.gif"></img>')
    {
        
    } else {
        div = document.createElement('div');
        div.id = 'help_div_'+id;
        //div.style.background = "#e0efd5";
        div.style.border = "0px solid #000000";
        div.style.zIndex = "1";
        div.style.position = "absolute";
        div.style.overflow = "hidden";
        div.style.height = "105px";
        div.style.width = "250px";
        if(isIE6)
          div.style.backgroundImage = "url(/img/bublinka.gif)";
        else
          div.style.backgroundImage = "url(/img/bublinka.png)";

        div.innerHTML = '<img src="/img/loader.gif" style="margin:20px auto;"></img>';
        div.appendChild(script);
        div.style.display = 'block';
        document.body.appendChild(div); 
    }

    //showElementAtItem(div.id, id, -30);
    showElementAtItemWithOffset(div.id, id,-168,-105);

    return false;    
}

function hide_help(id)
{
    if (document.getElementById('help_div_'+id) != null)
    {
        document.getElementById('help_div_'+id).style.display = 'none';    
    }
}

function hideOnEscape(event, sender)
{
    if (event.which)
        key = event.which;
    else key = event.keyCode;

    if (key == 27)
    {
        sender.display = 'none';
    }
}

    function btn_hilite(t){//t.style.backgroundImage='url(/img/buttons/light.png)';
    }
    function btn_lolite(t){//t.style.backgroundImage='none';
    }
    
function vardump(obj)
{
    var s;
    for (x in obj)
    {
     
        s += x + ' = ' + obj[x] + '<br />';
    }
    return s;    
}

                function SetValueOfAllCheckBoxes(containerID,controlerID){
                    var container = document.getElementById(containerID);
                    if(!container)
                        return;                   
                                         
                    if(document.getElementById(controlerID))
                        CheckValue = document.getElementById(controlerID).checked; 
                    theInputs = container.getElementsByTagName('input');
                    for(var y=0; y<theInputs.length; y++){
                        if(theInputs[y].type == 'checkbox'){
                            if(theInputs[y].disabled == false)                            
                                theInputs[y].checked = CheckValue;
                        }
                    }
                }

function showhideElement(el_id){
    if (document.getElementById(el_id).style.display == "none"){        
        document.getElementById(el_id).style.display="";
    } else { 
        document.getElementById(el_id).style.display="none";
    }
}            

           function showEtargetMovie(obid,aframes,frate,nextid,imgprefix){
                var temp = aframes.split(',');
                var newind = temp[nextid];
                var iter = 0;
                while(newind<=0){                    
                    nextid++;
                    if(nextid>=5) nextid=0;
                    newind = temp[nextid];
                    iter++;
                    if(iter>10) return;                    
                }
                
                if(document.getElementById(obid)){
                    if(typeof(document.getElementById(obid).src)!='undefined')                    
                        document.getElementById(obid).src = imgprefix+newind+'.jpg';
                    else    
                        document.getElementById(obid).style.backgroundImage = 'url('+imgprefix+newind+'.jpg)';
                }
                nextid++;
                if(nextid>=5) nextid=0;
                setTimeout('showEtargetMovie(\"'+obid+'\",\"'+aframes+'\",'+frate+','+nextid+',\"'+imgprefix+'\")',frate);
                
            }    
            
function mktime () {    
    var d = new Date(),
        r = arguments,
        i = 0,
        e = ['Hours', 'Minutes', 'Seconds', 'Month', 'Date', 'FullYear'];

    for (i = 0; i < e.length; i++) {
        if (typeof r[i] === 'undefined') {
            r[i] = d['get' + e[i]]();
            r[i] += (i === 3); // +1 to fix JS months.
        } else {
            r[i] = parseInt(r[i], 10);
            if (isNaN(r[i])) {
                return false;
            }
        }
    }

    // Map years 0-69 to 2000-2069 and years 70-100 to 1970-2000.
    r[5] += (r[5] >= 0 ? (r[5] <= 69 ? 2e3 : (r[5] <= 100 ? 1900 : 0)) : 0);

    // Set year, month (-1 to fix JS months), and date.
    // !This must come before the call to setHours!
    d.setFullYear(r[5], r[3] - 1, r[4]);

    // Set hours, minutes, and seconds.
    d.setHours(r[0], r[1], r[2]);

    // Divide milliseconds by 1000 to return seconds and drop decimal.
    // Add 1 second if negative or it'll be off from PHP by 1 second.
    return (d.getTime() / 1e3 >> 0) - (d.getTime() < 0);
}            

