//javascript
//eingesetzt auf jeder Seite, um zu testen, ob ein gültiges Cookie gesetzt ist,
//wenn nicht, wird auf die Seite 167 umgeleitet, um Cookie zu setzen


var Splash = GetCookie('smartinvest10');

//document.writeln ('cookie:' + Splash);
//var URL = unescape(window.document.location);
var addtoPath = '';
var HTTP_GET_VARS=new Array();

var strGET=document.location.search.substr(1,document.location.search.length);

if(strGET!=''){
 gArr=strGET.split('&');
 for(i=0;i<gArr.length;++i){
 v='';vArr=gArr[i].split('=');
 if(vArr.length>1){v=vArr[1];}
 HTTP_GET_VARS[unescape(vArr[0])]=unescape(v);
 }
}




    function GET(v)
    {
          if(!HTTP_GET_VARS[v]){return 'undefined';}
          return HTTP_GET_VARS[v];
    
    }


//Startland im Cookie gespeichert?
//dann Startseite und Sprache an die URL anhängen

      function getRedirectAddToPathStartSite(){
            switch(Splash){
                    case 'de': var addtoPath ='nc/home.html';
                                   break;
                 
                    case 'ch': var addtoPath ='ch/home-ch/home.html';
                                     break;
                 
                    case 'at': var addtoPath ='at/home-at/home.html';
                                     break;
                 
                    case 'lb':var addtoPath ='lb/home-lb/home.html';
                                       break;
                    case 'sl': var addtoPath ='sl/home-sl/home.html';
                    // auf die 167 schicken, um Cookie zu setzen
                   default: var addtoPath ='?id=167';
                   
            }
            return addtoPath;
      }


//Startland im Cookie gespeichert?
//dann Sprache an die URL anhängen
      function getRedirectAddToPath(){
                switch (Splash) {
                    case 'de': var addtoPath ='?L=0';
                                   break;
                 
                    case 'ch': var addtoPath ='?L=3';
                                     break;
                 
                    case 'at': var addtoPath ='?L=5';
                                     break;
                 
                    case 'lb':var addtoPath ='?L=4';
                                       break;
                    case 'sl': var addtoPath ='?L=1';
                    default: var addtoPath ='?id=167';
                     
                }
                return addtoPath;
      }


      
      




//document.writeln (document.URL);
function ReDirect () {
      var langparm = GET('L');
      var idparm = GET('id');
      //document.writeln (langparm);
      
      //nur umleiten, wenn auf Startseite ohne weitere Parameter
      if(document.URL == 'http://www.smart-invest.de' || document.URL == 'http://www.smart-invest.de/'|| document.URL == 'http://smart-invest.eccn-dev.de' || document.URL == 'http://smart-invest.eccn-dev.de/'){
              if (langparm == 'undefined' || Splash!= null){
                  //document.writeln ("weiche 1");
                  var addtoPath = getRedirectAddToPathStartSite();
                  window.location=(document.URL + addtoPath);
                  
              }
              else{
                  //gültiges Cookie, Sprache schon angehängt
                 //document.writeln ("weiche 2");
              }
         
      }
      else{
          if (Splash!= null){
              if (langparm == 'undefined' ){
                  
                  //document.writeln ("weiche 3");
                   //Sprache anhängen ...
                  var addtoPath = getRedirectAddToPath();
                 // window.location=(document.URL + addtoPath);
              }
              else{
                 //gültiges Cookie, Sprache schon angehängt
                  //document.writeln ("weiche 4");
                  
              }
          }
          else{
              //167 logpage
              if ( idparm == 'undefined'){
                  var addtoPath = getRedirectAddToPath();
                  // geht auf die 167, um Cookie zu setzen
                  //window.location=(document.URL + addtoPath);
                  window.location=('http://' + document.location.host + addtoPath);
                  //document.writeln ("weiche 5");
              }
              else{
                 //document.writeln ("weiche 6");
              }
              
          }
      }
}


//Umleitung notwendig?

ReDirect();



function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function sendForm(formname){
	document.forms[formname].submit();
}





