	function getFullYear(date) 
	{
		fullyear = date.getYear();
		if (fullyear < 1000) fullyear = fullyear + 1900;
		return fullyear;
	}

	function Common_GetWindowPosString(width, height)
	{
		var windowy = (screen.height - height) / 2;
		var windowx = (screen.width - width) / 2;
		
		return ("left=" + windowx + ",top=" + windowy + ",width=" + width + ",height=" + height);
	}


	function CheckForValidNumericKeys ()
	{
		
		if (event.srcElement.tagName == "INPUT" || event.srcElement.tagName == "TEXTAREA")
		{			
			if((event.keyCode != 48) && (event.keyCode != 49) && (event.keyCode != 50) && (event.keyCode != 51) && 
			   (event.keyCode != 52) && (event.keyCode != 53) && (event.keyCode != 54) && (event.keyCode != 55) && 
			   (event.keyCode != 56) && (event.keyCode != 57) && (event.keyCode != 46)) 
			{
				alert ("Valid keys are 0123456789.");
				event.returnValue = false;
			}
		}
	}

	function ValidNumber(sDigit){
		//var iTmp = parseInt(sDigit);
		if(isNaN(sDigit))
			return false;
		else
			return true;
	}	
	
	function ValidString(strText){
		//if(strText=='' | strText==' ' | strText=='\t')
		//MPS Changed to stop space-only strings
		if (strText.split(" ").join("") == '' | strText =='\t')
			return false;
		else
			return true;
	}
	
	function NumberOfChars(strChar, strString) {
	
		var intCounter = 0;
		var intPosition = 0;
		var intLastPosition = 0;
		var strNewString

		//MPS - Return the number of occurences of a particular string within a given string
		strNewString = strString.substr(intPosition)
		while (intPosition != -1) {
			intPosition = (strNewString.indexOf(strChar))
			if (intPosition != -1) {
				//Found the string
				strNewString = strNewString.substr(intPosition +1)
				//intPosition ++;
				intCounter ++;
			}
		}

		return intCounter;
	}			
			
	function ValidURL(strInput) {
	
		//MPS - Return whether or not a given string is a valid internet URL (as best we can)
		if (!ValidString(strInput))
			return false;
		
		if (strInput.indexOf("http://") == -1 & strInput.indexOf("ftp://") == -1) 
			//Not Valid internet URL
			return false;
			
		if (NumberOfChars(".",strInput) < 2 )
			//Should be at least 2 '.'
			return false;
		
		if (strInput.length == strInput.lastIndexOf(".") +1) {
			//No characters after last '.'
			return false;
		}
			
		return true;		
	
	}			
	
	function ValidEmail(emailField)
	{
		var emailStr=emailField.value;
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var firstChars=validChars;
		var quotedUser="(\"[^\"]*\")";
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom="(" + firstChars + 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 seems incorrect (check @ and .'s)");
			emailField.value="";
			return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];

		if (user.match(userPat)==null)
		{
			alert("The username doesn't seem to be valid.");
			emailField.value="";
		    return false;
		}
		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null)
		{
			for (var i=1;i<=4;i++);
			{
				if (IPArray[i]>255)
				{
					alert("Destination IP address is invalid!");
					emailField.value="";
					return false;
				}
			}
		return true;
		}
		var domainArray=domain.match(domainPat);
		if (domainArray==null)
		{
			alert("The domain name doesn't seem to be valid.");
			emailField.value="";
			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>3)
		{
			alert("The address must end in a three-letter domain, or two letter country.");
			emailField.value="";
			return false;
		}
		/*if (domArr[domArr.length-1].length==2 && len<3)
		{
			var errStr="This address ends in two characters, which is a country";
			errStr+=" code.  Country codes must be preceded by "
			errStr+="a hostname and category (like com, co, pub, pu, etc.)";
			alert(errStr);
			emailField.value="";
			return false;
		}*/
		if (domArr[domArr.length-1].length==3 && len<2)
		{
			var errStr="This address is missing a hostname!";
			alert(errStr);
			emailField.value="";
			return false;
		}
		return true;
	}	
