// konstruktor 

function navigation ( navurl, navFrame, mainFrame ) {

var pos ;

   this.initialized = false ;
   this.InternetExplorer = true;
//   this.InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
   this.flashNav = this.InternetExplorer ;
   this.context = "CASA" ;
   this.language = "engl" ;
   this.contexts = new Array ;
   this.contexts["engl"] = new Array ;
   this.contexts["de"] = new Array ;
   this.initCont = initCont ;
   this.initContLang = initContLang ;
   this.initCont ( "neutral", 0 ) ;
   this.initCont ( "CASA", 1 ) ;
   this.initCont ( "Archipro", 2 ) ;
   this.initCont ( "Plastic", 3 ) ;
   this.initCont ( "Press", 4 ) ;
   this.initCont ( "Projects", 5 ) ;
   this.initCont ( "Team", 6 ) ;
   this.navFrame = navFrame ;
   this.mainFrame = mainFrame ;
   this.newContext = contextM ;
   this.reset = resetContext ;
   this.setLanguage = setLanguage ;
   this.updateContext = updateContext ;
   this.initContext = initContext ;
   this.getMovie = getMovie ;
   this.initialized = true ;
   //   this.positionMovie = positionMovie ;
   this.positionMovie = positionMovie ;
   pos = navFrame.location.href.indexOf ( navurl ) ;
   if ( pos == -1 ) alert ( "falscher navurl : "+navurl ) ;
   this.httpprefix = navFrame.location.href.substring ( 0, pos ) ;
   this.httpprefixlen = this.httpprefix.length ;
   }

// methoden

function voidfunc () {

   // alert ( "VOID" ) ;
}

function initContLang ( language, context, index ) {

   this.contexts[language][context] = index ;
   }

function initCont ( context, englIndex ) {

   this.initContLang ( "engl", context, englIndex ) ;
   this.initContLang ( "de", context, englIndex+9 ) ;
   }

function contextM ( context ) {

   if ( context == this.context ) return ;
   this.updateContext ( context, this.language ) ;
}   

function getMovie () {
   if ( this.movie != null ) return this.movie ;
   if ( this.InternetExplorer )
       this.movie = Navigation ;
   else {
       this.movie = this.navFrame.Document.Navigation;
       // alert ( "!Movie "+this.movie ) ;
       }
   return this.movie ;
   }

function positionMovie () {

   if ( !this.flashNav ) return ;
   this.positionMovie = voidfunc ;
   this.getMovie().GotoFrame ( this.contexts[this.language][this.context] ) ;
   this.positionMovie = positionMovie ;
   }   
function updateContext ( context, language ) {

   this.context = context ;
   this.language = language ;
//   alert ( 'context = '+context+', language = '+language ) ;
//   alert ( 'goto Frame '+(this.contexts[this.language][this.context]) ) ;
   this.positionMovie () ;
}

function setLanguage ( lang ) {

   this.language = lang ;
   if ( this.context != "neutral" )
      this.mainFrame.location.href = this.httpprefix+this.context+"/"+this.language+"/index.html" ;
   else
      this.mainFrame.location.href = this.httpprefix+this.subcontext+"/"+this.language+"/index.html" ;
   // alert ( 'href = '+this.mainFrame.location.href ) ;
}

function resetContext () {

   this.updateContext ( this.context, this.language ) ;
   }

function initContext ( location ) {

   var len, pos ;
   var context, lang ;
   var topcontext ;

  //alert ( "initcontext "+location ) ;
   if ( !this.initialized ) {
      alert ( "not inizialized yet" ) ;
      return ;
      }
   len = this.httpprefixlen ;
   pos = location.indexOf ( "/index.html" ) ;
   if ( pos == -1 ) alert ( "falscher href : "+location ) ;
   location = location.substring ( len, pos ) ;
   pos = location.lastIndexOf ( "/" ) ;
   if ( pos == -1 ) alert ( "falscher href ( lang ) : "+location ) ;
   context = location.substring ( 0, pos ) ;
   lang = location.substring ( pos+1, location.length ) ;
   if ( this.contexts[lang] == null )
      alert ( "falsche sprache : "+location ) ;
   topcontext = ( this.contexts["de"][context] != null ) ;
   if ( topcontext )
      this.updateContext ( context, lang ) ;
   else {
      this.updateContext ( "neutral", lang ) ;
      this.subcontext = context ;
      }
}

function getNavigation () {

   var w = window ;

   while ( w != null ) {
     if ( w.nav != null ) return w.nav ;
     w = w.parent ;
     }
   return null ;
}


function context ( context ) {

    getNavigation().newContext ( context ) ;
}

function navigationInit ( navurl ) {


   if ( window.parent.nav != null ) return ;
   // alert ( "init ..." ) ;
   window.parent.nav = new navigation ( navurl, window.parent.Unten, window.parent.Oben ) ;
   // alert ( "init ...!!!" ) ;
}

function navigationNoFlash () {

   navigationInit () ;
   
}

function language ( lang ) {

    window.parent.nav.setLanguage ( lang ) ;
    }
    
function reset () {

    window.parent.nav.reset () ;
    }

