/*** TEXT WRITE FOR MAP ***/
function writeText(txt) {
 document.getElementById('desc').innerHTML=txt
}

/*** IMAGE MOUSEOVER FUNCTIONS ***/
function PreloadImgs() {
 var d=document,a=arguments; if(!d.imgs) d.imgs=new Array();
 for(var i=0; i<a.length; i++) { d.imgs[i]=new Image; d.imgs[i].src=a[i]; }
}

function SwapImg() {
 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
 n+=2) { elm=GetObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
 elm.$src=elm.src; elm.src=args[n+1]; } }
}

function GetObjectByID(id,o) {
 var c,el,els,f,m,n; if(!o)o=document; if(o.GetElementById) el=o.GetElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=GetObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=GetObjectByID(id,els[n]); if(el) return el; } }
 return null;
}

function PopupPic(picURL) {
 window.open("http://www.iogt.us/picwin.htm?"+picURL,"","resizable=1,screenX=100,left=100,screenY=100,top=100,width=500,height=500");
}

function openForm(formURL) {
 window.open(formURL,"","resizable=1,screenX=30,left=30,screenY=30,top=30,width=400,height=470");
}




/*** IMAGEMAP DROPMENU SCRIPTS HERE ***/
//Contents for menus
var menu1=new Array()
	menu1[0]='<a href="http://www.link.ba" target="_blank"><img border="0" src="../imgs/flgs/ba.gif" width="16px" height="11px">&nbsp; www.link.ba</a>'
var menu2=new Array()
	menu2[0]='<a href="http://www.fybg.org" target="_blank"><img border="0" src="../imgs/flgs/bg.gif" width="16px" height="11px">&nbsp; www.fybg.org</a>'
var menu3=new Array()
	menu3[0]='<a href="http://www.iogt.dk" target="_blank"><img border="0" src="../imgs/flgs/dk.gif" width="16px" height="11px">&nbsp; www.iogt.dk</a>'
var menu4=new Array()
	menu4[0]='<a href="http://www.juvente.ee" target="_blank"><img border="0" src="../imgs/flgs/ee.gif" width="16px" height="11px">&nbsp; www.juvente.ee</a>'
var menu5=new Array()
	menu5[0]='<a href="http://www.raitis.fi" target="_blank"><img border="0" src="../imgs/flgs/fi.gif" width="16px" height="11px">&nbsp; www.raitis.fi</a>'
	menu5[1]='<a href="http://www.raitis.fi/sinuli" target="_blank">www.raitis.fi/sinuli</a>'
	menu5[2]='<a href="http://www.fsn-mhf.fi" target="_blank">www.fsn-mhf.fi</a>'
var menu6=new Array()
	menu6[0]='<a href="http://www.guttempler.de" target="_blank"><img border="0" src="../imgs/flgs/de.gif" width="16px" height="11px">&nbsp; www.guttempler.de</a>'
	menu6[1]='<a href="http://www.forut.de" target="_blank">www.forut.de</a>'
	menu6[2]='<a href="http://www.juvente.de" target="_blank">www.juvente.de</a>'
var menu7=new Array()
	menu7[0]='<a href="http://www.iogt.is" target="_blank"><img border="0" src="../imgs/flgs/is.gif" width="16px" height="11px">&nbsp; www.iogt.is</a>'
var menu8=new Array()
	menu8[0]='<a href="http://www.ggpf.it" target="_blank"><img border="0" src="../imgs/flgs/it.gif" width="16px" height="11px">&nbsp; www.ggpf.it</a>'
var menu9=new Array()
	menu9[0]='<a href="http://www.baltuainiai.net" target="_blank"><img border="0" src="../imgs/flgs/lt.gif" width="16px" height="11px">&nbsp; www.baltuainiai.net</a>'
var menu10=new Array()
	menu10[0]='<a href="http://www.iogt.no" target="_blank"><img border="0" src="../imgs/flgs/no.gif" width="16px" height="11px">&nbsp; www.iogt.no</a>'
	menu10[1]='<a href="http://www.juvente.no" target="_blank">www.juvente.no</a>'
	menu10[2]='<a href="http://www.dnt.no" target="_blank">www.dnt.no</a>'
var menu11=new Array()
	menu11[0]='<a href="http://www.saap.web.pt" target="_blank"><img border="0" src="../imgs/flgs/pt.gif" width="16px" height="11px">&nbsp; www.saap.web.pt</a>'
var menu12=new Array()
	menu12[0]='<a href="http://www.nan.ru" target="_blank"><img border="0" src="../imgs/flgs/ru.gif" width="16px" height="11px">&nbsp; www.nan.ru</a>'
var menu13=new Array()
	menu13[0]='<a href="http://www.nom.sk" target="_blank"><img border="0" src="../imgs/flgs/sk.gif" width="16px" height="11px">&nbsp; www.nom.sk</a>'
	menu13[1]='<a href="http://www.healthystyle.sk" target="_blank">www.healthystyle.sk</a>'
var menu14=new Array()
	menu14[0]='<a href="http://www.adicsrilanka.org" target="_blank"><img border="0" src="../imgs/flgs/lk.gif" width="16px" height="11px">&nbsp; www.adicsrilanka.org</a>'
	menu14[1]='<a href="http://www.ymma.org" target="_blank">www.ymma.org</a>'
	menu14[2]='<a href="http://www.sarvodaya.org" target="_blank">www.sarvodaya.org</a>'
var menu15=new Array()
	menu15[0]='<a href="http://www.iogt.se" target="_blank"><img border="0" src="../imgs/flgs/se.gif" width="16px" height="11px">&nbsp; www.iogt.se</a>'
	menu15[1]='<a href="http://www.junis.org" target="_blank">www.junis.org</a>'
	menu15[2]='<a href="http://www.nsf.scout.se" target="_blank">www.nsf.scout.se</a>'
	menu15[3]='<a href="http://www.unf.se" target="_blank">www.unf.se</a>'
var menu16=new Array()
	menu16[0]='<a href="http://www.iogt.ch" target="_blank"><img border="0" src="../imgs/flgs/ch.gif" width="16px" height="11px">&nbsp; www.iogt.ch</a>'
	menu16[1]='<a href="http://www.jugendland.ch" target="_blank">www.jugendland.ch</a>'
	menu16[2]='<a href="http://www.juvente.populus.ch" target="_blank">www.juvente.populus.ch</a>'
var menu17=new Array()
	menu17[0]='<a href="http://www.oncb.go.th" target="_blank"><img border="0" src="../imgs/flgs/th.gif" width="16px" height="11px">&nbsp; www.oncb.go.th</a>'
var menu18=new Array()
	menu18[0]='<a href="http://www.iogt-ew.org" target="_blank"><img border="0" src="../imgs/flgs/gb.gif" width="16px" height="11px">&nbsp; www.iogt-ew.org</a>'
var menu19=new Array()
	menu19[0]='<a href="http://www.adic.org.ua" target="_blank"><img border="0" src="../imgs/flgs/ua.gif" width="16px" height="11px">&nbsp; www.adic.org.ua</a>'
	menu19[1]='<a href="http://better.zaraz.org" target="_blank">better.zaraz.org</a>'
var menu20=new Array()
	menu20[0]='<a href="http://www.iogt.us" target="_blank"><img border="0" src="../imgs/flgs/us.gif" width="16px" height="11px">&nbsp; www.iogt.us</a>'

//Other vars		
var menuwidth='180px' //default menu width
var menubgcolor='silver'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in milliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?
var IE = document.all?true:false
var tempX = 0
var tempY = 0
var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" align="center" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}

function dropdownmenu(obj, e, menucontents, menuwidth){
if (ie4) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
if (tempX < 0){tempX = 0}
if (tempY < 0){tempY = 0}  

if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=tempX - 80 //getposOffset(obj, "left") ***added tempX for placement
dropmenuobj.y=tempY + 5//getposOffset(obj, "top") ***added tempY for placement
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}else if (ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=tempX - 80 //getposOffset(obj, "left") ***added tempX for placement
dropmenuobj.y=tempY - 270 //getposOffset(obj, "top") ***added tempY for placement
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

// Pano Functions

function PanoButtons() {
  document.getElementById("ctl_reset").title   = "Reset";
  document.getElementById("ctl_left").title    = "Move Left";
  document.getElementById("ctl_stop").title    = "Stop";
  document.getElementById("ctl_right").title   = "Move Right";
  document.getElementById("ctl_zoomout").title = "Zoom Out";
  document.getElementById("ctl_zoom50").title  = "50%";
  document.getElementById("ctl_zoom100").title = "100%";
  document.getElementById("ctl_zoom200").title = "200%";
  document.getElementById("ctl_zoomin").title  = "Zoom In";
  document.getElementById("ctl_hotyes").title  = "Hotspots On";
  document.getElementById("ctl_hotno").title   = "Hotspots Off";
  document.getElementById("ctl_help").title    = "Help";
  document.getElementById("ctl_close").title   = "Close Window";
}

function showHelp() {
  wndHelp = self.open("help.htm", "Help",
   "width=480,height=480,resizable=no,scrollbars=no,menubar=no,status=no,toolbar=no,directories=no");

  if (wndHelp != null) wndHelp.focus();
}

function checkCloseHelp() {
  if (!this.wndHelp);
  else if (!(this.wndHelp.closed))
    this.wndHelp.close();
}

function showPano(strParams) {
  if (!navigator.javaEnabled()) {
    alert("Please enable Java to open the panorama viewer!");
    return;
  }

  var availWidth  = screen.availWidth - 10;
  var availHeight = screen.availHeight - 32;
  var width  = Math.min(840, availWidth);
  var height = Math.min(560, availHeight);
  var left   = (availWidth - width) / 2;
  var top    = (availHeight - height) / 2;
  var strWidthName  = isMSIE() ? "width" : "innerWidth";
  var strHeightName = isMSIE() ? "height" : "innerHeight";

  var strResizable = navigatorSupportsAppletScaling() ? "yes" : "no";
  var strWndParams = "left=" + left + ",top=" + top + "," +
                     strWidthName + "=" + width + "," + strHeightName + "=" + height +
                     ",resizable=" + strResizable +
                     ",scrollbars=no,menubar=yes,status=no,toolbar=no,directories=no";

  wndImage = self.open("VRTs/vrt.php","_Image_Viewer_", strWndParams);
  if (wndImage != null) wndImage.focus();
}

function isMSIE() {
  return (navigator.userAgent.indexOf("MSIE") >= 0);
}

function isNetscape() {
  return (navigator.userAgent.indexOf("Netscape") >= 0);
}

function isFirefox() {
  return (navigator.userAgent.indexOf("Firefox") >= 0);
}

function isOpera() {  // klappt bei Opera 8.5 und allen Fälschungsvarianten
  return (navigator.userAgent.indexOf("Opera") >= 0);
}

function isOldBrowser() {
  if (isMSIE() || isOpera()) // Opera's Default: simuliert MSIE
    return (navigator.appVersion.substring(0,1) < "4");
  else if (isNetscape())
    return (navigator.appVersion.substring(0,1) < "5");
  else                       // Firefox oder unbekannt
    return false;
}

function navigatorSupportsAppletScaling() {
  return (isMSIE() || isFirefox());
}
