// SNF JAVASCRIPT utility_functions.js VERSION 1.2a



// *************************************************************
//  CLIENT_SIDE SNIFFER CODE
// *************************************************************
// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();

// *** BROWSER VERSION ***
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

// *** BROWSER TYPE ***
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
            && (agt.indexOf('webtv') == -1));
var is_nav4up = (is_nav && (is_major >= 4));
var is_nav5up = (is_nav && (is_major >= 5));
var is_nav4   = (is_nav && (is_major == 4));
var is_nav5   = (is_nav && (is_major == 5));
var is_ie   = (agt.indexOf("msie") != -1);
var is_ie3  = (is_ie && (is_major < 4));
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) );
var is_ie4up  = (is_ie  && (is_major >= 4));
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie55 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5")!=-1) );
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
var is_dom = (document.getElementById);

// *** PLATFORM ***
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac    = (agt.indexOf("mac")!=-1);
var is_sun   = (agt.indexOf("sunos")!=-1);
var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
var is_hpux  = (agt.indexOf("hp-ux")!=-1);
var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
var is_linux = (agt.indexOf("inux")!=-1);
var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
var is_unixware = (agt.indexOf("unix_system_v")!=-1);
var is_mpras    = (agt.indexOf("ncr")!=-1);
var is_reliant  = (agt.indexOf("reliantunix")!=-1);
var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) ||
       (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) ||
       (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1));
var is_sinix = (agt.indexOf("sinix")!=-1);
var is_freebsd = (agt.indexOf("freebsd")!=-1);
var is_bsd = (agt.indexOf("bsd")!=-1);
var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux ||
             is_sco ||is_unixware || is_mpras || is_reliant ||
             is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);



// Handle Navigator 4 window resizing
if ((is_nav4up) && (!is_dom)  && (!is_nav5up)) {
   var initWidth, initHeight;
   initWidth = window.innerWidth;
   initHeight = window.innerHeight;
   window.captureEvents(Event.RESIZE);
   window.onresize = handleResize;
}



// Define genObj and genStyle in order to handle layer actions
function init() {
  if (is_ie)
    {
      genObj="document.all";
      genStyle=".style";
      genX=".offsetLeft";
      genY=".offsetTop";
    }
  if (is_nav4up) {
    genObj="document.layers";
    genStyle="";
    genX=".x";
    genY=".y";
  }
}
init();
// *********************************************************************
//  UTILITY FUNCTIONS
// *********************************************************************
// Function to handle window resizing on Navigator 4
function handleResize() {
   if (((initWidth != window.innerWidth) || (initHeight != window.innerHeight)) && (typeof disableReload == "undefined")) {
     location.reload();
   }
   return false;
}

// preLoad function to preload all the images given by argument
/*function preLoadImg()
  {
    var imgArray = new Array();
    for (var i = 0; i < preLoadImg.arguments.length; i++)
      {
        imgArray[i] = new Image();
        imgArray[i].src = preLoadImg.arguments[i];
    }
}*/
//preload images
var preloadArray = new Array();
var preloadArrayLength = 0;

function preloadImages() {
	if (document.images) {
		var imgName = preloadImages.arguments;
		for (var i=0; i<imgName.length; i++) {
	    	preloadArray[preloadArrayLength] = new Image;
		    preloadArray[preloadArrayLength].src = pfad + imgName[i] + ".gif";
			preloadArrayLength++;
		}
	}
}

//preload der login-gifs im layer
/*
if (document.images) {
pfad='/de/img/';
preloadImages("username", "passwort", "speichern");
pfad='/img/';
preloadImages("login_go", "bg_092869", "bg_A7B2CA");
}
*/

// createObj to create an layer-object
/*
function createObj(divName) {
    if(is_dom){
            var stand_obj=document.getElementById(divName);
            if (stand_obj && stand_obj.style) var obj=stand_obj.style;
              else var obj = "";
    }
    else{
            var obj=eval(genObj+"['"+divName+"']"+genStyle);
    }
    return obj;
}

*/
/*
function show(divName) 
{
  if ((typeof divName == "undefined") || (divName == "")) {  return (-1); }
  var obj = createObj(divName);
  if ((typeof obj == "undefined") || (obj == "")) { 
    if ((is_nav) && (!is_dom)) {
      // vielleicht nested Layer im alten Netscape
      var nsLayers = findNavLayers();
      obj = null;
      for (var i in nsLayers) {
        var nes_obj = document.layers[nsLayers[i]].document.layers[divName];
        if ((obj) && (typeof(obj) == 'object')) {
          obj = nes_obj;
        }
      }
      if (obj == null) return(-1);
    }
    else return (-1); // ie & dom
  }
  obj.visibility='visible';
  
}
*/

function fenster(ort,w,h,ix,yps) {
	win = window.open(ort, 'Hauptfenster', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+w+',height='+h+',screenX='+ix+',screenY='+yps+'');
	}
  
//-- ScrollContainer -----------------------------------------------------------------------

var scrollSpeed = 70;
var scrollTimeout;
var scrollText;

function initScrollContainer(height) {
  if (!height) height = 350;
	scrollText = new ScrollContainer('ScrollAbschn1', 'FormatContainer2', height);
	scrollText.jumpTop();
	scrollText.css.visibility='visible';
	}

function ScrollContainer(Objekt, Formatierung, height) {
	Formatierung = (!Formatierung) ? '' : 'document.'+Formatierung+'.';
	
	if(is_ie) { // fuer ie
		this.css = eval('document.all.'+Objekt+'.style');
		this.height = eval('document.all.'+Objekt+'.offsetHeight');
		}

	if(is_nav) {
		if(is_dom) { // fuer ns >= 6
			this.css = document.getElementById(Objekt).style;
			this.height = document.getElementById(Objekt).offsetHeight;
			}
		else { // fuer ns < 5
			this.css = eval(Formatierung+'document.'+Objekt);
			this.height = this.css.document.height;
			}
		}			
	this.jumpTop = jumpTop;
	this.jumpBottom = jumpBottom;
	this.moveTopBy = moveTopBy;
  this.down = down;
  this.up = up;
  this.stop = stopScrolling;
  this.myHeight = height;
  this.obj = this.name + "Object";
  eval(this.obj + " = this;");
//  alert(this.myHeight);
	}

function jumpTop() {
	this.css.top = 0;
	}

function jumpBottom() {
	this.css.top = -(scrollText.height - this.myHeight);
	}

function moveTopBy(movePX) {
	this.css.top = (parseInt(this.css.top) + movePX);
  window.status=this.css.top;
	}

function down(movePX) {
	if(parseInt(scrollText.css.top) > -(scrollText.height - this.myHeight)) 
  {
		scrollText.moveTopBy(-movePX);
		scrollTimeout = setTimeout(this.obj + ".down(" + movePX + ")", scrollSpeed);
		}
	}

function up(movePX) {
	if(parseInt(scrollText.css.top) <= -movePX) 
  {
		scrollText.moveTopBy(movePX);
		scrollTimeout = setTimeout(this.obj + ".up(" + movePX + ")", scrollSpeed);
		}
	}
	
function down2(movePX) {
	if(parseInt(scrollText.css.top) > -(scrollText.height - this.myHeight)) {
		scrollText.moveTopBy(-movePX);
		scrollTimeout = setTimeout(this.obj + ".down(" + movePX + ")", scrollSpeed);
		}
	}

function up2(movePX) {
	if(parseInt(scrollText.css.top) <= -movePX) {
		scrollText.moveTopBy(movePX);
		scrollTimeout = setTimeout(this.obj + ".up(" + movePX + ")", scrollSpeed);
		}
	}
	
function stopScrolling() {
	clearTimeout(scrollTimeout);
	}
  
// createObj to create an layer-object
function createObj(divName) {
    if(is_dom){
            var stand_obj=document.getElementById(divName);
            var obj=stand_obj.style;
    }
    else{
            var obj=eval(genObj+"['"+divName+"']"+genStyle);
    }  
    return obj; 
}

// show a given layer
function show(divName) {
  if ((typeof divName == "undefined") || (divName == "")) return (-1);
  var obj = createObj(divName);
  if ((typeof obj == "undefined") || (obj == "")) return (-1);
  //alert (divName);
  obj.visibility='visible';
  obj.zIndex = 20;
	return(1);
}

// hide a given layer
function hide(divName) {
  if ((typeof divName == "undefined") || (divName == "")) return (-1);
  var obj = createObj(divName);
  if ((typeof obj == "undefined") || (obj == "")) return (-1);
  //alert ('sdf'+divName);
  obj.visibility='hidden';
  obj.zIndex = 1;
  return(1);
}

function showCountry (divName) {
  var layers = ['DIVEurope', 'DIVAfrika', 'DIVNAmerika', 'DIVSAmerika', 'DIVAsien', 'DIVAustralien'];
  for (var i in layers) {
    if (divName != layers[i]) {
      hide (layers[i]);
    }
  }
  show (divName);
}

function showCountry2 (divName) {
  var layers = ['DIVEurope2', 'DIVAfrika2', 'DIVNAmerika2', 'DIVSAmerika2', 'DIVAsien2', 'DIVAustralien2'];
  for (var i in layers) {
    if (divName != layers[i]) {
      hide (layers[i]);
    }
  }
  show (divName);
}

function myOpenWindow(url, w, h) {
  var window_left=(screen.width-w)/2;
  var window_top=(screen.height-h)/2;
  window.open(url, "","width=" + w + ",height=" + h + ",top=" + window_top + ",left=" + window_left + ",scrollbars=1");
} 

function myOpenWindow2(url, w, h) {
  var window_left=(screen.width-w)/2;
  var window_top=(screen.height-h)/2;
  window.open(url, "","width=" + w + ",height=" + h + ",top=" + window_top + ",left=" + window_left + ",scrollbars=0");
} 
