// JavaScript fuer Schuler
DOM = (document.getElementById) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
// We need to explicitly detect Konqueror
// because Konqueror 3 sets IE = 1 ... AAAAAAAAAARGHHH!!!
Konqueror = (navigator.userAgent.indexOf("Konqueror") > -1) ? 1 : 0;
// We need to detect Konqueror 2.2 as it does not handle the window.onresize event
Konqueror22 = (navigator.userAgent.indexOf("Konqueror 2.2") > -1 || navigator.userAgent.indexOf("Konqueror/2.2") > -1) ? 1 : 0;
Opera = (navigator.userAgent.indexOf("Opera") > -1) ? 1 : 0;
Opera5 = (navigator.userAgent.indexOf("Opera 5") > -1 || navigator.userAgent.indexOf("Opera/5") > -1) ? 1 : 0;
Opera6 = (navigator.userAgent.indexOf("Opera 6") > -1 || navigator.userAgent.indexOf("Opera/6") > -1) ? 1 : 0;
Opera56 = Opera5 || Opera6;
IE = (navigator.userAgent.indexOf("MSIE") > -1) ? 1 : 0;
IE = IE && !Opera;
IE5 = IE && DOM;
IE4 = (document.all) ? 1 : 0;
IE4 = IE4 && IE && !DOM;


// Bildertausch standard
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_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];}
}


// Setzt Fokus auf Eingabefeld in der Suchmaske
function setFocus() {
  document.Suchformular2.suchbegriff.focus();
  document.Suchformular2.suchbegriff.select();
}

//Ruft das Druckmenu in der Druckversion auf
function DruckMenu () {
  window.print ();
}

//Neues Fenster fuer Druckversionen
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//Laendermenu
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//Preloader
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];}}
}

//Scripts Standorteseite

//layer ein und ausblenden nach 7 sekunden
var timeobject = window.setTimeout("", 1);
var timeobject2 = window.setTimeout("", 1); //bugfix: pinuts.de

function zeitlimit(){
    window.clearTimeout(timeobject);
    timeobject=window.setTimeout('allelayeraus()',14000);
    window.clearTimeout(timeobject2);
    timeobject2=window.setTimeout('MM_swapImgRestore()',14000);
}
function allelayeraus(){
    MM_showHideLayers('russland','','hide','mexiko','','hide','italien','','hide','schweiz','','hide','tschechien','','hide','deutschland','','hide','slowakei','','hide','usa','','hide','brasil','','hide','frankreich','','hide','spanien','','hide','indien','','hide','china','','hide','england','','hide','presse1','','hide','presse2','','hide','presse3','','hide','presse4','','hide','presse5','','hide','presse6','','hide','presse7','','hide','presse8','','hide','presse9','','hide','uebersichtklein','','hide');
    MM_swapImgRestore();
    //self.focus()
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

//Funktionen stellt Position de Weltkarte fest und passt Layer an
var BV=parseFloat(navigator.appVersion.indexOf("MSIE")>0?navigator.appVersion.split(";")[1].substr(6):navigator.appVersion);
var BN=navigator.appName;
var IsWin=(navigator.userAgent.indexOf('Win')!=-1);
var IsMac=(navigator.userAgent.indexOf('Mac')!=-1);
var OP=(navigator.userAgent.indexOf('Opera')!=-1&&BV>=4)?true:false;
var NS=(BN.indexOf('Netscape')!=-1&&(BV>=4&&BV<5)&&!OP)?true:false;
var SM=(BN.indexOf('Netscape')!=-1&&(BV>=5)||OP)?true:false;
var IE=(BN.indexOf('Explorer')!=-1&&(BV>=4)||SM)?true:false;

if(!eval(frames['self'])) {
    frames.self = window;
    frames.top = top;
}

var mFrame;
mFrame = eval(frames['self']);


function RelativePlaceLayer(mName, imgName, relX, relY) {

    var Image = mFrame.document.images[imgName];

    if(IE)
        if(BV>=5)
            var Menu = mFrame.document.getElementById(mName);
        else
            var Menu = mFrame.document.all[mName];
    if(NS)
        var Menu = mFrame.document.layers[mName];

    if(!Menu) {
        return false;
    }

    if(IE) {
        Menu = Menu.style;
    }

    if (NS) {
        Menu.w = Menu.clip.width;
        Menu.h = Menu.clip.height;
    }

    // Do some MAGIC...
    var pW = GetWidthHeight()[0] + GetLeftTop()[0];
    var pH = GetWidthHeight()[1] + GetLeftTop()[1];

    var x = GetImgXY(Image)[0] + relX;
    var y = GetImgXY(Image)[1] + relY;

    if(IE) {
        Menu.left = (parseInt(Menu.width)>pW)?pW - parseInt(Menu.width):x + "px";
        Menu.top =  (parseInt(Menu.height)>pH)?pH - parseInt(Menu.height):y + (OP?"":"px");
    }
    if(NS) {
        x = (x+Menu.w>pW)?pW - Menu.w:x;
        y = (y+Menu.h>pH)?pH - Menu.h:y;
        alert("/js/default RelativePlaceLayer() x:"+x+" y:"+y);
        Menu.moveToAbsolute(x,y);
    }
    return true;
}

function GetImgXY(imgObj) {
    //IE,NS,SM,OP
    //This function returns the x,y coordinates of an image.

    var x;
    var y;

    if(IE)  {
        x = getOffset(imgObj)[0];
        y = getOffset(imgObj)[1];
    } else  {
        x = imgObj.x;
        y = imgObj.y;
    }

    return [x, y];
}

function GetImgWH(imgObj) {
    //IE,NS,SM,OP
    //This function returns the width and height of an image.

    return [parseInt(imgObj.width), parseInt(imgObj.height)];
}

function getOffset(imgObj) {
    //IE,NS,SM,OP
    //This function returns the horizontal and vertical offset of an object.

    x = imgObj.offsetLeft;
    y = imgObj.offsetTop;
    ce =imgObj.offsetParent;
    while (ce!=null)    {
        y += ce.offsetTop;
        x += ce.offsetLeft;
        ce = ce.offsetParent;
    }
    return [x,y];
}

function GetLeftTop(f) {
    //IE,NS,SM,OP
    //This function returns the scroll bars position on the menus frame.

    if(!f) f = mFrame;
    if(IE)
        return [OP?0:SM?f.scrollX:f.document.body.scrollLeft,OP?0:SM?f.scrollY:mFrame.document.body.scrollTop];
    if(NS)
        return [f.pageXOffset,f.pageYOffset];
}

function GetWidthHeight(f) {
    //IE,NS,SM,OP
    //This function returns the width and height of the menus frame.

    if(!f) f = mFrame;
    if(IE&&!SM)
        return [f.document.body.clientWidth,f.document.body.clientHeight];
    if(NS||SM)
        return [f.innerWidth,f.innerHeight];
}

//Country Ziellinks
function jump(x)
    {
    if(x==1) window.open ('/INTERNET/major/pool/index.html?sLang=en','_self','');
    if(x=='1.2') window.open ('/INTERNET/major/pool/index.html?sLang=de','_self','');
    if(x=='x1') window.open ('index.html?sLang=en','_self','');
    if(x=='x1.2') window.open ('index.html?sLang=de','_self','');
    if(x==2) window.open ('/INTERNET/minor/br/index.html','_self','');
    if(x==3) window.open ('/INTERNET/major/cn/index.html','_self','');
    if(x==4) window.open ('/INTERNET/minor/fr/index.html','_self','');
    if(x==5) window.open ('/INTERNET/major/pool/index.html?sLang=de','_self','');
    if(x=='x5') window.open ('index.html?sLang=de','_self','');
    if(x==6) window.open ('/INTERNET/minor/uk/index.html','_self','');
    if(x==7) window.open ('/INTERNET/minor/in/index.html','_self','');
    if(x==8) window.open ('/INTERNET/minor/it/index.html','_self','');
    if(x==9) window.open ('/INTERNET/minor/mx/index.html','_self','');
   if(x==10) window.open ('/INTERNET/minor/ru/index.html','_self','');
   if(x==11) window.open ('/INTERNET/minor/sk/index.html','_self','');
   if(x==12) window.open ('/INTERNET/minor/es/index.html','_self','');
   if(x==13) window.open ('/INTERNET/major/us/index.html','_self','');
    }
/*
		1 - Schuler Homepage
		2 - Brasil
		3 - China
		4 - France
		5 - Germany
		6 - Great Britain
		7 - India
		8 - Italy
		9 - Mexico
		10 - Russia
		11 - Slovakia
		12 - Spain
		13 - USA
*/
function jumpVS(x,pre)
{
    if(x==1) window.open (pre + '/INTERNET/major/pool/index.html?sLang=en','_self','');
    if(x=='1.2') window.open (pre + '/INTERNET/major/pool/index.html?sLang=de','_self','');
    if(x=='x1') window.open ('index.html?sLang=en','_self','');
    if(x=='x1.2') window.open ('index.html?sLang=de','_self','');
    if(x==2) window.open (pre + '/INTERNET/minor/br/index.html','_self','');
    if(x==3) window.open (pre + '/INTERNET/major/cn/index.html','_self','');
    if(x==4) window.open (pre + '/INTERNET/minor/fr/index.html','_self','');
    if(x==5) window.open (pre + '/INTERNET/major/pool/index.html?sLang=de','_self','');
    if(x=='x5') window.open ('index.html?sLang=de','_self','');
    if(x==6) window.open (pre + '/INTERNET/minor/uk/index.html','_self','');
    if(x==7) window.open (pre + '/INTERNET/minor/in/index.html','_self','');
    if(x==8) window.open (pre + '/INTERNET/minor/it/index.html','_self','');
    if(x==9) window.open (pre + '/INTERNET/minor/mx/index.html','_self','');
   if(x==10) window.open (pre + '/INTERNET/minor/ru/index.html','_self','');
   if(x==11) window.open (pre + '/INTERNET/minor/sk/index.html','_self','');
   if(x==12) window.open (pre + '/INTERNET/minor/es/index.html','_self','');
   if(x==13) window.open (pre + '/INTERNET/major/us/index.html','_self','');
}

