// Show/hide text functionality (show more) on project detail page
function showHideMore (el) {
	if ($(el).hasClassName('more-link')) {
		moreLink = el;
		target = $(el).next();
		hideLink = $(target).next();
		$(hideLink).setStyle({display: 'inline'});
		$(target).setStyle({display: 'inline'});
		$(moreLink).setStyle({display: 'none'});
	} else {
		hideLink = el;
		target = $(el).previous();
		moreLink = $(target).previous();
		$(moreLink).setStyle({display: 'inline'});
		$(target).setStyle({display: 'none'});
		$(hideLink).setStyle({display: 'none'});
	};
}

function startList() {
	if (document.all && document.getElementById) {
		var navRoot = document.getElementById("navPrimary");
		if(navRoot){
			for (i=0, j=navRoot.childNodes.length; i<j ; i++) {
				var node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
		  		}
		  		node.onmouseout=function() {
		  			this.className=this.className.replace(" over", "");
		   		}
		   	}
			}
		}
	
		// Form buttons
		var buttonRoot = document.getElementById("buttonsLeft");
		if(buttonRoot){			
			for (i=0, j=buttonRoot.childNodes.length; i<j; i++) {
				var node = buttonRoot.childNodes[i];
				if (node.nodeName=="INPUT") {
					node.onmouseover=function() {
						this.className+=" button_over";
		  		}
		  		node.onmouseout=function() {
		  			this.className=this.className.replace(" button_over", "");
	   			}
	   		}
	  	}
		}
		buttonRoot = document.getElementById("buttonsRight");
		if(buttonRoot){	
			for (i=0, j=buttonRoot.childNodes.length; i<j; i++) {
				node = buttonRoot.childNodes[i];
				if (node.nodeName=="INPUT") {
					node.onmouseover=function() {
						this.className+=" button_over";
		  		}
		  		node.onmouseout=function() {
		  			this.className=this.className.replace(" button_over", "");
	   			}
	   		}
	  	}
		}
	}
}

// window.onload=startList;
document.observe("dom:loaded", function(){ startList(); });


// Set visibility of empty Sub Nav list
function blanknav(which) {
	obj = document.getElementById('blanknav');
	if(obj){obj.style.visibility = which;}
}


// Custom Scriptalicious
var folded = new Object();            
function slide(el){
  if(folded[el] == 1) {
	  Effect.BlindUp(el, {duration: 0.3});
	  folded[el] = 0;
  } 
	else{
	  Effect.BlindDown(el, {duration: 0.3});
	  folded[el] = 1;
  }
}

// Change class of table row when errors are present in form submitssion

function highlightErrors(){
	var errors = getElementsByClassName("fieldWithErrors");
}

function uncheck(item){
		document.getElementById(item).checked = false;
}

function toggle_display(obj){
	myDiv = $(obj).ancestors()[0].next('div', 0);
	Effect.toggle(myDiv, 'appear');
	if (myDiv.getStyle('display') == "none") {
		// change to hide
		obj.innerHTML = "Hide";
	}
	else {
		// change to show
	  obj.innerHTML = "Show";
	}
}