﻿// JScript File
function doClick(buttonName,e)
    {
//the purpose of this function is to allow the enter key to 
//point to the correct button to click.
        var key;

         if(window.event)
              key = window.event.keyCode;     //IE
         else
              key = e.which;     //firefox
    
        if (key == 13)
        {
            //Get the button the user wants to have clicked
            var btn = document.getElementById(buttonName);
            if (btn != null)
            { //If we find the button click it
                if(window.event){
                    btn.click();
                    event.keyCode = 0;
                }else{
                    var e = document.createEvent("MouseEvents");
                    e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
                    btn.dispatchEvent(e);
                }
                              
                
            }
        }
   }
   
function doLink(linkName,e)
    {
        //Get the button the user wants to have clicked
        var btn = document.getElementById(linkName);
        if (btn != null)
        { //If we find the button click it
            if(window.event){ //IE
                btn.click();
                event.keyCode = 0
            }else{
                btn.onclick(); //firefox
                return true;
            }
        }
   }

   
function Confirm(message)
    {
        var ans; 
		ans=window.confirm(message);  
		if (ans == false) { 
		    if(window.event){
			    window.event.returnValue = false; //important
			}
			return false; 
		}
    }

function ignoreEnter(event) {

            if (typeof event == "undefined")

                  event = window.event;

            

            var val = event.keyCode;

            if(val == 13)
                  return false;

      }


    
   /* <script language="javascript"> 
			function getMessage() { 
				var ans; 
				ans=window.confirm('Are you sure you want to delete selected messages?');  
				if (ans == false) { 
					window.event.returnValue = false; //important
					return false; 
				}
			} 
		</script>*/


      // Keep user from entering more than maxLength characters
      function doKeypress(control) {
          maxLength = control.attributes["maxLength"].value;
          value = control.value;
          if (maxLength && value.length > maxLength - 1) {
              event.returnValue = false;
              maxLength = parseInt(maxLength);
          }
      }
      // Cancel default behavior
      function doBeforePaste(control) {
          maxLength = control.attributes["maxLength"].value;
          if (maxLength) {
              event.returnValue = false;
          }
      }
      // Cancel default behavior and create a new paste routine
      function doPaste(control) {
          maxLength = control.attributes["maxLength"].value;
          value = control.value;
          if (maxLength) {
              event.returnValue = false;
              maxLength = parseInt(maxLength);
              var oTR = control.document.selection.createRange();
              var iInsertLength = maxLength - value.length + oTR.text.length;
              var sData = window.clipboardData.getData("Text").substr(0, iInsertLength);
              oTR.text = sData;
          }
      }
