///////////////////////////////////////////////////////////
// java script functions to validate html form objects
//***************************INDEX**********************
// 1. validateDecimal(string as this.value) remove all string except for numbers and .
// 2. validateInteger(string as this.value)   remove all string except for numbers
// 3. checkEmail(InputBox name as this)
// 4. isEmpty(InputBox name as this, string as Inputbox label)
///////////////////////////////////////////////////////////

// 1.
function validateDecimal(sText)
{
   var ValidChars = "0123456789.";
   var Char;
   var returnValue = '';
   var hasDecimal = false;
 
   for (i = 0; i < sText.length; i++) 
      { 
      Char = sText.charAt(i); 

      if (ValidChars.indexOf(Char) != -1) 
         {
			if(Char == "." && hasDecimal == false){
			 returnValue = returnValue + Char;
			 hasDecimal = true;
			}
			else if (Char != "."){
			 returnValue = returnValue + Char;
			}
         }
      }
      return returnValue;
}

// 2.
function validateInteger(sText)
{
   var ValidChars = "0123456789";
   var Char;
   var returnValue = '';
 
   for (i = 0; i < sText.length; i++) 
      { 
      Char = sText.charAt(i); 

      if (ValidChars.indexOf(Char) != -1) 
         {
           	 returnValue = returnValue + Char;
         }
      }
      return returnValue;
}
   
// 3.
function checkEmail(txtBox) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById(txtBox).value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
document.getElementById(txtBox).selected();
document.getElementById(txtBox).focus();
return (false)
}

//4.
function IsEmpty(aTextField, label) {
   if ((document.getElementById(aTextField).value.length!=0) ||
   (document.getElementById(aTextField).value!=null)) {
      return true;
   }
   else { 
   alert(label + ' cannot be empty');
   document.getElementById(aTextField).focus();
   return false; }
}

// Function that prevents the user from submitting the form more than once.
// Requires onsubmit="return submitonce();" in the form
var submitcount=0;
function submitonce() {
	if (submitcount == 0) {
    	submitcount++;
    	return true;
	}
	else {
		alert("This form has already been submitted. Please wait for it to finish. Thanks!");
		return false;
	}
}
function resetsubmitcount(){
	submitcount = 0;
}
// This is the function that will toggle the main menu hidden or shown along with channging
// the the button text depending on if the menu is hidden or shown
function toggle_menu() {
	if (parent.mainset.rows == "0,*,0,0") {
		parent.mainset.rows = "100,*,0,0";
		buttontext.innerHTML = "<b>Hide Menu</b>";
	}
	else if (parent.mainset.rows == "0,0,*,0") {
		parent.mainset.rows = "100,0,*,0";
		buttontext.innerHTML = "<b>Hide Menu</b>";
	}
	else if (parent.mainset.rows == "100,*,0,0") {
		parent.mainset.rows = "0,*,0,0";
		buttontext.innerHTML = "<b>Show Menu</b>";
	}
	else if (parent.mainset.rows == "100,0,*,0") {
		parent.mainset.rows = "0,0,*,0";
		buttontext.innerHTML = "<b>Show Menu</b>";
	}
}
// This is the function that will allow for expanding the description of items
function show_details(table, arrow) {
	var tag = document.getElementById(table);
	var toggleImage = document.getElementById(arrow);
	// include backwards compatible code, just incase someone is passing in an element name property for the above params
		if (!tag) {tag = eval(table);}
		if (!toggleImage){toggleImage = arrow;}
	if (tag.length) {
		// show/hide array of items
		for (var i = 0; i < tag.length; i++) {
			if (tag[i].style.display == 'none') {
				tag[i].style.display = '';
				image = siteurl + "/graphics/ArrowExpanded.gif";
			}
			else {
				tag[i].style.display = 'none';
				image = siteurl + "/graphics/ArrowExpand.gif";
			}
		}
	}
	else {
		if (tag.style.display == 'none') {
			tag.style.display = '';
			image = siteurl + "/graphics/ArrowExpanded.gif";
		}
		else {
			tag.style.display = 'none';
			image = siteurl + "/graphics/ArrowExpand.gif";
		}
	}
	toggleImage.src = image;
}
// This is the function that will process the logout when the button is pressed
function process_logout() {
	if (confirm("This will log you out of the system, are you sure?")) {
		parent.document.location = "../Logout.cfm";
	}
	else {
		return false;
	}
}
// This is the function that will confirm any deletes
function confirm_delete(data) {
	if(confirm(data)) {
		return true;
	}
	else {
		return false;
	}
}
/////////////////////////////////////////////////
// Functions to perform select all/un-select all
/////////////////////////////////////////////////
// This is the function that will select all and un-select all checkboxes
function selectall_checkbox() {
//	alert(document.form.rec_select.length);
	if(document.form.rec_select == undefined) 
		return;
	if (document.form.rec_select.length) {
		for (var i = 0; i < document.form.rec_select.length; i++) {
			if (document.form.rec_select[i].checked == true) {
				document.form.rec_select[i].checked = false;
				var status = 1;
			}
			else {
				document.form.rec_select[i].checked = true;
				var status = 2;
			}
		}
	}
	else {
		if (document.form.rec_select.checked == true) {
			document.form.rec_select.checked = false;
			var status = 1;
		}
		else {
			document.form.rec_select.checked = true;
			var status = 2;
		}
	}
	if (status == 1) {
		selecttoggle.innerHTML = "[select all]";
	}
	else {
		selecttoggle.innerHTML = "[un-select all]";
	}
}

// This is the function that is used to show/hide selected div's
function ShowHideItems(data,img) {
	if(document.all.item(data).style.display == '') {
		document.all.item(data).style.display = 'none';
		openimage = "../graphics/IconDown.gif";
		document.all.item(img).src = openimage;
	}
	else {
		document.all.item(data).style.display = '';
		openimage = "../graphics/IconUp.gif";
		document.all.item(img).src = openimage;
	}
}
// This is the function that is used to show/hide and reposition into place the calender divs
function ShowHideCal(y,x,divname) {
	if(divname.style.visibility == 'hidden') {
		divname.style.visibility = 'visible';
		divname.style.top = y;
		divname.style.left = x;
	}
	else {
		divname.style.visibility = 'hidden';
	}
}
// This is the function that is used to create nice looking popup windows
function popup_window(width,height,url) {
	var popupwin = window.open(url, "", "fullscreen=1");
	popupwin.blur();
	var swa = window.screen.availWidth;
	var sha = window.screen.availHeight;
	popupwin.resizeTo(width, height);
	popupwin.moveTo((swa - width) / 2, (sha - height) / 2);
	popupwin.focus();
}
function createRequest(){
    var request;
    try {
        request = new XMLHttpRequest();
    } 
    catch (trymicrosoft) {
        try {
            request = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (othermicrosoft) {
            try {
                request = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (failed) {
                request = null;
            }
        }
    }
    
    if (request == null) 
        alert("Error creating request object!");
    
    return request;
}
function flushAppVars(){
    var request = createRequest();
    request.open('POST', '/index.cfm?flushappvars=true', false);
    request.send();
}
////////////////////////////////////////////
// Functions to perform user keyword search
// also displays the user info pages
////////////////////////////////////////////
// This is the function to do searching based on search criteria and center id
function get_searchresults() {
	var request = createRequest();
	request.open('GET','../include/getUserSearchResults.cfm?keyword='+ document.form.keyword.value + '&centerid=' + document.form.centerid.value,false)
	request.send(null);
	results.innerHTML = request.responseText;
	if(request.responseText == 0) {
		document.form.keyword.focus();
		clear_details();
	}
}
function get_searchresultsIgnoreCenter() {
	var request = createRequest();
	request.open('GET','../include/getUserSearchResultsIgnoreCenter.cfm?keyword='+ document.form.keyword.value ,false);
	request.send(null);
	results.innerHTML = request.responseText;
	if(request.responseText == 0) {
		document.form.keyword.focus();
		clear_details();
	}
}
// This is the function to do searching based on search criteria
function get_searchresultsmisc(data) {
    var request = createRequest();
	request.open('GET','../include/getUserSearchResultsMisc.cfm?keyword='+ document.form.keyword.value + '&type=' + data,false)
	request.send();
	results.innerHTML = request.responseText;
	if(request.responseText == 0) {
		document.form.keyword.focus();
		clear_details();
	}
}
// This is the function to show the results of selected user
function show_userdetails(data) {
    var request = createRequest();
	request.open('GET','../include/getSelectedUserInfo.cfm?user='+ data,false)
	request.send();
	userinfo.innerHTML = request.responseText;
}
// This is the function to clear out areas so that error can be displayed nicely
function clear_details() {
	results.innerHTML = "No users returned on your search.";
	userinfo.innerHTML = "";
	document.form.keyword.focus();
}
// This is the function that will control the private message alerts
function private_alert() {
	var temp = (confirm("New private message has arrived. Would you like to view it now?"));
	if(temp) {
		parent.main.document.location="../tools/PrivateMessageQueue.cfm";
	}
}
// This is the funciton that will popup the color palette
function showColorPicker(formname,fieldname) {
	var swa = window.screen.availWidth;
	var sha = window.screen.availHeight;
	var left = (swa - 180) / 2;
	var top = (sha - 150) / 2;
	var colorPalette = window.open(siteurl + '/include/ColorPicker.cfm?formname=' + formname + '&fieldname=' + fieldname, '', 'status=0, menu=0, toolbar=0, scrollbars=0, width=180, height=150, resizable=0, top=' + top + ',left=' + left);
}
// This is the function that will only allow the to input numbers and a dash
function InputPhoneNumber(e) {
	key = e.keyCode;
	if ((key > 44 && key <58) || key == 8 || key == 9 || (key > 95 && key < 106)){
		return true;
	} else {
		return false;
	}
}

// This is the function that will format properly the phone if not formated
function CheckPhone(data) {
	var temp = data;
	if(temp.length != 12) {
		return false;
	}
	if (temp.charAt(3) != "-")
		return false;
	if (temp.charAt(7) != "-")
		return false;
}

// This is the function that will format the data properly if not in the right format
function FormatPhone(e) {
	var temp = e;
	if(temp.length == 10) {
		var AreaCode = temp.substring(0,3);
		var PrefixCode = temp.substring(3,6);
		var SuffixCode = temp.substring(6,10);
		var newPhone = AreaCode+'-'+PrefixCode+'-'+SuffixCode;
		e.srcElement.value = newPhone;
	}
}
// Function that will check to see if obj1 date is later than obj2 date
function checkDateToday(str1,str2) {
	// Returns true if the value of the object passed is NULL
	if(str1.length == 0 || str2.length == 0) {
		return true;
	}
	// Start to split up the date passed
	var temp = str1.indexOf('/');
	var str1Month = str1.substring(0,temp);
	alert(str1Month);
}
function CheckDate(object_value) {
	//Returns true if value is a date format or is NULL
    	//otherwise returns false	
    	if (object_value.length == 0)
        	return true;
    	//Returns true if value is a date in the mm/dd/yyyy format
	isplit = object_value.indexOf('/');
	if (isplit == -1 || isplit == object_value.length)
		return false;
    	sMonth = object_value.substring(0, isplit);
	if (sMonth.length == 0)
        	return false;
	isplit = object_value.indexOf('/', isplit + 1);
	if (isplit == -1 || (isplit + 1 ) == object_value.length)
		return false;
	sDay = object_value.substring((sMonth.length + 1), isplit);
	if (sDay.length == 0)
        	return false;
	sYear = object_value.substring(isplit + 1);
	if (!checkInteger(sMonth)) //check month
		return false;
	else if (!checkRange(sMonth, 1, 12)) //check month 
		return false;
	else if (!checkInteger(sYear)) //check year
		return false;
	else if (!checkRange(sYear, 1900, 2050)) //check year
		return false;
	else if (!checkInteger(sDay)) //check day
		return false;
	else if (!checkDay(sYear, sMonth, sDay)) // check day
		return false;
//	else if (sMonth.length != 2)
//		return false;
//	else if (sDay.length != 2)
//		return false;
//	else if (sYear.length != 4)
//		return false;
	else
		return true;
}

function CheckDateUK(object_value) {
	//Returns true if value is a date format or is NULL
    	//otherwise returns false	
    	if (object_value.length == 0)
        	return true;
    	//Returns true if value is a date in the mm/dd/yyyy format
	isplit = object_value.indexOf('/');
	if (isplit == -1 || isplit == object_value.length)
		return false;
    	sDay = object_value.substring(0, isplit);
	if (sDay.length == 0)
        	return false;
	isplit = object_value.indexOf('/', isplit + 1);
	if (isplit == -1 || (isplit + 1 ) == object_value.length)
		return false;
	sMonth = object_value.substring((sDay.length + 1), isplit);
	if (sMonth.length == 0)
        	return false;
	sYear = object_value.substring(isplit + 1);
	if (!checkInteger(sMonth)) //check month
		return false;
	else if (!checkRange(sMonth, 1, 12)) //check month 
		return false;
	else if (!checkInteger(sYear)) //check year
		return false;
	else if (!checkRange(sYear, 1900, 2050)) //check year
		return false;
	else if (!checkInteger(sDay)) //check day
		return false;
	else if (!checkDay(sYear, sMonth, sDay)) // check day
		return false;
//	else if (sMonth.length != 2)
//		return false;
//	else if (sDay.length != 2)
//		return false;
//	else if (sYear.length != 4)
//		return false;
	else
		return true;
}

function checkDay(checkYear, checkMonth, checkDay) {
	var maxDay = 31;
	if (checkMonth == 4 || checkMonth == 6 || checkMonth == 9 || checkMonth == 11)
        maxDay = 30;
	else if (checkMonth == 2) {
        if (checkYear % 4 > 0)
            maxDay = 28;
        else if (checkYear % 100 == 0 && checkYear % 400 > 0)
            maxDay = 28;
        else
            maxDay = 29;
	}
	return checkRange(checkDay, 1, maxDay); //check day
}

function checkInteger(object_value) {
    //Returns true if value is a number or is NULL
    //otherwise returns false	
    if (object_value.length == 0)
		return true;
    	//Returns true if value is an integer defined as
    	//   having an optional leading + or -.
    	//   otherwise containing only the characters 0-9.
	var decimal_format = '.';
	var check_char;
    	//The first character can be + -  blank or a digit.
	    check_char = object_value.indexOf(decimal_format);
    	//Was it a decimal?
    	if (check_char < 1)
		    return checkNumber(object_value);
    	else
		    return false;
}
// Function to make sure a number is between a specified range
function numberRange(object_value, min_value, max_value) {
	// check minimum
    if(min_value != null) {
        if (object_value < min_value)
			return false;
    }
    // check maximum
    if(max_value != null) {
        if (object_value > max_value)
            return false;
    }
    //All tests passed, so...
    return true;
}
// Function to make sure the passed value is a number
function checkNumber(object_value) {
	//Returns true if value is a number or is NULL
	//otherwise returns false	
	if (object_value.length == 0)
		return true;
    // Returns true if value is a number defined as
    // having an optional leading + or -.
    // having at most 1 decimal point.
    // otherwise containing only the characters 0-9.
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;
	// The first character can be + - .  blank or a digit.
	check_char = start_format.indexOf(object_value.charAt(0))
	//Was it a decimal?
	if (check_char == 1)
		decimal = true;
	else if (check_char < 1)
		return false;
	//Remaining characters can be only . or a digit, but only one decimal.
	for(i=1;i<object_value.length;i++) {
        check_char = number_format.indexOf(object_value.charAt(i))
        if(check_char < 0) {
            return false;
        }
        else if(check_char == 1) {
            // Second decimal
            if (decimal)
				return false;
            else
                decimal = true;
        }
        else if(check_char == 0) {
            if(decimal || digits) {
                trailing_blank = true;
				// ignore leading blanks
            }
		}
        else if(trailing_blank) {
            return false;
        }
		else {
			digits = true;
        }
    }
    //All tests passed, so...
    return true;
}

function checkRange(object_value, min_value, max_value) {
	//if value is in range then return true else return false
    	if (object_value.length == 0)
        	return true;
    	if (!checkNumber(object_value))
	{
		return false;
	}
    	else
	{
		return (numberRange((parseFloat(object_value)), min_value, max_value));
	}	
    	//All tests passed, so...
    	return true;
}
function checkZip(object_value)
{
	if (object_value.length == 0)
        	return true;
	if (object_value.length != 5 && object_value.length != 10)
        	return false;
	// make sure first 5 digits are a valid integer
	if (object_value.charAt(0) == "-" || object_value.charAt(0) == "+")
        	return false;
	if (!checkInteger(object_value.substring(0, 5)))
		return false;
	if (object_value.length == 5)
		return true;
	// check if separator is either a'-' or ' '
	if (object_value.charAt(5) != "-" && object_value.charAt(5) != " ")
        	return false;
	// check if last 4 digits are a valid integer
	if (object_value.charAt(6) == "-" || object_value.charAt(6) == "+")
        	return false;
	return (checkInteger(object_value.substring(6, 10)));
}

function trim(object_value) 
{
  	return ltrim(rtrim(object_value));
}

function ltrim(object_value) 
{
	// check if first character is a space
	while (object_value.indexOf(' ') == 0)
		object_value = object_value.substring(1, object_value.length);
  	return object_value;
}

function rtrim(object_value)
{
	// check if last character is a space
	while (object_value.indexOf(' ', object_value.length - 1) != -1)
		object_value = object_value.substring(0, object_value.length - 1);
	return object_value;
}

// reformat (TARGETSTRING, STRING, INTEGER, STRING, INTEGER ... )       
//
// Handy function for arbitrarily inserting formatting characters
// or delimiters of various kinds within TARGETSTRING.
//
// reformat takes one named argument, a string s, and any number
// of other arguments.  The other arguments must be integers or
// strings.  These other arguments specify how string s is to be
// reformatted and how and where other strings are to be inserted
// into it.
//
// reformat processes the other arguments in order one by one.
// * If the argument is an integer, reformat appends that number 
//   of sequential characters from s to the resultString.
// * If the argument is a string, reformat appends the string
//   to the resultString.
//
// NOTE: The first argument after TARGETSTRING must be a string.
// (It can be empty.)  The second argument must be an integer.
// Thereafter, integers and strings must alternate.  This is to
// provide backward compatibility to Navigator 2.0.2 JavaScript
// by avoiding use of the typeof operator.
//
// It is the caller's responsibility to make sure that we do not
// try to copy more characters from s than s.length.
//
// EXAMPLES:
//
// * To reformat a 10-digit U.S. phone number from "1234567890"
//   to "(123) 456-7890" make this function call:
//   reformat("1234567890", "(", 3, ") ", 3, "-", 4)
//
// * To reformat a 9-digit U.S. Social Security number from
//   "123456789" to "123-45-6789" make this function call:
//   reformat("123456789", "", 3, "-", 2, "-", 4)
//
// HINT:
//
// If you have a string which is already delimited in one way
// (example: a phone number delimited with spaces as "123 456 7890")
// and you want to delimit it in another way using function reformat,
// call function stripCharsNotInBag to remove the unwanted 
// characters, THEN call function reformat to delimit as desired.
//
// EXAMPLE:
//
// reformat (stripCharsNotInBag ("123 456 7890", digits),
//           "(", 3, ") ", 3, "-", 4)
function reformat (s)
{   
	var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) 
	{
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else 
	   {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

// Removes all characters which do NOT appear in string bag 
// from string s.
function stripCharsNotInBag (s, bag)
{   
	var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) != -1) returnString += c;
    }
    return returnString;
}

//takes phone value and strips all non-integer characters,
//then reformats the first 10 digits as 123-456-7890
function reformatUSPhone (USPhone)
{   
	// set variable of integer characters in the phone field
	var digits = "0123456789";
	var phoneTarget;
	
	// Make sure browser compatible 
		if (USPhone.target)  {phoneTarget = USPhone.target;}
		else if (USPhone.srcElement) {phoneTarget = USPhone.srcElement;}
		if (phoneTarget.nodeType == 3) {phoneTarget = phoneTarget.parentNode;}  //defeat Safari bug
		
	var holdphone = phoneTarget.value;
	phoneTarget.value = reformat(stripCharsNotInBag (holdphone, digits), "", 3, "-", 3, "-", 4);
}

/**
 * DO NOT USE: apparently the following format is wrong for Great Britain: (123) 4567 8901
 * @param GBPhone
 * takes phone value and strips all non-integer characters,
 * then reformats the first 11 digits as (123) 4567 8901
 */
function reformatGBPhone (GBPhone)
{   
	// set variable of integer characters in the phone field
	var digits = "0123456789";
	var phoneTarget;
	
	// Make sure browser compatible 
		if (GBPhone.target)  {phoneTarget = GBPhone.target;}
		else if (GBPhone.srcElement) {phoneTarget = GBPhone.srcElement;}
		if (phoneTarget.nodeType == 3) {phoneTarget = phoneTarget.parentNode;}  //defeat Safari bug
		
	var holdphone = phoneTarget.value;
	phoneTarget.value = reformat(stripCharsNotInBag (holdphone, digits), "(", 3, ") ", 4, " ", 4);
}


// Function that will show popup box for help or explaination of things
function show_popup(title,body) {
	// Initialize variable to hold reference to object
	var ref = this.event.srcElement;
		// Outline the div with this color
		ref.style.borderColor='Silver';
	// If there is a popup div then kill it before displaying another one
	if (ref.popup_shown) {
		document.body.removeChild(ref.popup_shown);
		ref.onblur = null;
		return;
	}
	// Create a div and layout look/text
	var d = document.createElement("DIV");	
		// Append the new div to the body of document
		document.body.appendChild(d);
		// This is what the div will say
		var tempTitle = "<b>" + title + "</b><br/>";
		var tempText = tempTitle + body;
		d.innerHTML = tempText;
		// This is what defines the look of the div
		d.style.backgroundColor = "Infobackground";
		d.style.width = "300px";
		d.style.border = "2px solid #8e8e8e";
		d.style.position = "absolute";
		d.style.paddingTop = "5px";
		d.style.paddingBottom = "5px";
		d.style.paddingRight = "3px";
		d.style.paddingLeft = "10px";
		d.style.font = "StatusBar";
		d.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color=#777777, Direction=135, Strength=3)"
		// This will place the div where the mouse coordinates are
		d.style.left = this.event.clientX + 25;
		d.style.top = this.event.clientY;
	// Create a reference for the div
	ref.popup_shown = d;
	// Create a function for mouseout
	ref.onmouseout = function () {
		ref.style.borderColor='Black';
		document.body.removeChild(ref.popup_shown);
		ref.popup_shown = null;
		ref.onmouseout = null;
		ref.onblur = null;
	}
}
function hasValue(obj, obj_type)
{
	if (obj_type == "TEXT" || obj_type == "PASSWORD")
	{
		if (obj == null)
			return false;
    		if (obj.value.length == 0) 
      			return false;
    		else 
      			return true;
    	}
    	else if (obj_type == "SELECT")
	{
		if (obj == null)
			return false;
        	for (var i = 0; i < obj.length; i++)
	    	{
			if (obj.options[i].selected)
				return true;
		}
		return false;	
	}
    	else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
	{
		if (obj == null)
			return false;
		if (obj.checked)
			return true;
		else
       			return false;	
	}
    	else if (obj_type == "RADIO" || obj_type == "CHECKBOX")
	{
		if (obj == null)
			return false;  
		if (obj.length == null)
			return hasValue(obj, "SINGLE_VALUE_CHECKBOX");
		for (var i = 0; i < obj.length; i++)
        	{
			if (obj[i].checked)
				return true;  
		}
		return false;
	}	
}
// Function that will return true/false whether the item is a letter
function isLetter(c) {
	if (((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z"))) {
		return true;
	}
	else {
		return false;
	}
}
// Function that return true/false whether the item is a number
function isDigit(c) {
	return ((c >= "0") && (c <= "9"))
}
// Function that will check for the characters in the passed string 
var charsBlocked = /[\\\$\@\#\%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|\"\.]/;
var charsBlocked = /[\#\%\&\"\<\>]/;
function checkCharsAllowed(data) {
	var data = eval(data);
	if(data.value.search(charsBlocked) == -1) {
		return true;
	}
	else {
		alert('The following characters are not allowed!\n\n'
			+ '# % & < > ' + "' " + '" ');
		data.select();
		data.focus();
		return false;
	}
}
var fieldCharsBlocked = /[^ A-Za-z0-9_]/;
function checkFieldCharsAllowed(data) {
	var data = eval(data);
	if (data.value.search(fieldCharsBlocked) == -1) {
		return true;
	}
	else {
		alert('The following characters are not allowed!\n\n' 
			+ ' ` ~ ! @ # $ % ^ & * ( ) [ ] { } ? / < > , . + = | \\ :' + "' " + '" ');
		data.select();
		data.focus();
		return false;
	}
}

function NewWindow(mypage, myname, w, h, scroll) {
		var winl = (screen.width - w) / 3;
		var wint = (screen.height - h) / 3;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',status=1resizable'
		win = window.open(mypage, myname, winprops)
		if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
