function checkAll(theForm, cName, allNo_stat) {
	var n=theForm.elements.length;
	for (var i=0;i<n;i++){
		if (theForm.elements[i].className.indexOf(cName) !=-1){
			if (allNo_stat.checked) {
				theForm.elements[i].checked = true;
			} else {
				theForm.elements[i].checked = false;
			}
		}
	}
}

function go()
{
	box = document.forms[0].navi;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = destination;
}

/*POPUPS*/
/*
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
*/

function MM_openBrWindow(theURL,winName,w,h,scroll) { //v2.0
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(theURL,winName,winprops);
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

/*FROM PROCESSING*/
function Localize(pStr){return pStr;}
	var ProcessingText = Localize("Please While Processing...");
	var cnt=0;

function doValidate(f){
	f.BIN_button.value=ProcessingText;
	f.BIN_button.disabled=true;
	if (cnt==0)f.submit();
	cnt++;
	}
/*SELECT / DESELECT CHECKBOXES*/
function checkNum(obj,box){
	cCount=0
	for (i=0;i<obj.elements.length;i++)
		if ((obj.elements[i].type=='checkbox') && (obj.elements[i].checked) ) cCount+=1
		if ((box.checked) && (cCount > 50)){
		box.checked=false
		alert('Maximum allowed : 50')
	}
}
/*CALENDAR FUNCTIONS*/
var oldLink = null;
function setActiveStyleSheet(link, title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  if (oldLink) oldLink.style.fontWeight = 'normal';
  oldLink = link;
  link.style.fontWeight = 'bold';
  return false;
}

function selected(cal, date) {
  cal.sel.value = date;
  if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
    cal.callCloseHandler();
}

function closeHandler(cal) {
  cal.hide();
  _dynarch_popupCalendar = null;
}

//function showCalendar(id, format, showsTime, showsOtherMonths) {
function showCalendar(id, format,  showsOtherMonths) {
  var el = document.getElementById(id);
  if (_dynarch_popupCalendar != null) {
    _dynarch_popupCalendar.hide();
  } else {
    var cal = new Calendar(1, null, selected, closeHandler);
    if (typeof showsTime == "string") {
      cal.showsTime = true;
      cal.time24 = (showsTime == "24");
    }
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
    _dynarch_popupCalendar = cal;    // remember it in the global var
    cal.setRange(1900, 2150);        // min/max year allowed.
    cal.create();
  }
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use
  _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar
  return false;
}

var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;

function isDisabled(date) {
  var today = new Date();
  return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
}

function flatSelected(cal, date) {
  var el = document.getElementById("preview");
  el.innerHTML = date;
}

function showFlatCalendar() {
  var parent = document.getElementById("display");
  var cal = new Calendar(0, null, flatSelected);
  cal.weekNumbers = false;
  cal.setDisabledHandler(isDisabled);
  cal.setDateFormat("%A, %B %e");
  cal.create(parent);
  cal.show();
}

/*LOAD HTML EDITOR*/
/*
_editor_url = "../objects/htmlarea/";
_editor_lang = "en";
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
	document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
	document.write(' language="Javascript1.2"></scr' + 'ipt>');  
}else{ 
	document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>');
}
*/
/*SELECT / DESELECT CHECKBOXES*/
isSelected = false;
function toggleSelect() {
	if (isSelected == false) {
		for (i = 0; i < document.form.length; i++)
			document.form.elements[i].checked = true ;
			//document.write.selectdiv = "Select All";
			isSelected = true;
			return isSelected;
		}
	else {
		for (i = 0; i < document.form.length; i++)
			document.form.elements[i].checked = false ;
			//document.write.selectdiv = "Deselect All";
			isSelected = false;
			return isSelected;       
	}
}
/*SELECT / DESELECT CHECKBOXES*/
function HR (element) {
    newClassName="unChecked" 
     if (element.checked) { newClassName="Checked" }
    while (element.tagName.toUpperCase() != 'TR' && element != null)
        element = document.all ? element.parentElement : element.parentNode;
    element.className = newClassName
}

function CA (element)
{   
     for (var i=0;i<document.questions.elements.length;i++)
    {   
         var e = document.questions.elements[i];
        if (e.name != "allbox") {
          e.checked = document.questions.allbox.checked;
          HR(e) }
    }
}