	/*
	Some of the functions witten here are used by topban.inc file.
	Make sure, that you give reference to this file in the parent
	source file where topban is included
	
	//copy these lines of code
	<script language=javascript src="../../../root_utils.js">
	</script>

	Note: the dots will differ depending upon the tree
	
	*/
	
	
	function WinFocusResize(iwpos,ihpos,nwpos,nhpos)
	{
		if (document.all)
			{window.resizeTo(iwpos,ihpos);
			}
		else
			{window.resizeTo(nwpos,nhpos);
			}
						
		window.focus();
	}


	function OpenWindow(pagename,WindowName,width,height,yn)
	{
		var nHeight	= parseInt(height);
		var nWidth	= parseInt(width);
		
		var X	= (screen.width - nWidth)/2;
		var Y	= (screen.height - nHeight)/2;	
		
		//alert("X= " + X + " Y= " + Y + " W= " + nWidth + " H= " + nHeight)

		return window.open(pagename,WindowName,"width="+nWidth+",height="+nHeight+",resizable=yes,scrollbars="+yn+",top="+Y+",left="+X);
	}		

	function checkEMail(strEmailAdd)
	{	
		var strRetCode			= new String()
		var locAt;	
		var locPeriod;
		
		//debug code
		//alert(strEmailAdd + "-- EMAIL ADDRESS ENTERED")					

		strRetCode = "" //No Errors
			
		//Check 1
		if((strEmailAdd.indexOf(" ") != -1)  || (strEmailAdd == null))
		{
				strRetCode = "INVALID EMAIL ADDRESS!!" + "\n\n"
				strRetCode = strRetCode + "Address Cannot Contain Blank/Null Characters."
				return strRetCode;
		}
	
		//Check 2
		if(strEmailAdd == "")
		{
				strRetCode = "INVALID EMAIL ADDRESS!!" + "\n\n"
				strRetCode = strRetCode + "Address Cannot Be Empty"
				return strRetCode;
		}

		//Check 3
		for(var cnt=0; cnt < strEmailAdd.length; cnt++)
		{
				nCharCode = strEmailAdd.charCodeAt(cnt)
					
				//debug code
				//alert(strEmailAdd.charAt(cnt)+ " Code =" +nCharCode)
										
				//check to see if between "A" - "Z" or "a" - "z" or "0" - "9" or "@" or "." or "_" or "-"
				if( !(((nCharCode > 64) && (nCharCode < 91)) || ((nCharCode > 96) && (nCharCode < 123))  || ((nCharCode > 47) && (nCharCode < 58)) || (nCharCode == 64) || (nCharCode == 46) || (nCharCode == 95) || (nCharCode == 45)))
				{
					//debug code
					//alert(strEmailAdd.charAt(cnt)+ " Code= " +nCharCode + " -- trap inside if")
						
					strRetCode = "INVALID EMAIL ADDRESS!!" + "\n\n"
					strRetCode = strRetCode + "Invalid characters encountered in Address"
					return strRetCode
				} 
		}
			
		//Check 4
		locAt = strEmailAdd.indexOf("@");	
		if(!(((locAt != -1) && (locAt != 0) &&	(locAt != (strEmailAdd.length - 1)) && (strEmailAdd.indexOf("@", locAt + 1) == -1))))
		{
				strRetCode = "INVALID EMAIL ADDRESS!!" + "\n\n"
				strRetCode = strRetCode + "@ is at invalid location / missing "
				return strRetCode;
		}	
		
		//Check 5
		locPeriod = strEmailAdd.indexOf(".");
		if(!(((locPeriod != -1) && (locPeriod != (strEmailAdd.length - 1)) && (locPeriod != 0))))
		{
				strRetCode = "INVALID EMAIL ADDRESS!!" + "\n\n"
				strRetCode = strRetCode + "Location of . is invalid"
				return strRetCode;
		}
		
		//debug code
		//if(strRetCode == "")
			//alert("Email Address Valid")
		//else
			//alert("Email Address INValid")

		return strRetCode	;
	
	}
	
	function checkPassword(strPassword)
	{
			var strRetCode			= new String()
			var nMinPwdLength		= 3
			var nCharCode
			
			
			//debug code
			//alert(strPassword + "-- Password Entered")					

			strRetCode = "" //No Errors
			
			//Check 1
			if((strPassword.indexOf(" ") != -1)  || (strPassword == null))
			{
					strRetCode = "PASSWORD INVALID !!" + "\n\n"
					strRetCode = strRetCode + "Password Cannot Contain Blank/Null Characters."
					return strRetCode;
			}
	
			//Check 2
			if(strPassword == "")
			{
					strRetCode = "PASSWORD INVALID !!" + "\n\n"
					strRetCode = strRetCode + "Password Cannot Be Empty"
					return strRetCode;
			}
			
			
			//Check 3
			if(strPassword.length < nMinPwdLength)
			{
					strRetCode = "PASSWORD INVALID !!" + "\n\n"
					strRetCode = strRetCode + "Password Should Not Be Less Than 3 Characters"
					return strRetCode;
			}
			
			
			//Check 4
			for(var cnt=0; cnt < strPassword.length; cnt++)
			{
					nCharCode = strPassword.charCodeAt(cnt)
					
					//debug code
					//alert(strPassword.charAt(cnt)+ " Code =" +nCharCode)
										
					//check to see if between "A" - "Z" or "a" - "z" or "0" - "9"
					if( !(((nCharCode > 64) && (nCharCode < 91)) || ((nCharCode > 96) && (nCharCode < 123))  || ((nCharCode > 47) && (nCharCode < 58))))
					{
						//debug code
						//alert(strPassword.charAt(cnt)+ " Code= " +nCharCode + " -- trap inside if")
						
						strRetCode = "PASSWORD INVALID !!" + "\n\n"
						strRetCode = strRetCode + "Only Alphanumeric characters allowed"
						return strRetCode
					} 
			}
			
			//debug code
			//if(strRetCode == "")
				//alert("Password Valid")
			//else
				//alert("Password INValid")
			
			return strRetCode
	}
	
	
	function CheckText(strName)
	{
	
		var strRetCode = new String();
		strRetCode = "" //No Errors
		
		
		//Check 1
		//Trim Spaces - Currently Just Warn The User. No Automatic Deletion Done In The Function
		strRetCode = JSTrimSpaces(strName);
		if(strRetCode != "")
		{
			return strRetCode;
		}
	
		//Check 2
		if(strName == "")
		{
				strRetCode = "INVALID TEXT ENTERED!!" + "\n\n"
				strRetCode = strRetCode + "TEXT Field Cannot Be Empty"
				return strRetCode;
		}

		//Check 3
		for(var cnt=0; cnt < strName.length; cnt++)
		{
				nCharCode = strName.charCodeAt(cnt)
					
				//debug code
				//alert(strName.charAt(cnt)+ " Code =" +nCharCode)
										
				//check to see if between "A" - "Z" or "a" - "z" or "." or "_" or " " or "'"
				if( !(((nCharCode > 64) && (nCharCode < 91)) || ((nCharCode > 96) && (nCharCode < 123))  || (nCharCode == 46) || (nCharCode == 95) || (nCharCode == 32)  || (nCharCode == 39)))
				{
					//debug code
					//alert(strName.charAt(cnt)+ " Code= " +nCharCode + " -- trap inside if")
						
					strRetCode = "INVALID TEXT ENTERED!!" + "\n\n"
					strRetCode = strRetCode + "Invalid characters encountered in TEXT Field"
					return strRetCode
				} 
		}

		return strRetCode;
	}


	function JSTrimSpaces(strToTrim)
	{
		var strRetCode = new String()
		
		strRetCode = ""
		
		//Trim Leading Spaces
		//alert("strToTrim.length= " + strToTrim.length);
		
		if(strToTrim.indexOf(" ") == 0)
		{
			strRetCode = "Leading Space/s Encountered !!. \n\n Please remove the spaces and then re-post the form";
			return strRetCode;
		}
		
		//Trim Trailing Spaces
		if(strToTrim.charAt(strToTrim.length-1) == " ")
		{
			strRetCode = "Trailing Space/s Encountered !!. \n\n Please remove the spaces and then re-post the form" ;
			return strRetCode;
		}
		
		return strRetCode;
	
	}
	
	function CheckNumber(strNumber, nMaxValue)
	{
		var strRetCode = new String()
		
		strRetCode = "" //No Errors

		//Check 1		
		if (strNumber == "")
		{
			strRetCode = "Invalid Number !! \n\n Reason : Field Cannot Be Blank";
			return strRetCode;
		}
			
		//Check 2		
		if (strNumber.indexOf(" ") != -1)
		{
			strRetCode = "Invalid Number !! \n\n Reason : Field Cannot Contain Spaces";
			return strRetCode;
		}

		//Check 3
		if ((Number(strNumber) < 1) || (Number(strNumber) > nMaxValue))
		{
			strRetCode = "Invalid Number !! \n\n Reason : \n\n (a) This Field Cannot Contain A Zero Value \n\n (b) Or The Number Exeeds The Max Value Allowed For This Field";
			return strRetCode;
		}
		
		//Check 4
		if (isNaN(strNumber))
		{
			strRetCode = "Invalid Number !! \n\n Reason : Invalid Characters";
			return strRetCode;
		}
		
		return strRetCode;
	
	}
	
	