function OpenPopupWindow(url, wname, w, h) {	
	OpenPopupWindow(url, wname, w, h, 0, 0);
}
function OpenPopupWindow(url, wname, w, h, scrollable, resizable){
	OpenPopupWindow(url, wname, w, h, scrollable, resizable, 0, 0, 0, 0, 0);
}
function OpenPopupWindow(url, wname, w, h, scrollable, resizable, toolbar, location, directories, status, menubar) {		
	if(navigator.appName == "Netscape"){
		w = w + 20;
		h = h + 50;
	}
	var newwindow = window.open(url, wname,
							   'toolbar='+toolbar+',location='+location+',directories='+directories+',status='+status+',menubar='+menubar+',scrollbars='+scrollable+',resizable='+resizable+',width='+w+',height='+h);
    if (window.focus) {
		newwindow.focus()
    }
	newwindow.moveTo(screen.availWidth/2-(w/2),screen.availHeight/2-(h/2));
}
function ReloadParent(){	
	opener.location.reload(true);
	self.close();
}
function RedirectParent(url){		
	opener.location.href = url;	
	setTimeout("self.close()",1250);		
	//self.close();
}

function IsValidEmail(emailStr) {
    var emailPat=/^(.+)@(.+)$/
    var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
    var validChars="\[^\\s" + specialChars + "\]"
    var quotedUser="(\"[^\"]*\")"
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
    var atom=validChars + '+'
    var word="(" + atom + "|" + quotedUser + ")"
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

    var matchArray=emailStr.match(emailPat)
    if (matchArray==null) {
          return false;
    }

    var user=matchArray[1]
    var domain=matchArray[2]

    if (user.match(userPat)==null) {
      return false;
    }

    var IPArray=domain.match(ipDomainPat)
    if (IPArray!=null) {
          for (var i=1;i<=4;i++) {
            if (IPArray[i]>255) {
              return false;
            }
      }
      return true;
    }

    var domainArray=domain.match(domainPat);
    if (domainArray==null) {
      return false;
    }

    var atomPat=new RegExp(atom,"g");
    var domArr=domain.match(atomPat);
    var len=domArr.length;

    if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
      return false;
    }

    if (len<2) {
      return false;
    }

    return true;
}
function transferFrom(source, dest) {	
    var f, s, d, i, xx;
    f = document.forms[0];
    s = findControl(f, source);
    d = findControl(f, dest);
    for (i = s.options.length-1; i >= 0; i--) {
        if (s.options[i].selected) {
            xx = new Option();
            xx.value = s.options[i].value;
            xx.text = s.options[i].text;
            d.options[d.options.length] = xx;
            s.options[i] = null;
        }
    }
    sortList(d);
}
function findControl(f, s) {
    var i;
    for (i = 0; i < f.length; i++) {
        if (f[i].name == s) {
            return f[i];
        }
    }
    return null;
}
function sortList(d){
    var i, j;
    for (i = 0; i < d.options.length - 1; i++) {
        for (j = i+1; j < d.options.length; j++) {
            if (d.options[i].text > d.options[j].text) {
                t1 = d.options[i].text;
                t2 = d.options[i].value;
                d.options[i].text = d.options[j].text;
                d.options[i].value = d.options[j].value;
                d.options[j].text = t1;
                d.options[j].value = t2;
            }
        }
    }
}
function SelectAllFromList(objName) {
    f = document.forms[0];
    z = findControl(f, objName);
    for (i = 0; i < z.options.length; i++) {
        z.options[i].selected = true;
    }	    
}
function GetSelectedRadioItem(radioObj){		
	return GetSelectedRadioValue(radioObj);
}
function GetSelectedRadio(buttonGroup) {   
	if (buttonGroup[0]) { 
		for (var i=0; i<buttonGroup.length; i++) {
			if (buttonGroup[i].checked) {
            return i
			}
		}
	} else {
		if (buttonGroup.checked) { return 0; } 
	}   
	return -1;
} 
function GetSelectedRadioValue(buttonGroup) {   
	var i = GetSelectedRadio(buttonGroup);
	if (i == -1) {
		return "";
	} else {
		if (buttonGroup[i]) { 
			return buttonGroup[i].value;
		} else { 
			return buttonGroup.value;
		}
	}
}
function getSelectedCheckbox(buttonGroup) {
   // Go through all the check boxes. return an array of all the ones
   // that are selected (their position numbers). if no boxes were checked,
   // returned array will be empty (length will be zero)
   var retArr = new Array();
   var lastElement = 0;
   if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            retArr.length = lastElement;
            retArr[lastElement] = i;
            lastElement++;
         }
      }
   } else { // There is only one check box (it's not an array)
      if (buttonGroup.checked) { // if the one check box is checked
         retArr.length = lastElement;
         retArr[lastElement] = 0; // return zero as the only array value
      }
   }
   return retArr;
} // Ends the "getSelectedCheckbox" function
function getSelectedCheckboxValue(buttonGroup) {
   // return an array of values selected in the check box group. if no boxes
   // were checked, returned array will be empty (length will be zero)
   var retArr = new Array(); // set up empty array for the return values
   var selectedItems = getSelectedCheckbox(buttonGroup);
   if (selectedItems.length != 0) { // if there was something selected
      retArr.length = selectedItems.length;
      for (var i=0; i<selectedItems.length; i++) {
         if (buttonGroup[selectedItems[i]]) { // Make sure it's an array
            retArr[i] = buttonGroup[selectedItems[i]].value;
         } else { // It's not an array (there's just one check box and it's selected)
            retArr[i] = buttonGroup.value;// return that value
         }
      }
   }
   return retArr;
} // Ends the "getSelectedCheckBoxValue" function
function IsInteger(field) {
    var valid = "0123456789"
    var ok = "yes";
    var temp;
    for (var i=0; i<field.value.length; i++) {
        temp = "" + field.value.substring(i, i+1);
        if (valid.indexOf(temp) == "-1") ok = "no";
    }    
    return (ok != "no");
}
function getSelectedCheckboxNew(thisForm, objName){
    param = "";    
    for (i = 0; i < thisForm.elements.length; i++) {
        if ((thisForm.elements[i].name == objName) && (thisForm.elements[i].type == "checkbox")
            && (thisForm.elements[i].checked)) {
            if (param != "") param = param + ",";
            param = param + thisForm.elements[i].value;
        }
    }	
    return param;
}
//added by Brian	[07.25.08]
function getInputtedText(thisForm, objName){
    param = "";
    for (i = 0; i < thisForm.elements.length; i++) {
        if ((thisForm.elements[i].name == objName) && (thisForm.elements[i].type == "text")
            && (thisForm.elements[i].value>0)) {
            if (param != "") param = param + ",";
            param = param + thisForm.elements[i].value;
        }
    }	
    return param;
}
