function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_displayStatusMsg(msgStr) { //v2.0
  status=msgStr;
  document.MM_returnValue = true;
}

function MM_goToURL() { //v2.0
  for (var i=0; i< (MM_goToURL.arguments.length - 1); i+=2) //with arg pairs
    eval(MM_goToURL.arguments[i]+".location='"+MM_goToURL.arguments[i+1]+"'");
  document.MM_returnValue = false;
}

function setStatus(msgStr) {
  status=msgStr;
}

function togglePrePaid(checkObj) {
  var myState = checkObj.checked
	 document.theForm.prepaidRadio[0].checked = myState;
	 document.theForm.preLimitChk.checked = myState;
		if (myState){
	  	document.theForm.prePaidFld.value = 1;
	  	document.theForm.preLimitFld.value = 100;
  } else {
	  	document.theForm.prePaidFld.value = "";
	  	document.theForm.preLimitFld.value = "";
		}
}

function emailCheck(emailFld, destination) {
  if (!emailFld.value) {
	   alert("Please enter an email address before clicking the 'Add' or 'Find' button.");
				return false
		} else {
				location.href = destination;
				return true
  }
}

function nameCheck(nameFld, emailFld, buttonObj, destination) {
  var button = buttonObj.value
		if (button == 'Find'){
		  if (!nameFld.value && !emailFld.value) {
			   alert("Please enter a partial name or email address before clicking the '" + button + "' button.");
	  	} else {
			  	location.href = destination;
			  	// return true
    }

		} else if (button == 'Create' || button == 'Add'){
				  if (!nameFld.value && !emailFld.value) {
			   alert("Please enter a name before clicking the '" + button + "' button. You can enter one or more email addresses before clicking the '" + button + "' button too.");
	    	} else if (!nameFld.value) {
			       alert("Please enter a name before clicking the '" + button + "' button.");
	    	} else if (!emailFld.value) {
			       alert("Please enter one or more email addresses before clicking the '" + button + "' button.");
	    	} else {

		    		location.href = destination;
		    		// return true
      }

		} else // we don't know. assume no errors.
				location.href = destination;
		  // return true
}


function folderCheck(folderFld, destination) {
  if (!folderFld.value) {
	   alert("Please enter a folder name before clicking the 'Create' or 'Find' button.");
				return false
		} else {
				location.href = destination;
				return true
  }
}

function toggleSelCheck(selCheckObj) {
		if (selCheckObj[0]) {
    var firstSelCheck = selCheckObj[0].checked;
	   for (var i=0; i < selCheckObj.length; i+=1){
	  	  selCheckObj[i].checked = !firstSelCheck;
    }
  } else{
		  selCheckObj.checked = !selCheckObj.checked;
		}
}

function moveTo(selObj, selCheckObj) {
  var selVal = selObj.options[selObj.selectedIndex].value;
		
	 var totChecks = 0;
		if (selCheckObj) {
	   for (var i=0; i < selCheckObj.length; i+=1){
	    	totChecks += (selCheckObj[i].checked);
	  	}
		} else {
  	 totChecks = 1;
		}

  if (selVal && totChecks) {
    location.href = selVal;
		} else if (!selVal && !totChecks) {
	   alert("Please check the box of the package(s) you would like to move, and select a folder to receive the package(s), before clicking the 'Move To' button.");
		} else if (!selVal) {
    alert("Please select a folder to move the checked packages to before clicking the 'Move To' button.");
		} else { // (!totChecks)
	   alert("Please check the box of the package(s) you would like to move before clicking the 'Move To' button.");
  }
}

function tidySel(selObj) {
  var selVal = selObj.options[selObj.selectedIndex].value;
  if (!selVal) {
    selObj.selectedIndex = 0;
  }
}


// Used by  GoToPageBox tag
function gotoPage(formName,boxField,pageField) {
	var page=document.forms[formName][boxField].value;
	var i;
	if (typeof page == 'string') {
		if (page == "") return;
		i=parseInt(page);
	} else i=page;

	if (isNaN(i) || (i<1 && i!=-1)) {
		alert("Invalid page number !");
		return;
	}

	document.forms[formName][pageField].value=i;	
	document.forms[formName].submit();
}

function openSmallWindow(theURL,winName) { 
  window.open(theURL,winName,"resizable=yes,width=640,height=410,scrollbars=yes");
}