function urlEncode(clearString)
{
	var output='';
	var x=0;
	clearString=clearString.toString();
	var regex=/(^[a-zA-Z0-9_.]*)/;
	while(x<clearString.length){
		var match=regex.exec(clearString.substr(x));
		if(match!=null&&match.length>1&&match[1]!=''){
			output+=match[1];
			x+=match[1].length;
		}else{
			if(clearString[x]==' ')
			output+='+';else{
				var charCode=clearString.charCodeAt(x);
				var hexVal=charCode.toString(16);output+='%'+(hexVal.length<2?'0':'')+hexVal.toUpperCase();
			}
				x++;}
	}
		
	return output;
}


function pausecomp(millis)
{
	var date = new Date();
	var curDate = null;
	do { curDate = new Date(); }
	while(curDate-date < millis);
}


function alphanumericonly(e)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;
// alphas and numbers
else if ((("abcdefghijklmnopqrstuvwxyz0123456789_").indexOf(keychar) > -1))
   return true;
else
   return false;
}


function alphaonly(myfield,e)
{
	var key;
	var keychar;
	 	
	 if (window.event) key = window.event.keyCode;
	 	else if (e) key = e.which;
	 else return true;	 
	 	keychar = String.fromCharCode(key);	 
	 
	 if (iscontrolkey(key)) return true;
	 // numbers or decimal
	 else if ((("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").indexOf(keychar) > -1)) return true;
	 else return false;		
}


function numericonly(myfield,e)
{
	var key;
	var keychar;
	 	
	 if (window.event) key = window.event.keyCode;
	 	else if (e) key = e.which;
	 else return true;	 
	 	keychar = String.fromCharCode(key);	 
	 
	 if (iscontrolkey(key)) return true;
	 // numbers or decimal
	 else if ((("0123456789").indexOf(keychar) > -1)) return true;
	 else return false;		
}

function validateEmail(value)
{	
	var field=value; 		
	
	with (field)
	{
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) 
		  {return false;}
		else{return true;}
	}	
}


function isAlphabetNumeric(strData){
	
	var iCount,iDataLen;
	var strCompare;
	var bFlag = true;
	
	strCompare = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	iDataLen = strData.length;
	
	if (iDataLen >0)
	{
	
	for (iCount=0; iCount<iDataLen;iCount++)
	{
		var cData = strData.charAt(iCount);
		if (strCompare.indexOf(cData) < 0 )
		{			
			return false;
		} 
	}
	return true;
	}
	else{
	return false;
	}
}

function changeFocus(currentId, nextId, maxCount){
	var currentElement = document.getElementById(currentId);
	var nextElement = document.getElementById(nextId);
	
	allowOnlyNumeric(currentId);

	if(currentElement.value.length == maxCount){
		nextElement.focus();
	}
}

function allowOnlyNumeric(id){
	var element = document.getElementById(id);

	if(!isNumeric(element)){
		element.value = element.value.substring(0, element.value.length - 1) 
	}
}







