/*
 * Name: 			lc_scripts.js
 *	Author: 		J. Aguillon
 *	Description:	Javascript functions used by Lockcombos
 *	Created:		July 30, 2007
 *  Modified:       August 4, 2007 J. Aguillon
 *					Set focus on Email address on index.cfm page.
  *					Clear status function when any input on scratchpad.
*/

/* Use this function to see if Cookies are enabled.
 * Use this in the body onload event and use a hidden field on the main page.
 *
 * We are trying to detect if both Javascript and Cookies are enabled.
 * This is done by using Javascript to set a cookie and then checking it.
 * If Javascript is enabled then we can check if cookies are enabled.
 * If Javascript is not enabled then we will be able to check if cookes are enabled, but 
 * that's ok since both need to be enabled.
 *
 * This code is taken from http://www.aspfaqs.com/webtech/082400-1.shtml
 *
 * We also set the focus on the login input box as a side benefit.
 */
function cc()
{
 /* check for a cookie */
  if (document.cookie == "") 
  {
    /* if a cookie is not found - alert user -
     change cookieexists field value to false */
    alert("You must have Javascript and Cookies enabled!");

    /* If the user has Cookies disabled an alert will let him know 
        that cookies need to be enabled to log on.*/ 

    document.Form.cookieexists.value ="false"  
  } else {
   /* this sets the value to true and nothing else will happen,
       the user will be able to log on*/
    document.Form.cookieexists.value ="true"
  }
  
  document.Form.login.focus();
}

/* Set a cookie to be sure that one exists.
   Note that this is outside the function*/
document.cookie = 'killme' + escape('nothing')

// Check when we enter data into the scratchpad that we have not exceeded the maximum allowable length.
 function maxlength(element, maxvalue)
 {
     var q = eval("document.Login."+element+".value.length");
     var r = q - maxvalue;
     var msg = "DEBUG, DEBUG: you have input "+q+" characters into the "+
       "text area box you just completed. It can return no more than "+
       maxvalue+" characters to be processed. Please abbreviate "+
       "your text by at least "+r+" characters";
	alert(msg);
	/*
	if (q > maxvalue)
	{
		alert(msg); 
		return false;
	}
	else
	{
		return true;
	}
	*/
  }
  
function print_todays_date()
{
	  var d = new Date();  // today's date and time.
	  document.write(d.toLocaleString());
}

// Clear the status display on the scratchpad page when a keypress is detected.
function clear_status(obj)
{
	var x=document.getElementById('statusdisplay').rows[0].cells;
	x[0].innerHTML = "                           ";
}

 