
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~vvv
	*This function opens a window for the contextual help
	*
	*This function is called with: <input type="button" value="?" onClick="return HelpPopUp('/appropriateURL');" name=helpbutton>
	*/
function HelpPopUp(HelpUrl){
		HelpScreen=window.open(HelpUrl,"targetHelpScreen","toolbar=yes, width=500, height=400, status=no, scrollbars=yes, resize=yes, menubar=no, alwaysRaised=yes");
		HelpScreen.focus();
		  return true;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^



//~~~~~~~~~~~~~~~~~~~~~~~~~~~vvv
	function Select_jump(targ,selObj,restore){ 
		//	jumps to a new location 'targ'
		// called from a select menu with:
		//		<select name="Y_jump" onChange="Select_jump('self',this,0)" size="1">
		//     and <option value="targetURL">explanation</option>
		
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		if (restore) selObj.selectedIndex=0;
	}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^


//~~~~~~~~~~~~~~~~~~~~~~~~~~~vvv
function isFilled(element) {
	// Check for null and for empty
	
	if (element.value == "" || element.value == null) 
		return false;
	else return true;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^



//~~~~~~~~~~~~~~~~~~~~~~~~~~~vvv
	function isDate(day,month,year) {
			// checks if date passed is valid
				// will accept dates in following format:
				// isDate(dd,mm,ccyy), or
				// isDate(dd,mm) - which defaults to the current year, or
				// isDate(dd) - which defaults to the current month and year.
				// Note, if passed the month must be between 1 and 12, and the year in ccyy format.
		var today = new Date();
		year = ((!year) ? y2k(today.getYear()):year);
		month = ((!month) ? today.getMonth():month-1);
		if (!day) return false
		var test = new Date(year,month,day);
		if ( (y2k(test.getYear()) == year) &&
		     (month == test.getMonth()) &&
		     (day == test.getDate()) )
		    return true;
		else
		    return false
	}

	function y2k(number) { return (number < 1000) ? number + 1900 : number; }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^


//~~~~~~~~~~~~~~~~~~~~~~~~~~~vvv
	function isDec(elm) {
	
	// Is it a positive decimal with either a . or a , for the decimal point 
	
	var elmstr = elm.value + ""; 
	    if (elmstr == "") return false;
	    for (var i = 0; i < elmstr.length; i++) {
	        if ( (elmstr.charAt(i) < "0" || elmstr.charAt(i) > "9") && (elmstr.charAt(i) != "." && elmstr.charAt(i) != "," ) ){
	        return false;
	        }
	    }
	return true;
	}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^




//~~~~~~~~~~~~~~~~~~~~~~~~~~~vvv
	function repComma(elm) {
		//replaces comma with decimal point
		re = /,/gi;
		str = elm.value;
		str = str.replace(/,/gi, ".");
		newstr = str.replace(" ", "");
		elm.value = newstr
	}	
//~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^



//~~~~~~~~~~~~~~~~~~~~~~~~~~~vvv
function BudgetPrime(form,FieldName,FieldTitle){
	var theField   = form.elements[FieldName];
	var FieldValue = theField.value;
				
	if (isFilled(theField) == true) {	
		repComma(theField);
		FieldValue = theField.value;
		if (isNaN(FieldValue)) {
			alert("Please enter a decimal number for the field:\n\n\n''" + FieldTitle + "''");
			theField.focus();
			return false;
		}
	}else{
		theField.value = 0
	}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^

