var req;
var iedit;  
createAJAX();


if (navigator.userAgent.indexOf("MSIE 5") != -1)
    document.location.href = "ie6.php";
    
if (navigator.userAgent.indexOf("MSIE 6") != -1)
    document.location.href = "ie6.php";

    
    
function fixMozilla()
{   
    //alert(navigator.userAgent);
    if (navigator.userAgent.indexOf("Mozilla") != -1)
    {
     // gilt für Firefox, Safari und Chrome
     document.getElementById("main_oben1").style.backgroundPosition = "49.94% 0px";
     document.getElementById("main_oben2").style.backgroundPosition = "49.94% 0px";
    }
}
    
    
function createAJAX()
{
    try{           req = new XMLHttpRequest();      }      catch (e){          try{               req = new ActiveXObject("Msxml2.XMLHTTP");          }           catch (e){             try{                 req = new ActiveXObject("Microsoft.XMLHTTP");            }             catch (failed){                req = null;            }         }        }   
}

function process(action,f1,f2) 
{ 
   if (action == "kontakt")
   {
           
   }
   
   if(req.readyState == 4 || req.readyState == 0) 
   {   
       if (action == "showwebOver")
       {            
          req.open("POST", "ajax.php", true); 
          req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
          req.onreadystatechange = handleServerResponse; 
          req.send("action="+action+"&id="+f1);  
          return false;
       }
       
       if (action == "showgrafikOver")
       {
          req.open("POST", "ajax.php", true); 
          req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
          req.onreadystatechange = handleServerResponse; 
          req.send("action="+action+"&id="+f1);  
          return false;
       }
       
       if (action == "showmotionOver")
       {
          req.open("POST", "ajax.php", true); 
          req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
          req.onreadystatechange = handleServerResponse; 
          req.send("action="+action+"&id="+f1);  
          return false;
       }
       
       if (action == "motion_ref")
       {
          req.open("POST", "ajax.php", true); 
          req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
          req.onreadystatechange = handleServerResponse; 
          req.send("action="+action+"&id="+f1);  
          return false;
       }
       
       if (action == "kontakt")
       {
            var ix = document.getElementById("iname").value;
            var iy = document.getElementById("iemail").value;
            var iz = document.getElementById("iinhalt").value;
            document.getElementById("hiddenform").innerHTML = document.getElementById("kontakt_formular").innerHTML;
            document.getElementById("kontakt_formular").innerHTML = "<div align=center style=\"width:350px\"><div style=\"height:140px;\"></div><img src='png/loader.gif'/></div>"; 
          req.open("POST", "ajax.php", true); 
          req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
          req.onreadystatechange = handleServerResponse_kontakt; 
          req.send("action="+action+"&iname="+ix+"&iemail="+iy+"&inhalt="+iz);  
          return false;
       }
   }
}

function handleServerResponse() 
{ 
   if(req.readyState == 4) 
   { 
      if(req.status == 200) 
      { 
         xmlResponse = req.responseText; 

            var realHeight = document.body.scrollHeight + document.body.offsetHeight;
            

    document.getElementById("overall").style.top = "0px";
    document.getElementById("overall").style.height = realHeight;
    document.getElementById("overall").style.display = "block";
          
  document.getElementById("overall_pic").innerHTML = xmlResponse;
  document.getElementById("overall_pic").style.display = "block"; 
  document.getElementById("overall_pic").style.opacity = 0;
 // document.getElementById("overall_pic").style.filter = "alpha(opacity=0)"; 
  document.getElementById("overall_pic").style.left = document.getElementById("value_opic").innerHTML;
    
  
  
  
  
  var iii = "-165px";
  
  if (document.getElementById("kindof").innerHTML == "web")
  {
      var ori = document.getElementById("orientation").innerHTML;
      if (ori == "hochkant")
        iii = "-242px";
      else
        iii = "-165px";
  }
  

    document.getElementById("overall_pic").style.top = iii;  
  
  if (document.body.scrollTop > 0)
  {
    document.getElementById("overall_pic").style.top = (document.body.scrollTop-187); 
    
  }
    
    setTimeout("picshow()",500);

      } else { 
         alert("There was a problem accessing the server: " + req.statusText); 
      } 
   } 
} 

function picshow()
{
  document.getElementById("overall_pic").style.opacity = 1;
 // document.getElementById("overall_pic").style.filter = "alpha(opacity=100)";
}

function handleServerResponse_kontakt() 
{ 
   if(req.readyState == 4) 
   { 
      if(req.status == 200) 
      { 
         xmlResponse = req.responseText; 
         document.getElementById("kontakt_formular").innerHTML = xmlResponse; 
    
      } else { 
         alert("There was a problem accessing the server: " + req.statusText); 
      } 
   } 
} 


function open_link(id,typ)
{
    var $id = document.getElementById("webid"+id).innerHTML;
    process("show"+typ+"Over",$id)    
    return 0;
}

function overall_off()
{
   document.getElementById("overall").style.display = "none"; 
   document.getElementById("overall_pic").style.display = "none";
   document.getElementById("divimpressum").style.display = "none"; 
}

function overall_sel(id)
{
   document.getElementById("overall_img").src = id;
}

function overall_mover(id)
{
    document.getElementById(id).style.border = "1px solid white";
}

function overall_mout(id)
{
    document.getElementById(id).style.border = "";
}


function menu_over(id)
{
    document.getElementById(id).style.backgroundImage = "url(png/" + id + "_over.png)";
}

function menu_out(id)
{
    document.getElementById(id).style.backgroundImage = "url(png/" + id + ".png)";
}

function blend_kontakt(what)
{
        document.getElementById("kontakt_info").style.display = what;
}

function blend_grafik(what)
{
    document.getElementById("grafik_bereich").style.display = what; 
}

function blend_web(what)
{
     document.getElementById("web_bereich").style.display = what;  
}

function blend_207(what)
{
     document.getElementById("w207_bereich").style.display = what; 
}

function blend_audio(what)
{
     document.getElementById("audio_bereich").style.display = what; 
}

function blend_motion(what)
{
    document.getElementById("motion_bereich").style.display = what;  
}

function blend_software(what)
{
    document.getElementById("software_bereich").style.display = what;  
}

function blend_main(what)
{
    document.getElementById("main_bereich").style.display = what;  
}


function menu_click(id)
{
    document.getElementById("menu_main").style.background = "url(png/logo.png)";
    document.getElementById("logo_menu_grafik").style.display = "none";
    document.getElementById("logo_menu_web").style.display = "none";
    document.getElementById("logo_menu_motion").style.display = "none";
    document.getElementById("logo_menu_audio").style.display = "none";
    document.getElementById("logo_menu_207").style.display = "none";
    document.getElementById("logo_menu_software").style.display = "none";
    document.getElementById("logo_menu_kontakt").style.display = "none";
        
    if (id == "menu_main")
    {
        document.getElementById("page_rand").style.backgroundImage = "url(png/normal_rand.png)";  
        document.getElementById("menu_main").style.background = "";
        AboutUsEmpty();
    }
    else
    {
        document.getElementById("page_rand").style.backgroundImage = "url(png/" + id + "_rand.png)";                                
        document.getElementById("logo_"+id).style.display = "block";
    }
            

    if (id == "menu_kontakt")
    {
        blend_kontakt("block");
        blend_grafik("none");
        blend_web("none");
        blend_207("none");
        blend_audio("none");
        blend_motion("none");
        blend_software("none");
        blend_main("none");
    }
    
    if (id == "menu_web")
    {
        blend_kontakt("none");
        blend_grafik("none");
        blend_web("block");
        blend_207("none");
        blend_audio("none");
        blend_motion("none");
        blend_software("none");
        blend_main("none");
    }
    
    if (id == "menu_grafik")
    {
        blend_kontakt("none");
        blend_grafik("block");
        blend_web("none");
        blend_207("none");  
        blend_audio("none");
        blend_motion("none");
        blend_software("none");
        blend_main("none");
    }
    
    if (id == "menu_motion")
    {
        blend_kontakt("none");
        blend_grafik("none");
        blend_web("none");
        blend_207("none");
        blend_audio("none");
        blend_motion("block");
        blend_software("none");
        blend_main("none");
    }
    
    if (id == "menu_207")
    {
        blend_grafik("none");
        blend_kontakt("none");
        blend_web("none");
        blend_207("block");
        blend_audio("none");
        blend_motion("none");
        blend_software("none");
        blend_main("none");
    }
    
    if (id == "menu_audio")
    {
        blend_grafik("none");
        blend_kontakt("none");
        blend_web("none");
        blend_207("none");    
        blend_audio("block");
        blend_motion("none");
        blend_software("none");
        blend_main("none");
    }
    
    if (id == "menu_software")
    {
        blend_kontakt("none");
        blend_grafik("none");
        blend_web("none");
        blend_207("none");
        blend_audio("none");
        blend_motion("none");
        blend_software("block");
        blend_main("none");
    }
    
    if (id == "menu_main")
    {
        blend_kontakt("none");
        blend_grafik("none");
        blend_web("none");
        blend_207("none");
        blend_audio("none");
        blend_motion("none");
        blend_software("none");
        blend_main("block");
    }
    

    
    
}


function web_over(id)
{


    document.getElementById("web_over"+id).style.display = "block";

}

function web_out(id)
{
    document.getElementById("web_over"+id).style.display = "none";
}


function impressum()
{     
    var realHeight = document.body.scrollHeight + document.body.offsetHeight;
    document.getElementById("overall").style.height = realHeight;
  
  
  document.getElementById("overall").style.display = "block"; 
  document.getElementById("overall").style.top = "0px"; 
  document.getElementById("divimpressum").style.display = "block";
  document.getElementById("divimpressum").style.top = document.body.scrollTop+100-187;
}

function impressum_off()
{
overall_off();
document.getElementById("divimpressum").style.display = "none";
}


function clientlogin()
{
 alert("Die eingegeben Benutzerdaten sind inkorrekt.");
 document.getElementById("ben").value = "";
 document.getElementById("pas").value = "";
}

function emailit()
{
    var ix = document.getElementById("iname").value;
    var iy = document.getElementById("iemail").value;
    var iz = document.getElementById("iinhalt").value;
    
    
    if (EMail(iy) == false)
    {
        alert("Die E-Mail Adresse ist nicht korrekt.");
        return 0;
    }
    
    if (ix.length < 2)
    {
        alert("Bitte einen gütigen Namen eingeben!");
        return 0;
    }
    
    if (iz.length < 5)
    {
        alert("Bitte eine konkrete Nachricht formulieren.");
        return 0;
    }
    
    process("kontakt");
    

}


function EMail(s)
{
 var a = false;
 var res = false;
 if(typeof(RegExp) == 'function')
 {
  var b = new RegExp('abc');
  if(b.test('abc') == true){a = true;}
  }

 if(a == true)
 {
  reg = new RegExp('^([a-zA-Z0-9\-\.\_]+)'+
                   '(\@)([a-zA-Z0-9\-\.]+)'+
                   '(\.)([a-zA-Z]{2,4})$');
  res = (reg.test(s));
 }
 else
 {
  res = (s.search('@') >= 1 &&
         s.lastIndexOf('.') > s.search('@') &&
         s.lastIndexOf('.') >= s.length-5)
 }
 return(res);
}


function newContactMail()
{
 document.getElementById("kontakt_formular").innerHTML = document.getElementById("hiddenform").innerHTML;
 document.getElementById("iname").value = "";
 document.getElementById("iemail").value = "";
 document.getElementById("iiinhalt").value = "";
 document.getElementById("hiddenform").innerHTML = "&nbsp;";

}

var activeAboutUs = "";

function AboutUs(id)
{

   
    var isIe/*@cc_on = true@*/;
    var word = "class";
    if (isIe == true)
        var word = "className"; 

    document.getElementById("owasist").setAttribute(word, "linesempty");
    document.getElementById("owaskann").setAttribute(word, "linesempty");
    document.getElementById("owaswill").setAttribute(word, "linesempty");
    document.getElementById("owoist").setAttribute(word, "linesempty");
    document.getElementById("uwasist").setAttribute(word, "linesempty");
    document.getElementById("uwaskann").setAttribute(word, "linesempty");
    document.getElementById("uwaswill").setAttribute(word, "linesempty");
    document.getElementById("uwoist").setAttribute(word, "linesempty");    
    document.getElementById("o"+id).setAttribute(word, "olines"); 
    document.getElementById("u"+id).setAttribute(word, "olines"); 
    activeAboutUs = id;
    document.getElementById("startbox_content").innerHTML = document.getElementById("content_"+id).innerHTML;
    document.getElementById("idtablebox").style.display = "block";
    
}


function AboutUsOver(id)
{   
  /*  document.getElementById("owasist").setAttribute("class", "linesempty");
    document.getElementById("owaskann").setAttribute("class", "linesempty");
    document.getElementById("owaswill").setAttribute("class", "linesempty");
    document.getElementById("owoist").setAttribute("class", "linesempty");*/

    var isIe/*@cc_on = true@*/;
    var word = "class";
    if (isIe == true)
        var word = "className";  
    
    if (activeAboutUs != id)
        document.getElementById("o"+id).setAttribute(word, "olines"); 
}


function AboutUsOut(id)
{   
    var isIe/*@cc_on = true@*/;
    var word = "class";
    if (isIe == true)
        var word = "className";  

    if (activeAboutUs != id)
        document.getElementById("o"+id).setAttribute(word, "linesempty");  
}

function AboutUsEmpty()
{
    var isIe/*@cc_on = true@*/;
    var word = "class";
    if (isIe == true)
        var word = "className";    
    
    document.getElementById("owasist").setAttribute(word, "linesempty");
    document.getElementById("owaskann").setAttribute(word, "linesempty");
    document.getElementById("owaswill").setAttribute(word, "linesempty");
    document.getElementById("owoist").setAttribute(word, "linesempty");
    document.getElementById("uwasist").setAttribute(word, "linesempty");
    document.getElementById("uwaskann").setAttribute(word, "linesempty");
    document.getElementById("uwaswill").setAttribute(word, "linesempty");
    document.getElementById("uwoist").setAttribute(word, "linesempty");    
    activeAboutUs = "";
    document.getElementById("idtablebox").style.display = "none";
}


function motion_dot_normal(id)
{ 
    document.getElementById("motiondot"+id).innerHTML ="<img src='png/motion_dot_normal.png'/>";
}

function motion_dot_over(id)
{

    document.getElementById("motiondot"+id).innerHTML ="<img src='png/motion_dot_over.png'/>";
}

function UnCryptMailto( s )
    {
        var n = 0;
        var r = "";
        for( var i = 0; i < s.length; i++)
        {
            n = s.charCodeAt( i );
            if( n >= 8364 )
            {
                n = 128;
            }
            r += String.fromCharCode( n - 1 );
        }
        return r;
    }

    function linkTo_UnCryptMailto( s )
    {
        location.href=UnCryptMailto( s );
    }

    
function makeinfo(id)
{
    if (document.getElementById(id).style.display == "none")
        Effect.BlindDown(id);
    else
        Effect.BlindUp(id);
}


