// JavaScript Document
function switchCountry(){
 location.href=document.forms.frmCountry.selectCountry.value;
}
function switchAction(act){
 document.forms[0].action = 'index.cfm?action=' + act;
 return true;
}
function switchActionSubmit(act){
 document.forms[0].action = 'index.cfm?action=' + act;
 document.forms[0].submit();
 return true;
}
function switchLocation(act){
 location.href = 'index.cfm?action=' + act;
 return true;
}
function helpWindow(url){
 helpWin = window.open(url, 'helpWindow','scrollbars=yes,resizable=yes,toolbar=no,height=450,width=400');
 if(window.focus){ helpWin.focus(); }
}
function smallWindow(url){
 smallWin = window.open(url, 'smallWindow','scrollbars=yes,resizable=yes,toolbar=no,height=500,width=475');
 if(window.focus){ smallWin.focus(); }
}
function forceForward(){
 history.forward(+1);
}
function setAssocOptions(changedSel, assocSel, changedToAssoc, assocText){
 var changedValue = changedSel.options[changedSel.selectedIndex].value;//value of changed select
 if (changedValue != null){
  if (changedValue != ""){
   assocSel.disabled = false;
   var optionValues = changedToAssoc[changedValue];//lookup list of associated option values for value of changed select
  } else{
   assocSel.disabled = true;
   optionValues = "";
  }//end not empty if
  setOptions(assocSel, optionValues, assocText);
 }//end not null if
}//end function
function setOptions(select, optionValues, optionText, selectValue){
 select.options.length = 1;//clears the existing options except label
 var j = 0;
 for (var i=0; i < optionValues.length; i++){//build options
  j = i + 1;//increment option counter - since we always leave default 'select a whatever' message in list
  select.options[j] = new Option(optionText[optionValues[i]],optionValues[i]);
  if (selectValue != null && selectValue == select.options[j].value){//if the previous selected value is still in list preserve the selection
   select.options[j].selected = true;
  }//end previous selected value if
 }//end option loop
}
function isWhite(ch){
 //utility method to determine if a character in a string is whitespace / blank
 var white;
  white = " \t\n\r";
 return (white.indexOf(ch) != -1);
}
function disableControl(controlId){
 //controlId is a space delimited list of form control id(s) -
 //each control passed in should have a unique "id" attribute within their tag (should be same value as name tag)
 var items, count, index;
  items = [];
  count = 0;
  doAction = new String();
 while (controlId != ""){
  index = 0;
  while (index < controlId.length && isWhite(controlId.charAt(index))){
   index++;
  }
  if (index < controlId.length){
   var item = "";
   while (index < controlId.length && !isWhite(controlId.charAt(index))){
    item += controlId.charAt(index);
    index++;
   }
   items[count] = item
   count++;
  }
  controlId = controlId.substring(index+1, controlId.length);
  document.getElementById(item).disabled = true;
 }
 return items;
}
function enableControl(controlId){
 //controlId is a space delimited list of form control id(s) -
 //each control passed in should have a unique "id" attribute within their tag (should be same value as name tag)
 var items, count, index;
  items = [];
  count = 0;
 while (controlId != ""){
  index = 0;
  while (index < controlId.length && isWhite(controlId.charAt(index))){
   index++;
  }
  if (index < controlId.length){
   var item = "";
   while (index < controlId.length && !isWhite(controlId.charAt(index))){
    item += controlId.charAt(index);
    index++;
   }
   items[count] = item
   count++;
  }
  controlId = controlId.substring(index+1, controlId.length);
  document.getElementById(item).disabled = false;
 }
 return items;
}
function openWin(winurl,winname,w,h,features){ //link values: URL,Name,Width,Height,Features
 var win = null;
 var winl = (screen.width-w)/2;
 var wint = (screen.height-h)/2;
 if (winl < 0) winl = 0;
 if (wint < 0) wint = 0;
 var settings = 'height=' + h + ',';
 settings += 'width=' + w + ',';
 settings += 'top=' + wint + ',';
 settings += 'left=' + winl + ',';
 settings += features; //Features are: resizable,scrollbars,status,toolbar
 win = window.open(winurl,winname,settings);
 win.window.focus();
}
function setSubmitFocus(e,form,act,target){
 var key=e.keyCode || e.which;
 if (key==13){
  form.target = target;
  document.forms[0].action = 'index.cfm?action=' + act;
  document.forms[0].submit();
  return true;
 }
}
function setSubmitFocusExplicit(e,frmName,act,target){
 var key=e.keyCode || e.which;
 if (key==13){
  document[frmName].target = target;
  document[frmName].action = 'index.cfm?action=' + act;
  document[frmName].submit();
  return true;
 }
}
function setInputFocus(formName,formField){
 var myAction = 'document.' + formName + ' . ' + formField + ' . ' + ' focus();';
 eval(myAction);
}
function printFrame(frameName){
 frames[frameName].focus();
 frames[frameName].print();
}
function switchActionSubmitExplicit(frmName,act){
 document[frmName].action = 'index.cfm?action=' + act;
 document[frmName].submit();
 return true;
}
function redirectLocation(locUrl){
 location.href = locUrl;
 return true;
}
function outboundSubmitExplicit(frmName,act){
 document[frmName].action = act;
 document[frmName].submit();
 return true;
}
function setAssocLists(optIdx,tarObj,jsList,jsDel){
 var jsListArr = new Array(1);
 jsListArr = jsList.split(jsDel);
 tarObj.value = jsListArr[optIdx];
}
function changeValue(isChecked,sourceElement,targetElement){
 targetElement.value = "";
 if (isChecked){
  targetElement.value = sourceElement.value;
 }
}
function anchorNoResubmit (formIDName,anchorIDName) {
 if (document.getElementById) {
  var clickedOnce = 1;
  document.getElementById(anchorIDName).onclick = function() {
  if (clickedOnce==1) {
   return false;
  }
  clickedOnce=1;
  document.getElementById(formIDName).submit();
  };
 }
}
function changeValueLists(isChecked,srcForm,targetFormList,srcFieldName,targetFieldName){
 var items, count, index;
 items = [];
 count = 0;
 while (targetFormList != ""){
  index = 0;
  while (index < targetFormList.length && isWhite(targetFormList.charAt(index))){
   index++;
  }
  if (index < targetFormList.length){
   var item = "";
   while (index < targetFormList.length && !isWhite(targetFormList.charAt(index))){
    item += targetFormList.charAt(index);
    index++;
   }
   items[count] = item;
   count++;
  }
  targetFormList = targetFormList.substring(index+1, targetFormList.length);
  if(isChecked != "" || isChecked){
   document.forms[item][targetFieldName].value = document.forms[srcForm][srcFieldName].value;
  }
 }
 return items;
}
function Login(form) {
 var username = form.username.value;
 var password = form.password.value;
 var server = form.server.value;
 if (username && password) {
  var htsite=server+"?UserName="+username+"&PassWord="+password;
  window.location=htsite;
 }
 else {
  alert("Please enter your username and password.");
 }
}

