
var tid;
var closetimeout;closetimeout=200; //Timeout to close open menu window
var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;
var isNS6    = (navigator.appName.indexOf("Netscape") >=0 && parseFloat(navigator.appVersion) >= 5) ? 1 : 0;

var activemenu = -1;

var datasearch = Array();
var sdatasearch = Array();


var canopen; //The bit to show, that pop-up can be oppenned
canopen = false;

function show(what,action) {
 if (canopen) {
   obj = 'menu'+ what;
   if (action=="hide") {
      if(isMinNS4 && (!isNS6)) {
         layer = document.layers[obj];
      } else {
         layer = (document.getElementById)? document.getElementById(obj) : document.all[obj];
      }     
      if (isMinNS4 && (!isNS6)) 
        layer.visibility = "hide";
      if (isNS6) 
        document.getElementById(obj).style.visibility = "hidden";
      if (isMinIE4)
        layer.style.visibility = "hidden";     
      activemenu = -1;
   }
   if (action=="show") {
      clearTimeout(tid);
      if (activemenu>-1) {
        show(activemenu,'hide');
      }
      obj = 'menu'+what;
      if(isMinNS4 && (!isNS6)) {
        layer = document.layers[obj];
      } else {
        layer = (document.getElementById)? document.getElementById(obj) : document.all[obj];
      }     
      if (isMinNS4 && (!isNS6))
         layer.visibility = "show";
      if (isNS6)
         document.getElementById(obj).style.visibility = "visible";
      if (isMinIE4)
         layer.style.visibility = "visible";       
      activemenu = what;
   }
 }
}

function div_show(div,action) {
 if (canopen) {
   obj = div;
   if (action=="hide") {
      if(isMinNS4 && (!isNS6)) {
         layer = document.layers[obj];
      } else {
         layer = (document.getElementById)? document.getElementById(obj) : document.all[obj];
      }     
      if (isMinNS4 && (!isNS6)) 
        layer.visibility = "hide";
      if (isNS6) 
        document.getElementById(obj).style.visibility = "hidden";
      if (isMinIE4)
        layer.style.visibility = "hidden";     
   }
   if (action=="show") {
      if(isMinNS4 && (!isNS6)) {
        layer = document.layers[obj];
      } else {
        layer = (document.getElementById)? document.getElementById(obj) : document.all[obj];
      }     
      if (isMinNS4 && (!isNS6))
         layer.visibility = "show";
      if (isNS6)
         document.getElementById(obj).style.visibility = "visible";
      if (isMinIE4)
         layer.style.visibility = "visible";       
   }
 }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function update_div(div,html) {
//   alert(html);
   var layer = (document.getElementById)? document.getElementById(div) : document.all[div];
   if(layer && layer.innerHTML) {
     layer.innerHTML = html;
   }
}

function get_div_html(div) {
   var layer = (document.getElementById)? document.getElementById(div) : document.all[div];
   if(layer && layer.innerHTML) {
     return layer.innerHTML;
   }
}

function xaction(commands) {
   try {
     eval(commands);
   } catch (e) {
     alert('error');
     alert(commands);
   }
}

opened_wiki = '';

function wiki_open(id) {
  if (opened_wiki) wiki_close(opened_wiki);
  var div =  'an'+id;
  var layer = (document.getElementById)? document.getElementById(div) : document.all[div];
  layer.className='wikis';   
  sajax_do_call('getWiki',Array(id,xaction));
  opened_wiki = id;
  return false;
}

function wiki_open_en(id) {
  if (opened_wiki) wiki_close(opened_wiki);
  var div =  'an'+id;
  var layer = (document.getElementById)? document.getElementById(div) : document.all[div];
  layer.className='wikis';   
  sajax_do_call('getWiki',Array(id,'en',xaction));
  opened_wiki = id;
  return false;
}



function wiki_close(id) {
  var div =  'an'+id;
  update_div(div,'&nbsp;');
  var layer = (document.getElementById)? document.getElementById(div) : document.all[div];
  layer.className='wikie';   
  opened_wiki = '';
  return false;
}



//Function to work with arrays
function in_array(str,arr) {
 res = -1;
 for (var i=0;i<arr.length;i++) {
   if (arr[i]==str) {
     res = i;
     i=arr.length;
   }
 }
 return res;
}

function del_from_array(str,arr) {
 res = -1;
 newarr = Array();
 for (var i=0;i<arr.length;i++) {
   if (arr[i]!=str) newarr.push(arr[i]);
 }
 return newarr;
}

function add_to_array(str,arr) {
  lastid=arr.length;
  arr[lastid]=str;
  return lastid;
}

function add_unique_to_array(str,arr) {
  if (in_array(str,arr)==-1) {
     arr.push(str);
     lastid=arr.length-1;
     return lastid;
  }else{
     return -1;
  }
}

function add_to_top_array(str,arr) {
  lastid=arr.length;
  for (i=lastid; i>0;i--) {
    arr[i]=arr[i-1];
  }
  arr[0]=str;
  return lastid;
}


function add_unique_to_top_array(str,arr) {
  var m;
  if (in_array(str,arr)==-1) {
     m = add_to_top_array(str,arr);
     return m;
  }else{
     return -1;
  }
}

var p_x = 100;
var p_y = 100;
defaultWidth  = 600;
defaultHeight = 600;
var AutoClose = true;
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+p_x+',top='+p_y;
var optIE='scrollbars=no,width=150,height=100,left='+p_x+',top='+p_y;
function loadPhoto(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');
writeln('window.innerWidth=document.images["img"].width;');writeln('window.innerHeight=document.images["img"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="img" src='+imageURL+' style="display:block"></body></html>');
close();		
}}

