	// check that field got value
	function mandatory(fieldobject,fieldname){
		if (fieldobject.value=="") {
			alert("Please enter value for "+fieldname);
			fieldobject.focus();        
			return false;
		}
		return true;
	}
	
	// check that field contain only numeric value
	function validNumeric(fieldobject,fieldname, minlength){
		fieldvalue=fieldobject.value;
		fieldvalue = fieldvalue.replace(/,/g, '')
		if (minlength > 0){
			if (fieldvalue.length < minlength){
					alert("Min "+minlength+" characters for "+fieldname);
					fieldobject.focus();     
					return false;
			}
		}
	
		for(i=0; i<fieldvalue.length; i++){
			if (fieldvalue.charAt(i) < "0" || fieldvalue.charAt(i) > "9"){
				alert("Please correct "+fieldname+" format");
				fieldobject.focus();     
				return false;
			}
		}
		return true;
	}
	
	// check for no spaces in field
	function noSpaces(fieldobject,fieldname, minlength){
		fieldvalue=fieldobject.value;
	
		for(i=0; i<fieldvalue.length; i++){
			if (fieldvalue.charAt(i) == " "){
				alert("Please correct "+fieldname+" format");
				fieldobject.focus();     
				return false;
			}
		}
		return true;
	}
	
	// check that field is a valid email address
	function validEmail(fieldobject){
		fieldvalue=fieldobject.value;
		if(fieldvalue.indexOf ('@',0) == -1){
			alert("Please enter a valid email address");
			fieldobject.focus();
			return false;
		}
		return true;
	}
	
	// check that password same as confirm password
	function confirmPassword(fieldobject1,fieldobject2){
		if (fieldobject1.value!=fieldobject2.value) {
			alert("Password and confirm password differ");
			fieldobject1.focus();
			return false;
		}
		return true;
	}
	
	// confirmation alert
	function confirmation(msg){
		var ok = confirm(msg);
		if(ok){
			return true;
		}else{
			return false;
		}
	}
	
	function checkEmail(element)
	{
		var emailStr = element.value;
		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) 
		{
			alert("Email address is invalid");
			element.focus();
			return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];

		// See if "user" is valid 
		if (user.match(userPat)==null) 
		{
		    // user is not valid
		    alert("The username is invalid.");
			element.focus();
		    return false;
		}

		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) 
		{
		    // this is an IP address
			  for (var i=1;i<=4;i++) 
			  {
			    if (IPArray[i]>255) 
				{
			        alert("Destination IP address is invalid!");
					element.focus();
					return false;
			    }
		      }
		      return true;
		}

		// Domain is symbolic name
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			alert("The domain name is invalid!");
			element.focus();
		    return false;
		}
		
		/* domain name seems valid, but now make sure that it ends in a
		   three-letter word (like com, edu, gov) or a two-letter word,
		   representing country (uk, nl), and that there's a hostname preceding 
		   the domain or country. */
		
		/* Now we need to break up the domain to get a count of how many atoms
		   it consists of. */
		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>3) {
		   // the address must end in a two letter or three letter word.
		   alert("The address must end in a three-letter domain, or two letter country.");
		   element.focus();
		   return false;
		}
		
		// Make sure there's a host name preceding the domain.
		if (len<2) {
		   var errStr="This address is invalid!";
		   alert(errStr);
		   element.focus();
		   return false;
		}
		return true;
	}
	
	// valid file name to upload
	function validUploadFilename(fieldobj){
		fileName = fieldobj.value;
		if (fileName == ""){
			return true;
		}
		
		chk = /'|&|%|#/;
		if (chk.test(fileName) == true){
			alert("Filename contains invalid characters.\nPlease only use alphabets or numbers for image name");
			return false;
		}else{
			return true;
		}
	}
	
	// valid extension to upload
	function validUploadFileExt(fieldobj){
		fileName = fieldobj.value;
		if (fileName == ""){
			return true;
		}
		ext = fileName.substring(fileName.length-3,fileName.length);
		ext = ext.toLowerCase();
		if (ext != 'jpg'){
			alert('You selected a .'+ext+' file. Please select a .jpg file instead!');
		  return false;
		}else{
			return true;
		}
	}
	
	// got select file(s) to upload
	function gotSelectFile(frm){
		var validated;
		validated = false;
		for(i=0; i<frm.length ; i++){
			if(frm.elements[i].type == 'file'){
				if(frm.elements[i].value != ''){
					validated = true;
				}
			}
		}
		return validated;
	}
	
	// got checked item(s)
	function gotCheckItem(frm){
		var validated;
		validated = false;
		for(i=0; i<frm.length ; i++){
			if(frm.elements[i].type == 'checkbox'){
				if(frm.elements[i].checked == true){
					validated = true;
				}
			}
		}
		return validated;
	}
	
	// select all checkbox
	var selectFlag;
	function selectAll(frm){
		var i;
		
		testExp = new RegExp("imageID\\[\\w{0,9}\\]");
		for(i=0; i<frm.length ; i++){
			if (testExp.test(frm.elements[i].name) == true){
				if(selectFlag)	frm.elements[i].checked = false;
				else						frm.elements[i].checked = true;
			}
		}
		if(selectFlag){
			selectFlag=false;
		}else{
			selectFlag=true;
		}
	}
	
	// search text
	function searchField(frm, fieldobj){
		if (fieldobj.value != ""){
			frm.status.value="searchField";
			frm.searchText.value=fieldobj.value;
			frm.submit();
		}else
		{	
			if (frm.status.value=="login")				
				frm.submit();
			else
				return false;
		}
	}

<!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Right click is disabled";

///////////////////////////////////
function clickIE4()
{
	if (event.button==2)
	{
		alert(message);
		return false;
	}
}

function clickNS4(e)
{
	if (document.layers||document.getElementById&&!document.all)
	{
		if (e.which==2||e.which==3)
		{
			alert(message);
			return false;
		}
	}
}

if (document.layers)
{
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS4;
}
else 
if (document.all&&!document.getElementById)
{
	document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// --> 



