/* changes the td background color on rollover */
//function change_color(myCell, color) {
function change_color(myCell, opt) {
  if(opt == 1) {
  	myCell.style.backgroundColor = '#C8D1DF';
  }
  else if(opt == 0) {
    myCell.style.backgroundColor = '#ffffff';
  }
}

/* opens a popup window to display the requested webcam image */
function popUp() {
  newWin = window.open("", "display", "width=640, height=510, left=0, top=0");
  newWin.focus();
}

function showImg(w, h) {
  newWin = window.open("", "imp", "width="+w+", height="+h+", left=0, top=0");
}

/* checks the input from 02_webcam_detail.php contact form */
function checkInput(){
	var pre = document.contact;
	var name = pre.name.value.length;
	var email = pre.email.value;
	var message = pre.message.value.length;
  
	if(name < 5){
		alert("Bitte geben Sie einen Namen ein.");
		pre.name.focus();
		return false;
	}
  else if(parseMail(email) == false) {
    alert("Bitte geben Sie eine gültige Email ein.");
		pre.email.focus();
		return false;
  }
	else if(message < 10){
		alert("Bitte geben Sie eine Nachricht ein.");
		pre.message.focus();
   	return false;
	}
	else{
		return true;
	}
}

/* checks if a given email address is valid */
function parseMail(str) {
 var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|\s/; // not valid
 var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; // valid
 if (!reg1.test(str) && reg2.test(str)) return true;
 return false;
}

function BrowserCheck() {
	if(navigator.appVersion.substring(0,1) == "4" && navigator.appName == "Netscape")
		alert("Diese Seite ist nicht für Netscape 4.x optimiert!");
}