<!--
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_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_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 MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}


function display_img(src, name, width, height, infotext) {
    hWnd = window.open(src, name, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + width + ',height=' + height);
    hWnd.document.write('<html><head>');
    hWnd.document.write('<title>' + infotext + '</title>');
    hWnd.document.write('<LINK rel="stylesheet" href="styles.css" type="text/css">');
    hWnd.document.write('</head><body>');
    hWnd.document.write('<a href="javascript:window.close()" style="color: #003399">');
    hWnd.document.write('<img src="' + src + '" border="0" alt="click the image to close this window..." />');

    hWnd.document.write('</a>');
    hWnd.document.write('</body></html>');

  hWnd.document.close();
}

function send_form_once(formptr, btn, btnCaption, btnClass) {
  var result = 0;
  if (! form_submitted) {
    form_submitted = 1;
        btn.className = btnClass;
        btn.value = btnCaption;
        btn.disabled = true;
    formptr.submit();
    result = 1;
  }
  return result;
}

//###############################################

function noenter() {
  if (event.keyCode == 13) { event.returnValue = false;}
}

//###############################################

function make_float(amount) {
  amount = amount*100;
  amount = amount/100;
  return amount.toFixed(2);
}

//###############################################

function validDigits(fieldname) {
//document.write(event.keyCode);
  if (!(event.keyCode >= 48 && event.keyCode <= 57)) { event.returnValue = false;}

}

//###############################################

function validFloat(fieldname) {
//document.write(event.keyCode);
  if (!(event.keyCode >= 48 && event.keyCode <= 57 || event.keyCode==46)) { event.returnValue = false;}

}

//###############################################
function setCheckboxes(the_form, do_check, elementname) {
    var items_to_delete = document.forms[the_form].elements[elementname+'[]'];
    var items_to_delete_num = items_to_delete.length;

  if (items_to_delete_num) {
    for (var i = 0; i < items_to_delete_num; i++) {
      items_to_delete[i].checked = do_check;
    } // end for
  } else {
    items_to_delete.checked = do_check;
  }

    return true;
} // end of the 'setCheckboxes()' function

function operateCheckBoxes(e, the_form, elementname) {
//  alert(document.forms[the_form].elements[obj].checked);
//  alert(obj);
  if (e.checked) {
    setCheckboxes(the_form, true, elementname); 
    return false;
  } else {
    setCheckboxes(the_form, false, elementname);
    return false;
  }
}


//###############################################
function checked_num(the_form, elementname) {
    var items_to_check = document.forms[the_form].elements[elementname+'[]'];
    var items_to_check_num = items_to_check.length;

  var num_checked=0;

  if (items_to_check_num) {
    for (var i = 0; i < items_to_check_num; i++) {
      if (items_to_check[i].checked) {
        num_checked=num_checked+1;
      }
    } // end for
  } else if (items_to_check) {
    num_checked = items_to_check.checked;
  }
  
  return num_checked;
}

function confirmDelete(formname, elementname) {
    if (checked_num(formname, elementname) == 0) {
        alert('Please select items to delete!');
        return false;
    } else {
        return confirm('Are you sure you want to delete the selected items?\nATTENTION you will lose all the information for this section!!!');
    } 
}

function openwin(filename) {
  params='width='+750+',height='+580+',left=10,top=10,menubar=no,scrollbars=yes,resizable=no';
  newWin = window.open(filename, 'nextstep', params);
}

function opensizedwin(filename, width, height) {
  params='width='+width+',height='+height+',left=5,top=5,menubar=no,scrollbars=yes,resizable=no';
//  params='width='+width+',height='+height+',left=10,top=10,menubar=yes,scrollbars=yes,resizable=yes, status=yes';
  newWin = window.open(filename, 'nextstep', params);
}

function openresizablewin(filename, width, height) {
  params='width='+width+',height='+height+',left=5,top=5,toolbar=yes,scrollbars=yes,resizable=yes,status=yes';
  newWin = window.open(filename, 'nextstep', params);
}

function openresizable(filename, width, height) {
  params='width='+width+',height='+height+',left=5,top=5,toolbar=no,scrollbars=yes,resizable=yes,status=yes';
  newWin = window.open(filename, 'nextstep', params);
}

function helpWin(filename, width, height) {
  params='width='+width+',height='+height+',left=10,top=10,menubar=no,scrollbars=yes,resizable=yes';
  newWin = window.open(filename, 'help', params);
  newWin.focus();
}


function addamount(paybox, amount) {
    acc = parseFloat(paybox.form.amount.value);
    if (paybox.checked) {
        acc = acc + amount;
    } else {
        acc = acc - amount;
    }

    if (paybox.form.amount.value < 0) {
        acc = 0;
    }
    paybox.form.amount.value = acc.toFixed(2);
}


function deleteElements(formname) {
    var the_form = document.forms[formname];
    if (confirmDelete(the_form.name, 'items')) {
        the_form.submit();
        return true;
    } else {
        return false;
    }
}

function show_hide_layer(element_name) {
  var today = new Date()
  var expires = new Date()
  expires.setTime(today.getTime() + 60*60*24*365)

  element = document.getElementById(element_name);
  style = "none";

  if (element) {
    if (element.style.display == "none") {
      element.style.display = "inline";
      document.cookie = element_name + "_state=1; expires=" + expires.toGMTString();
    } else {
      element.style.display = "none";
      document.cookie = element_name + "_state=0; expires=" + expires.toGMTString();
    }
  }

  return true;
}
function swap_menu_image(image_name, element_name) {
  image = document.getElementById(image_name);
  element = document.getElementById(element_name);
  if (element) {
    if (element.style.display == "none") {
      image.src = "images/" + image_name + "_expand_off.jpg";
    } else {
      image.src = "images/" + image_name + "_collapse_off.jpg";
    }
  }

  return true;
}

function swap_step_button(step, action) {
  btn = document.getElementById('btn_step' + step);
  lnk = document.getElementById('lnk_step' + step);
  if (action == "on") {
    btn.src='images/step'+step+'_on.jpg';
    lnk.className='menulink_hov';
  } else {
    btn.src='images/step'+step+'_off.jpg';
    lnk.className='menulink';
  }

  return true;
}

function preload_images() {
  var d=document; if(d.images){ if(!d._p) d._p=new Array();
    var i,j=d._p.length,a=preload_images.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d._p[j]=new Image; d._p[j++].src=a[i];}}
}

function highlight_comment(id, flag) {
  var classSuffix = flag ? '_hl' : '';
  var element = document.getElementById('question' + id);
  element.className = 'question' + classSuffix;

  element = document.getElementById('answer' + id);
  element.className = 'answer' + classSuffix;

  element = document.getElementById('question_username' + id);
  element.className = 'question_username' + classSuffix;

  element = document.getElementById('question_date' + id);
  element.className = 'question_date' + classSuffix;

  return false;
}

function expand_faq(id) {
  if (document.getElementById('faq'+id).style.display == 'block')
  {
    document.getElementById('faq'+id).style.display='none';
  } else {
    document.getElementById('faq'+id).style.display='block';
  }
}

function expand_all_faq(count) {
  var i=0
  for (i=1;i<=count;i++)
  {
    if (document.getElementById('faq'+i).style.display == 'none')
    {
      document.getElementById('faq'+i).style.display='block';
    } else {
      document.getElementById('faq'+i).style.display='block';
    }
  }
  document.getElementById('href_expand').style.display='none';
  document.getElementById('href_collapse').style.display='block';
}

function collapse_all_faq(count) {
  var i=0
  for (i=1;i<=count;i++)
  {
    if (document.getElementById('faq'+i).style.display == 'block')
    {
      document.getElementById('faq'+i).style.display='none';
    } else {
      document.getElementById('faq'+i).style.display='none';
    }
  }
  document.getElementById('href_expand').style.display='block';
  document.getElementById('href_collapse').style.display='none';
}

function underline_faq(id) {
  document.getElementById('title_faq'+id).style.textDecoration='underline';
}
function underline_faq_no(id) {
  document.getElementById('title_faq'+id).style.textDecoration='none';
}
//-->
