function makeSublist(parent,child,isSubselectOptional,childVal) 
{ 
	$("body").append("<select style='display:none' id='" + parent + child + "'></select>"); 
	$('#'+parent+child).html($("#"+child+" option")); 
 		   
	var parentValue = $('#'+parent).attr('value'); 
	$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone()); 
 		   
	childVal = (typeof childVal == "undefined")? "" : childVal ; 
	if(isSubselectOptional) $('#'+child).prepend("<option> Select round </option>"); 
	$("#"+child+' option[value="'+ childVal +'"]').attr('selected','selected');  
	$('#'+parent).change(  
		function() 
		{ 
			var parentValue = $('#'+parent).attr('value'); 
			$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone()); 
			if(isSubselectOptional) $('#'+child).prepend("<option> Select round </option>"); 
			$('#'+child+' option:first').attr('selected', 'selected'); 
			$('#'+child).trigger("change");  
			$('#'+child).focus(); 
		} 
	); 
}

function OnRFChange(dropdown)
{
	var myindex  = dropdown.selectedIndex
	var SelValue = dropdown.options[myindex].value
	var baseURL  = "http://www.debatingmatters.com/events/rf/" + SelValue
	if (myindex != 0) top.location.href = baseURL;
    
	return true;
}

function OnChange(dropdown)
{
	var myindex  = dropdown.selectedIndex
	var SelValue = dropdown.options[myindex].value
	var baseURL  = "http://www.debatingmatters.com/events/qr/" + SelValue
	if (myindex != 0) top.location.href = baseURL;
    
	return true;
}
 	
$(document).ready(function() {
	makeSublist('parent','child',true,'none');
});
