	/*
		PURPOSE			:	JavaScript Functions
		VERSION			:	1.0.0	
		DATE			:	2004-08-02
		MAINTAINER		:	
		DESCRIPTION		:	
		Todo			:
	*/

	//function to used to link <TD>
	function LinkTD(strDest)
		{
			window.location	=	strDest;
		}
	
	//function to submit form through a button
	//SubmitForm(document.forms(0),'filename') -- to call this function
	function SubmitForm(myform,strTargetFile)
		{
			myform.action = strTargetFile;
			myform.submit();
		}
	
	//function for popup window
	function OpenWin(strTargetFile,intWidth,intHeight)
		{	
			var top;
			var left;
				
			top		=	(screen.height - intHeight) / 2;
			left	=	(screen.width - intWidth) / 2;
			
			window.open(strTargetFile,"DetailWindow","scrollbars=yes,toolbars=no,status=no,width=" + intWidth + ",height=" + intHeight + ",top=" + top + ",left=" + left);	
		}
		
	//function to flip the <div>
	//dosen't work with Netscape version <= 6.0 
	//not yet tested with Netscape version 7.0
	var divOpen = 0;		
	function ShowHide(selectDiv)
		{
			var control = document.all(selectDiv);
			if(control.style.display == '')
				{
					control.style.display = 'none';
					divOpen -= 1;
				}
			else
				{
					control.style.display = '';
					divOpen += 1;
				}
		}
	
	//function to change tab
	//dosen't work with Netscape version <= 6.0
	//not yet tested with Netscape version 7.0
	var currentTab = null;
	function ShowTab(strTab)
		{
			if (currentTab != null)
				currentTab.style.display = 'none';
		
			strTab.style.display = '';
			currentTab = strTab;
		}
	
	// Example:
	// writeCookie("myCookie", "my name", 24);
	// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
	function writeCookie(name, value, hours)
		{
		  var expire = "";
		  if(hours != null)
			  {
				expire = new Date((new Date()).getTime() + hours * 3600000);
				expire = "; expires=" + expire.toGMTString();
			  }
		  document.cookie = name + "=" + escape(value) + expire;
		}
	
	
	// Example:
	// alert( readCookie("myCookie") );
	function readCookie(name)
		{
		  var cookieValue = "";
		  var search = name + "=";
		  if(document.cookie.length > 0)
			  { 
				offset = document.cookie.indexOf(search);
				if (offset != -1)
					{ 
					  offset += search.length;
					  end = document.cookie.indexOf(";", offset);
					  if (end == -1) end = document.cookie.length;
					  cookieValue = unescape(document.cookie.substring(offset, end))
					}
			  }
		  return cookieValue;
		}
	
	function validateEmail(email)
		{
		// a very simple email validation checking. 
		// you can add more complex email checking if it helps 
			var splitted = email.match("^(.+)@(.+)$");
			if(splitted == null) return false;
			if(splitted[1] != null )
			{
			  var regexp_user=/^\"?[\w-_\.]*\"?$/;
			  if(splitted[1].match(regexp_user) == null) return false;
			}
			if(splitted[2] != null)
			{
			  var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
			  if(splitted[2].match(regexp_domain) == null) 
			  {
				var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
				if(splitted[2].match(regexp_ip) == null) return false;
			  }// if
			  return true;
			}
		return false;
		}
		
	function CheckDomain(domain)
		{
			if(domain != null)
			{
			  var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
			  if(domain.match(regexp_domain) == null) 
			  {
				var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
				if(domain.match(regexp_ip) == null) return false;
			  }// if
			  return true;
			}
		}//end of function
	
	//function to check if number or not
	function IsNumber(field)
		{
			var charpos = field.value.search("[^0-9]"); 
			if(field.value.length > 0 &&  charpos >= 0) 
				{ 
				return "FALSE";
				}//if 
			else
				return "TRUE";
		}
	
	//functino to alert n' focus
	function AlertFocus(MSG,OBJECT)
		{
			alert(MSG);
			OBJECT.focus();
		}//end of function
	
	//function to check if alpnanumeric or not .... hyphen is allowed
	function IsAlnumHyphen(field)
		{
			var charpos = field.value.search("[^A-Za-z0-9\-_]"); 
			if(field.value.length > 0 &&  charpos >= 0) 
				{ 
					return "FALSE";
				}
			else
				return "TRUE";
		}