function cronoOpenDiv(obj){
	var cIndex = parseInt(obj.id.replace(/tdata_/,""),10);
	if(!document.getElementById("tr_"+cIndex)){
		var row=document.getElementById("horarios").insertRow(obj.rowIndex+1);row.id="tr_"+cIndex;
		var cell=row.insertCell(0);row.className="temp";cell.colSpan=obj.cells.length;cell.align="right";cell.valign="top";
		getDetalle(cell,cIndex);
	}else{
		cIndex=document.getElementById("tr_"+cIndex).rowIndex;
		document.getElementById("horarios").deleteRow(cIndex);
	}	    
}
function getDetalle(obj,cIndex){
	if(crono.length < cIndex ){return;}else{var dbid=crono[cIndex][10];}
	var html="<div id=\"crono_detail_"+cIndex+"\" class=\"crono_detalle\">";
	html+="<img src=\"/images/loaders/4-0.gif\" width=16 height=16 border=0 title=\"cargando...\">";
	html+="</div>";
	obj.innerHTML=html;html=null;
	$("#crono_detail_"+cIndex).load("/control/wml_ajax_cronograma.asp",{id: dbid,fase:"sumilla"}, function(){return;});
	
}	
//	0		1		2			3		4								5			6				7	8			9						10
// idCurso	curTipo	curTitulo	Local	Area,							Inicio		Final			Mes	Dia			Path				  idHorario	
// ["10",	"E",	"TEST EVENTO","Surco","Arquitectura y Construcción","2009-05-20","2009-05-22","Mayo","Miércoles","/store/eventos/10/","x"]
function showFiltro(controlName,index,sStyle){
	var html="<select class=\"inputSelect\" id=\""+controlName+"\" name=\""+controlName+"\" size=\"1\" onchange=\"doFilter(this,'"+index+"');\">";
	var cstring="";
	html+="<option value=\"\">---</option>";
	for (var i=0;i<crono.length;i++){
		if(cstring.indexOf("#"+crono[i][index]+"#")==-1){
			cstring+="#"+crono[i][index]+"#";
			html+="<option value=\""+crono[i][index]+"\">"+crono[i][index]+"</option>";
		}	
	}
	html+="</select>";
	if(!document.getElementById("div_filtro_"+controlName)){document.write("<div id=\"div_filtro_"+controlName+"\"></div>");}
	document.getElementById("div_filtro_"+controlName).innerHTML=html;html=null;	
}
function doFilter(filtro,index){displayregs();$("#horarios").tablesorter();}
function displayregs(){
	var filters = new Array(["mes",7,""],["locales",3,""],["tipos",1,""],["areas",4,""]);var srtFilter="";for (var i=0;i<filters.length;i++){filters[i][2]=document.getElementById(filters[i][0]).value;if (filters[i][2]!=""){	srtFilter+="(crono[i]["+filters[i][1]+"]==\""+filters[i][2]+"\") && ";};};srtFilter="("+srtFilter+"(1==1))";
	var html="<table  class=\"tablesorter\" id=horarios width=705 cellpadding=0 cellspacing=1 border=0 style=\"table-layout:fixed;\">";
	html+="<col width=80><col width=80><col width=80><col width=80><col width=50><col width=295>";
	html+="<thead>";		
	html+="	<th class=cronotit>Mes</th>";	
	html+="	<th align=center class=cronotit>Inicio</th>";
	html+="	<th align=center class=cronotit>Término</th>";
	html+="	<th class=cronotit>Local</th>";
	html+="	<th class=cronotit>Tipo</th>";
	html+="	<th class=cronotit>Tema</th>";
	html+="</thead>";	
	html+="<tbody>"; 
	for (i=0;i<crono.length;i++){
		if (eval(srtFilter)){
			html+="<tr id=\"tdata_"+i+"\" onclick=\"cronoOpenDiv(this);\" title=\"pulse aquí para ver u ocultar el detalle\">";		
			html+="	<td><b>"+crono[i][7]+"</b></td>";	
			html+="	<td align=center>"+crono[i][5]+"</td>";
			html+="	<td align=center>"+crono[i][6]+"</td>";
			html+="	<td>"+crono[i][3]+"</td>";
			html+="	<td>"+crono[i][1]+"</td>";
			html+="	<td><b>"+crono[i][2]+"</b></td>";
			html+="</tr>";
		}
	}
	html+="</tbody>";
	html+="</table>";
	if(!document.getElementById("div_cronograma")){document.write("<div id=\"div_cronograma\"></div>");}
	document.getElementById("div_cronograma").innerHTML=html;html=null;			    
};