﻿//create onDomReady Event
      window.onDomReady = initReady;
 
      // Initialize event depending on browser
      function initReady(fn)
      {
      	//W3C-compliant browser
      	if(document.addEventListener) {
          document.addEventListener("DOMContentLoaded", fn, false);
        }
      	//IE
      	else {
          document.onreadystatechange = function(){readyState(fn)}
        }
      }
 
      //IE execute function
      function readyState(func)
      {
      	// DOM is ready
      	if(document.readyState == "interactive" || document.readyState == "complete")
      	{
      		func();
      	}
      }

// JavaScript Document
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;
var globalid = '';

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0} 
  if(globalid != ''){
  	document.getElementById(globalid).style.left=tempX+15+"px";
  	document.getElementById(globalid).style.top=tempY+20+"px";}
  return true
}


function auf(tuer) {
	if (document.getElementById(tuer).style.display=="inline"){
	document.getElementById(tuer).style.display="none"}
	else{
	document.getElementById(tuer).style.display="inline"}
}

function zu(tuer) {
  document.getElementById(tuer).style.display="none"}


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_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];}}
}

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_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];}
}
function anzeigen(das){
	globalid=das;
	
 if(document.getElementById(das).style.display=="none") {
 	document.getElementById(das).onmousemove = getMouseXY;
	document.getElementById(das).style.display="inline";
	//document.getElementById(das).style.left=tempX+"px";
  	//document.getElementById(das).style.top=tempY+20+"px";
}}

function ausblenden(das){
if(document.getElementById(das).style.display=="inline"){
  document.getElementById(das).style.display="none";
  }
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function changecolor(id,farbe){
	document.getElementById(id).style.color="#"+farbe;
}
function backbild (bild,nummer) {
	document.getElementById('content').style.backgroundImage="url("+bild+")";
	pushContent(nummer);
}

/*var content = '';
function pushContent(bild) {
	if (bild==1){
		content = '<p><a href="#">DOWNLOAD PROJEKT&Ouml;LFIBEL</a></p><p><a href="#">...mehr Informationen...</a></p>';
	}
	else if (bild==2){
		content = '<p><a href="#">DOWNLOAD MODU FLYER</a></p><p><a href="#">...mehr Informationen...</a></p>';
	}
	else if (bild==3){
		content = '<p><a href="#">DOWNLOAD INDUSTRIE&Ouml;LFLYER</a></p><p><a href="#">...mehr Informationen...</a></p>';
	}
	else{
		content = '';
	}
    
	if (bild!=0)
	{
		div = document.getElementById('topadd');
	    div.innerHTML = content;
	}
}*/

//<![CDATA[
    $(document).ready(function() {
      function addMega(){
        $(this).addClass("hovering");
        }
      function removeMega(){
        $(this).removeClass("hovering");
        }
    var megaConfig = {
         interval: 200,
         sensitivity: 8,
         over: addMega,
         timeout: 500,
         out: removeMega
    };
    $("li.mega").hoverIntent(megaConfig)
    });
    //]]>

function checkForm(formular){
	var strFehler='';
	var ret=false;
	var anfrage = document.getElementById(formular);
	var donothing = 0;
	if (!anfrage.checkbox.checked && !anfrage.checkbox2.checked && !anfrage.checkbox3.checked && !anfrage.checkbox4.checked && !anfrage.checkbox5.checked && !anfrage.checkbox6.checked)
		strFehler += "Produktbereich wurde nicht angegeben\n";
	
	if (anfrage.branche[0].checked || anfrage.branche[1].checked || anfrage.branche[2].checked || anfrage.branche[3].checked || anfrage.branche[4].checked)
		donothing=1;
	else if (donothing==0)
		strFehler += "Branche wurde nicht angegeben\n";
	
	if (anfrage.Firma.value=="")
		strFehler += "Feld Firma wurde nicht ausgefüllt\n";
	
	if (anfrage.Strasse.value=="")
		strFehler += "Feld Straße wurde nicht ausgefüllt\n";
	
	if (anfrage.Ort.value=="")
		strFehler += "Feld PLZ/Ort wurde nicht ausgefüllt\n";
	
	if (!validEmail(anfrage.email.value))
		strFehler += "E-Mail-Adresse fehlerhaft";
	
	if (strFehler.length>0) {
		alert("Festgestellte Probleme: \n\n"+strFehler);
		
	}
	else {
		ret=true;
	}
	return (ret);
}

function validEmail(email) {

  var strReg = "^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$";

  var regex = new RegExp(strReg);

  return(regex.test(email));

}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
