function viewSpecifiedImage(which) {
	var x = window.open('','pictureViewer','width=800,height=800,resizable=1');
	if( !x ) { return true; }
	x.document.open();
	x.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><title>Picture Viewer<\/title>');
	x.document.write('<sc'+'ript type="text/javascript">');
	x.document.writeln('var isNN,isIE;');
	x.document.writeln('function reSizeToImage(){');
	if (navigator.appName.indexOf("Microsoft")==-1)
	{
		x.document.writeln('window.innerWidth=document.images["ex_popimage"].width;');
		x.document.writeln('window.innerHeight=document.images["ex_popimage"].height;');
		x.document.writeln('document.title="Picture Viewer";');
	}else if(window.opera){
		x.document.writeln('window.resizeTo(100,100);');
		x.document.writeln('width=130-(document.body.clientWidth-document.images[0].width);');
		x.document.writeln('height=100-(document.body.clientHeight-document.images[0].height);');
		x.document.writeln('window.resizeTo(width,height);');
	}else{
		x.document.writeln('window.resizeTo(100,100);');
		x.document.writeln('width=100-(document.body.clientWidth-document.images[0].width);');
		x.document.writeln('height=100-(document.body.clientHeight-document.images[0].height);');
		x.document.writeln('window.resizeTo(width,height);');
	}
	x.document.writeln('}<\/sc'+'ript>');
	x.document.write('<\/head><body style="margin:0px;" id="ex_popbody" onload="reSizeToImage();self.focus();">');
	x.document.write('<img id="ex_popimage" name="ex_popimage" src="'+which+'" onclick="window.close();" alt="" \/><\/body><\/html>');
	x.document.close();
	if( x.focus ) { x.focus(); }
}

// Window opening
function winOpenCenter(url,name,statbar,scroll,locate,resize,xWidth,yWidth)	{
var adjustedleft = 8//optional
var adjustedheight = 30//adjust height because of windows taskbar
var screenwidthremainder = screen.availWidth%2//really not needed, but won't hurt
var screenheightremainder = screen.availHeight%2
var screenwidth = screen.availWidth - screenwidthremainder
var screenheight = screen.availHeight - screenheightremainder
var winheight = yWidth //set new window height properties
var winwidth = xWidth //set new window width properties
var winleft = parseInt(screenwidth/2) - (winwidth/2) - adjustedleft//optional
var wintop = parseInt(screenheight/2) - (winheight/2) - adjustedheight

var win = window.open(url,name,'width=' +winwidth+ ',height=' +winheight+',status=' +statbar+',resizable='+resize+',scrollbars='+scroll+',location='+locate+',top='+wintop+',left='+winleft);
return win;
}

// Email checker
function ValidateEmailAddress(emailStr) {
	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) {
		var textObj =document.getElementById("Email"); 
		alert("Please enter a valid email address.")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null) {
		var textObj =document.getElementById("Email"); 
	    alert("Email address username is not valid.")
	    return false
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
				var textObj =document.getElementById("Email"); 
		        alert("Email address destination IP is invalid.")
			return false
		    }
	    }
	    return true
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		var textObj =document.getElementById("Email"); 
		alert("Email address 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
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4) {
		var textObj =document.getElementById("Email"); 
		alert("Email address must end in a three or four-letter domain, or two letter country.")
		return false
	}
	if (len<2) {
		var textObj=document.getElementById("Email"); 
		var errStr="Email address is missing a hostname."
		alert(errStr)
		return false
	}
	return true;
}
