/* rollOverImg */
function rollOverImg(elId, tagName) {
	var el = document.getElementById(elId).getElementsByTagName(tagName);
	for (i=0; i<el.length; i++) {
		  if (el[i].src.substring(el[i].src.indexOf(".gif"))
				||el[i].src.substring(el[i].src.indexOf("_on.gif"))) {
				el[i].onmouseover = rollOverImgOver;
				el[i].onmouseout = rollOverImgOut;
		  }
		 }
}
function rollOverImgOver() {
	this.src=this.src.replace(".gif", "_on.gif");
}
function rollOverImgOut() {
  this.src=this.src.replace("_on.gif", ".gif");
}

/* rollOverClass */
function rollOverClass(elId, tagName, searchclass){
	var el = document.getElementById(elId).getElementsByTagName(tagName);
	for (i = 0; i < el.length; i++) {
		if (el[i].className == searchclass || el[i].className == searchclass + " on") {
			el[i].onmouseover = rollOverClassOver;
			el[i].onmouseout = rollOverClassOut;
		}
	}
}
function rollOverClassOver(){
	if (this.className == "") {
		this.className = this.className + " on";
	}
	else {
		this.className = "on";
	}
}
function rollOverClassOut(){
	if (this.className == "on") {
		this.className = "";
	}
	else {
		this.className = this.className.replace(" on", "");
	}
}

/* fnlClass */
function fnlClass(elId, tagName) {
	var el = document.getElementById(elId).getElementsByTagName(tagName);
	el[0].className="first";
	el[el.length-1].className="last";
}

/* tabContents */
function tabContents(tabContainerID, tagName) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName(tagName);
	var i = 0;
	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tablist")
			thismenu = tabAnchor.item(i);
		else
			continue;
		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;
			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", ".gif");
				} else {
					currentmenu.className = currentmenu.className.replace(" selected", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
			} else {
				this.className += " selected";
			}
			this.container.current = this;
			return false;
		};
		if (!thismenu.container.first) thismenu.container.first = thismenu;
	}
	if (tabContainer.first)	tabContainer.first.onclick();
}

/* countnAddClass */
function countnAddClass(tagName, addClass) {
	var count = 0;
	var el = document.getElementsByTagName(tagName);
	for (i=0; i<el.length; i++) {
		if (el[i]) {
			if (!(count%2-1)) {
				el[i].className = addClass;
			}
		count++;
		}
	}
}