glbl_numeric = '1234567890';
glbl_alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
glbl_specialChar = '-._';
glbl_alphanumeric = glbl_alpha + glbl_numeric;
glbl_permissibleString = glbl_alphanumeric + glbl_specialChar;

//Server
glbl_root = urlDomain(location.href)+'/';
glbl_admin_root = 'https://www.investingwithinsight.com/';

//Development
//glbl_root = 'http://localhost/investingwithinsight/';
//glbl_admin_root = 'http://localhost/investingwithinsight/';


function urlDomain(url)
{
  prefix = url.substring(0,5);
  switch (prefix)
  {
    case 'http:':
      prefixStripped = url.substring(7);
      fullPrefix = 'http://';
      break;

    case 'https':
      prefixStripped = url.substring(8);
      fullPrefix = 'https://';
      break;

    default:
      prefixStripped = url;
      fullPrefix = 'http://';
      break;
  }

  firstSlash = prefixStripped.indexOf('/');
  domain = fullPrefix + (prefixStripped.substring(0,firstSlash));
  return domain;
}



function permitOnly (permissibleString, haystack)
{
  aryHaystack = haystack.split('');
  returnInt = true;

  for (x = 0; x < aryHaystack.length; x++)
  {
    tmpIndex = permissibleString.indexOf(aryHaystack[x]);
    if (tmpIndex == -1)
    {
      returnInt = false;
      break;
    }
  }
  return returnInt;
}



function strlen(str)
{
  return str.legnth;
}


function iv_parseInt(stringNumber)
{
  raw = stripLeadingZero(stringNumber);
  switch (raw)
  {
    case '8':
      parsedNumber = 8;
      break;
    case '9':
      parsedNumber = 9;
      break;
    default:
      parsedNumber = parseInt(raw);
      break;
  }
  return parsedNumber;
}



function stripLeadingZero(stringNumber)
{
  for (x = 0; x < stringNumber.length; x++)
  {
    if (stringNumber.charAt(x) != '0')
    {
      break;
    }
  }
  noZeroNumber = stringNumber.substring(x);
  return noZeroNumber;
}



function str_replace(needle, newNeedle, haystack)
{
  maxLoop = haystack.length;
  newNeedleLength = newNeedle.length;
  needleLength = needle.length;

  x = 0;

  proceed = true

  while (proceed)
  {
    //if this is the needle we're looking for...
    if (haystack.substring(x, (x + needleLength)) == needle)
    {
      //get the substring before this character (watch out for the first character)
      if (x == 0)
      {
        preString = '';
      }
      else
      {
        preString = haystack.substring(0, x);
      }

      //get the substring after this character (watch out for the last character
      if (x == (haystack.length - needleLength))
      {
        postString = '';
      }
      else
      {
        postString = haystack.substring(x + needleLength);
      }

      //build new haystack
      haystack = preString + newNeedle + postString;

      x = x + newNeedleLength;

      //if the newNeedle is 0 characters long, the haystack is shorter, so run the search for charAt(x) again
      if (newNeedleLength == 0)
      {
        if (x != 0)
        {
          x = x - 1;
        }
      }
    }

    //Move along
    x = x + 1;

    //if we're shortened the haystack so that the new length is less than the original, and we're at the end of the new, then break.
    if (haystack.length < x)
    {
      proceed = false;
    }
    else
    {
      proceed = true;
    }

  }

  //return the new haystack
  return haystack;
}



function trim(sString)
{
  //alert(sString);
  trimString = lTrim(rTrim(sString));
  return trimString;
}



function rTrim(sString)
{
  while (sString.substring(sString.length-1, sString.length) == ' ')
  {
    sString = sString.substring(0,sString.length-1);
  }
  return sString;
}



function lTrim(sString)
{
  while (sString.substring(0,1) == ' ')
  {
    sString = sString.substring(1, sString.length);
  }
  return sString;
}



function strtolower(str)
{
  return str.toLowerCase();
}



function strtoupper(str)
{
  return str.toUpperCase();
}



function findDropDownText(dropDownObject, lookForText)
{
  textFound = -1;

  targetText = lookForText.toLowerCase();

  dropDownLength = dropDownObject.length;

  for (x = 0; x < dropDownLength; x++)
  {
    currentText = dropDownObject[x].text;
    arrowText = currentText.toLowerCase();

    if (arrowText == targetText)
    {
      textFound = x;
      break;
    }
  }

  return textFound;
}



function enDisRadio(radioObject, clickedValue, thisForm, targetObjectPrefix) //(rdoTest, 'cats', 'document.frmTest', 'slt')
{
  //get number of elements in object
  objectLength = radioObject.length;
  //alert (objectLength);
  for (x = 0; x < objectLength; x++)
  {
    thisRadioValue = radioObject[x].value;
    changeObject = eval(thisForm+"."+targetObjectPrefix+thisRadioValue);
    //alert(changeObject);

    if (radioObject[x].value == clickedValue)
    {
      changeObject.disabled = false;
    }
    else
    {
      changeObject.disabled = true;
    }
  }
}





function clearMultipleSelect(obj)
{
  objLength = obj.length;
  for (x = 0; x < objLength; x++)
  {
    obj[x].selected = false;
  }
}





function getMultipleSelect(obj)
{
  optCount = obj.length;
  selectedIDs = '';
  selectedCount = 0;
  for (x = 0; x < optCount; x++)
  {
    if (obj.options[x].selected == true)
    {
      selectedIDs = selectedIDs + obj.options[x].value + ',';
      selectedCount = selectedCount + 1;
    }
  }
  if (selectedCount > 0)
  {
    selectedIDs = selectedIDs.substring(0, (selectedIDs.length - 1));
  }
  else
  {
    selectedIDs = 'noSelection';
  }
  //alert(selectedIDs);
  return selectedIDs;
}






function refreshPage()
{
  location.reload(true);
}






function checkTextLength(thisObject, targetID, maxLength) //use onKeyUp event for this function
{
  currText = thisObject.value;
  textLength = currText.length;
  charMsg = maxLength - textLength;
  if (charMsg >= 0)
  {
    document.getElementById(targetID).innerHTML = charMsg;
  }
  else
  {
    thisObject.value = currText.substring(0, maxLength);
    textLength = thisObject.value.length;
    charMsg = maxLength - textLength;
    document.getElementById(targetID).innerHTML = charMsg;
    alert('The input data is only permitted to be '+maxLength+' characters in length\n\nThe input data has been reduced to '+maxLength+' characters');
  }
}







function showSuccess(changeType)
{
  showNothing = 0;
  switch (changeType)
  {
    case 'loginFail':
      successMsg = 'The username and password entered is not recognized by the database\n\n'+
                   'Please try again, or contact the systems administrator for assistance';
      break;

    case 'dbScs':
      successMsg = 'The database has been successfully updated';
      break;

    case 'fail':
      successMsg = 'The requested operation failed';
      break;

    case 'unUse':
      successMsg = 'The person record WAS NOT saved\n\n'+
                   'The username is currently is use by another person';
      break;

    case 'notFound':
      successMsg = 'The page you are looking for was not found in The Revolution\n\n'+
                   'Please report this to the system administrator';
      break;

    case 'addrConf_CSZ':
      successMsg = 'The address WAS NOT saved\n\n'+
                   'The city / state / zip combination was not found in the database\n'+
                   'Please double check the city, state, and zip entered, and\n'+
                   'after confirming that they are correct, please click "Confirm"';
      break;

    case 'addrAbort_SZ':
      successMsg = 'The address WAS NOT saved\n\n'+
                   'The state was not found in the database and/or the zip-code is not a valid format\n\n'+
                   'Please contact the system administrator';
      break;

    default:
      showNothing = 1;
      break;
  }
  if (showNothing == 0)
  {
    alert (successMsg);
  }
}




function findDropDownValue(dropDownObject, lookForValue)
{
  valueFound = -1;

  targetValue = lookForValue.toLowerCase();

  dropDownLength = dropDownObject.length;

  for (x = 0; x < dropDownLength; x++)
  {
    currentValue = dropDownObject[x].value;
    arrowValue = currentValue.toLowerCase();

    if (arrowValue == targetValue)
    {
      valueFound = x;
      break;
    }
  }

  return valueFound;
}



function getOut()
{
  window.location = 'logout.php';
}




function makeDateFromInt(intDate, showTime)
{
  var aryWeekday = new Array(7);
  aryWeekday[0] = "Sunday";
  aryWeekday[1] = "Monday";
  aryWeekday[2] = "Tuesday";
  aryWeekday[3] = "Wednesday";
  aryWeekday[4] = "Thursday";
  aryWeekday[5] = "Friday";
  aryWeekday[6] = "Saturday";

  var aryMonth = new Array(12);
  aryMonth[0]  = "January";
  aryMonth[1]  = "February";
  aryMonth[2]  = "March";
  aryMonth[3]  = "April";
  aryMonth[4]  = "May";
  aryMonth[5]  = "June";
  aryMonth[6]  = "July";
  aryMonth[7]  = "August";
  aryMonth[8]  = "September";
  aryMonth[9]  = "October";
  aryMonth[10] = "November";
  aryMonth[11] = "December";

  var aryHour = new Array(24);
  aryHour[0] = "12";
  aryHour[1] = "1";
  aryHour[2] = "2";
  aryHour[3] = "3";
  aryHour[4] = "4";
  aryHour[5] = "5";
  aryHour[6] = "6";
  aryHour[7] = "7";
  aryHour[8] = "8";
  aryHour[9] = "9";
  aryHour[10] = "10";
  aryHour[11] = "11";
  aryHour[12] = "12";
  aryHour[13] = "1";
  aryHour[14] = "2";
  aryHour[15] = "3";
  aryHour[16] = "4";
  aryHour[17] = "5";
  aryHour[18] = "6";
  aryHour[19] = "7";
  aryHour[20] = "8";
  aryHour[21] = "9";
  aryHour[22] = "10";
  aryHour[23] = "11";

  var aryAmPm = new Array(24);
  aryAmPm[0] = "am";
  aryAmPm[1] = "am";
  aryAmPm[2] = "am";
  aryAmPm[3] = "am";
  aryAmPm[4] = "am";
  aryAmPm[5] = "am";
  aryAmPm[6] = "am";
  aryAmPm[7] = "am";
  aryAmPm[8] = "am";
  aryAmPm[9] = "am";
  aryAmPm[10] = "am";
  aryAmPm[11] = "am";
  aryAmPm[12] = "pm";
  aryAmPm[13] = "pm";
  aryAmPm[14] = "pm";
  aryAmPm[15] = "pm";
  aryAmPm[16] = "pm";
  aryAmPm[17] = "pm";
  aryAmPm[18] = "pm";
  aryAmPm[19] = "pm";
  aryAmPm[20] = "pm";
  aryAmPm[21] = "pm";
  aryAmPm[22] = "pm";
  aryAmPm[23] = "pm";



  year = parseInt(intDate.substring(0, 4));
  month = intDate.substring(4, 6);
  day = intDate.substring(6, 8);
  hour = intDate.substring(8, 10);
  minute = intDate.substring(10, 12);

  //alert ('hour = '+hour+'; minute = '+minute);

  intYear = parseInt(year);
  intMonth = iv_parseInt(month) - 1;
  intDay = iv_parseInt(day);

  if (intDate.substring(8, 10) == '00')
  {
    intHour = 0;
  }
  else
  {
    intHour = iv_parseInt(intDate.substring(8, 10));
  }

  var jsDate = new Date();
  jsDate.setFullYear(intYear, intMonth, intDay);
  strDate = aryWeekday[jsDate.getDay()]+', '+aryMonth[jsDate.getMonth()]+' '+intDay+', '+year;

  if (showTime == 1)
  {
    strDate = aryHour[intHour]+':'+minute+''+aryAmPm[intHour]+', '+strDate;
  }
  return strDate;
}




function makeSQLDate(intDate)
{
  sqlDate = intDate.substring(0,4)+'-'+intDate.substring(4,6)+'-'+intDate.substring(6,8)+' '+intDate.substring(8,10)+':'+intDate.substring(10,12)+':00';
  //alert (sqlDate);
  return sqlDate;
}





function makeIntDateFromHTML(strHour, strMinute, strAmPm)
{
  if (strAmPm == 'pm')
  {
    switch (strHour)
    {
      case '08':
        strHour = '20';
        break;

      case '09':
        strHour = '21';
        break;

      case '12':
        strHour = '12';
        break;

      default:
        strHour = parseInt(strHour) + 12;
        break;
    }
  }
  else
  {
    if (strHour == '12')
    {
      strHour = '00';
    }
  }
  strTime = strHour+''+strMinute+'00';
  return strTime;
}




function makeIntFromSQLDate(sqlDate)
{
  if (sqlDate.length > 16)
  {
    intYear = sqlDate.substring(0,4);
    intMonth = sqlDate.substring(5,7);
    intDay = sqlDate.substring(8,10);
    intHour = sqlDate.substring(11,13);
    intMinute = sqlDate.substring(14,16);
    intDate = intYear+''+intMonth+''+intDay+''+intHour+''+intMinute;
  }
  else
  {
    intDate = -1;
  }
  //alert('From '+sqlDate+' to '+intDate);
  return intDate;
}




function setNow(now, target, dateVersion)
{
  switch (dateVersion)
  {
    case 2:
      intDate = makeIntFromSQLDate(now);
      currentTime = makeDateFromInt(intDate, 1);
      break;

    case 1:
    default:
      currentTime = now;
      break;
  }
  targetElement = eval(target);
  targetElement.value = currentTime;
}





function getForm(formName, cmd)
{
  formName.cmd.value = cmd;
  formName.submit();
}




function selectRadioOption(objForm, radioName, radioIndex)
{
  //alert(objForm);

  formName = objForm;//.name;
  thisRadio = eval(formName+'.'+radioName);
  for (x = 0; x < thisRadio.length; x++)
  {
    if (x == radioIndex)
    {
      thisRadio[x].checked = true;
      //alert('index['+x+'] is checked');
    }
    else
    {
      thisRadio[x].checked = false;
      //alert('index['+x+'] is NOT checked');
    }
  }
}




function openCalendar(dateField, sqlDate, showTime)
{
  day = new Date();
  id = day.getTime();
  URL = glbl_root+'inc/popupcalendar.php?opid='+dateField+'&shwtm='+showTime;
  if ((trim(sqlDate) != '-1') && (trim(sqlDate) != '') && (trim(sqlDate) != 'NULL'))
  {
    URL = URL + '&dte='+(sqlDate.substring(0,4))+''+(sqlDate.substring(5,7))+''+(sqlDate.substring(8,10))+''+(sqlDate.substring(11,13))+''+(sqlDate.substring(14,16))+''+(sqlDate.substring(17,19));
  }
  if (showTime == 1)
  {
    ppHeight = '635';
  }
  else
  {
    ppHeight = '580';
  }
  //alert(URL);
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height="+ppHeight+",left=25,top=25');");
  //window.open(URL);
}

function openAdminCalendar(dateField, sqlDate, showTime)
{
  day = new Date();
  id = day.getTime();
  URL = glbl_admin_root+'inc/popupcalendar.php?opid='+dateField+'&shwtm='+showTime;
  if ((trim(sqlDate) != '-1') && (trim(sqlDate) != '') && (trim(sqlDate) != 'NULL'))
  {
    URL = URL + '&dte='+(sqlDate.substring(0,4))+''+(sqlDate.substring(5,7))+''+(sqlDate.substring(8,10))+''+(sqlDate.substring(11,13))+''+(sqlDate.substring(14,16))+''+(sqlDate.substring(17,19));
  }
  if (showTime == 1)
  {
    ppHeight = '635';
  }
  else
  {
    ppHeight = '580';
  }
  //alert(URL);
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height="+ppHeight+",left=25,top=25');");
  //window.open(URL);
}



function openURL(theURL, windowWidth, windowHeight)
{
  day = new Date();
  id = day.getTime();
  //alert(theURL);
  eval("page" + id + " = window.open(theURL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="+windowWidth+",height="+windowHeight+"');");
  //window.open(theURL);
}


function openMCOption(questionID)
{
  openURL('pup_mcoption.php?q='+questionID, 500, 160);
}



function openState()
{
  openURL(glbl_root+'pup/pup_statelist.php', 730, 400);
}




function openCity(stateAbbrev)
{
  openURL(glbl_root+'pup/pup_citylist.php?stt='+stateAbbrev, 900, 600);
}



function findLocation(cityID)
{
  openURL(glbl_root+'pup_location.php?cid='+cityID, 900, 600);
}


function pickFollowUp(newThread)
{
  document.frmMain.action = 'revelationentry.php?n='+newThread;
  document.frmMain.submit();
}


function newPost(newThread)
{
  document.frmMain.action = 'forumthread.php?n='+newThread;
  document.frmMain.submit();
}


function newGeneralPost(newThread, fID)
{
  document.frmMain.action = 'forumthread.php?n='+newThread+'&f='+fID;
  document.frmMain.submit();
}


function openProfile(personID)
{
  openURL(glbl_root+'profile.php?perID='+personID, 960, 600);
}


function openPostKeyword(keywordID)
{
  openURL(glbl_root+'pup_postkeyword.php?k='+keywordID, 330, 180);
}


function openPostView(postID)
{
  openURL(glbl_root+'pup_postview.php?p='+postID, 750, 350);
}


function openPostScripture()
{
  openURL(glbl_root+'pup_postscripture.php', 830, 400);
}

function openAdminPostScripture()
{
  openURL(glbl_admin_root+'pup_postscripture.php', 830, 400);
}

function openLookupScripture(fromVerseID, toVerseID, canEdit)
{
  openURL(glbl_root+'pup_postscripture.php?cmd=lookup&fvid='+fromVerseID+'&tvid='+toVerseID+'&edt='+canEdit, 830, 400);
}


function openAvatarUpload(personID)
{
  if (personID > 0)
  {
    avatarWindow = glbl_root+'pup_avatarupload.php?p='+personID;
  }
  else
  {
    avatarWindow = glbl_root+'pup_avatarupload.php';
  }
  openURL(avatarWindow, 500, 315);
}

function viewBlog(blogID)
{
  openURL(glbl_root+'pup_viewblog.php?b='+blogID, 750, 700);
}

function openCreateBlog()
{
  openURL(glbl_root+'pup_newblog.php', 415, 500);
}

function openEditBlog(blogID)
{
  openURL(glbl_root+'pup_newblog.php?cmd=edit&b='+blogID, 500, 670);
}

function openProfileImageUpload()
{
  openURL(glbl_root+'pup_profileupload.php', 500, 315);
}

function openForumImageUpload()
{
  openURL(glbl_root+'pup_imageupload.php', 470, 540);
}

function openGeneralForumImageUpload(fID)
{
  //alert(fID);
  openURL(glbl_root+'pup_imageupload.php?f='+fID, 430, 400);
}

function openPostImage(postID)
{
  openURL(glbl_root+'pup_postimage.php?p='+postID, 930, 400);
}

function editLG(lgID,cmd)
{
  openURL(glbl_root+'pup_logistic.php?cmd='+cmd+'&lg='+lgID, 600, 500);
}

function openGeneralPostImage(postID, fID)
{
  openURL(glbl_root+'pup_postimage.php?p='+postID+'&f='+fID, 930, 400);
}


function openTermsOfUse()
{
  openURL(glbl_root+'termsofuse.php', 910, 600);
}


function openPrivacyPolicy()
{
  openURL(glbl_root+'privacypolicy.php', 910, 600);
}


function openAuthor(authorID)
{
  openURL(glbl_root+'pup_author.php?a='+authorID, 750, 550);
}


function openCompany(companyID)
{
  openURL(glbl_root+'pup_company.php?c='+companyID, 750, 550);
}


function openPersonSelector()
{
  openURL(glbl_root+'pup_personselector.php', 800, 600);
}


function openSource(sourceID)
{
  openURL(glbl_root+'pup_source.php', 750, 500);
}


function openFileUpload(dir)
{
  openURL(glbl_root+'pup_fileupload.php?d='+dir, 750, 500);
}


function openDocload(resourceID, optStr)
{
  openURL(glbl_root+'pup_docload.php?r='+resourceID+'&'+optStr, 700, 500);
}


function openPupCart()
{
  openURL(glbl_root+'pup_cart.php', 900, 600);
}


function openPupReceiptList(personID)
{
  //alert('here');
  openURL(glbl_root+'pup_personreceipt.php?p='+personID, 600, 400);
}


function openImageBrowser(dir)
{
  //alert(type);
  openURL(glbl_root+'pup_imgbrowse.php?d='+dir, 700, 500);
}


function openCompanyArticle(companyIDList)
{
  openURL(glbl_root+'pup_company.php?cmd=multi&cl='+companyIDList, 700, 500);
}


function openSubscriptionResource(srID, releaseDate)
{
  openURL(glbl_root+'pup_subscriptionresource.php?cmd=edt&sr='+srID+'&rd='+releaseDate, 700, 500);
}


function openPersonCCInfo(personID)
{
  openURL(glbl_root+'pup_personccinfo.php?p='+personID, 700, 250);
}


function openShippingAddress(receiptID)
{
  openURL(glbl_root+'pup_shippingaddress.php?r='+receiptID, 400, 500);
}


function openTax(personID)
{
  openURL(glbl_root+'pup_tax.php?p='+personID, 400, 215);
}


function openShipping(cmd,id)
{
  openURL(glbl_root+'pup_shipping.php?cmd='+cmd+'&id='+id, 500, 300);
}


function openReceipt(receiptID)
{
  openURL(glbl_root+'pup_receipt.php?cmd=view&r='+receiptID, 700, 500);
}


function openFulfillmentNote(cmd,receiptID)
{
  openURL(glbl_root+'pup_fulfillmentnote.php?cmd='+cmd+'&r='+receiptID, 600, 280);
}


function openARB(idType,targetID)
{
  openURL(glbl_root+'pup_arb.php?type='+idType+'&id='+targetID, 800, 500);
}


function openImportData(dataImportID)
{
  openURL(glbl_root+'pup_dataimport.php?di='+dataImportID, 700, 500);
}


function openPackagePricing()
{
  openURL(glbl_root+'pup_packagepricing.php', 730, 400);
}


function openTemplate(articleTypeID, articleID)
{
  //alert('here');
  if ((articleTypeID > 0) || (articleID > 0))
  {
    openURL(glbl_root+'admin/pup_articletemplate.php?at='+articleTypeID+'&a='+articleID, 800, 500);
  }
  else
  {
    alert('Insufficient information was provided to proceed with the template');
  }
}


function pressEnter(executeString)
{
  if (event.keyCode==13)
  {
    eval(executeString);
  }
}


function checkScreenName(exception, current)
{
  if (exception.length > 5)
  {
    openURL(glbl_root+'pup_screennamecheck.php?e='+exception+'&c='+current, 415, 200);
  }
  else
  {
    alert('This function has been called incorrectly');
  }
}



function validEmail(email)
{
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
  {
    return 1;
  }
  else
  {
    return 0;
  }
}



function pageNavigation_x(goToPage)
{
  //alert(goToPage);
  document.frmMain.pageListNumber.value = goToPage;
  //alert(document.frmMain.pageListNumber.value);
  document.frmMain.submit();
}


/*
//Test function for later (submitting a form to a popup)
function sendMe(personID)
{
  document.frmMain.personID.value = personID;
  window.open("pup_addraed.php","","width=500,height=300,toolbar=0");
  var a = window.setTimeout("document.form1.submit();",500);
}
*/


function sltElementDisplay(showMe, target)
{
  switch (showMe)
  {
    case 1:
    case 'block':
      document.getElementById(target).style.display = 'block';
      break;

    case 2:
    case 'inline':
      document.getElementById(target).style.display = 'none';
      break;

    case 'none':
    default:
      document.getElementById(target).style.display = 'none';
      break;
  }
}


function elementDisplay(showMe, target)
{
  if (showMe == true)
  {
    document.getElementById(target).style.display = 'block';
  }
  else
  {
    document.getElementById(target).style.display = 'none';
  }
}


function showHideSpan(target, showType)
{
  if (document.getElementById(target).style.display == 'none')
  {
    document.getElementById(target).style.display = showType;
  }
  else
  {
    document.getElementById(target).style.display = 'none';
  }
}



function reverseElementDisplay(showMe, target)
{
  if (showMe == true)
  {
    elementDisplay(false, target);
  }
  else
  {
    elementDisplay(true, target);
  }
}



function checkCountry(countryID)
{
  country = iv_parseInt(countryID);
  switch (country)
  {
    case 1:
      elementDisplay(true,'USA_State');
      elementDisplay(false,'Canada_State');
      elementDisplay(false,'Other_State');
      break;

    case 34:
      elementDisplay(false,'USA_State');
      elementDisplay(true,'Canada_State');
      elementDisplay(false,'Other_State');
      break;

    default:
      elementDisplay(false,'USA_State');
      elementDisplay(false,'Canada_State');
      elementDisplay(true,'Other_State');
      break;
  }
}



function alphaNumeric(stringValue, fieldName, showMsg)
{
  cleanString = permitOnly(glbl_permissibleString, stringValue);
  if ((showMsg == 1) && (!(cleanString)))
  {
    alert('The '+fieldName+' can only contain alpha-numeric characters, periods ("."), dashes ("-"), or underscores ("_")');
  }
  return cleanString;
}



function validateUsername(username, showMsg)
{
  if ((alphaNumeric(username,'username',0) == 1) && (username.length >= 5) && (username.length < 51))
  {
    return 1;
  }
  else
  {
    if (showMsg == 1)
    {
      alert('The username must:\n'+
            '\n1) Contain only alpha-numeric characters, periods ("."), dashes ("-"), or underscores ("_")'+
            '\n2) Be between 5 to 50 characters in length');
    }
    return 0;
  }
}



function validatePassword(password, showMsg)
{
  if ((alphaNumeric(password,'password',0) == 1) && (password.length >= 5) && (password.length < 21))
  {
    return 1;
  }
  else
  {
    if (showMsg == 1)
    {
      alert('The password must:\n'+
            '\n1) Contain only alpha-numeric characters, periods ("."), dashes ("-"), or underscores ("_")'+
            '\n2) Be between 5 to 20 characters in length');
    }
    return 0;
  }
}




function numericOnly(fieldValue, showMsg)
{
  cleanString = permitOnly(glbl_numeric, fieldValue);
  if ((!(cleanString)) && (showMsg == 1))
  {
    alert('This data field can only contain numeric characters (0-9)');
  }
  return cleanString;
}


function resizeWindow(curWindow, width, height)
{
    curWindow.resizeTo(width, height);
}


function enableDisable_X(target)
{
  obj = eval("document.frmMain."+target);
  if (obj.disabled)
  {
    obj.disabled = false;
  }
  else
  {
    obj.disabled = true;
  }
}
