	/* MISC FUNCTIONS */
	/* *************************************************************************************************** */		
    function show(id) {
	    var elem = document.getElementById(id);
	    elem.style.visibility = 'visible';
    }

    function hide(id) {
	    var elem = document.getElementById(id);
	    elem.style.visibility = 'hidden';
    }
    
	function getRadioValue(radioObj) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	}
	
	function setRadioValue(radioObj, newValue) {
		if(!radioObj)
			return;
		var radioLength = radioObj.length;
		if(radioLength == undefined) {
			radioObj.checked = (radioObj.value == newValue.toString());
			return;
		}
		for(var i = 0; i < radioLength; i++) {
			radioObj[i].checked = false;
			if(radioObj[i].value == newValue.toString()) {
				radioObj[i].checked = true;
			}
		}
	}
	
	function setCheckedValue(checkObj, checkValue){
		if(!checkObj)
			return;
			
		if (checkValue == "on" || checkValue == 1){
			checkObj.checked = true;	
		}
		
		return;
	}	
	
	function getSelectValue(selectObject) {
			  return selectObject.options[selectObject.selectedIndex].value
		 }
	
	function setSelectValue(SelectObject, Value)
			 {
			 //eval('SelectObject = document.' +               SelectName + ';');
			 for(index = 0; 
				 index < SelectObject.length; 
				 index++)
				{
				if(SelectObject[index].value == Value)
				   SelectObject.selectedIndex = index;
				}
			 }
			 
	function isNumeric(sText)
	{
	   var ValidChars = "0123456789.";
	   var IsNumber=true;
	   var Char;
	
	 
	   for (i = 0; i < sText.length && IsNumber == true; i++) 
		  { 
		  Char = sText.charAt(i); 
		  if (ValidChars.indexOf(Char) == -1) 
			 {
			 IsNumber = false;
			 }
		  }
	   return IsNumber;
	   
	   }
			
	function showTip(tip){
		newTop = self.screenTop+100;
		newLeft = self.screenLeft+100;
		features = "top="+newTop+", left="+newLeft+", width=780, height=420, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no";
		url = "show-tip.php?";	
		
		url += "t="+tip;
		window.open(url, "showTip", features);	
	}
	
	function checkNumeric(obj){
		if (!isNumeric(obj.value)){
			obj.value = '';
			alert("This value must be numeric.");
			return false;
		}
		
		return true;
	}
	function isValidEmailAddress(email) {
        // These comments use the following terms from RFC2822:
        // local-part, domain, domain-literal and dot-atom.
        // Does the address contain a local-part followed an @ followed by a domain?
        // Note the use of lastIndexOf to find the last @ in the address
        // since a valid email address may have a quoted @ in the local-part.
        // Does the domain name have at least two parts, i.e. at least one dot,
        // after the @? If not, is it a domain-literal?
        // This will accept some invalid email addresses
        // BUT it doesn't reject valid ones. 
        var atSym = email.lastIndexOf("@");
        if (atSym < 1) { return false; } // no local-part
        if (atSym == email.length - 1) { return false; } // no domain
        if (atSym > 64) { return false; } // there may only be 64 octets in the local-part
        if (email.length - atSym > 255) { return false; } // there may only be 255 octets in the domain

        // Is the domain plausible?
        var lastDot = email.lastIndexOf(".");
        // Check if it is a dot-atom such as example.com
        if (lastDot > atSym + 1 && lastDot < email.length - 1) { return true; }
        //  Check if could be a domain-literal.
        if (email.charAt(atSym + 1) == '[' &&  email.charAt(email.length - 1) == ']') { return true; }
        return false;  	}
	
	function isPhoneNumber(s){			 
		 // Check for correct phone number
		 rePhoneNumber = new RegExp(/^[1-9]\d{2}\-\s?\d{3}\-\d{4}$/);
	 
		 if (!rePhoneNumber.test(s)) {					  
			  return false;
		 }
	 
		return true;
	}		
	
	function submitenter(myfield,e){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return false;
	
	if (keycode == 13)
	   {
	   return true;
	   }
	else
	   return false;
	}	