function WM_preloadImages() {

/*
WM_preloadImages()
Loads images into the browser's cache for later use.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Nadav Savio
Author Email: nadav@wired.com

Usage: WM_preloadImages('image 1 URL', 'image 2 URL', 'image 3 URL', ...);
*/

  // Don't bother if there's no document.images
  if (document.images) {
    if (typeof(document.WM) == 'undefined'){
      document.WM = new Object();
    }
    document.WM.loadedImages = new Array();
    // Loop through all the arguments.
    var argLength = WM_preloadImages.arguments.length;
    for(arg=0;arg<argLength;arg++) {
      // For each arg, create a new image.
      document.WM.loadedImages[arg] = new Image();
      // Then set the source of that image to the current argument.
      document.WM.loadedImages[arg].src = WM_preloadImages.arguments[arg];
    }
  }
}

function WM_imageSwap(daImage, daSrc){
  var objStr,obj;
  /*
    WM_imageSwap()
    Changes the source of an image.

    Source: Webmonkey Code Library
    (http://www.hotwired.com/webmonkey/javascript/code_library/)

    Author: Shvatz
    Author Email: shvatz@wired.com

    Usage: WM_imageSwap(originalImage, 'newSourceUrl');

    Requires: WM_preloadImages() (optional, but recommended)
    Thanks to Ken Sundermeyer (ksundermeyer@macromedia.com) for his help
    with variables in ie3 for the mac. 
    */

  // Check to make sure that images are supported in the DOM.
  if(document.images){
    // Check to see whether you are using a name, number, or object
    if (typeof(daImage) == 'string') {
      // This whole objStr nonesense is here solely to gain compatability
      // with ie3 for the mac.
      objStr = 'document.' + daImage;
      obj = eval(objStr);
      obj.src = daSrc;
    } else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
      daImage.src = daSrc;
    }
  }
}

function fShowImage(vPath,vName,vWidth,vHeight) {

	vWWidth = vWidth + 0;

	vWHeight = vHeight + 0;

	window.open(vPath,vName,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+(vWWidth)+",height="+(vWHeight));

}

var statusWin;
function showProgress() {
	statusWin = open('/upload_progress.php','uploadstatus','height=150,width=350,location=no,scrollbars=no,menubars=no,toolbars=no,resizable=yes');  }

function hideProgress() {
	if (typeof(statusWin) != "undefined") {
		statusWin.close();
		statusWin = void(0);
	}
}

function hideProgressAndReload() {
	hideProgress();
	history.go(0);
}

/*  
Made by Martial Boissonneault © 2001-2003 http://getElementById.com/
May be used and changed freely as long as this msg is intact
Visit http://getElementById.com/ for more free scripts and tutorials.
*/
var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var W3C = (!document.all && document.getElementById);

function AdjustWin(){
	var w = 380;                   
	var h = 200;                   
	var x = (screen.width-w)/2;    
	var y = (screen.height-h)/2;   
	window.resizeTo(w,h);
	window.moveTo(x,y);
}

function fSwitch(vElement, vToChange){
	// Netscape 4
	if(ns4){
		document.layers[id].visibility = "show";
		//alert('ns4');
	}
	// Explorer 4
	else if(ie4){
		document.all[id].style.visibility = "visible";
		//alert('ie4');
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if(ie5 || W3C){
		//document.getElementById(vElement).style.visibility = "visible";
		//alert('W3C');
		document.getElementById(vElement).className = vToChange;
	}
}

function MM_showHideLayers() { //v3.0A Modified by Al Sparber and Massimo Foti for NN6 Compatibility
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  if(document.getElementById){
   for (i=0; i<(args.length-1); i+=2){
    obj=tmt_findObj(args[i]);
    v=args[i+1];
    v=(v=='show')?'visible':(v='hide')?'hidden':v;
    if(obj)obj.style.visibility=v;
   }
  } else{
   for (i=0; i<(args.length-1);i+=2) 
   if ((obj=MM_findObj(args[i]))!=null) { 
    v=args[i+1];
    if (obj.style) {
     obj=obj.style; 
     v=(v=='show')?'visible':(v='hide')?'hidden':v;
    }
    obj.visibility=v;
   }
  }
}

function tmt_findObj(n){
	var x,t;
	if((n.indexOf("?"))>0&&parent.frames.length){
 	 t=n.split("?");
     x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
	} else {
	 x=document.getElementById(n)
	}
  return x;
}

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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('Dieses Formular kann nur abgeschickt werden, wenn alle Felder ausgefŸllt sind. \nBitte ergŠnzen Sie die fehlenden Felder. Besten Dank.');
  document.MM_returnValue = (errors == '');
}

