// Javascript, Author Frank Scholz Computer Support


    function findPos(variable,SearchValue,max)
    {
      if ((variable.search(SearchValue)>-1) && (variable.search(SearchValue)<max))
       return variable.search(SearchValue);
      else
       return max;
    }

    function switch_db()
    {
      switch(document.forms[1].elements['desc_set'].options.value)
      {
        case '0':
          document.forms[1].elements['year'].maxLength=4;
          document.forms[1].elements['power_kw'].maxLength=5;
          document.forms[1].elements['power_hp'].maxLength=5;
          document.getElementsByName("year")[0].value = document.getElementsByName("year")[0].value.slice(0,4);
          document.forms[1].elements['power_kw'].value=document.forms[1].elements['power_kw'].value.slice(0,findPos(document.forms[1].elements['power_kw'].value,",",5));
          document.forms[1].elements['power_hp'].value=document.forms[1].elements['power_hp'].value.slice(0,findPos(document.forms[1].elements['power_hp'].value,",",5));
          document.forms[1].elements['year'].style.borderWidth='0px';
          document.forms[1].elements['power_kw'].style.borderWidth='0px';
          document.forms[1].elements['power_hp'].style.borderWidth='0px';
          document.forms[1].elements['desc_set'].style.borderWidth='0px';
        break;
        case '1':
          document.forms[1].elements['year'].maxLength=14;
          document.forms[1].elements['power_kw'].maxLength=10;
          document.forms[1].elements['power_hp'].maxLength=10;
          document.forms[1].elements['year'].style.borderWidth='thin';
          document.forms[1].elements['power_kw'].style.borderWidth='thin';
          document.forms[1].elements['power_hp'].style.borderWidth='thin';
          document.forms[1].elements['desc_set'].style.borderWidth='thin';
          document.forms[1].elements['year'].style.borderColor='#ff0000';
          document.forms[1].elements['power_kw'].style.borderColor='#ff0000';
          document.forms[1].elements['power_hp'].style.borderColor='#ff0000';
          document.forms[1].elements['desc_set'].style.borderColor='#ff0000';
        break;
        default:
      }

    }
    function read_lang()
    {
      if (navigator.appName == "Netscape")
      {
        if (navigator.language.indexOf('de')<0) // browser language is not equal de, switch default de to en
          lang('EN');
      }
      else
      {
        if (navigator.browserLanguage != 'de') // browser language is not equal de, switch default de to en
          lang('EN');
      }
    }
    
    function lang_reg(todo)
    {
      document.getElementById('reg_de').style.backgroundColor = '#D5D5FF';
      document.getElementById('reg_en').style.backgroundColor = '#D5D5FF';
      document.getElementById('reg_fr').style.backgroundColor = '#D5D5FF';
      document.getElementById('type').style.visibility = 'hidden';
      document.getElementById('type_en').style.visibility = 'hidden';
      document.getElementById('type_fr').style.visibility = 'hidden';
      document.getElementById('colour').style.visibility = 'hidden';
      document.getElementById('colour_en').style.visibility = 'hidden';
      document.getElementById('colour_fr').style.visibility = 'hidden';
      document.getElementById('text').style.visibility = 'hidden';
      document.getElementById('text_en').style.visibility = 'hidden';
      document.getElementById('text_fr').style.visibility = 'hidden';
      switch(todo)
      {
        case 'DE':
          document.getElementById('reg_de').style.backgroundColor = 'white';
          document.getElementById('type').style.visibility = 'visible';
          document.getElementById('colour').style.visibility = 'visible';
          document.getElementById('text').style.visibility = 'visible';
          document.getElementById('type').style.display = 'run-in';
          document.getElementById('colour').style.display = 'run-in';
          document.getElementById('text').style.display = 'run-in';
          break;
        case 'EN':
          document.getElementById('reg_en').style.backgroundColor = 'white';
          document.getElementById('type_en').style.visibility = 'visible';
          document.getElementById('colour_en').style.visibility = 'visible';
          document.getElementById('text_en').style.visibility = 'visible';
          document.getElementById('type_en').style.display = 'run-in';
          document.getElementById('colour_en').style.display = 'run-in';
          document.getElementById('text_en').style.display = 'run-in';
          break;
        case 'FR':
          document.getElementById('reg_fr').style.backgroundColor = 'white';
          document.getElementById('type_fr').style.visibility = 'visible';
          document.getElementById('colour_fr').style.visibility = 'visible';
          document.getElementById('text_fr').style.visibility = 'visible';
          break;

      }

    }

     function adjustLang()
     {
       var availHeight=" ";
       if (self.innerHeight) // all except Explorer
	        availHeight = self.innerHeight;
       else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
    	   availHeight = document.documentElement.clientHeight;
       else if (document.body) // other Explorers
   	    availHeight = document.body.clientHeight;
       elementx=document.getElementById('lang-content');
       if (availHeight <= 552)
       {
        elementx.style.position='absolute';
        elementx.style['top']=313+'px';
       }
       elementx.style.visibility = 'visible';
     }


     function lang(todo)
     {
       var path   = window.location.pathname;
       var active = path.indexOf(".") == path.lastIndexOf(".");
       var act_l  = path.slice(path.indexOf("."),path.lastIndexOf("."))
       if ((path.indexOf(".php")<0) && (path.indexOf(".htm")<0) && (todo != 'DE'))
         location.replace(path + "index." + todo.toLowerCase() + ".php");
       else if ((todo != 'DE') && (todo.ToLowerCase != act_l))
         location.replace(path.slice(0,path.indexOf(".")) + "." + todo.toLowerCase() + path.slice(path.lastIndexOf("."),path.length)) ;
       else if ((todo == 'DE') && (!active))
         location.replace(path.slice(0,path.indexOf(".")) + path.slice(path.lastIndexOf("."),path.length));
     }

     function addUrl(addOn)
     {
          window.location.href = window.location.href + addOn;
     }

     function goTo(url)
     {
          window.location.href = url;
     }
     function bigpicture()
     {
        var src_complete = document.images.prev_big.src;
        var src =src_complete.slice(src_complete.lastIndexOf("/")+1,src_complete.lastIndexOf("&")) + "&full=true";
        full = window.open(src);
        full.focus();
     }

     function pictureprev(src)
     {
        document.images.prev_big.src = src;
     }
     

     function confirmTask(destination,text)
     {
        path = window.location.pathname;
        Check = confirm(text);
        if (Check == true)
          location.replace(destination);

     }

     function hello(test)
     {
       alert(test);
     }
