var opened_div;

function collapse_div(id) {
  if(document.all) { // IE
      div_elem = document.all[id];
      if( div_elem ) { div_elem.style.display = 'none'; }
  }
  if(!document.all && document.getElementById) { // Netscape 6
    div_elem = document.getElementById(id);
    if ( div_elem ) { div_elem.style.display = 'none'; }
  }
}

function expand_div(id) {
  if(document.all) { // IE
      div_elem = document.all[id];
      if( div_elem ) { div_elem.style.display = 'block'; }
  }
  if(!document.all && document.getElementById) { // Netscape 6
    div_elem = document.getElementById(id);
    if ( div_elem ) { div_elem.style.display = 'block'; }    

//alert( document.getElementById(id).style.display );
  }
}

//---help functions

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function overlayrollover(curobj, subobjstr, opt_position){

if( opened_div ) { overlayclose( opened_div ); }

if (document.getElementById){
var subobj=document.getElementById(subobjstr)
document.onmousemove=function(e){
clicktohiderollover(curobj, subobjstr, e)
}
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
opened_div = subobjstr;
return false
}
else
return true
}


function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}

function clicktohide(linkobj, subobj, e){
var currentnode=(window.event)? event.srcElement : e.target
var hidesubobj=true
while (currentnode.tagName!="BODY" && currentnode.tagName!="HTML"){
//if (currentnode.id==subobj || currentnode==linkobj){
if ( currentnode==linkobj){
 hidesubobj=false
 break
}
currentnode=currentnode.parentNode
}
if (hidesubobj)
overlayclose(subobj)
}


function clicktohiderollover(linkobj, subobj, e){
var currentnode=(window.event)? event.srcElement : e.target
var hidesubobj=true
while (currentnode.tagName!="BODY" && currentnode.tagName!="HTML"){
if (currentnode.id==subobj || currentnode==linkobj){
//if ( currentnode==linkobj){
 hidesubobj=false
 break
}
currentnode=currentnode.parentNode
}
if (hidesubobj)
overlayclose(subobj)
}

function overlay(curobj, subobjstr, opt_position){

if( opened_div ) { overlayclose( opened_div ); }

if (document.getElementById){
var subobj=document.getElementById(subobjstr)
document.onclick=function(e){
//clicktohide(curobj, subobjstr, e)
}
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
if( typeof opt_position!="undefined" && opt_position.indexOf("above")!=-1 )
{
   ypos=getposOffset(curobj, "top")-(subobj.offsetHeight-curobj.offsetHeight);
}

subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
opened_div = subobjstr;
return false
}
else
return true
}


//---/help functions

function open_help_window(url)
{
  myWin1= window.open(url,"helpwin","width=600,height=600,status=no,toolbar=no,resizable=yes,scrollbars=yes,menubar=no,location=no,titlebar=no");

  if (navigator.appName != "Microsoft Internet Explorer") {
  if (window.focus) myWin1.focus(); 
}
}

//--- cookie
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function setCookie( name, value ) 
{
   var cookie_date = new Date ( 2015, 01, 01 );
   var cookie_value =name+"="+value+
                     ";expires=" + cookie_date.toGMTString(); 
   document.cookie = cookie_value;
}
//----
function open_full_screen(url)
{
  myWin1= window.open(url,"helpwin","fullscreen=yes,status=no,toolbar=no,resizable=yes,scrollbars=yes,menubar=no,location=no,titlebar=no");

  if (navigator.appName != "Microsoft Internet Explorer") {
  if (window.focus) myWin1.focus(); 
}
}
