function generateMouseOverEffect(rows)
{

  for (var i = 0; i < rows.length; i++)
  {    
    if (rows[i].onclick != null)  //only hover-highlight rows that are links
    {
      rows[i].className+= " clickable"; 

      rows[i].onmouseover = function()
      {
        this.className += " hover";
      };
      rows[i].onmouseout = function()
      {
        this.className = this.className.replace(new RegExp("hover\\b"), "");
      };
      rows[i].onfocus = rows[i].onmouseover;
      rows[i].onblur = rows[i].onmouseout;


      //stop header elements from acquiring the hover/click effects
      var headers = rows[i].getElementsByTagName("th");
      for (var j = 0; j < headers.length; j++)
      {
        headers[j].onmouseover = function(event)
        {
          if(document.all)
          {
            window.event.cancelBubble = true;
          }
          else
          {
            event.stopPropagation();
          }
        };
        headers[j].onfocus = headers[j].onmouseover;
        headers[j].onclick = headers[j].onmouseover;
      }


      //stop onclick event from bubbling up document tree farther than a checkbox
      //prevents the effect of clicking a checkbox causing <tr> onclick to fire
      var check = rows[i].getElementsByTagName("input")[0];
      if(check && check.className.indexOf("radio") > -1)
      {
		if(check.onclick) {check.onclickOrig = check.onclick; }
        check.onclick = function(event)
        {
		  if(this.onclickOrig) {this.onclickOrig(); }
          if(document.all)
          {
            window.event.cancelBubble = true;
          }
          else
          {
            event.stopPropagation();
          }
        };
		var p=check.parentNode;
		if(p && p.className == "colorband") {
			p.cb = check;
			p.onclick = function(event) {
				this.cb.checked = !this.cb.checked;
				this.cb.onclick(event);
			}
			p.onmouseover = p.onfocus = highlightColorband;
			p.onmouseout = p.onblur = lowlightColorband;
		}
      }
      //also for any stray links that may appear in a table
      var anchors = rows[i].getElementsByTagName("a");
      for (var j= 0; j < anchors.length; j++)
      {
        var anchor = anchors[j];
        if(anchor)
        {
          anchor.onclick = function(event)
          {
            if(document.all)
            {
              window.event.cancelBubble = true;
            }
            else
            {
              event.stopPropagation();
            }
          };
        }
      }
    }
  }
}


function generateTableEffects() {
  /*Table row highlighting*/
  var rows = document.getElementsByTagName('tr');
  generateMouseOverEffect(rows);
  
  /* highlighting effects for td used in nonjs calendar  */
  var calendar = document.getElementById('aspcalendar');
  if(calendar!=null){
  	var dates = calendar.getElementsByTagName('td');
  	generateMouseOverEffect(dates);
  }
  
  hideDetails();
}


function highlightColorband() {
    this.className = this.className.replace(new RegExp(/ *selected/), "");
	this.className = this.className + " selected";
}

function lowlightColorband() {
    this.className = this.className.replace(new RegExp(" *selected"), "");
}


/*
'-----------
'Description: Hide/Show Details
'-----------
*/
function hideDetails()
{
    var detailclass,urlHTML,IsChange;
    var timeUrl = document.getElementById("timeurl");
    if(timeUrl!=null){
    	if(timeUrl.innerHTML.toString().indexOf("Hide Times")<0){
    		detailclass="inlinetime";
    		urlHTML="Hide Times";
    	}
    	else{
    		detailclass="inlinetime  hidden";
    		urlHTML="Show Times";
    	}
        
	var totalDetailsCellValue=document.getElementById('totalDetails');
	if(totalDetailsCellValue!=null)
	{
		var totalDetailsCell=new Number(totalDetailsCellValue.value);
	}
	for (var i = 1; i <= totalDetailsCell; i++)
	{
		var detailid =  "detailid_" + i; 
		var detail = document.getElementById(detailid);
		if(detail!=null){
			detail.className = detailclass;
			IsChange=true;
		}
	}
	if(IsChange){
		timeUrl.innerHTML=urlHTML;
	}
     }
}

/*
'-----------
'Description: Writes Hide Times URL
'-----------
*/
function writeTimeURL(){
	if (typeof(document)=='object'){
		document.write('<a id="timeurl" href="javascript:hideDetails()">Hide Times</a>');
	}
}



