var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var ns6 = ns5;
var ns6_1= (ns5 && navigator.userAgent.indexOf("6.1") != -1) ? true : false;
var ns6_2= (ns5 && navigator.userAgent.indexOf("6.2") != -1) ? true : false;
var ie6 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ns6 && !ns6_1 && !ns6_2 && !ie4 && !ie5 && !ie6) ? true : false;
if (nodyn) { event = "nope" }
var tooltip;
var off_x = 8; var off_y = 8;
function dT(evt,txt,txg,xxt) {
var line;
if (xxt=='0') { line = " "; }
if (xxt=='1') { line = "<hr style=\"color: #000000; width:192px;\">"; }
if (xxt=='2') { line = "<br>"; }
var tip;
if (ns4) {
tip = '<TABLE BGCOLOR="#000000" WIDTH="200" CELLSPACING="0" CELLPADDING="1" BORDER="1"><TR><TD><TABLE BGCOLOR="#E3CD9A" WIDTH="100%" CELLSPACING="0" CELLPADDING="3" BORDER="0"><TR><TD CLASS="tip">'+ '<font face=Arial color=black size=2>' + txt + '</font>' + line + '<font face=Arial color=black size=2>' + txg +'</font></TD></TR></TABLE></TD></TR></TABLE>';
tooltip = document.tipDiv;
tooltip.document.write(tip);
tooltip.document.close();
if ((evt.pageX + off_x + tooltip.clip.width) > (window.innerWidth + window.pageXOffset)) {
tooltip.left = evt.pageX - tooltip.clip.width;
} else { tooltip.left = evt.pageX + off_x; }
if ((evt.pageY + off_y + tooltip.clip.height) > (window.innerHeight + window.pageYOffset)) {
tooltip.top = evt.pageY - tooltip.clip.height;
} else { tooltip.top = evt.pageY + off_y; }
tooltip.visibility = "show";
}
if (ie4 || ie5 || ie6) {
evt = window.event;
tip = '<DIV CLASS="tp">' + txt + line + txg + '</DIV>';
tooltip = document.all.tipDiv;
tooltip.innerHTML = tip;
if ((evt.clientX + off_x + tooltip.style.pixelWidth) > (document.body.clientWidth)) {
tooltip.style.pixelLeft = (evt.clientX + document.body.scrollLeft) - tooltip.style.pixelWidth;
} else { tooltip.style.pixelLeft = evt.clientX + off_x + document.body.scrollLeft; }
if ((evt.clientY+off_y+tooltip.clientHeight) > (document.body.clientHeight)) {
tooltip.style.pixelTop = (evt.clientY + document.body.scrollTop) - tooltip.clientHeight;
} else { tooltip.style.pixelTop = evt.clientY + off_y + document.body.scrollTop; }
tooltip.style.visibility = "visible";
}
if (ns5 || ns6 || ns6_1 || ns6_2) {
tip = '<DIV CLASS="tp">' + txt + line + txg + '</DIV>';
tooltip = document.getElementById('tipDiv');
tooltip.innerHTML = tip;
if ((evt.pageX + off_x + tooltip.offsetWidth) > (window.innerWidth + window.pageXOffset)) {
tooltip.style.left = evt.pageX - tooltip.offsetWidth;
} else { tooltip.style.left = evt.pageX + off_x; }
if ((evt.pageY + off_y + tooltip.offsetHeight) > (window.innerHeight + window.pageYOffset)) {
tooltip.style.top = evt.pageY - tooltip.offsetHeight;
} else { tooltip.style.top = evt.pageY + off_y; }
tooltip.style.visibility = "visible"; }
}
function hT() {
if (ns4) { tooltip.visibility = "hide" }
if (ie4 || ie5 || ie6 || ns5 || ns6 || ns6_1 || ns6_2) {tooltip.style.visibility = "hidden"}
}

function IsValidDate(DateToCheck, FormatString) {
  var strDateToCheck;
  var strDateToCheckArray;
  var strFormatArray;
  var strFormatString;
  var strDay;
  var strMonth;
  var strYear;
  var intday;
  var intMonth;
  var intYear;
  var intDateSeparatorIdx = -1;
  var intFormatSeparatorIdx = -1;
  var strSeparatorArray = new Array("-"," ","/",".");
  var strMonthArray = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
  var intDaysArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

  strDateToCheck = DateToCheck.toLowerCase();
  strFormatString = FormatString.toLowerCase();
  
  if (strDateToCheck.length != strFormatString.length) {
    return false;
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strFormatString.indexOf(strSeparatorArray[i]) != -1) {
      intFormatSeparatorIdx = i;
      break;
    }
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strDateToCheck.indexOf(strSeparatorArray[i]) != -1) {
      intDateSeparatorIdx = i;
      break;
    }
  }

  if (intDateSeparatorIdx != intFormatSeparatorIdx) {
    return false;
  }

  if (intDateSeparatorIdx != -1) {
    strFormatArray = strFormatString.split(strSeparatorArray[intFormatSeparatorIdx]);
    if (strFormatArray.length != 3) {
      return false;
    }

    strDateToCheckArray = strDateToCheck.split(strSeparatorArray[intDateSeparatorIdx]);
    if (strDateToCheckArray.length != 3) {
      return false;
    }

    for (i=0; i<strFormatArray.length; i++) {
      if (strFormatArray[i] == 'mm' || strFormatArray[i] == 'mmm') {
        strMonth = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'dd') {
        strDay = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'yyyy') {
        strYear = strDateToCheckArray[i];
      }
    }
  } else {
    if (FormatString.length > 7) {
      if (strFormatString.indexOf('mmm') == -1) {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mm'), 2);
      } else {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mmm'), 3);
      }

      strDay = strDateToCheck.substring(strFormatString.indexOf('dd'), 2);
      strYear = strDateToCheck.substring(strFormatString.indexOf('yyyy'), 2);
    } else {
      return false;
    }
  }

  if (strYear.length != 4) {
    return false;
  }

  intday = parseInt(strDay, 10);
  if (isNaN(intday)) {
    return false;
  }
  if (intday < 1) {
    return false;
  }

  intMonth = parseInt(strMonth, 10);
  if (isNaN(intMonth)) {
    for (i=0; i<strMonthArray.length; i++) {
      if (strMonth == strMonthArray[i]) {
        intMonth = i+1;
        break;
      }
    }
    if (isNaN(intMonth)) {
      return false;
    }
  }
  if (intMonth > 12 || intMonth < 1) {
    return false;
  }

  intYear = parseInt(strYear, 10);
  if (isNaN(intYear)) {
    return false;
  }
  if (IsLeapYear(intYear) == true) {
    intDaysArray[1] = 29;
  }

  if (intday > intDaysArray[intMonth - 1]) {
    return false;
  }
  
  return true;
}


var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var ns6 = ns5;
var ns6_1= (ns5 && navigator.userAgent.indexOf("6.1") != -1) ? true : false;
var ns6_2= (ns5 && navigator.userAgent.indexOf("6.2") != -1) ? true : false;
var ie6 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ns6 && !ns6_1 && !ns6_2 && !ie4 && !ie5 && !ie6) ? true : false;
if (nodyn) { event = "nope" }
var tooltip;
var off_x = 15; var off_y = 15;

function showTooltip(evt,txt) {
	var tipcode;
	tipcode = '<div class="ToolTipInfo">' + txt  + "</div>";

	if (ie4 || ie5 || ie6) {
		evt = window.event;
		tooltip = document.all.otrack;
		tooltip.innerHTML = tipcode;
		if ((evt.clientX + off_x + tooltip.style.pixelWidth) > (document.body.clientWidth)) {
		 tooltip.style.pixelLeft = (evt.clientX + document.body.scrollLeft) - tooltip.style.pixelWidth;
		} else { tooltip.style.pixelLeft = evt.clientX + off_x + document.body.scrollLeft; }
		if ((evt.clientY+off_y+tooltip.clientHeight) > (document.body.clientHeight)) {
		 tooltip.style.pixelTop = (evt.clientY + document.body.scrollTop) - tooltip.clientHeight;
		} else { tooltip.style.pixelTop = evt.clientY + off_y + document.body.scrollTop; }
		tooltip.style.visibility = "visible";
	}
	
	if (ns5 || ns6 || ns6_1 || ns6_2) {
		tooltip = document.getElementById('otrack');
		tooltip.innerHTML = tipcode;
		if ((evt.pageX + off_x + tooltip.offsetWidth) > (window.innerWidth + window.pageXOffset)) {
		 tooltip.style.left = evt.pageX - tooltip.offsetWidth;
		} else { tooltip.style.left = evt.pageX + off_x; }
		if ((evt.pageY + off_y + tooltip.offsetHeight) > (window.innerHeight + window.pageYOffset)) {
		 tooltip.style.top = evt.pageY - tooltip.offsetHeight;
		} else { tooltip.style.top = evt.pageY + off_y; }
		tooltip.style.visibility = "visible"; 
    }
}

function hideTooltip() {
	if ((ie4 || ie5 || ie6 || ns5 || ns6 || ns6_1 || ns6_2) && tooltip) {tooltip.style.visibility = "hidden"}
}

