var hrefPages=new Array();
function changeSelect(id){
	if(hrefPages[id]!=null){
		document.location=hrefPages[id];		
	}
}

$(document).ready(function()
		{	totaltable=1;
	$(".contenttoc").each(function(){
		contenido="";
		select=new Array();
		inicio=$(this).find("tr").eq(0).html();
		total=0;
		$(this).find("tr").each(function() {
			if (total>0){
				data=$(this).find("td").eq(0).find("a").eq(0).html();
				href=$(this).find("td").eq(0).find("a").eq(0).attr("href");
				active=false;
				if($(this).find("td").eq(0).find("a").eq(0).hasClass("active")){
					active=true;	
				}	
				select.push({'data':data, 'href': href, 'active': active});	
			}
			total++;
		});
		option="";
		for(i=0; i<select.length; i++){
			clave="table_"+totaltable+"_"+i;
			hrefPages[clave]=select[i].href;
			option+='<option value="'+clave+'" class="toclink ';
			if(select[i].active){
				option+=' active" selected="selected';
			}
			option+='">'+select[i].data+'</option>';
		}
		if(option!=""){
			html_r="<tr>"+inicio+"</tr>";
			html_r+='<tr><td><select name="table_'+totaltable+'" id="table_'+totaltable+'" onchange="changeSelect(this.value)">';
			html_r+=option;
			html_r+='</select></td></tr>';
			$(this).html(html_r);
		}
		totaltable++;
	});
});

