function toggleBlock(block,divs){

   blockOff(divs);

   blockOn(block);

}

function blockOff(divs){

	var i=0;

	if(typeof(divs) == "string"){

		//turn off a single

		document.getElementById(divs).style.display = "none";

	}else{

		//turn off multiple layers

		for (var i = 0; i < divs.length; i++) {

		   document.getElementById(divs[i]).style.display = "none";

		}

	}

}

function blockOn(idBlock) {

	document.getElementById(idBlock).style.display = "block";

}

function visibleOff(divs){

	var i=0;

	if(typeof(divs) == "string"){

		//turn on a single layer

		document.getElementById(divs).style.visibility = "hidden";

	}else{

		//turn on multiple layers

		for (var i = 0; i < divs.length; i++) {

		   document.getElementById(divs[i]).style.visibility = "hidden";

		}

	}



}

function visibleOn(idBlock) {

	document.getElementById(idBlock).style.visibility = "visible";

}

//divs are the fields that are to be checked

count=0;

function validateForm(theForm,divs,msgdiv) {

	err = false;

    visibleOff(msgdiv);//turn of error div

	for(i=0;i<divs.length;i++){

       var div = divs[i];

	   visibleOff('err'+div);//turn off every div

	   if(div == 'email'){

			if(!isEmail(theForm[div].value)){

				err = true;

				var errdiv = 'err'+div;

				visibleOn(errdiv);

			}

	   }else{//check for empty

		   if(theForm[div].value ==""){

			    err = true;

				var errdiv = 'err'+div;

				visibleOn(errdiv);

		   }

	   }

	}

	if (err) {

	   visibleOn(msgdiv);

       return false;

    }

	count++;

	if(count==1){

	  return true;

	}else{

	  alert ("We are currently processing your request.");

	  return false;

	}

}



function isEmail (s){   

    var i = 1;

    var sLength = s.length;

    // look for @

    while ((i < sLength) && (s.charAt(i) != "@"))

    { i++

    }

    if ((i >= sLength) || (s.charAt(i) != "@")){

	 	return false;

	 }else{

	  i += 2;

	 }

    // look for .

    while ((i < sLength) && (s.charAt(i) != "."))

    { i++

    }

    // there must be at least one character after the .

    if ((i >= sLength - 1) || (s.charAt(i) != ".")){

	 	return false;

    }else{

	 	return true;

	}

}

function popImage(img,x,y){

	unique = new Date();

	unique = unique.getTime();

	url = '/viewImage.php?imageName='+img;

 	paramlist = 'width='+x+',height='+y+',resizable=no,scrollbars=no,status=no,titlebar=no,menubar=no';

	newWindow = window.open(url,unique,paramlist);

	newWindow.focus();

}