var high = new Array(); //highlighted imgs
var norm = new Array(); //normal imgs

//standard image preloader
// the array "navitems" has to be defined directly
// in the page before this script is called
for (i=0;i<navitems.length;i++) {
  curritem=navitems[i];
  high[curritem] = new Image(); high[curritem].src="/img/nav/"+curritem+"_f2.gif";
  norm[curritem] = new Image(); norm[curritem].src="/img/nav/"+curritem+".gif";
}

//mouse(over|out)
function moo(img_name,moo_action) {
  switch(moo_action) {
    case 1: document.images[img_name].src = high[img_name].src;break;
    case 2: document.images[img_name].src = norm[img_name].src;break;
  }
}

function konsole(konsurl,konswidth,konsheight) {
  kons = window.open(konsurl, "zoom", "width="+konswidth+",height="+konsheight+",location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no");
  if(kons && kons.focus)kons.focus();
}

function gallery(gid,imgnum) {
  galwin = window.open("/cme/gallery.php?gid="+gid+"&imgnum="+imgnum, "gallery", "width=440,height=440,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no");
  if (galwin && galwin.focus) galwin.focus();
}

function cme_login() {
  window.open("/cme/login.php", "login", "width=450,height=300,resizable=yes");
}

function form_error(errortext,formelement) {
  alert("Bitte vollstaendig ausfuellen: " + errortext);
  if (formelement && formelement.focus) formelement.focus();
  return false;  
}

function check_kontaktform() {
  fe = document.kontaktform.elements; //fe = form elements
  var mailregex = /^[0-9a-zA-Z][0-9a-zA-Z\._-]*@([0-9a-zA-Z-_]+\.)+([a-z]{2,4})$/;

  if (fe.betreff.value=="")      return form_error("Betreff",fe.betreff);
  if (fe.fullname.value=="")	 return form_error("Name",fe.fullname);
  if (!mailregex.test(document.kontaktform.email.value)) 	return form_error("E-Mail",fe.email);
  if (fe.nachricht.value=="")	 return form_error("Nachricht",fe.nachricht);
  return true;
}

function check_gbform() {
  fe = document.gb_form.elements; //fe = form elements
  if (fe.gb_name.value=="")      return form_error("Name",fe.gb_name);
  if (fe.gb_text.value=="")	 return form_error("Nachricht",fe.gb_text);
  return true;
}
