		
		var running = false;
		var endTime=null;
		var timerID=null;
		var MAX_MSG_LEN="100";
		  
		ie5 = navigator.appVersion.indexOf("MSIE 5");
		if(ie5 < 0) ie5=false;
		else ie5 = true;
		ie6 = navigator.appVersion.indexOf("MSIE 6");
		if(ie6 > 0) ie5 = 1;
		if(ie5 < 0) ie5=false;
		else ie5 = true;
		
		function OpenWindow(page, width, height)
		{
			
			//page = "TransferOrder.aspx"
			var strAttr = "status:no;dialogWidth:"+ width+ "px;dialogHeight:"+ height+ "px;help:no;center:yes;";
			var ChildWindow = showModalDialog(page, 'Transfer', strAttr);
			//if the user closed the dialog showModalDialog(box the returned value is undefined
			if(""+ChildWindow=='undefined')
			{
				ChildWindow = "";
			}
			//document.getElementById(CtrlName).value = ChildWindow;
			window.location.reload( true );
		}
		
		function IsOnlyAlphaNumeric(literal)
		{

			var invalidCharactersRegExp = /[^a-z\d ]/i; 

			var isValid = !(invalidCharactersRegExp.test(string) );

			return isValid;

		}
		
		//Enables another control using a checkbox, if checkbox
		//is checked then the control is enabled, otherwise disabled
		function EnableControlByCheckbox(chkBox,control)
		{
			if(document.getElementById(chkBox).checked == true)
			{
				document.getElementById(control).value = '';
				document.getElementById(control).readOnly = true;
			}
			else
			{
				document.getElementById(control).value = '';
				document.getElementById(control).readOnly = false;
			}
		}
		
		function SetMaxAlerts(chkBox,control)
		{
			if(document.getElementById(chkBox).checked == false)
			{
				document.getElementById(control).value = '';
			}
		}
		
		function OpenPopUp(strPage,strTitle)    
		{  
			/****************************************************      
			Use Javascript method showModalDialog to PopUp a new window    
			which contains the password reminder      
			*****************************************************/       
			//var strPage = strPage
			var strAttr = "status:no;dialogWidth:470px;dialogHeight:300px;help:no;center:yes;";
			//var strParams = "Forgot Password"; //,
			window.open(strPage,'',"left=300,top=300,width=400,height=150,toolbar=0,resizable=0");
			//showModelessDialog(strPage, strParams, strAttr);
			
		} 
		function Cancel()
		{
			var bconfirmed = window.confirm('Are you sure you wish to cancel?');
			if(bconfirmed)
			{
				window.close();
			}
		}
		
		
		
		function GetDate(CtrlName)    
		{  
			/****************************************************      
			Use Javascript method showModalDialog to PopUp a new window    
			which contain a Calendar Control.      
			*****************************************************/       
			var strPage = "calendarHolder.aspx";
			var strAttr = "status:no;dialogWidth:290px;dialogHeight:281px;help:no;center:yes;";
			var strParams = "PopUpCalendar";
			
			var ChildWindow = showModalDialog(strPage, strParams, strAttr);
			//if the user closed the dialog showModalDialog(box the returned value is undefined
			if(""+ChildWindow=='undefined')
			{
				ChildWindow = "";
			}
			document.getElementById(CtrlName).value = ChildWindow;
		} 
		
		function dateChk(element1, element2,element3,element4) {
		//	if (document.all || document.getElementById) {
		////	for (i = 0; i < theform.length; i++) {
		//	var tempobj = theform.elements[i];
		//	if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
			if(document.getElementById(element1).disabled)
			{
				document.getElementById(element1).disabled = false;
				
				document.getElementById(element2).disabled = false;
				
				document.getElementById(element3).disabled = false;
				
				document.getElementById(element4).disabled = false;
			}
			else
			{
				document.getElementById(element1).disabled = true;
				document.getElementById(element2).disabled = true;
				document.getElementById(element1).value= '';
				document.getElementById(element2).value='';
				document.getElementById(element3).disabled = true;
				document.getElementById(element4).disabled = true;
			}
		}
		
		function ShowHideListBox(element)
		{
			//hide last choice
			hidediv();
			//hide last choice
			showdiv(document.getElementById(element).options[document.getElementById(element).selectedIndex].value);
		}
		function ShowListBox(element)
		{
			showdiv(document.getElementById(element).options[document.getElementById(element).selectedIndex].value);
		}
		
		function ShowHideBox(element,thisdiv)
		{
			showdiv(thisdiv);
			if(document.getElementById(element).checked)
			{
				
				showdiv(thisdiv);
			}
			else
			{
				hidediv();
			}
		}
		function getRefToDivNest( divID, oDoc ) {
		if( !oDoc ) { oDoc = document;  }
		if( document.layers ) {
			if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
				for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
					y = getRefToDivNest(divID,oDoc.layers[x].document); }
				return y; } }
		if( document.getElementById ) { return document.getElementById(divID); }
		if( document.all ) { return document.all[divID]; }
		return document[divID];
	}

	function showdiv(thisdiv) {
		//this function shows the div
		//hidediv(); //first, hide the last one
		//Convert the name of the div into a reference to it. Basically, get a reference to the object
		olddiv = getRefToDivNest(thisdiv);
		if( !olddiv ) {
			//Nothing found. This browser is not compliant with any!
			notifyFail();
			return;
		}
		//Make the object visible
		if( olddiv.style ) {
			//DOM compliant
			olddiv.style.display = '';
		} else {
			if( olddiv.visibility ) {
				//Netscape and old versions of Mozilla compliant
				olddiv.display = '';
			} else {
				//Nothing found, no known way of changing the style
				notifyFail();
				return;
			}
		}
		divshown = 1;
	}

	function hidediv() {
		if( olddiv ) {
			if( olddiv.style ) {
				//DOM compliant
				olddiv.style.display = 'none';
			} else {
				//Netscape and old versions of Mozilla compliant
				olddiv.display = 'none';
			}
			//No need for else notifyFail()
			//If it was going to fail, it would have failed while it was being shown
		}
		olddiv = false;
	}

	function notifyFail() {
	//oops, I guess nothing works in this browser
		if( window.myalternative ) {
			if( window.confirm( "You are having problems displaying some components of this page.\n"+
				"\nWould you like to try the other page design?" ) ) { location.href = myalternative; }
		} else {
			window.alert( "You are having problems displaying some components of this page.\n\n"+
				"Sorry, but there is not yet an alternative page." );
		}
	}
	
	function remove(message)
	{
		alert(message);
	}
	
	function swapFromList(elementFrom, elementTo, chkMaxLength)
	{
	    if(document.getElementById(elementFrom).selectedIndex > -1)
	    {
	
		    document.getElementById(elementTo).value = 
		    document.getElementById(elementTo).value + document.getElementById(elementFrom).options[document.getElementById(elementFrom).selectedIndex].value;
		    document.getElementById(elementTo).focus();
		    if(chkMaxLength)
		    {
		        //update the chars count
		        maxLength2('_ctl0_ContentPlaceHolder1_txtAText','_ctl0_ContentPlaceHolder1_txtAction','_ctl0_ContentPlaceHolder1_txtAText','txtChars') ;
		        maxLength('_ctl0_ContentPlaceHolder1_txtAText','_ctl0_ContentPlaceHolder1_txtAction','txtChars');
		    }
		}
		else
		{
		    alert('Please select an item first');
		}
	}
	function startTimer(e1, e2)
	{
		running = true;
		now = new Date();
		now = now.getTime();
		endTime = now + (1000 * 0.1 * 1);
		showCountDown(e1,e2);
	}
	function showCountDown(e1, e2)
	{
		var now= new Date();
		now = now.getTime();
		if(endTime - now <=0)
		{
			if(!ie5) document.forms[0].txtChars.focus();
			//document.forms[0].txtAText.focus();
			document.getElementById(e1).focus();
			maxLength2(e1,e2,e1,'txtChars');
		}
		else
		{
			var delta=new Date(endTime - now);
			var theMin = delta.getMinutes();
			var theSec = delta.getSeconds();
			var theTime = theMin;
			theTime += ((theSec < 10) ? ":0" : ":") + theSec;
			if(running)
			{
				timerID=setTimeout("showCountDown('" + e1 + "','" + e2 + "')", 500);
			}
		}
	}
	function stopTimer()
	{
		clearTimeout(timerID);
		running = false;
	}
	function maxLength2(e1, e2,element,element2)
	{
	    CheckActionSpace();
		var charleft;
		inputStr = document.getElementById(e1).value;
		strlength= inputStr.length + document.getElementById(e2).value.length;

		if(strlength > MAX_MSG_LEN)
		{
			LEFTOVER = MAX_MSG_LEN - document.getElementById(e2).value.length
			document.getElementById(element).value=inputStr.substring(0, LEFTOVER);
			charleft=0;
		}
		else
		{
			charleft=MAX_MSG_LEN - strlength;
		}
		document.getElementById(element2).value=charleft;
		
		document.getElementById('_ctl0_ContentPlaceHolder1_txtComplete').value = document.getElementById('_ctl0_ContentPlaceHolder1_txtAText').value  + document.getElementById('_ctl0_ContentPlaceHolder1_txtAction').value;
		startTimer(e1,e2);
	}
	function maxLength(element,element3, element2)
	{
	    CheckActionSpace();
		var charleft;
		inputStr = document.getElementById(element).value;
		inputStr2 = document.getElementById(element3).value
		strlength=inputStr.length + inputStr2.length;
		if(strlength > MAX_MSG_LEN) 
		{
			LEFTOVER = MAX_MSG_LEN - inputStr2.length
			document.getElementById(element).value=inputStr.substring(0, LEFTOVER);
			charleft=0;
		}
		else
		{
			charleft=MAX_MSG_LEN - strlength;
		}
		document.getElementById('_ctl0_ContentPlaceHolder1_txtComplete').value = document.getElementById('_ctl0_ContentPlaceHolder1_txtAText').value  + document.getElementById('_ctl0_ContentPlaceHolder1_txtAction').value;
		document.getElementById(element2).value=charleft;
		stopTimer();
	} 
	
	function CheckActionSpace()
	{
	    var actionstr = document.getElementById('_ctl0_ContentPlaceHolder1_txtAction').value;
	    var alertstr = document.getElementById('_ctl0_ContentPlaceHolder1_txtAText').value;
	    var len = alertstr.length;
	    if(actionstr.length > 0 && len > 0)
	    {
	        //get the length of the alert string 
	        if(actionstr.indexOf(' ') != 0 && alertstr.lastIndexOf(' ') != (len- 1) )
	        {
	            document.getElementById('_ctl0_ContentPlaceHolder1_txtAction').value = " " + actionstr;
	        }
	    }
	}
