function showPopup(url, name, initSettings, width, height) {    var winSettings = initSettings;    if(width != -1) {        var winL = (screen.width - width) / 2;        winSettings += ',left=' + winL + ',screenX=' + winL;    }    if(height != -1) {        var winT = (screen.height - height) / 2;        winSettings += ',top=' + winT + ',screenY=' + winT;    }    return window.open(url, name, winSettings);}function isBlank(field, label) {    if(field.value=="") {	alert("Don't forget to enter all required information. Enter '" + label + "' please...");	field.focus();    	return true;    }else	return false;}function swapIcon(imageName, newImageUrl) {    if(document.images) {        document.images[imageName].src = newImageUrl;    }}function lengthCheck(field, minLength, label) {    if(field.value.length < minLength) {	alert("'" + label + "' must be at least " + minLength + " characters long ...");	field.focus();    	return false;    }else	return true;}function isNumber(field, label) {    numbers="0123456789";    for(i=0; i<field.value.length; i++) {	if(numbers.indexOf(field.value.charAt(i)) == -1) {	  alert("'" + label + "' must be a numeric value ...");	  field.focus();    	  return false;	  	}    }    return true;}function isNumberInRange(field, minVal, maxVal, label) {   if(!isNumber(field, label)) return false;   if((field.value-0)<minVal || (field.value-0)>maxVal) {     alert("'" + label + "' value must be between " + minVal + " and " + maxVal + " ...");     field.focus();     return false;	     }}function isAlphaNumeric(field, label) {    alphas="0123456789abcdefghijklmnopqrstuvxwyzABCDEFGHIJKLMNOPQRSTUVXWYZ";    for(i=0; i<field.value.length; i++) {	if(alphas.indexOf(field.value.charAt(i)) == -1) {	  alert("'" + label + "' must be an alphanumeric value ...");	  field.focus();    	  return false;	  	}    }    return true;}function containsInvalidChars(invalidChars, field) {    return containsInvalidCharsString(invalidChars, field.value)}function containsInvalidCharsString(invalidChars, svalue) {    for(i=0; i<svalue.length; i++) {	if(invalidChars.indexOf(svalue.charAt(i)) != -1) {    	  return true;	  	}    }    return false;}function isValidEmail(field, label) {    if(!isValidEmailString(field.value)) {        alert("Please enter a valid '" + label + "' ...");        field.focus();        return false;	      }    return true;}function isValidEmailString(email){   invalidChars="[]|?\",;~`!#$^&*()=<>/\\+{}: ";   requiredChars="@.";   if(email.length < 6 || containsInvalidCharsString(invalidChars, email) || 		!containsInvalidCharsString(requiredChars, email)) {      return false;	     }   ixat=email.indexOf('@');				// @ index   ixdot=email.lastIndexOf('.');			// . index from the end   ixat2=email.substring(ixat+1).indexOf('@');		// a second @  --> invalid email   if(ixat<1 || ixat2!=-1 || ixdot<ixat || (ixdot==email.length-1)) {				// must contain a . after @      return false;	     }   return true;}function isValidUrl(field, label) {   invalidChars="[]\"`*()'\\: ";   requiredChars=".";   if(field.value.length < 6 || containsInvalidChars(invalidChars, field) || 		!containsInvalidChars(requiredChars, field)) {      alert("Please enter a valid '" + label + "' ...");      field.focus();      return false;	     }   return true;}function getCheckedAsString(cbox) {  var selCount=0;  var cboxStr="";  if(!cbox) {    num = 0;  }else {    num = cbox.length;  }  if (cbox && !num) {    if(cbox.checked) {        cboxStr="-1," + cbox.value + ",-1";    }  }else if(num) {    for(i=0; i<num; i++) {        if(cbox[i].checked) {            if(selCount==0) cboxStr="-1,";            cboxStr = cboxStr + cbox[i].value + ",";            selCount++;        }    }    if(selCount>0) cboxStr = cboxStr + "-1";  }  return cboxStr;}function getUnCheckedAsString(cbox) {  var selCount=0;  var cboxStr="";  if(!cbox) {    num = 0;  }else {    num = cbox.length;  }  if (cbox && !num) {    if(!cbox.checked) {        cboxStr="-1," + cbox.value + ",-1";    }  }else if(num) {    for(i=0; i<num; i++) {        if(!cbox[i].checked) {            if(selCount==0) cboxStr="-1,";            cboxStr = cboxStr + cbox[i].value + ",";            selCount++;        }    }    if(selCount>0) cboxStr = cboxStr + "-1";  }  return cboxStr;}function checkboxToString(cbox) {  var selCount=0;  var cboxStr="";  if(!cbox) {    num = 0;  }else {    num = cbox.length;  }  if (cbox && !num) {    if(cbox.checked) {        cboxStr="-1," + cbox.value + ",-1";    }  }else if(num) {    for(i=0; i<num; i++) {        if(cbox[i].checked) {            if(selCount==0) cboxStr="-1,";            cboxStr = cboxStr + cbox[i].value + ",";            selCount++;        }    }    if(selCount>0) cboxStr = cboxStr + "-1";  }  return cboxStr;}function deselectAll(cbox) {  if(!cbox) {    num = 0;  }else {    num = cbox.length;  }  if (cbox && !num) {    cbox.checked = false;  }else if(num) {    for (i=0; i < num; i++) {      cbox[i].checked = false;    }  }}function selectAll(cbox) {  if (!cbox)  {    num = 0;  }else {    num = cbox.length;  }  if(cbox && !num) {    cbox.checked = true;       // only 1 checkbox on the page.  }else if (num) {    for (i=0; i < num; i++) {      cbox[i].checked = true;    }  }}function getBrowser() {    var OS,browser;   var detect = navigator.userAgent.toUpperCase();     //if(detect.indexOf('KONQUEROR') >= 0) {    //        browser = "KONQUEROR";    //        OS = "Linux";    //}else if(detect.indexOf('SAFARI') >= 0) browser = "SAFARI";    //else if(detect.indexOf('OMNIWEB') >= 0) browser = "OMNIWEB";    //else if(detect.indexOf('OPERA') >= 0) browser = "OPERA";    //else if(detect.indexOf('WEBTV') >= 0) browser = "WEBTV";    //else if(detect.indexOf('ICAB') >= 0) browser = "ICAB";    if(detect.indexOf('SAFARI') >= 0) browser = "SAFARI";    else if(detect.indexOf('MSIE') >= 0) browser = "MSIE";    else if(detect.indexOf('Firefox') >= 0) browser = "FIREFOX";    else if(detect.indexOf('COMPATIBLE') < 0) browser = "NAVIGATOR";    else browser = "NOTSUPPORTED";    if(!OS) {	if(detect.indexOf('LINUX') >= 0) OS = "LINUX";	else if(detect.indexOf('X11') >= 0) OS = "UNIX";	else if(detect.indexOf('MAC') >= 0) OS = "MAC"	else if(detect.indexOf('WIN') >= 0) OS = "WINDWOS"	else OS = "NOTSUPPORTED";    }    return browser + " " + OS;}function popupMsg(msg) {   alert(msg);}function trim(value){    //trim whitespaces at the end of the string    var ch = value.substring(value.length-1, value.length);    while (ch == " "){        value = value.substring(0, value.length-1);        ch = value.substring(value.length-1, value.length);    }    //trim whitespaces at the beginning of the string    ch = value.substring(0,1);    while (ch == " "){        value = value.substring(1, value.length);        ch = value.substring(0,1);    }        return value;}