 var dcDelay = 800;  //delay beyond clicks
 
 var isFirstClickForTwo = true;
 var isSecondClickForTwo = false;
 var firstClickTimeForTwo = 0;

 var isFirstClickForThree = true;
 var isSecondClickForThree = false;
 var isThirdClickForThree = false;
 var firstClickTimeForThree = 0;
 var secondClickTimeForThree = 0;
 
 
 var isFirstClickForFour = true;
 var isSecondClickForFour = false;
 var isThirdClickForFour = false;
 var isForthClickForFour = false;
 var firstClickTimeForFour = 0;
 var secondClickTimeForFour = 0;
 var thirdClickTimeForFour = 0;
 
 
 var isFirstClickForFive = true;
 var isSecondClickForFive = false;
 var isThirdClickForFive = false;
 var isForthClickForFive = false;
 var isFifthClickForFive = false;
 var firstClickTimeForFive = 0;
 var secondClickTimeForFive = 0;
 var thirdClickTimeForFive = 0;
 var forthClickTimeForFive = 0;
 
 var CapsLock = false; 
 var ShiftEnabled = false; 

 
 //If it is a Character trgt_fld is the TextBox
 //else trgt_fld --> panel to show  src_field --> panel to hide
 
 function OneClick(src_field, trgt_fld, firstAction, itemToFocus) 
 {
	//if(firstAction != 'doBold')
	//{
	if(firstAction == 'home')
	{
		moveHome(trgt_fld);
	}
	else if(firstAction == 'end')
	{
		moveEnd(trgt_fld);
	}
	else
	{
		insertAtCursor(trgt_fld, firstAction);
		document.getElementById(src_field).focus();	
	}
	
	document.getElementById(itemToFocus).focus();
	
	//}
	//else
	//{
	//	doBold(trgt_fld);
	//	src_field.focus();
	//}
	
	
 }
 
 //src_ch_field --> button to make invisible
 //src_ch_trgt_field --> button to make visible
 function OneChangeClick(src_field, trgt_fld, firstAction, src_ch_field, trgt_ch_field, itemToFocus) 
 {
	if(firstAction == 'left')
	{
		leftAtCursor(trgt_fld);
	}
	else if(firstAction == 'right')
	{
		rightAtCursor(trgt_fld);
	}
	else if(firstAction == 'up')
	{
		upAtCursor(trgt_fld);
	}
	else if(firstAction == 'down')
	{
		downAtCursor(trgt_fld);
	}
	else if(firstAction == 'delete')
	{
		deleteAtCursor(trgt_fld);
	}
	else if(firstAction == 'Caps')
	{
		if(CapsLock == false)
		{
			CapsLock = true;
		}
		else
		{
			CapsLock = false;
		}
	}
	else
	{
		insertAtCursor(trgt_fld, firstAction);	
		document.getElementById(src_field).focus();
	}
	
	document.getElementById(src_ch_field).style.display = "none";
	document.getElementById(src_ch_field).style.position = "relative";
	
	if(window.event)	//IE
	{        
		document.getElementById(trgt_ch_field).style.display = "inline-block";
	}     
	else	//firefox
	{
		document.getElementById(trgt_ch_field).style.display = "block"; 
	}
	
	document.getElementById(itemToFocus).focus();
	
 }
 
 function MenuClick(src_field, trgt_fld, itemToFocus) 
 {
	document.getElementById(src_field).style.display = "none";
	document.getElementById(src_field).style.position = "relative";
	
	if(window.event)	//IE
	{        
		document.getElementById(trgt_fld).style.display = "inline-block";
	}     
	else	//firefox
	{
		document.getElementById(trgt_fld).style.display = "block"; 
	}
	
	document.getElementById(itemToFocus).focus();
 }
  
 function TwoMenuClick(trgt_fld, src_field, firstAction, fld_toShow, fld_toHide, itemToFocus) 
 {
   var d = new Date();  
   
   if(isFirstClickForTwo)
   {
   		var now = d.getTime();
		firstClickTimeForTwo = now;

		isFirstClickForTwo = false;
		isSecondClickForTwo = true;
		
		insertAtCursor(trgt_fld, firstAction);	
   }
   else if(isSecondClickForTwo)//Writes the character and then changes menu
   {
		var now = d.getTime();
		
		if(now - firstClickTimeForTwo < dcDelay)	//second click
		{	
			fld_toHide.style.display = "none";
			fld_toHide.style.position = "relative";
			
			fld_toShow.style.display = "block";
	
			backAtCursor(trgt_fld); //deletes the character
			
			firstClickTimeForTwo = 0; 
			
			isFirstClickForTwo = true;
			isSecondClickForTwo = false;			
		}
		else
		{	
			insertAtCursor(trgt_fld, firstAction);			    
			firstClickTimeForTwo = now;
	   
			isFirstClickForTwo = false;
			isSecondClickForTwo = true;
		}
	}	
	//document.getElementById(src_field).focus();
 }
  
  function TwoClick(trgt_fld, src_field, firstAction, secondAction, itemToFocus) 
 {
   var d = new Date();  

   if(isFirstClickForTwo)
   {
   		var now = d.getTime();
		firstClickTimeForTwo = now;

		isFirstClickForTwo = false;
		isSecondClickForTwo = true;
		
		insertAtCursor(trgt_fld, firstAction);	
   }
   else if(isSecondClickForTwo)
   {
		var now = d.getTime();
		
		if(now - firstClickTimeForTwo < dcDelay)	//second click
		{	
			backAtCursor(trgt_fld);
			insertAtCursor(trgt_fld, secondAction);
	
			firstClickTimeForTwo = 0; 
			
			isFirstClickForTwo = true;
			isSecondClickForTwo = false;
		}
		else
		{	
			insertAtCursor(trgt_fld, firstAction);			    
			firstClickTimeForTwo = now;
	   
			isFirstClickForTwo = false;
			isSecondClickForTwo = true
		}
	}
	document.getElementById(src_field).focus();
	
 }

  
 function ThreeClick(trgt_fld, src_field, firstAction, secondAction, thirdAction, itemToFocus) 
 {
   var d = new Date();  
   
   if(isFirstClickForThree)
   {
   		var now = d.getTime();
		firstClickTimeForThree = now;

		isFirstClickForThree = false;
		isSecondClickForThree = true;
		isThirdClickForThree = false;
		insertAtCursor(trgt_fld, firstAction);	
   }
   else if(isSecondClickForThree)
   {
		var now = d.getTime();
		
		if(now - firstClickTimeForThree < dcDelay)	//second click
		{	
			backAtCursor(trgt_fld);
			insertAtCursor(trgt_fld, secondAction);
	
			secondClickTimeForThree = now; 
			
			isFirstClickForThree = false;
			isSecondClickForThree = false;
			isThirdClickForThree = true;
		}
		else
		{	
			insertAtCursor(trgt_fld, firstAction);			    
		    firstClickTimeForThree = now;
	   
			isFirstClickForThree = false;
			isSecondClickForThree = true;
			isThirdClickForThree = false;
		}
	}
	else if(isThirdClickForThree)
	{
		var now = d.getTime();
		if(now - secondClickTimeForThree < dcDelay)	//trird click
		{	
			backAtCursor(trgt_fld);
			insertAtCursor(trgt_fld, thirdAction);		
			firstClickTimeForThree = 0;
	
			isFirstClickForThree = true;
			isSecondClickForThree = false;
			isThirdClickForThree = false;
		}
		else
		{
			insertAtCursor(trgt_fld, firstAction);			
			secondClickTimeForThree = 0;
			firstClickTimeForThree = now;
	   
			isFirstClickForThree = false;
			isSecondClickForThree = true;
			isThirdClickForThree = false;
		}
	}
	document.getElementById(src_field).focus();
	
 }

   
 function FourClick(trgt_fld, src_field, firstAction, secondAction, thirdAction, forthAction, itemToFocus) 
 {
   var d = new Date();  
   
   if(isFirstClickForFour)
   {
   		var now = d.getTime();
		firstClickTimeForFour = now;

		isFirstClickForFour = false;
		isSecondClickForFour = true;
		isThirdClickForFour = false;
		isForthClickForFour = false;

		insertAtCursor(trgt_fld, firstAction);	
   }
   else if(isSecondClickForFour)
   {
		var now = d.getTime();
		
		if(now - firstClickTimeForFour < dcDelay)	//second click
		{	
			backAtCursor(trgt_fld);
			insertAtCursor(trgt_fld, secondAction);
			secondClickTimeForFour = now; 
			
			isFirstClickForFour = false;
			isSecondClickForFour = false;
			isThirdClickForFour = true;
			isForthClickForFour = false;
		}
		else
		{	
			insertAtCursor(trgt_fld, firstAction);			    
		    firstClickTimeForFour = now;
	   
			isFirstClickForFour = false;
			isSecondClickForFour = true;
			isThirdClickForFour = false;
			isForthClickForFour = false;
		}
	}
	else if(isThirdClickForFour)
	{
		var now = d.getTime();
		if(now - secondClickTimeForFour < dcDelay)	//trird click
		{	
			backAtCursor(trgt_fld);
			insertAtCursor(trgt_fld, thirdAction);		
			thirdClickTimeForFour = now; 
	
			isFirstClickForFour = false;
			isSecondClickForFour = false;
			isThirdClickForFour = false;
			isForthClickForFour = true;
		}
		else
		{
			insertAtCursor(trgt_fld, firstAction);			
			secondClickTimeForFour = 0;
			firstClickTimeForFour = now;
	   
			isFirstClickForFour = false;
			isSecondClickForFour = true;
			isThirdClickForFour = false;
			isForthClickForFour = false;
		}
	}
	else if(isForthClickForFour)
	{
		var now = d.getTime();
		if(now - thirdClickTimeForFour < dcDelay)	//forth click
		{	
			backAtCursor(trgt_fld);
			insertAtCursor(trgt_fld, forthAction);		
	
			isFirstClickForFour = true;
			isSecondClickForFour = false;
			isThirdClickForFour = false;
			isForthClickForFour = false;
		}
		else
		{
			insertAtCursor(trgt_fld, firstAction);			
			secondClickTimeForFour = 0;
			firstClickTimeForFour = now;
	   
			isFirstClickForFour = false;
			isSecondClickForFour = true;
			isThirdClickForFour = false;
			isForthClickForFour = false;
		}
	
	}
	document.getElementById(src_field).focus();
	
 }

 function FiveClick(trgt_fld, src_field, firstAction, secondAction, thirdAction, forthAction, fifthAction, itemToFocus) 
 {
   var d = new Date();  
   
   if(isFirstClickForFive)
   {
   		var now = d.getTime();
		firstClickTimeForFive = now;

		isFirstClickForFive = false;
		isSecondClickForFive = true;
		isThirdClickForFive = false;
		isForthClickForFive = false;
		isFifthClickForFive = false;

		insertAtCursor(trgt_fld, firstAction);	
   }
   else if(isSecondClickForFive)
   {
		var now = d.getTime();
		
		if(now - firstClickTimeForFive < dcDelay)	//second click
		{	
			backAtCursor(trgt_fld);
			insertAtCursor(trgt_fld, secondAction);
			secondClickTimeForFive = now; 
			
			isFirstClickForFive = false;
			isSecondClickForFive = false;
			isThirdClickForFive = true;
			isForthClickForFive = false;
			isFifthClickForFive = false;
		}
		else
		{	
			insertAtCursor(trgt_fld, firstAction);			    
		    firstClickTimeForFive = now;
	   
			isFirstClickForFive = false;
			isSecondClickForFive = true;
			isThirdClickForFive = false;
			isForthClickForFive = false;
			isFifthClickForFive = false;
		}		
	}
	else if(isThirdClickForFive)
	{
		var now = d.getTime();
		if(now - secondClickTimeForFive < dcDelay)	//trird click
		{	
			backAtCursor(trgt_fld);
			insertAtCursor(trgt_fld, thirdAction);		
			thirdClickTimeForFive = now; 
	
			isFirstClickForFive = false;
			isSecondClickForFive = false;
			isThirdClickForFive = false;
			isForthClickForFive = true;
			isFifthClickForFive = false;
		}
		else
		{
			insertAtCursor(trgt_fld, firstAction);			
			secondClickTimeForFive = 0;
			firstClickTimeForFive = now;
	   
			isFirstClickForFiver = false;
			isSecondClickForFive = true;
			isThirdClickForFive = false;
			isForthClickForFive = false;
			isFifthClickForFive = false;
		}
	}
	else if(isForthClickForFive)
	{
		var now = d.getTime();
		if(now - thirdClickTimeForFive < dcDelay)	//forth click
		{	
			backAtCursor(trgt_fld);
			insertAtCursor(trgt_fld, forthAction);		
			forthClickTimeForFive = now; 
	
			isFirstClickForFive = false;
			isSecondClickForFive = false;
			isThirdClickForFive = false;
			isForthClickForFive = false;
			isFifthClickForFive = true;
		}
		else
		{
			insertAtCursor(trgt_fld, firstAction);			
			secondClickTimeForFive = 0;
			firstClickTimeForFive = now;
	   
			isFirstClickForFiver = false;
			isSecondClickForFive = true;
			isThirdClickForFive = false;
			isForthClickForFive = false;
			isFifthClickForFive = false;
		}
	}
	else if(isFifthClickForFive)
	{
		var now = d.getTime();
		if(now - forthClickTimeForFive < dcDelay)	//fifth click
		{	
			backAtCursor(trgt_fld);
			insertAtCursor(trgt_fld, fifthAction);		
	
			isFirstClickForFive = true;
			isSecondClickForFive = false;
			isThirdClickForFive = false;
			isForthClickForFive = false;
			isFifthClickForFive = false;
		}
		else
		{
			insertAtCursor(trgt_fld, firstAction);			
			secondClickTimeForFive = 0;
			firstClickTimeForFive = now;
	   
			isFirstClickForFive = false;
			isSecondClickForFive = true;
			isThirdClickForFive = false;
			isForthClickForFive = false;
			isFifthClickForFive = false;
		}
	}

	document.getElementById(src_field).focus();
 }

function insertAtCursor(myField, myValue) 
{
	if(myValue == '&#x0027;')
	{
		myValue = "'";
	}
	else if(myValue == '&#x005C;')
	{
		myValue = "\\";
	}
	
	if(myValue == 'backspace')
	{
		backAtCursor(myField);
	}
	else if(myValue == 'shift')
	{
		ShiftEnabled = true;
	}
	else if (document.selection) //IE support
	{
		if(CapsLock || ShiftEnabled)
		{
			myValue = myValue.toUpperCase();
		}
		
		var temp;
		document.getElementById(myField).focus();
		
		sel = document.selection.createRange();
		temp=sel.text.lenght;
		sel.text=myValue;
		if (myValue.length==0)
		{
			sel.moveStart('character',myValue.length);
			sel.moveEnd('character',myValue.length);
		}
		else 
		{
			sel.moveStart('character',-myValue.length+temp);
		}
		
		sel.select();
		ShiftEnabled = false;
	}
	else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart=='0') //NETSCAPE Support
	{
		if(CapsLock || ShiftEnabled)
		{
			myValue = myValue.toUpperCase();
		}
		var startPos = document.getElementById(myField).selectionStart;
		var endPos = document.getElementById(myField).selectionEnd;
		document.getElementById(myField).value = document.getElementById(myField).value.substring(0,startPos) + myValue + document.getElementById(myField).value.substring(endPos, document.getElementById(myField).value.length);
		document.getElementById(myField).selectionStart = startPos + myValue.length;
		document.getElementById(myField).selectionEnd = startPos + myValue.length;
		document.getElementById(myField).focus();
		
		ShiftEnabled = false;
	}
	else
	{
		if(CapsLock || ShiftEnabled)
		{
			myValue = myValue.toUpperCase();
		}
		document.getElementById(myField).value += myValue;
		
		ShiftEnabled = false;
	}
	
}

function backAtCursor(myField)
{
	if (document.selection)//IE Support
	{
		document.getElementById(myField).focus();
		sel = document.selection.createRange();
		
		if(sel.text.length>0)
		{ 
			sel.text='';
		}
		else
		{
			sel.moveStart('character',-1); 
			sel.text='';
		}
		sel.select();
	}
	else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0')//Netscape Support
	{
		var startPos = document.getElementById(myField).selectionStart;
		var endPos = document.getElementById(myField).selectionEnd;
		document.getElementById(myField).value = document.getElementById(myField).value.substring(0,startPos-1)+ document.getElementById(myField).value.substring(endPos, document.getElementById(myField).value.length);
		document.getElementById(myField).selectionStart=startPos-1;
		document.getElementById(myField).selectionEnd=startPos-1;
		document.getElementById(myField).focus();
	}
	else
	{
		document.getElementById(myField).value = document.getElementById(myField).value.substr(0,(document.getElementById(myField).value.length-1));
		document.getElementById(myField).focus();
	}
}

function deleteAtCursor(myField)
{
	if (document.selection)//IE Support
	{
		document.getElementById(myField).focus();
		sel = document.selection.createRange();
		
		if(sel.text.length>0)
		{ 
			sel.text='';
		}
		else
		{
			sel.moveEnd('character',+1); 
			sel.text='';
		}
		sel.select();
	}
	else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0')//Netscape Support
	{
		var startPos = document.getElementById(myField).selectionStart;
		var endPos = document.getElementById(myField).selectionEnd + 1;
		document.getElementById(myField).value = document.getElementById(myField).value.substring(0, startPos )+ document.getElementById(myField).value.substring(endPos, document.getElementById(myField).value.length);
		document.getElementById(myField).selectionStart=startPos;
		document.getElementById(myField).selectionEnd=startPos;
		document.getElementById(myField).focus();
	}
}




function onNineKeyPress(src1, src2, src3, src4, src5, src6, src7, src8, src9) 
{
	var keycode;
	
	if(event.which || event.keyCode)
	{
		if ((event.which == 97) || (event.keyCode == 97))	//1
		{
			document.getElementById(src1).focus();
			document.getElementById(src1).onclick();
		}
		else if ((event.which == 98) || (event.keyCode == 98))	//2
		{
			document.getElementById(src2).focus();
			document.getElementById(src2).onclick();
		}
		else if ((event.which == 99) || (event.keyCode == 99))	//3
		{
			document.getElementById(src3).focus();
			document.getElementById(src3).onclick();
		}
		else if ((event.which == 100) || (event.keyCode == 100))	//4
		{
			document.getElementById(src4).focus();
			document.getElementById(src4).onclick();
		}
		else if ((event.which == 101) || (event.keyCode == 101))	//5
		{
			document.getElementById(src5).focus();
			document.getElementById(src5).onclick();
		}
		else if ((event.which == 102) || (event.keyCode == 102))	//6
		{
			document.getElementById(src6).focus();
			document.getElementById(src6).onclick();
		}
		else if ((event.which == 103) || (event.keyCode == 103))	//7
		{
			document.getElementById(src7).focus();
			document.getElementById(src7).onclick();
		}
		else if ((event.which == 104) || (event.keyCode == 104))	//8
		{
			document.getElementById(src8).focus();
			document.getElementById(src8).onclick();
		}
		else if ((event.which == 105) || (event.keyCode == 105))	//9
		{
			document.getElementById(src9).focus();
			document.getElementById(src9).onclick();
		}
	}
}

var prevKeyShift = false;

function onArrowsKeyPress(right, down, event) 
{
	event = event || window.event;//IE sucks
	var keycode = event.keyCode;
	
	if (keycode == 9)	//Tab key
	{
		if(!prevKeyShift)
		{
			document.getElementById(right).focus();  		
			if(window.event)
			{
				event.returnValue = false; // IE sucks
			}
			else
			{
				event.preventDefault();
				event.stopPropagation();
			}	
		}
		else
		{
			prevKeyShift = false;
			if(window.event)
			{
				event.returnValue = false; // IE sucks
			}
			else
			{
				event.preventDefault();
				event.stopPropagation();
			}	
		}
	}
	else if (keycode == 16)	//Shift - tab
	{
		document.getElementById(down).focus();
		prevKeyShift = true;
	}	
	else if (keycode == 13)	//Enter Works Automatically
	{}
}

function onNextKeyPress(next, event) 
{
	event = event || window.event;//IE sucks
	var keycode = event.keyCode;
	if (keycode == 9)	//Tab key
	{
		document.getElementById(next).focus();  		
		if(window.event)
		{
			event.returnValue = false; // IE sucks
		}
		else
		{
			event.preventDefault();
			event.stopPropagation();
		}	
	}
	else if (keycode == 13)	//Enter Works Automatically
	{}
}

/*function onFiveKeyPress(src, right, left, up, down, event) 
{
	event = event || window.event;//IE sucks
	var keycode = event.keyCode;
	
	if (keycode == 16)	//Shift - tab
	{
		document.getElementById(left).focus();
		prevKeyShift = true;
	}
	else if (keycode == 9)	//Tab key
	{
		if(!prevKeyShift)
		{
			document.getElementById(right).focus();  		
			if(window.event)
			{
				event.returnValue = false; // IE sucks
			}
			else
			{
				event.preventDefault();
				event.stopPropagation();
			}	
		}
		else
		{
			prevKeyShift = false;
			if(window.event)
			{
				event.returnValue = false; // IE sucks
			}
			else
			{
				event.preventDefault();
				event.stopPropagation();
			}	
		}
	}
	else if (keycode == 8)	//Back space
	{
		document.getElementById(up).focus();
		if(window.event)
		{
			event.returnValue = false; // IE sucks
		}
		else
		{
			event.preventDefault();
			event.stopPropagation();
		}	
	}
	else if (keycode == 32)	//Space
	{
		document.getElementById(down).focus();
		if(window.event)
		{
			event.returnValue = false; // IE sucks
		}
		else
		{
			event.preventDefault();
			event.stopPropagation();
		}	
	}
	else if (keycode == 13)	//Enter
	{
		//document.getElementById(src).onclick();
	}
	
}*/

function onFiveKeyPress(src, right, left, up, down, event) 
{
	event = event || window.event;//IE sucks
	var keycode = event.keyCode;
	
	if (keycode == 37)	//Shift - tab
	{
		document.getElementById(left).focus();
	}
	else if (keycode == 39)	//Tab key
	{
		document.getElementById(right).focus();  		
	}
	else if (keycode == 38)	//Back space
	{
		document.getElementById(up).focus();
	}
	else if (keycode == 40)	//Space
	{
		document.getElementById(down).focus();
	}
	else if (keycode == 13)	//Enter
	{
		//document.getElementById(src).onclick();
	}
	
}

function disableSpaceBackSpace(event)
{
	event = event || window.event;//IE sucks
	var keycode = event.keyCode;
	
	if (keycode == 32 || keycode == 8)	//Space - Back space
	{
		if(window.event)
		{
			event.returnValue = false; // IE sucks
		}
		else
		{
			event.preventDefault();
			event.stopPropagation();
		}	
	}
}

function ChangeImageOnFocus(src_field, onFocusClassName)
{
	document.getElementById(src_field).className = onFocusClassName;
}

function ChangeImageOnBlur(src_field, defaultClassName)
{
	document.getElementById(src_field).className = defaultClassName;
}

function setfocus(field) 
{
	document.getElementById(field).focus()
}

function doBold(field)
{
	//field.document.execCommand('bold', false, null);
	
	 //BackColor
   var mCommand, uInterface, vValue;

	mCommand = 'bold';			
	uInterface = false;
	vValue = null;
	
	document.getElementById(field).focus ();
	document.getElementById(field).document.execCommand (mCommand, uInterface, vValue);
	//field.focus ();
}

function setVisibility(field, value)
{
	if(value == true)
	{
		document.getElementById(field).style.display = "block";	
	}
	else
	{
		document.getElementById(field).style.display = "none";
	}
}

function leftAtCursor(myField)
{
	if (document.selection)//IE Support
	{
		document.getElementById(myField).focus();
		sel = document.selection.createRange();
		sel.moveEnd('character',-1); 
		sel.select();		
		
	}
	else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0')//Netscape Support
	{
		var startPos = document.getElementById(myField).selectionStart;
		var endPos = document.getElementById(myField).selectionEnd;
		document.getElementById(myField).selectionStart=startPos-1;
		document.getElementById(myField).selectionEnd=startPos-1;
		document.getElementById(myField).focus();
	}
}

function rightAtCursor(myField)
{
	if (document.selection)//IE Support
	{
		document.getElementById(myField).focus();
		sel = document.selection.createRange();
		sel.moveStart('character',+1); 
		sel.select();		
		
	}
	else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0')//Netscape Support
	{
		var startPos = document.getElementById(myField).selectionStart;
		var endPos = document.getElementById(myField).selectionEnd;
		document.getElementById(myField).selectionStart=startPos+1;
		document.getElementById(myField).selectionEnd=startPos+1;
		document.getElementById(myField).focus();
	}
}

function moveHome(myField)
{
	if (document.selection)//IE Support
	{
		document.getElementById(myField).focus();
		sel = document.selection.createRange();
		var temp = document.getElementById(myField).value.length;
		sel.moveStart('character', -temp); 
		sel.moveEnd('character', -temp); 
		sel.select();		
		
	}
	else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0')//Netscape Support
	{
		var startPos = document.getElementById(myField).selectionStart;
		var endPos = document.getElementById(myField).selectionEnd;
		var temp = document.getElementById(myField).value.length;
		document.getElementById(myField).selectionStart=startPos - temp;
		document.getElementById(myField).selectionEnd=startPos - temp;
		document.getElementById(myField).focus();
	}		
}

function moveEnd(myField)
{
	if (document.selection)//IE Support
	{
		document.getElementById(myField).focus();
		sel = document.selection.createRange();
		var temp = document.getElementById(myField).value.length;
		sel.moveStart('character', temp); 
		sel.moveEnd('character', temp); 
		sel.select();		
		
	}
	else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0')//Netscape Support
	{
		var startPos = document.getElementById(myField).selectionStart;
		var endPos = document.getElementById(myField).selectionEnd;
		var temp = document.getElementById(myField).value.length;
		document.getElementById(myField).selectionStart = temp;
		document.getElementById(myField).selectionEnd = temp;
		document.getElementById(myField).focus();
	}		
}

function upAtCursor(myField)
{	
	if (document.selection)//IE Support
	{	
		document.getElementById(myField).focus();
		sel = document.selection.createRange();
		var temp = document.getElementById(myField).cols;
		sel.moveStart('character', -temp); 
		sel.moveEnd('character', -temp); 
		sel.select();		
		
	}
	else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0')//Netscape Support
	{
		var startPos = document.getElementById(myField).selectionStart;
		var endPos = document.getElementById(myField).selectionEnd;
		var temp = document.getElementById(myField).cols;
		document.getElementById(myField).selectionStart = startPos - temp;
		document.getElementById(myField).selectionEnd= startPos - temp;
		document.getElementById(myField).focus();
	}		
}

function downAtCursor(myField)
{	
	if (document.selection)//IE Support
	{	
		document.getElementById(myField).focus();
		
		var temp = document.getElementById(myField).cols;
		sel = document.selection.createRange();
		sel.moveStart('character', temp); 
		sel.select();
	
	}
	else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0')//Netscape Support
	{
	
		var startPos = document.getElementById(myField).selectionStart;
		var endPos = document.getElementById(myField).selectionEnd;
		var temp = document.getElementById(myField).cols;//Does not count columns correctly
	
		document.getElementById(myField).selectionStart = startPos + temp;
		document.getElementById(myField).selectionEnd= startPos + temp;
		document.getElementById(myField).focus();
		
	}		
}

//Checkbox
function checkEnterPress(myField,event) 
{
	event = event || window.event;//IE sucks
	var keycode = event.keyCode;
	if (keycode == 13)	//Enter Works Automatically
	{
		if(document.getElementById(myField).checked == false)
		{
			document.getElementById(myField).checked = true;
		}
		else
		{
			document.getElementById(myField).checked = false;
		}
		
		if(window.event)
		{
			event.returnValue = false; // IE sucks
		}
		else
		{
			event.preventDefault();
			event.stopPropagation();
		}
	}
	
	
}

//Radio button
function checkEnterNavigateRadio(myField,event) 
{
	event = event || window.event;//IE sucks
	var keycode = event.keyCode;
	if (keycode == 13)	//Enter Works Automatically
	{
		var radioGroup = document.getElementsByName(document.getElementById(myField).name);
		var len = radioGroup.length;
		var curIndex;
		for (i = 0; i <len; i++) 
		{
			if (radioGroup[i].checked == true) 
			{
				curIndex = i;	
				break;
			}
		}
		
		if(curIndex == radioGroup.length - 1)
		{
			radioGroup[0].checked = true;
			radioGroup[0].focus();	
		}
		else
		{
			radioGroup[curIndex + 1].checked = true;
			radioGroup[curIndex + 1].focus();	
		}
		
		if(window.event)
		{
			event.returnValue = false; // IE sucks
		}
		else
		{
			event.preventDefault();
			event.stopPropagation();
		}
	}
}

function checkEnterPressDrd(myField, event) 
{
	event = event || window.event;//IE sucks
	var keycode = event.keyCode;
	if (keycode == 13)	//Enter Works Automatically
	{
		var curIndex  = document.getElementById(myField).selectedIndex;
		
		if((curIndex + 1) == document.getElementById(myField).options.length)
		{
			document.getElementById(myField).selectedIndex = 0;
		}
		else
		{
			document.getElementById(myField).selectedIndex = curIndex + 1;
		}
		
		if(window.event)
		{
			event.returnValue = false; // IE sucks
		}
		else
		{
			event.preventDefault();
			event.stopPropagation();
		}
		
	}
}
 
 
function popFileSelector(myField, itemToFocus, event)
{
	
	event = event || window.event;//IE sucks
	var keycode = event.keyCode;
	if (keycode == 13)	//Enter Works Automatically
	{
		if(window.event)
		{
			document.getElementById( myField ).click(); 
			document.getElementById( myField ).value = document.getElementById( myField ).text;
			//document.getElementById( myField ).blur();
			//document.getElementById( itemToFocus ).focus();
			event.returnValue = false; // IE sucks		
		}
	}
		
}
