	
	$ = function()
	{
		var aElements=new Array();
		for(var i=0;i<arguments.length;i++)
		{
			var vElement=arguments[i];
			if(typeof vElement=='string')
				vElement=document.getElementById(vElement);
			if(typeof vElement=='object')
			{
				if(arguments.length==1)
				return vElement;
				aElements.push(vElement);
			}
		}
		return aElements;
	}
	
	function ce( t ) { return document.createElement( t ); }
	
	function Trim(pmStr)
	{
		pmStr = pmStr.replace( /^ +/, "" ).replace( / +$/, "" );
		return pmStr;
	}
		
	function IsProperName(pmString)
	{
	   if (!pmString) return false;
	   var vChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 '.";
	
	   for (var i = 0; i < pmString.length; i++)
	   {
		  if (vChars.indexOf(pmString.charAt(i)) == -1)
			 return false;
	   }
	   return true;
	}
	function IsString(pmString)
	{
	   if (!pmString) return false;
	   var vChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz '.";
	
	   for (var i = 0; i < pmString.length; i++)
	   {
		  if (vChars.indexOf(pmString.charAt(i)) == -1)
			 return false;
	   }
	   return true;
	}
	function IsValidIP(IPvalue)
	{
		vErrorMsg = "";
		
		var vIPPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
		var aIP = IPvalue.match(vIPPattern);
		
		if (IPvalue == "0.0.0.0" || IPvalue == "255.255.255.255")
			vErrorMsg = 'This is a special IP address and cannot be used here.';		
		else if (aIP == null)
			vErrorMsg = 'This is not a valid IP address.';
		else 
		{
			for (vTemp = 0; vTemp < 5; vTemp++) 
			{
				vThisSegment = aIP[vTemp];
				if (vThisSegment > 255) 
				{
					vErrorMsg = 'This is not a valid IP address.';
					vTemp = 4;
				}
			 }
		}
		if (vErrorMsg == "")
			return true;
		else
			return false;
	}
	
	function Trim1(pmString)
	{
		while(pmString.charAt(0)== " ")
		{
			pmString = pmString.replace(pmString.charAt(0),"");
		}
		
		while(pmString.charAt((pmString.length -1))==" ")
		{
			pmString = pmString.substring(0,pmString.length-1);
		}		
		return pmString;
	}
	
	function ToggleCombos(pmState)
		{
			if(document.all && navigator.userAgent.search(/MSIE/i) != -1)
			{
				var aCombo = document.getElementsByTagName('div');
				if(aCombo.length)
				{			
					for(vTemp = 0; vTemp < aCombo.length; vTemp++)
					{
						if(aCombo[vTemp].id.match(/divCombo/))
						aCombo[vTemp].style.visibility = (pmState == 1) ? 'hidden' : 'visible';
					}
				}
			}
		}
	
	function ToggleCombosFrames(pmState, pmFrameName)
		{
			if(document.all && navigator.userAgent.search(/MSIE/i) != -1)
			{
				var aCombo = window.frames[pmFrameName].document.getElementsByTagName('div');
				if(aCombo.length)
				{			
					for(vTemp = 0; vTemp < aCombo.length; vTemp++)
					{
						if(aCombo[vTemp].id.match(/divCombo/))
						aCombo[vTemp].style.visibility = (pmState == 1) ? 'hidden' : 'visible';
					}
				}
			}
		}	

	function isPhoneNum(pmPhNo,pmintMaxLen)
	{   
		var i;
		var returnString = "";
		var phoneNumberDelimiters = "+0123456789-()";
		var num = 0;
		var pmintMinLen = 0;
		// Search through string's characters one by one.
		// If character is not in bag, append to returnString.
		for (i = 0; i < pmPhNo.length; i++)
		{   
			// Check that current character isn't whitespace.
			var c = pmPhNo.charAt(i);
			//if(c == "-")
			//pmintMinLen++;
			if(!isNaN(c))
			num++;
			if (phoneNumberDelimiters.indexOf(c) == -1) 
			return false;
		}
		vValidPhone = pmPhNo.substr(1, pmPhNo.length);
		if(vValidPhone.indexOf('+') > 0)
			return false;
		
		return true;
			
	}
	function isPhoneNo(pmPhNo,pmintMinLen,pmintMaxLen)
	{   var i;
		var returnString = "";
		var phoneNumberDelimiters = "0123456789()-,  ext.";
		// Search through string's characters one by one.
		// If character is not in bag, append to returnString.
		for (i = 0; i < pmPhNo.length; i++)
		{   
			// Check that current character isn't whitespace.
			var c = pmPhNo.charAt(i);
			if(c == "-")
				pmintMinLen++;
			if (phoneNumberDelimiters.indexOf(c) == -1) 
				return false;
		}
		if(pmPhNo.length>pmintMaxLen || pmPhNo.length<pmintMinLen)
			return false;
		else	
			return true;
	}
	function isZipcode(pmStr)
	{ 
		string=Trim1(pmStr);
		if (!string) return false;
			var ichars = "!!*|,\":<>[]{}`\';()@&$#%";
		
		for (var i = 0; i < string.length; i++) 
		{
			if (ichars.indexOf(string.charAt(i)) != -1)
			return false;
		}
		return true;
	}
	
	function isEmail(pmStr)
	{
		/******************************
		// @pmStr = String contain email
		******************************/
		pmStr  = Trim1(pmStr);	//#-- trim the string
		pmStr  = pmStr.replace(/\r\n|\r|\n/g, ''); 
		pmStr  = pmStr.replace(/\r\n/g,'');
		pmStr  = pmStr.replace(/\r/g,'');
		pmStr  = pmStr.replace(/\n/g,''); 
		
		if (pmStr == "") return false;
		if (pmStr.length > 50) return false;
		if (!isRegExpSupported()) return (pmStr.indexOf(".") > 2) && (pmStr.indexOf("@") > 0);	//#-- is regular expressions supported
		//if the email does not have @ and . then return false
		if(pmStr.indexOf('@') == -1 || pmStr.indexOf('.') == -1 || pmStr.indexOf(' ') != -1)
			return false;
		var vPattern = "^[A-Za-z0-9](([_\\.\\-]?[a-zA-Z0-9_]+)*)@([A-Za-z0-9]+)(([\\_.\\-]?[a-zA-Z0-9]+)*)\\.([A-Za-z]{2,})$";
		var vRegExp = new RegExp(vPattern);
		return (vRegExp.test(pmStr));
	}
	
	function isRegExpSupported()
	{
		//#-- are regular expressions supported?
			if (window.RegExp)
			{
				//#-- assign expression
					var vTempStr = "a";
					var vTempReg = new RegExp(vTempStr);
				
				//#-- return status
					return (vTempReg.test(vTempStr));
			}
		
		//#-- return status
			return (false);
	} //#-- close of isRegExpSupported()
	
	function isMoney(pmStr)
	{
		/******************************
		// @pmStr = String contain email
		******************************/
		pmStr  = Trim1(pmStr);	//#-- trim the string
		
		if (pmStr == "") return false;
		if (pmStr.length > 50) return false;
		var vPattern = '^\d+(?:\.\d{0,2})?$';
		var vRegExp = new RegExp(vPattern);
	
			//#-- return true if it is valid Phone number or false for invalid Phone number
		return (vRegExp.test(pmStr));
	}
	
	function gNulAlNumSplKeys(pKeyType)
	{
		/*Function that allows only Alpahabets,Numbers 
		This is to be called 
		in the "KeyPress" event of a Text control."this" 
		reference is to be passed.	*/
		
		/* pKeyType  - 1 (Only Alphabets) and some special character  "white space - / ,'"
		   pKeyType  - 2 (Only Numeric)
		   pKeyType  - 3 (For Alphanumeric)
		   pKeyType  - 4 (For Email)
		   pKeyType -  5 (For Phone) */
		
		//alert(window.event.keyCode);
		// Variable to store the value of "KeyCode".
		pNumKeyCode = window.event.keyCode;
		// Check if the "KeyCode" is from "A" to "Z".
		if((pNumKeyCode > 64 && pNumKeyCode < 91) && (pKeyType == 1 || pKeyType == 3 || pKeyType == 4))
		{
			window.status ="Done";
			window.event.keyCode = pNumKeyCode; 
		}
		// Check if the "KeyCode" is from "a" to "z".
		else if((pNumKeyCode > 96 && pNumKeyCode < 123) && (pKeyType == 1 || pKeyType == 3 || pKeyType == 4))
		{
			window.status = "Done";
			window.event.keyCode = pNumKeyCode; 
		}
		// Check if the "KeyCode" is from "0" to "9".
		else if((pNumKeyCode > 47 && pNumKeyCode < 58) && (pKeyType == 2 || pKeyType == 3 || pKeyType == 4 || pKeyType == 5 || pKeyType == 10))
		{
			window.status ="Done";
			window.event.keyCode = pNumKeyCode; 
		}
		// Check if the "KeyCode" is  "()-"
		else if(((pNumKeyCode == 40) || (pNumKeyCode == 41) || (pNumKeyCode == 45)) && (pKeyType == 5))
		{
			window.status ="Done";
			window.event.keyCode = pNumKeyCode; 
		}
		// Check if the "Keycode" is "white space - / '"
		else if((pNumKeyCode == 32 || pNumKeyCode == 47 || pNumKeyCode == 45 || pNumKeyCode == 39 || pNumKeyCode == 44) && (pKeyType == 1 || pKeyType == 3))
		{
			window.status ="Done";
			window.event.keyCode = pNumKeyCode; 
		}
		// Check if the "KeyCode" is "@._"
		else if(((pNumKeyCode == 64) || (pNumKeyCode == 46) || (pNumKeyCode == 95)) && (pKeyType == 4))
		{
			window.status ="Done";
			window.event.keyCode = pNumKeyCode; 
		}
		// Check if the "KeyCode" is "."
		else if((pNumKeyCode == 46) && (pKeyType == 10) && (!IsAlreayaDot()) )
		{
			window.status ="Done";
			window.event.keyCode = pNumKeyCode; 
		}
		// Check if the "KeyCode" is anyother character, mentioned above.
		else 
		{
			window.status = "Invalid Character."
			window.event.keyCode = 0; 
		}
		
		function IsAlreayaDot()
		{
			var vValue;
			vValue = window.event.srcElement.value;
			for (vTemp = 0; vTemp < vValue.length; vTemp++)
			{   
				var vChar = vValue.charAt(vTemp);
				if(vChar == '.') return true;
			}
			return false;
		}
	}
	function CloseDebug()
	{
		var _log = $('log');
		_log.parentNode.removeChild( _log );
		_log = null;
	}	
	function Debug()
	{
		var i;
		var list = [];
	
		if( $('log') == null )
		{
			log = ce( 'div' );
			log.id = 'log';
			log.className = 'debug';
			log.innerHTML = '<nobr><b>Debug Window</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:CloseDebug()">close</a></nobr>';
			document.body.appendChild( log );
		}
	
		for( i = 0 ; i < arguments.length ; i++ )
		{
			list[i] = arguments[i];
		}
		$('log').innerHTML += '<br>' + list.join( ', ' );
		$('log').style.zIndex = 1000000;
		$('log').style.top = document.body.scrollTop + 10;
	}
	
	
	
	function GetHTTPObject()
	{
		var xmlhttp;
		try
		{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlhttp = new XMLHttpRequest();
				}
				catch (e)
				{
					xmlhttp = false; 				
				}
			}
		}
	
		return xmlhttp;
	
	} 
	
	function IsValidDate(dateStr, format) 
	{
		//   if (format == null) { format = "MDY"; }
	   format = format.toUpperCase();
	   if (format.length != 3) 
	   { 
	   		format = 'MDY'; 
	   }
	   if ( (format.indexOf("M") == -1) || (format.indexOf("D") == -1) || (format.indexOf("Y") == -1) ) 
	   { 
	   		format = "MDY"; 
	   }
	   if (format.substring(0, 1) == "Y") 
	   { // If the year is first
		  var reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
		  var reg2 = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
	   }
	   else if (format.substring(1, 2) == "Y") 
	   { // If the year is second
		  var reg1 = /^\d{1,2}(\-|\/|\.)\d{2}\1\d{1,2}$/
		  var reg2 = /^\d{1,2}(\-|\/|\.)\d{4}\1\d{1,2}$/
	   } 
	   else 
	   { // The year must be third
		  var reg1 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$/
		  var reg2 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
	   }
	   // If it doesn't conform to the right format (with either a 2 digit year or 4 digit year), fail
	   if ( /*(reg1.test(dateStr) == false) && */ (reg2.test(dateStr) == false) ) 
	   { 
	   	  return false; 
	   }
	   var parts = dateStr.split(RegExp.$1); // Split into 3 parts based on what the divider was
	   // Check to see if the 3 parts EndDate up making a valid date
	   if (format.substring(0, 1) == "M") 
	   { 
	   	  var mm = parts[0]; 
	   } 
	   else 
	   {
		  if (format.substring(1, 2) == "M") 
		  { 
		  	var mm = parts[1]; 
		  } 
		  else 
		  { 
		  	var mm = parts[2]; 
		  }
	   }
	   if (format.substring(0, 1) == "D") 
	   { 
	   	  var dd = parts[0]; 
	   } 
	   else 
	   {
		  if (format.substring(1, 2) == "D") 
		  { 
		  	var dd = parts[1]; 
		  } 
		  else 
		  { 
		  	var dd = parts[2]; 
		  }
	   }
	   if (format.substring(0, 1) == "Y") 
	   { 
	   	  var yy = parts[0]; 
	   } 
	   else 
	   {
		  if (format.substring(1, 2) == "Y") 
		  { 
		  	var yy = parts[1]; 
		  } 
		  else 
		  { 
		  	var yy = parts[2]; 
		  }
	   }
	   if (parseFloat(yy) < 1900) 
	   { 
	   		return false;
	   }
	   var dt = new Date(parseFloat(yy), parseFloat(mm)-1, parseFloat(dd), 0, 0, 0, 0);
	   if (parseFloat(dd) != dt.getDate()) 
	   { 
	   		return false; 
	   }
	   if (parseFloat(mm)-1 != dt.getMonth()) 
	   { 
	   		return false; 
	   }
	   return true;
	}
	// website entry validation
	function isvalidurl(pmurl)
	{
		 var theurl=pmurl
		 var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
		 if (tomatch.test(theurl))
		 {
			 return true;
		 }
		 else
		 {
			 return false; 
		 }
	}
