	/*
	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 CheckEmail1()
{
	var ctr1,max;
	var m1=new Array();
	ctr1=0;
	m=document.frmform.frmmail.value;
	//m=trim(m)
	//m1=m.split(',');
	//max=m1.length;
	//for(k=0;k<=max;k++)
	//{
		i1=m.indexOf('@');
		i4=m.lastIndexOf('@');
		i2=m.lastIndexOf('.');
		i3=m.length; 
		i5=m.indexOf(',');
		i6=m.lastIndexOf(',');
		//alert(i6)
		if(i5!=-1 || i5==-1)
		{
			return true;
		}
		if(i3==0 || i3>50 || i1<=2|| i2==-1 || i2-i1<=2 || i3-i2<2 || i1!=i4)
		{
			alert("Please Insert correct e-mail address")
			return false;                                                                                                                                                                                                                            
		}
		
	//}
		ret=ValidateEMail(m);
		if(ret==false) return false;
		else 
		{ctr1=1;return true;}
	
	function ValidateEMail(objName)
	{
		var sc=new Array(26)
		sc[0]="/"
		sc[1]="\\"
		sc[2]="*"
		sc[3]=" "
		sc[4]="|"
		sc[5]=","
		sc[6]=";"
		sc[7]="'"
		sc[8]="\""
		sc[9]="{"
		sc[10]="}"
		sc[11]="["
		sc[12]="]"
		sc[13]="("
		sc[14]=")"
		sc[15]="+"
		sc[16]="="
		sc[17]="<"
		sc[18]=">"
		sc[19]=":"
		sc[20]="%"
		sc[21]="?"
		sc[22]="&"
		sc[23]="#"
		sc[24]="$"
		sc[25]="!"
		sc[26]="`"
		intObj=objName.length
		for(i=0;i <= intObj;i++)
		{
			for(j=0; j<=27; j++)
			{
				if(objName.charAt(i)==sc[j])
				{
					alert("Please Insert correct e-mail address")
					return false;
				}	
			}
		}
	}
}

	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 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;
	
	}
	
	