// JavaScript Document

function openWin(url, width, height) {
	newWin = window.open(url, 'beiTraudl', 'width=' + width + ',' + 'height=' + height);
	newWin.moveTo((screen.availWidth - width)/2, (screen.availHeight - height)/2);
}

function changeImg(p, n) {
	document.images.mainImage.src = p;
}

function setTimer(picArray){
	
	function chImgInterval() {
		document.images.mainImage.src = picArray[i];
		(i < picArray.length - 1) ? i++ : i=0;
		setTimeout(chImgInterval, 7000);
	}
	
	var i = 0;
	chImgInterval();
}

function checkForm(){
	if(document.Anfrage.Firma.value == "")  {
	   alert("[Firma] bitte ausfüllen");
	   document.Anfrage.Firma.focus();
	   return false;
	}
	if(document.Anfrage.Name.value == "")  {
	   alert("[Name] bitte ausfüllen");
	   document.Anfrage.Name.focus();
	   return false;
	}
	/*
	if(document.Anfrage.Email.value == "")  {
	   alert("[Email] bitte ausfüllen");
	   document.Anfrage.Email.focus();
	   return false;
	}else{
		return checkMail(document.Anfrage.Nachname.value)
	}
	*/
}

function checkMail(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);
} 

