/*************************************************************
 * Copyright 2006 Avallo Multimedia and Creative Services Inc.
 * 
 * Code Edited by: Weston Shaw
 * Last Edited: 10/3/06 Weston Shaw
 * 
 * Behavior for http://www.avallo.com/
 *************************************************************/

/* =Load Functions
-----------------------------------------------------------------------------*/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(doNewWin);
addLoadEvent(startList);
addLoadEvent(dlStripe);



/* =Open a new window
-----------------------------------------------------------------------------*/
function doNewWin() {
  if (!document.getElementsByTagName) return false;
  var links=document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("newWin")) {
      links[i].onclick=function() {window.open(this.href);return false;
      }
    }
  }
}

/* =IE Menu dropdown support
-----------------------------------------------------------------------------*/
function startList() {
	if (document.all&&document.getElementById){
		navRoot = document.getElementById("nav").firstChild;
		for (i=0; i<navRoot.childNodes.length; i++){
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI"){
				node.onmouseover=function(){this.className+=" over";}
				node.onmouseout=function(){this.className=this.className.replace(" over", "");}
			}
		}
	}
}


/* =DL Stripe
-----------------------------------------------------------------------------*/
function dlStripe(){
	var bodyClass = document.body.className;
	var classArr = bodyClass.split(" ");
	if(!inArray("listStripe", classArr)) return false;
	var dds = document.getElementsByTagName("dd");
	var sw = 1;
	for(i in dds){
		if(!empty(sw)){
			addClass(dds[i],"odd");
			sw = null;
		} 
		else sw = 1;
	}
}


/* =Healper Functions
-----------------------------------------------------------------------------*/
function inArray(x, arr){
	for(i in arr){if(x == arr[i]) return true;}
	return false;
}
function empty(x){
	if(x == '' || x == null) return true;
	else return false;
}
function addClass(element,value) { 
	if(!element.className) element.className = value;
	else {
		newClassName = element.className;
		newClassName+= " ";
		newClassName+= value;
		element.className = newClassName;
	}
}

