//////////////////////////////////////////////////////////////////////////////
//inc.jazz-functions.js
//
//Desc: All functions used by the general site.
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
//updateArtists
//
//Desc: This gathers the states of the various pulldown filters for the 
//artists.php page and changes location using those values as GET
//////////////////////////////////////////////////////////////////////////////
function updateArtists(){
//	alert("()");
	//Get all values needed
		var sortby = document.getElementById("SortBy").value;
		var style = document.getElementById("Style").value;
	
	//Globals
		//ltr this is the current letter being looked at. 0 means 'all'
	
	
	//Assemble URL
		var url = "artists.php?SortBy="+sortby+"&Style="+style+"&pageStart=0&ltr="+ltr;	
	
	//Relocate
		location.href=url;
	
}//end function
//////////////////////////////////////////////////////////////////////////////
//updateArtists
//
//Desc: This version of updateArtists handles when the user clicked on a 
//letter to filter artists shown.
//////////////////////////////////////////////////////////////////////////////
function updateArtists2(newLetter){
//	alert("(newLetter)");
	//Get all values needed
		var sortby = document.getElementById("SortBy").value;
		var style = document.getElementById("Style").value;
		var pageStart = document.getElementById("pageStart").value;
	
	//Assemble URL
		var url = "artists.php?SortBy="+sortby+"&Style="+style+"&pageStart="+pageStart+"&ltr="+newLetter;	
	
	//Relocate
		location.href=url;
	
}//end function
//////////////////////////////////////////////////////////////////////////////
//updateArtists
//
//Desc: This version of updateArtists handles when the user clicked on a 
//pagination button or pulldown.
//////////////////////////////////////////////////////////////////////////////
function updateArtists3(newLetter,pageStart){
//	alert("(newLetter,pageStart)");
	//Get all values needed
		var sortby = document.getElementById("SortBy").value;
		var style = document.getElementById("Style").value;
	
	//Assemble URL
		var url = "artists.php?SortBy="+sortby+"&Style="+style+"&pageStart="+pageStart+"&ltr="+newLetter;	
	
	//Relocate
		location.href=url;
	
}//end function
//////////////////////////////////////////////////////////////////////////////
//swap
//
//Desc: shows one element and hides another
//////////////////////////////////////////////////////////////////////////////
function swap(show,hide){
	document.getElementById(show).style.display="block";
	document.getElementById(hide).style.display="none";
}
//////////////////////////////////////////////////////////////////////////////
//gotoMonth
//
//Desc:
//////////////////////////////////////////////////////////////////////////////
function gotoMonth(){
	var timestamp = document.getElementById("monthSelector").value;
	location.href="calendar.php?Time="+timestamp;
}//end function
//////////////////////////////////////////////////////////////////////////////
//gotoMonth2
//
//Desc:
//////////////////////////////////////////////////////////////////////////////
function gotoMonth2(){
	var timestamp = document.getElementById("monthSelector2").value;
	location.href="calendar.php?Time="+timestamp;
}//end function
//////////////////////////////////////////////////////////////////////////////
//checkValue
//
//Desc: gets the value of the currently selected button from a radion button
//set.
//////////////////////////////////////////////////////////////////////////////
function checkValue(set_name){
	var curValue = document.paypal_form[set_name];

	//error catch
	if(curValue==null){
		return null;
	}
	
	
	for(i=0;i<curValue.length;i++){
		if(curValue[i].checked==true){
			return curValue[i].value;
		}//end if
	}//end for
	
	
	return false; //on failure
}//end function
//////////////////////////////////////////////////////////////////////////////
//updateDonations
//
//Desc: This is used to update the paypal button used by the junior jazz
//donations form.
//////////////////////////////////////////////////////////////////////////////
function updateDonations(price){
	
	//Get the new price
	
	//Find the button and the amount field
	var button = document.getElementById("submit");
	var field = document.getElementById("amount");
	
	//Update button text
	button.value="Donate $"+price;
	
	//Update amount field
	field.value=price;
	
}//end function

function newsletterEmail(){
	var email = document.getElementById('newsletter_email').value;
	updateContentArea('newsletter_signup', 'action=newsletter&email='+email, 'php/run-custom.php');
	}
	
//////////////////////////////////////////////////////////////////////////////
//setFormHeight
//
//
//Desc: targets pae forms an dalters height
//////////////////////////////////////////////////////////////////////////////
function setFormHeight(ht){
		obj = document.getElementById('taForm');	
		obj.style.height = ht;
}//end function
//////////////////////////////////////////////////////////////////////////////
//openQuiz
//
//
//Desc: Wrapping the open window function so that nothing gets returned on click.
//Otherwise we wind up with the browser going to a page that says 'window object'
//////////////////////////////////////////////////////////////////////////////
function openQuiz(quiz_id,quiz_title){
	try{
		var location = 'quiz.php?Quiz_ID='+quiz_id;
		window.open(location,quiz_title,"toolbar=no,scrollbars=no,resizable=yes,width=420,height=500");		
	}catch(e){
		alert(e.string);
	}//end catch
}//end function
