
var slideShowSpeed = 3000

var crossFadeDuration = 3

var Pic = new Array()

Pic[0] = 'images/1.jpg'
Pic[1] = 'images/2.jpg'
Pic[2] = 'images/3.jpg'
/*Pic[3] = 'images/b4.jpg'
Pic[4] = 'images/b5.jpg'
Pic[5] = 'images/b6.jpg'
*/
isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function showMe(){
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.theLayer.visibility="show";
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)";
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
      document.images.SlideShow.filters.blendTrans.Apply();      
   }
   if (!isN4) document.images.SlideShow.src = preLoad[j].src;
   if (isN4) document.layers['theLayer'].document.images['SlideShow'].src = preLoad[j].src;
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play();
   }
   j = j + 1;
   if (j > (p-1)) j=0;
   t = setTimeout('runSlideShow()', slideShowSpeed);
}

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function EingabeCheck() {
	
	if(document.kontaktForm.name.value==""){
		alert("Bitte geben Sie Ihren Namen ins \"Name-Feld\" ein !");
		document.kontaktForm.name.focus();
		return false;
	}
	if(document.kontaktForm.email.value==""){
		alert("Bitte geben Sie Ihre E-Mail ins \"E-Mail-Feld\" ein !");
		document.kontaktForm.email.focus();
		return false;
	}
	if(!isEmail(document.kontaktForm.email.value)) {
		alert("Bitte geben Sie eine korrekte Email Adresse ein !");
		document.kontaktForm.email.focus();	
		return false;
	}
	if(document.kontaktForm.rechn.value==""){
		alert("Bitte geben Sie eine Rechnungsanschrift ins \"Rechnungsanschrift-Feld\" ein !");
		document.kontaktForm.rechn.focus();
		return false;
	}
	if (!document.kontaktForm.agb.checked){
		alert("Bitte lesen Sie die AGB!");
		document.kontaktForm.agb.focus();
		return false;
	}
}
function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}


function summeChecken(p,t){
  var stampa='€ ';
   if (document.kontaktForm.hol.checked){
   	  stampa+=p+'0';
	  stampa=stampa.replace(".", ",");
      document.kontaktForm.gesamt.value=addCommas(stampa);
   }
   else {
   	  stampa+=t+'0';
      stampa=stampa.replace(".", ",");
	  document.kontaktForm.gesamt.value=addCommas(stampa);
  }
}