addLoadEvent(distributeTasks);
addLoadEvent(highlight);
addLoadEvent(highlightForm);

function addLoadEvent(func) {
  	var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function distributeTasks(){
	if (!document.getElementsByTagName) return false;
	links = document.getElementsByTagName("a");
	for(i=0; i<links.length; i++){
		anchor = links[i];
		if(anchor.className == "external"){
			anchor.onclick = function(){
				var targetUrl = this.href;
				 window.open(targetUrl,'popup','resizable=1, scrollbars=1 toolbar=1, width=800,height=600');
				return false;	
			}
		}
		else if(anchor.className == "print"){
			anchor.onclick = function(){
				window.print();
				return false;	
			}
		}
		else if(anchor.className == "pin"){
			anchor.onclick = function(){
				var targetUrl = this.href;
				 window.open(targetUrl,'popup','width=400,height=320');
				return false;	
			}
		}
		
		else if(anchor.className == "back"){
			anchor.onclick = function(){
				var targetUrl = this.href;
				 history.back(0);
				return false;	
			}
		}
	}
}

function highlight(){
	if(!document.getElementsByTagName) return false;
	tables = document.getElementsByTagName("table");
	for(var j=0; j<tables.length; j++){
		var rows = tables[j].getElementsByTagName("tr");
		for(var i=0; i<rows.length; i++){
			var currColor;
			var textColor;
			rows[i].onmouseover = function(){
				currColor = this.style.backgroundColor;
				textColor = this.style.color;
				
				this.style.backgroundColor = "#ffffff";
				this.style.color = "#000000";
			}//end of mouseover
			rows[i].onmouseout = function(){
				this.style.backgroundColor = currColor;
				this.style.color = textColor;
			}//end of mouseout
		}//end of i loop
	}
}


 function highlightForm(){
 	var forms = document.getElementsByTagName("dl");
	var dlForms = new Array;
	var currStyle;
	for(i=0; i<forms.length; i++){
		if((forms[i].className == "form")|| (forms[i].className == "form50") || (forms[i].className == "search")){
			dlForms.push(forms[i]);
			for(j=0; j<dlForms.length; j++){
				var formInp = dlForms[j].getElementsByTagName("input");
				
				var selectInp = dlForms[j].getElementsByTagName("select");
				var textInp = dlForms[j].getElementsByTagName("textarea");
				
				
				for(z=0; z<formInp.length; z++){
					
					formInp[z].onfocus = function(){
							currStyle = this.className;
							this.className = currStyle + " focus";
					}
					formInp[z].onblur = function(){
							this.className = currStyle;
					}
				}
				for(x=0; x<selectInp.length; x++){
					
					selectInp[x].onfocus = function(){
							currStyle = this.className
							this.className = currStyle + " focus";
					}
					selectInp[x].onblur = function(){
							this.className = currStyle;
					}
				}
				
				for(y=0; y<textInp.length; y++){
					
					textInp[y].onfocus = function(){
							currStyle = this.className
							this.className = currStyle + " focus";
					}
					textInp[y].onblur = function(){
							this.className = currStyle;
					}
				}
			
			}
			
		}//end of if for dlform
			
		}
 }
 
function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}


 