function sendoff(thepageurl){
	if(thepageurl == ''){
		alert("Please select a location to continue.");
	}
	else{
		//alert("a state was chosen and the new redirect url is ../" + thepageurl);
		window.location = "../" + thepageurl;
		//alert("after");
		//return true;
	}
}

function update_date(month, day, year) {
	var selected = false;
	var num_days_in_month = new Array();
	var selected_day = day.value;
	num_days_in_month["00"] = "31";
	num_days_in_month["01"] = "31"; //January
	num_days_in_month["02"] = "28"; 
	num_days_in_month["03"] = "31"; 
	num_days_in_month["04"] = "30"; 
	num_days_in_month["05"] = "31"; 
	num_days_in_month["06"] = "30"; 
	num_days_in_month["07"] = "31"; 
	num_days_in_month["08"] = "31"; 
	num_days_in_month["09"] = "30"; 
	num_days_in_month["10"] = "31"; 
	num_days_in_month["11"] = "30"; 
	num_days_in_month["12"] = "31"; 

	if ( year.value % 4 == 0 && !(year.value % 100 == 0) || year.value % 400 == 0 ) {
		num_days_in_month["02"] = "29";
	}
	
	day.innerHTML = "";
	
	day.options[0] = new Option( "","00");
	for ( var i = 1; i <= num_days_in_month[month.value]; i++ ) {
		if (selected_day ==  i) {
			selected = true; 
		}
		var newoption = new Option( i, i)
		day.options[i] = newoption;
		day.options[i].selected = selected;
		selected = false; 
	}
}

function getElementsByClassName(clsName,htmltag){ 
	var arr = new Array(); 
	var elems = document.getElementsByTagName(htmltag);
	for ( var cls, i = 0; ( elem = elems[i] ); i++ ){
		if ( elem.className == clsName ){
			arr[arr.length] = elem;
		}
	}
	return arr;
}

//state drop down function
function showState(stateId) {
	allStates = getElementsByClassName('state_content','div');
	for( i=0; i < allStates.length; i++) {
		if(allStates[i].id == stateId){
			allStates[i].style.display = 'block';
		} else {
			allStates[i].style.display = 'none';
		}
	}
	return true;
}

//This ajax call sets the state in the cookie
function stateCookie(state) {
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
			
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	
	if (!http_request) {
		alert('Giving up :( Cannot create an HTTP instance');
		return false;
	}
	
	http_request.open('GET', '/setCookie.php?state='+state);
	http_request.send("null");
}

function alertContents() {}

function goURL(here){
	if( here != '' ) {
		location.href = here;
	}
}

function show_state_group_plan(sel) {	
	for(var x=0;x<sel.options.length;x++) {
		if(sel.options[x].selected) {
			document.getElementById("state_"+sel.options[x].value).style.display="";
		} else {
			document.getElementById("state_"+sel.options[x].value).style.display="none";
		}
	}
	
}
