
/*	
	======================================================================

	javascript/misc.js

	======================================================================
	Copyright 2007 Linda Werner & Associatespe
	======================================================================
*/


	/////////////////////////////////////////////////////////
	//
	//  FUNCTION:  OpenPopupWindow
	//
	/////////////////////////////////////////////////////////
	
		popup_windows = new Array ();

		function OpenPopupWindow (script, name, width, height) {
		
			args = "width=" + width + ",height=" + height + ",resizable=yes,scrollbars=yes";

			if (typeof (popup_windows[name]) != "object") {
			
				popup_windows[name] = window.open (script, name, args);
			}
			
			else {
			
				if (! popup_windows[name].closed) {
				
					popup_windows[name].location.href = script;
				}
			
				else {
		
					popup_windows[name] = window.open (script, name, args);
				}
			}
		
			popup_windows[name].focus();
		}



	/////////////////////////////////////////////////////////
	//
	//  FUNCTION:  IgnoreKeys
	//
	/////////////////////////////////////////////////////////
	
		function IgnoreKeys (event, restrictions) {
		
			var charCode = event.charCode ? 
			               event.charCode :
			              (event.which    ? 
			               event.which    : 
			               event.keyCode) ;
								 
			// allow arrow keys
			
			if (charCode >= 37 && charCode <= 40) {
				
				return true;
			}
			
			// allow tab keys
			
			if (charCode == 9) {
				
				return true;
			}
			
			// allow backspace
			
			if (charCode == 8) {
				
				return true;
			}
			
			// return false if return/enter key
			
			if (charCode == 13 || charCode == 3 || charCode == 0) {
				
				return false;
			}
			
			// handle digits restriction
			
			if (restrictions == 'digits') {

				if (charCode < 48 || charCode > 57) {
				
					alert ("Please enter digits only in this field");
				
					return false;
				}
			}
			
			// handle decimal restriction
			
			if (restrictions == 'decimal') {
			
				// decimal point
				
				if (charCode == 46) {
				
					return true;
				}
				
				// check for digits

				if (charCode < 48 || charCode > 57) {
				
					alert ("Please enter only digits or a decimal point in this field");
				
					return false;
				}
			}
			
			// handle decimal restriction
			
			if (restrictions == 'decimalPlusMinus') {
			
				// decimal point
				
				if (charCode == 46) {
				
					return true;
				}
				
				// hyphen
				
				if (charCode == 45 || charCode == 109 || charCode == 189 || charCode == 150) {
				
					return true;
				}
				
				// check for digits

				if (charCode < 48 || charCode > 57) {
				
					alert ("Please enter only digits, a decimal point, or a hyphen (negative sign) in this field");
				
					return false;
				}
			}
			
			// handle currency restriction
			
			if (restrictions == 'currency') {
			
				// decimal point
				
				if (charCode == 46) {
				
					return true;
				}
				
				// comma
				
				if (charCode == 44) {
				
					return true;
				}
				
				// check for digits

				if (charCode < 48 || charCode > 57) {
				
					alert ("Please enter only digits, a decimal point, or a comma in this field");
				
					return false;
				}
			}
			
			// handle phone number restriction
			
			if (restrictions == 'phoneNumber') {

				if ((charCode != 45) && (charCode < 48 || charCode > 57)) {
				
					alert ("Please enter digits or a hyphen (-) only in this field");
				
					return false;
				}
			}

			// handle no input restriction
			
			if (restrictions == 'noInput') {

				alert ("Direct input is not allowed in this field");
				
				return false;
			}

			return true;
		}


		

	/////////////////////////////////////////////////////////
	//
	//  FUNCTION:  HideDiv
	//
	/////////////////////////////////////////////////////////
	
		function HideDiv (id) {
		
			if (document.getElementById) { // DOM3 = IE5, NS6
		
				document.getElementById(id).style.display = 'none';
			}
		
			else {
		
				if (document.layers) { // Netscape 4
				
					document.id.display = 'none';
				}
				
				else { // IE 4
				
					document.all.id.style.display = 'none';
				}
			}
		}


	/////////////////////////////////////////////////////////
	//
	//  FUNCTION:  ShowDiv
	//
	/////////////////////////////////////////////////////////
	
		function ShowDiv (id) {

			if (document.getElementById) { // DOM3 = IE5, NS6
		
				document.getElementById(id).style.display = 'block';
			}
		
			else {
		
				if (document.layers) { // Netscape 4
		
					document.id.display = 'block';
				}
		
				else { // IE 4
		
					document.all.id.style.display = 'block';
				}
			}
		}
		