<!--
//fixIE6flicker
(function(){ /*Use Object Detection to detect IE6*/ var m = document.uniqueID /*IE*/ && document.compatMode /*>=IE6*/ && !window.XMLHttpRequest /*<=IE6*/ && document.execCommand ; try{ if(!!m){ m("BackgroundImageCache", false, true) /* = IE6 only */ } }catch(oh){}; })();

function todaysDate(){
  var now = new Date();

  var month = now.getMonth() + 1;
  if (month < 10) { document.write("0"); }
  document.write(month + "/");

  var day = now.getDate();
  if (day < 10) { document.write("0"); }
  document.write(day + "/");

  document.write(now.getFullYear());
} // todaysDate


function newPopup(object){
	window.open(object.href,object.target,'width=640,height=480,resizable,menubar=no,scrollbars=yes');
	return false;
}

function widePopup(object){
	window.open(object.href,object.target,'width=820,height=480,resizable,menubar=no,scrollbars=yes');
	return false;
}


function getItem(id) {
	var itm = false;
	if (document.getElementById)
		itm = document.getElementById(id);
	else if (document.all)
		itm = document.all[id];
	else if (document.layers)
		itm = document.layers[id];
	return itm;
}

function showItem(id, state) {//show/hide
	itm = getItem(id);
	if (!itm)
		return false;
	if (state == 'show') {
		itm.style.display = '';
	} else {
		itm.style.display = 'none';
	}
}

function toggleItem(id, image) {
	itm = getItem(id);
	if (!itm)
		return false;
	if (itm.style.display == 'none') {
		itm.style.display = '';
		if(image)document.getElementById(image).src="../images/icon_sort_down.gif";
	} else {
		itm.style.display = 'none';
		if(image)document.getElementById(image).src="../images/icon_sort_up.gif";
	}
}


function checkAll(flag, formName){
	for(i=0;i<formName.elements.length;i++){
		if(formName.elements[i].type == 'checkbox'){
			formName.elements[i].checked = flag;
		}
	}
} // checkAll

function checkAllGroup(flag, formName, id){
	for(i=0;i<formName.elements.length;i++){
		if(formName.elements[i].type == 'checkbox' && formName.elements[i].name.indexOf(id)!=-1){
			formName.elements[i].checked = flag;
		}
	}
} // checkAll



function populateSelect(controlToPopulate, arr) {
	var x ;
	var currentlength = controlToPopulate.length;
	for (var i=0; i < currentlength; i++) {
		controlToPopulate.options[0] = null;
	}
	if(arr){
	
		for ( x=0; x < arr.length; x++ ) {
				controlToPopulate.options[x]= new Option(arr[x],arr[x]);
		}
	}
} // populateSelect








// BrowserCheck Object
function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.min = (this.ns||this.ie)
}
is = new BrowserCheck()

// This function should be called by the onkeypress event handler for
// date fields, e.g. <input type="text" name="myDate" onkeypress="return dateKeyPressed(this)"/>
function dateKeyPressed (input) {
  // This function only works for IE, so if the browser is not IE, we simply allow
  // the character entered to pass through
  if (!is.ie) { return true; }

  var keyTyped = String.fromCharCode(event.keyCode);

  // If the field value does not represent a valid date pattern,
  // we do not try to do anything intelligent
  if (!isValidMmDdYyyySoFar(input.value)) { return true; }

  if (keyTyped == "/") {
    // Prevent user from entering a double-slash
    if (input.value.length > 0 && "/" == input.value.charAt(input.value.length-1)) { return false; }
    if (input.value.length == 1) {
      // Automatically insert leading year 0
      input.value = "0" + input.value + "/";
      return false;
    }
    else if (input.value.length == 4) {
      // Automatically insert leading month 0
      input.value = input.value.substr(0, 3) + "0" + input.value.charAt(3) + "/";
      return false;
    }
  }

  // If the field value does not represent a valid date pattern
  // once the newest key is added, we do not try to do anything intelligent
  if (!isValidMmDdYyyySoFar(input.value + keyTyped)) { return true; }

  // If the length is 10 or more, we return true; without this, the value
  // will not clear if the user has the entire field selected & presses a key
  if (input.value.length > 9) { return true; }

  input.value += keyTyped;

  // Automatically insert a slash if we are at the appropriate position
  if (input.value.length == 2 || input.value.length == 5) {
    input.value += "/";
  }

  // Prepend first two digits of year if it appears that the user is entering
  // the year in two digit form
  if (input.value.length == 8) {
    var yearPrefix = "";
    if ("3456789".indexOf(input.value.charAt(6)) > -1) {
      yearPrefix = "19";
    }
    else if ("012".indexOf(input.value.charAt(6)) > -1) {
      yearPrefix = "20";
    }
    input.value = input.value.substr(0, 6) + yearPrefix + input.value.substr(6, 2);
  }

  return false;
}

var validDatePattern = ["\\d", "\\d", "\\/", "\\d", "\\d", "\\/", "\\d", "\\d", "\\d", "\\d"];
// Returns true if the supplied value matches a MM/dd/yyyy pattern or a subset of
// that pattern
function isValidMmDdYyyySoFar (value) {
  if (value.length == 0) { return true; }
  var patternString = "^";
  for (var i=0; i < value.length; i++) {
    patternString += validDatePattern[i];
  }
  var expr = new RegExp(patternString);
  return expr.test(value);
}

//end date key scripts


function enable(fieldName) {
	if(fieldName.disabled){
		fieldName.disabled=false;
	}else{
		fieldName.readOnly=false;
	}
	fieldName.className = null;
} // enable
function disable(fieldName) {
	if(!fieldName.disabled){
		fieldName.disabled=true;
	}else{
		fieldName.readOnly=true;
	}
	fieldName.className = 'disable';
} // disable


function iFrameHeight() {
	if(document.getElementById && !(document.all)) {
		h = document.getElementById('reportiframe').contentDocument.body.scrollHeight;
		document.getElementById('reportiframe').style.height = h;
	}
	else if(document.all) {
		h = document.frames('reportiframe').document.body.scrollHeight;
		document.all.reportiframe.style.height = h;
	}
}

function selectField(field){
	field.focus();
	field.select();
}



function showSubItem(taskName,arrPos){
	try{
		var subItemArr = eval("subItem" + taskName);
		if(subItemArr)
		for (var x=0; x<subItemArr.length;x++){
			 if (x==arrPos){
				 showItem(subItemArr[x],'show');
			 }else{
				 showItem(subItemArr[x],'hide');
			 }
		}
	}catch (e) {}
}


//-->
