<!--

var submitcount = 0;

function checkSubmitPayment() {
  if (submitcount == 0) {
    submitcount++;
    return true;
  } else {
    alert("Payment is already in progress.\n\nClick OK now and please wait for a response.");
    return false;
  }
}

function openPrintWindow(op_source, op_itemid) {
  // opens print window for input source and item
  //   input: op_source
  //     1 - Print Job
  //     2 - Print Resume
  //     3 - Print Locum CV
  ////////////////////////////

  switch (op_source) {
    case 1:
      openBrWindow("print.asp?action=viewjob&itemid="+op_itemid,"printJob","scrollbars=yes,width=600,height=600");
      break;
    case 2:
      openBrWindow("print.asp?action=viewresume&itemid="+op_itemid,"printResume","scrollbars=yes,menubar=yes,width=600,height=600");
      break;
    case 3:
      openBrWindow("print.asp?action=viewlocum&itemid="+op_itemid,"printLocum","scrollbars=yes,menubar=yes,width=600,height=600");
      break;
    default:
      break;
  }
}

function checkMaxDimensions(cm_source, cm_object) {
  // enforces maximum dimensions of client uploaded images
  // to avoid design degredation
  //   input: cm_source
  //     1 - Feature Employer
  ////////////////////////////

  switch (cm_source) {
    case 1:
      if (cm_object.width > 190) {
        cm_object.width = 190;
      }
      break;
    default:
      break;
  }

}

function openReceiptWindow(op_itemid) {
  // opens receipt window for input itemid
  openBrWindow("receipt.asp?itemid="+op_itemid,"receipt","scrollbars=yes,width=600,height=600");
}

function openInfoWindow(contentID) {
  // opens receipt window for input itemid
  openBrWindow("content.asp?contentID="+contentID,"info","scrollbars=yes,width=600,height=600");
}

function openTemplatePreview(ot_source, ot_itemid) {
  // opens template preview for input source and item
  //   input: op_source
  //     1 - Job
  //     2 - Resume
  ////////////////////////////

  switch (ot_source) {
    case 1:
      openBrWindow('template.asp?action=job&itemid=' + ot_itemid,'template','toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=480,height=400');
      break;
    case 2:
      openBrWindow('template.asp?action=resume&itemid=' + ot_itemid,'template','toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=800,height=600');
      break;
    default:
      break;
  }
}

function conf(type, label) {
  // displays confirmation message
  var msg;
  msg = "Are you sure you wish to ";
  switch (type) {
    case "del":
      msg += "remove"
      break;
    case "pro":
      msg += "process"
      break;
  }
  msg += " this " + label;
  return confirm(msg);
}

function radioCheck(ID, tf) {
  tf.cardType[ID].checked = true;
}
function radioCheck_single(tf) {
  tf.cardType.checked = true;
}

function openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function setInnerHtml(si_divid, si_val) {
  var si_div = document.getElementById(si_divid);
  si_div.innerHTML = si_val;
}

function locum_editItem(step, iData) {
  var frm = document.mainForm;
  var data = iData.split("|[]|"); // iData = id, data|[]|data etc
  frm.updateID.value = data[0];
  frm.submit_form_add.value = 'Update Item';


  if (step == 3) { // Education
    frm.completionYear.selectedIndex = locateIndex(frm.completionYear, data[1]);
    frm.degreeAttained.value = data[2];
    frm.institution.value = data[3];

  } else if (step == 4) { // Employment
    frm.startMonth.selectedIndex = locateIndex(frm.startMonth, data[1].split("/")[0]); // 5/2006
    frm.startYear.selectedIndex = locateIndex(frm.startYear, data[1].split("/")[1]); // 5/2006
    frm.endMonth.selectedIndex = locateIndex(frm.endMonth, data[2].split("/")[0]); // 5/2006
    frm.endYear.selectedIndex = locateIndex(frm.endYear, data[2].split("/")[1]); // 5/2006
    frm.company.value = data[3];

    var tmpData = data[4];
    tmpData = tmpData.replace("singleQuote", "'");

    frm.areasOfLegalPractice.value = tmpData;

  } else if (step == 5) { // Experience
    frm.experience.value = data[1];

  } else if (step == 6) { // Prev Locum
    frm.startDay.selectedIndex = locateIndex(frm.startDay, data[1].split("/")[0]); // 4/12/2006
    frm.startMonth.selectedIndex = locateIndex(frm.startMonth, data[1].split("/")[1]); // 4/12/2006
    frm.startYear.selectedIndex = locateIndex(frm.startYear, data[1].split("/")[2]); // 4/12/2006
    frm.endDay.selectedIndex = locateIndex(frm.endDay, data[2].split("/")[0]); // 4/12/2006
    frm.endMonth.selectedIndex = locateIndex(frm.endMonth, data[2].split("/")[1]); // 4/12/2006
    frm.endYear.selectedIndex = locateIndex(frm.endYear, data[2].split("/")[2]); // 4/12/2006
    frm.assignments.value = data[3];

  } else if (step == 7) { // Referees
    frm.firstName.value = data[1];
    frm.lastName.value = data[2];
    frm.firm.value = data[3];
    frm.refereePosition.value = data[4];
    frm.phone.value = data[5];

  } else if (step == 8) { // Availability
    frm.startDay.selectedIndex = locateIndex(frm.startDay, data[1].split("/")[0]); // 4/12/2006
    frm.startMonth.selectedIndex = locateIndex(frm.startMonth, data[1].split("/")[1]); // 4/12/2006
    frm.startYear.selectedIndex = locateIndex(frm.startYear, data[1].split("/")[2]); // 4/12/2006
    frm.endDay.selectedIndex = locateIndex(frm.endDay, data[2].split("/")[0]); // 4/12/2006
    frm.endMonth.selectedIndex = locateIndex(frm.endMonth, data[2].split("/")[1]); // 4/12/2006
    frm.endYear.selectedIndex = locateIndex(frm.endYear, data[2].split("/")[2]); // 4/12/2006

  }
}

function locateIndex(f, v) {
  for (i=0;i<f.length;i++) {
    if (f[i].value == v || (v == 'Current' && f[i].value == -1)) {
      return i;
    }
  }
  return -1;
}

function confirmAction(msg, cURL) {
  if (confirm(msg) == true) {
    document.location.href = cURL;
  }
}

function showHide(sh_id, sh_show) {
  var sh_elem = document.getElementById(sh_id);
  if (sh_elem) {
    if (sh_show) {
      sh_elem.style.display = 'block';
      sh_elem.style.visibility = 'visible';
    } else {
      sh_elem.style.display = 'none';
      sh_elem.style.visibility = 'hidden';
    }
  }
}

function isValid(string,allowed) {
  for (var i=0; i< string.length; i++) {
    if (allowed.indexOf(string.charAt(i)) == -1)
      return false;
    }
  return true;
}

function InStr(strSearch, charSearchFor) {
  for (i=0; i < strSearch.length; i++) {
    if (charSearchFor == mid(strSearch, i, 1)) {
      return i;
      }
  }
  return -1;
}

function mid(str, start, len) {
  // jump out if not within bounds of string
  if (start < 0 || len < 0) { return ""; }
  var midEnd, midLen = String(str).length;
  if (start + len > midLen) { midEnd = midLen; }
  else { midEnd = start + len; }
  return String(str).substring(start,midEnd);
}

function IsEmail(ie_str) {
  // validates email address for x@x.x

  var atFound = -1;var dotFound = -1;var charFound = false;var checkStr;var splitString

  checkStr = ie_str;

  splitString = checkStr.split("");
  for (var i = 0; i < checkStr.length+1; i++) {
    if (splitString[i] == "\"" | splitString[i] == "'") {
      return false;
    }
    if (splitString[i] < " " | splitString[i] > " ") { charFound = true; }
    if (splitString[i] == "@") { atFound = i; }
    if (splitString[i] == ".") { dotFound = i; }
  }
  if (charFound == true) {
    if (atFound > -1) {
      if (dotFound > -1) {
        if (dotFound < atFound) {
          return false;
        } else {
		  if ((dotFound-atFound) == 1 | dotFound == (checkStr.length-1) | atFound == 0) {
            return false;
          }
        }
      } else {
        return false;
      }
    } else {
      return false;
    }
  }
  return true;
}

function IsNumeric(sText, isNormalCurrency) {
  var in_charList = "0123456789.";
  var in_searchChar;
  if (isNormalCurrency == true) {
    in_searchChar = '.';
  } else {
    in_searchChar = ',';
    in_charList += ',';
  }
  var in_char;

  if (sText.length == 0) { return false; }

  for (i = 0; i < sText.length; i++) {
    in_char = sText.charAt(i);
    if (in_charList.indexOf(in_char) == -1) { return false; }
    if (in_char == in_searchChar) {
      if (sText.length == 1) { return false; }
      else { in_charList = "0123456789"; }
      }
    }
  return true;
}

function trimString (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function fileManager(p, frm, fld) {
window.open('loadWindow.asp?m=-1&p=' + escape(p) + '&frm=' + escape(frm) + '&fld=' + escape(fld),'loadWindow','status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=680,height=480');
}

function openEditor(mode, contentID, languageID, langUpdateAll, template) {
   wysiwygWin = window.open('loadWindow.asp?m=' + mode + '&i=' + contentID + '&j=' + languageID + '&language_updateAll=' + langUpdateAll + '&template=' + template,'loadWindow' + contentID + languageID,'toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=900,height=650');

}

function checkWYSIWYGPopup() {
  if (wysiwygWin == null) {
    alert('Your popup window blocker may be preventing the WYSIWYG editor from opening after you save.\n\nPlease launch the editor by clicking on \'WYSIWYG HTML Editor link.\'');
  }
}

function showPreview(cID, cMode) {
  window.open('loadWindow.asp?m=9&cID=' + escape(cID) + '&contentMode=' + escape(cMode),'loadWindow','status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=900,height=550');
}

function showTemplatePreview(tID) {
  window.open('loadWindow.asp?m=10&templateHistoryID=' + escape(tID),'loadWindow','status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=900,height=550');


}

function showtemplateCode(tID) {
  openBrWindow("templates_view.asp?templateHistoryID=" + tID, "prv", "toolbar=no,menubar=no,scrollbars=yes,resizable=true,width=900,height=550");
}


function urlFunction(mode, cID) {
  if (mode == 1) {
    setTimeout("urlFunction(11," + cID + ")", 250);
  } else if (mode == 11) {
    document.location.reload();

  } else if (mode == 2) {
    setTimeout("urlFunction(22, " + cID + ")", 250);

  } else if (mode == 22) {
    document.location.href='content_publish.asp?contentID=' + cID;
  }
}


function addOption(formElement, optiontext, optionValue) {
  var optionName = new Option(optiontext, optionValue, false, false)
  var length = formElement.length;
  formElement.options[length] = optionName;
}

function removeElement(array, itemNo) {
  size = array.length;
  validNo = (itemNo != "NaN");
  inRange = ( (itemNo >= 0) && (itemNo <= array.length) );
  if (validNo && inRange) {
    for (var i=0; i<=size; i++)
      array[i] = ((i == itemNo) ? "delete" : array[i]);
      for (var j=itemNo; j<size-1; j++)
      if (j != size) array[j] = array[j+1];
      array.length = size-1;
    return array
  }
  return array
}

function viewJob(jID) {
  window.open('../print.asp?action=viewjob&itemid=' + jID,'vj','status=no,toolbar=no,menubar=yes,scrollbars=yes,resizable=false,width=500,height=550');
}


function locumEndDate() {
  if (document.lForm.endDateU.checked == true) {
    document.lForm.endDay.disabled = true;
    document.lForm.endMonth.disabled = true;
    document.lForm.endYear.disabled = true;
  } else {
    document.lForm.endDay.disabled = false;
    document.lForm.endMonth.disabled = false;
    document.lForm.endYear.disabled = false;
  }
}


//-->
