function valRequired(obj, msg) {
	var retVal = true;

	if (obj==null) {
		alert(msg)
		
		return true;
	}

	if (obj.type == "text" || obj.type == "textarea") {
		if (obj.value.length == 0) {
			if (msg!="") {
				alert("Please enter a value for the " + msg + " field.");
				obj.focus();
			}
			retVal = false;
		}
	} else if (obj.type == "select-one" || obj.type == "select-multiple") {
		if (obj.options[obj.selectedIndex].value == "NONE" || obj.options[obj.selectedIndex].value == "" || obj.selectedIndex==0) {
			if (msg!="") {
				alert("Please pick one of the options for the " + msg + " field.");
				obj.focus();
			}
			retVal = false;
		}
	} else if (obj[0] && typeof(obj) != "string") {
		var noneChecked = true;
		for (var i = 0; i < obj.length; i++) {
			if (obj[i].checked)
				noneChecked = false;
		}
		if (noneChecked) {
			if (msg!="") {
				alert("Please pick at least one of the answers to " + msg + ".");
				obj[0].focus();
			}
			retVal = false;
		}
	} else if (obj.type == "checkbox") {
		if (obj.checked==false) {
			if (msg!="") {
				alert("Please pick at least one of the answers to " + msg + ".");
				obj.focus();
			}
			
			retVal = false;
		}
	} 
	
	return retVal;
}


// General functions - Often useful

// Finds an object in a page by name - cross browser compatible
function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

// Shows or hides a layer - also cross browser compatible
function MM_showHideLayers() { //v6.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 MM_openBrWindow(theURL,winName,features) { //v2.0       
   eval(winName + "=window.open(theURL,winName,features);");
   eval(winName + ".focus();");
}

function setSelectedText(o, val) {
	var i
	
	for (i=0;i<o.length;i++) {
		if (o.options[i].text.toLowerCase()==val.toLowerCase()) {
			o.options[i].selected=true;
			
			break;
		}
	}
}

function isint(s) {   
	var i;
	for (i = 0; i < s.length; i++) {
		// Check that current character is number.
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
	}
	
	return true; // All characters are numbers.
}

function getSelectedText(sender) {
	return MM_findObj(sender).options[MM_findObj(sender).selectedIndex].text;
}


function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedValue(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return buttonGroup[i].value;
         }
      }
   } else {
      if (buttonGroup.checked) { return buttonGroup.value; } // if the one button is checked, return zero
   }

   return "";
}

function setSelectedList(sender, sValue) {
	for (var i=0;i<sender.length;i++) {
		if (sender[i].value==sValue) {
			sender[i].selected=true;
		}
	}
	
}

function formatCurrency(strValue)
{
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}

function resetRadioGroup(radioGroup) {
	if (typeof(radioGroup)=="string") {
		// if string name only specified, then convert to radio obj
		radioGroup=MM_findObj(radioGroup);
	}
	
	if (radioGroup[0]) { // radio group
		for (var i=0;i < radioGroup.length;i++) {
			radioGroup[i].checked = false; 
		}
	} else { // stand alone radio button
		radioGroup.checked=false;
	}
}

function disableRadioGroup(radioGroup) {
	if (typeof(radioGroup)=="string") {
		// if string name only specified, then convert to radio obj
		radioGroup=MM_findObj(radioGroup);
	}
	
	if (radioGroup[0]) { // radio group
		for (var i=0;i < radioGroup.length;i++) {
			radioGroup[i].disabled = true; 
		}
	} else { // stand alone radio button
		radioGroup.disabled=true;
	}
}

function enableRadioGroup(radioGroup) {
	if (typeof(radioGroup)=="string") {
		// if string name only specified, then convert to radio obj
		radioGroup=MM_findObj(radioGroup);
	}
	
	if (radioGroup[0]) { // radio group
		for (var i=0;i < radioGroup.length;i++) {
			radioGroup[i].disabled = false; 
		}
	} else { // stand alone radio button
		radioGroup.disabled=false;
	}
}

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function DisablingBackFunctionality()
{
	var URL;
	var i ;
	var QryStrValue;
	URL=window.location.href ;
	i=URL.indexOf("?");
	QryStrValue=URL.substring(i+1);
	if (QryStrValue!='X')
	{
	window.location=URL + "?X";
	}
}