
//changes the recipients of volunteer emails based on their rating
function changeRecipients(my_form, rating){
	for (i=0;i<my_form.length;i++){
		if (my_form[i].type=="checkbox"){
			if(my_form[i].alt >= rating){
				my_form[i].checked = true;
			} else {
				my_form[i].checked = false;
			}
		}
	}
}

//changes the rating of a volunteer{
function changeRating(volunteer_id,rating){
	for(i=1;i<=5;i++){
		if(i<=rating){
			document.getElementById("rating_"+volunteer_id+"_"+i).src = "/template_images/star_full.png";
		} else {
			document.getElementById("rating_"+volunteer_id+"_"+i).src = "/template_images/star_empty.png";
		}
	}

	if(!xmlHttp){
		var xmlHttp;
		try {
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
		catch (e) {
			// Internet Explorer
			try {
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				try {
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {
					//alert("Your browser does not support AJAX!");
					return true;
				}
			}
		}
	}
	
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			//print out the response
			//right_side.innerHTML = xmlHttp.responseText;
			
		} else if(xmlHttp.readyState==1){
			//right_side.innerHTML="<h3>loading venue info</h3>";
		}
	}
    
	xmlHttp.open("GET","update_volunteer_rating.php?volunteer_id="+volunteer_id+"&rating="+rating,true);
    xmlHttp.send(null);
	return false;
}

function toggle(which){
	if(which=='all_interests'){
		var el = getElementsByClassName('interest');
		for(i=0; i<el.length; i++){
			if(el[i].style.display=="none"){
				el[i].style.display = "block";
			} else {
				el[i].style.display = "none";
			}
		}
	} else if(which=='all_opportunities'){
		var el = getElementsByClassName('opportunity');
		for(i=0; i<el.length; i++){
			if(el[i].style.display=="none"){
				el[i].style.display = "block";
			} else {
				el[i].style.display = "none";
			}
		}
	} else {
		el = document.getElementById(which);

		if(el.style.display=="none"){
			el.style.display = "block";
		} else {
			el.style.display = "none";
		}
	}
}

function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(|\\\\s)" + className + "(\\\\s|)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}