//#############################################
//ONLY VALID CHARACTERS
function validChars(formName,fieldName,validChars)
{
	var ok = 'yes';
	var strName = eval('document.' + formName + '.' + fieldName + '.value');
	var temp;
	for (var i=0; i<strName.length; i++)
		{
			temp = eval('document.' + formName + '.' + fieldName + '.value.substring(i, i+1);')
			if (validChars.indexOf(temp) == "-1")
				{
					return false
				}
		}
	return true;
}
//#############################################


//##################################################
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//##################################################

//##################################################
function checkEmail(obj) {
	if (obj.value == null || obj.value == "") { 
		return true; 
  	} 
	var em = obj.value
	var re = new RegExp();
	re = /.+@.+\..+/
	if (em != "") 
	{
		if (!(re.test(em))) 
		{
			return false;
		}
		return true;
	}
}
//##################################################


//##################################################
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}


function isEmpty(inputStr, type) { 
	if ((type == "radio") || (type == "checkbox")) { 
		var checked = 0; 
		for (i=0; i < inputStr.length; i++) { 
 
			if (inputStr[i].checked) { 
			checked++; 
			} 
		}  
		if (checked > 0) { // at least one button is checked 
			return false; // isEmpty is false 
		} else { 
			return true; // no buttons, therefore isEmpty 
		} 
 
	} else if (type == "select") { 
		// please note - this only works when the first value is not valid value!!! 

		if (inputStr[inputStr.selectedIndex].value == "" || inputStr[inputStr.selectedIndex].value == null || inputStr[inputStr.selectedIndex].value == "00") { 
			return true; // the first (non-valid) value is still present, therefore isEmpty
		} 
		else { 
			return false; // another value other than the first has been selected 
		} 
 
	} else { // must be a text field 
		if (inputStr.value == null || inputStr.value == "") { 
		return true; 
	} 
		return false 
	} 
}


function checkOther(frmObj,frmRad,frmTxt) 
{
	var selectedButton = "";
	for (i=0; i<frmRad.length; i++)
		if (frmRad[i].checked == true)
			selectedButton = frmRad[i].name
	if (frmObj.name == selectedButton)
	{
		// the user clicked a button
		frmTxt.value = "";
	}
	else if (frmObj == frmTxt)
	{
		// the user has entered a text value
		for (i=0; i<frmRad.length; i++) 	
			frmRad[i].checked = false;
							
	}

}

//#############################################
// FORMAT CURRENCY
function moneyFormat(textObj)
{ 
            var newValue = textObj.value 
            var decAmount = "" 
            var dolAmount = "" 
            var decFlag = false 
            var aChar = "" 

		// ignore all but digits and decimal points 
            for (i=0; i < newValue.length; i++) { 
                        aChar = newValue.substring(i,i+1) 
                        if(aChar >= "0" && aChar <= "9") { 
                                    if(decFlag) { 
                                                decAmount = "" + decAmount + aChar 
                                    } 
                                    else { 
                                                dolAmount = "" + dolAmount + aChar 
                                    } 
                        } 
                        if(aChar == ".") { 
                                    if(decFlag) { 
                                                dolAmount = "" 
                                                break 
                                    } 
                                    decFlag=true 
                        } 
            } 
            // Ensure that at least a zero appears for the dollar amount. 
            if(dolAmount == "") { 
                        dolAmount = "0" 
            } 
            // Strip leading zeros. 
            if(dolAmount.length > 1) { 
                        while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") { 
                                    dolAmount = dolAmount.substring(1,dolAmount.length) 
                        } 
            } 
            // Round the decimal amount. 
            if(decAmount.length > 2) { 
                        if(decAmount.substring(2,3) > "4") { 
                                    decAmount = parseInt(decAmount.substring(0,2)) + 1 
                                                if(decAmount < 10) { 
                                                            decAmount = "0" + decAmount 
                                                } 
                                                else { 
                                                           decAmount = "" + decAmount 
                                                } 
                                    } 
                                    else { 
                                                decAmount = decAmount.substring(0,2) 
                                    } 
                                    if (decAmount == 100) { 
                                                decAmount = "00" 
                                                dolAmount = parseInt(dolAmount) + 1 
                                    } 
                        } 
                        // Pad right side of decAmount 
                        if(decAmount.length == 1) { 
                                    decAmount = decAmount + "0" 
                        } 
                        if(decAmount.length == 0) { 
                                    decAmount = decAmount + "00" 
                        } 
            // Check for negative values and reset textObj 
            if(newValue.substring(0,1) != '-' || (dolAmount == "0" && decAmount == "00")) { 
                        textObj.value = dolAmount + "." + decAmount 
            } 
            else{ 
                        textObj.value = '-' + dolAmount + "." + decAmount 
            } 
}
//#############################################