

function CaricaFoto(img){
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}
function Controlla(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}
function viewFoto(img){
  largh=foto1.width+20;
  altez=foto1.height+20;
  stringa= "width="+largh+",height="+altez;
  finestra=window.open(img,"",stringa);

  
}




function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function formHandler(form){
var URL = document.form.site.options[document.form.site.selectedIndex].value;
window.location.href = URL;
}

function addThem() {
document.kg.total.value =
parseInt(document.kg.hardware.value) +
parseInt(document.kg.software.value) +
parseInt(document.kg.people.value) +
parseInt(document.kg.equipment.value) +
parseInt(document.kg.other.value) +
parseInt(document.kg.other2.value) +
parseInt(document.kg.other3.value);
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
	/*
		top_nav_educators_over = newImage("images/top_nav_educators-over.gif");
		top_nav_students_over = newImage("images/top_nav_students-over.gif");
		top_nav_families_over = newImage("images/top_nav_families-over.gif");
		top_nav_you_t_over = newImage("images/top_nav_you-t-over.gif");	
	*/	
		preloadFlag = true;
	}
}
 function submitForm(form) {
       if (checkIt(form)) {
         form.submit();
       }
      }

      function checkIt(form) {
      var email = form.email.value;
	  var name = form.name.value; 
      var message = form.message.value;
      var msg = '';	 
	  
	  // Make sure the E-mail address field contains some data
      if(email.length < 1) {
      if(msg.length > 0)
      msg+=', ';
      msg += 'E-mail address';
      }
	  	  
	  //Make sure the name field contains some data
      if(name.length < 1) {
      if(msg.length > 0)
      msg+=', ';
      msg += 'Name';
      }
	           
	  //Make sure the Question field contains some data
      if(message.length < 1) {
      if(msg.length > 0)
      msg+=', ';
      msg += 'Message';
      }
      	  	   
	  //Display alert box for patron; he/she left at least one required field blank
      if (msg != '')
      {
      alert("One or more required fields are blank\r\n" + msg);
      return false;
      }
	  
	  if (!emailCheck(email, true)) { 
      return false;
      }
	  	  
	//function to verify e-mail syntax
	function emailCheck (emailStr, alertflag) {
		var emailPat=/^(.+)@(.+)$/		
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=emailStr.match(emailPat)
		
		if (matchArray==null) {
				if (alertflag)
			alert("Email address seems incorrect (check @ and .'s)")		
			return false
		}
		
		var user=matchArray[1]		
		var domain=matchArray[2]		
		
		// See if "user" is valid 		
		if (user.match(userPat)==null) {		
			// user is not valid
		
			 if (alertflag) 		
				alert("The username in your e-mail address doesn't seem to be valid.")		
			return false		
		}
		
		/* if the e-mail address is at an IP address (as opposed to a symbolic
		   host name) make sure the IP address is valid. */
		
		var IPArray=domain.match(ipDomainPat)		
		if (IPArray!=null) {		
			// this is an IP address		
			  for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
			  if (alertflag)
					alert("Destination IP address is invalid!")		
				return false		
				}		
			}
			return true		
		}
		
		// Domain is symbolic name		
		var domainArray=domain.match(domainPat)		
		if (domainArray==null) {		
			  if (alertflag)		
				alert("The domain name doesn't seem to be valid.")		
			  return false		
		}
		var atomPat=new RegExp(atom,"g")
		
		var domArr=domain.match(atomPat)
		var len=domArr.length
		musExp = /.museum/
		isMus = domain.search(musExp)
		
		if ( ( (domArr[domArr.length-1].length < 2) || (domArr[domArr.length-1].length > 6) ) ||
			(domArr[domArr.length-1].length == 5) ||
			( (domArr[domArr.length-1].length == 6) && (isMus == -1) ) ) {
		   // the address must end in a two, three, or four letter word, or .museum.
			  if (alertflag) 		
		   		alert("Your e-mail address must end in a three or four-letter domain,\ntwo-letter country code, or .museum.")
		   return false
		}
				
		// Make sure there's a host name preceding the domain.		
		if (len<2) {		
		   var errStr="Your e-mail address is missing a hostname!"
			  if (alertflag) 
		   alert(errStr)
		   return false		
		}		
		
		// If we've gotten this far, everything's valid!
		
		return true;	
	}
}


	
	//DisplayImage function
	function DisplayImage(picURL,picWidth,picHeight,picTitle){
	newWindow=window.open(picURL,'newWin','toolbar=no, width='+picWidth+',height='+picHeight)
	newWindow.document.write('<html><head><title>'+picTitle+'<\/title><\/head><body background="'+picURL+'"><\/body><\/html>')
	newWindow.resizeBy(picWidth-newWindow.document.body.clientWidth,picHeight-newWindow.document.body.clientHeight)
	newWindow.focus()
	}

	function popup(pageURL){
		newwindow=window.open(pageURL,'mailItem','toolbar=no,width=600,height=500,resizable=yes,scrollbars=yes')
	}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}