function openEstilo(idEstilo, pagina){
	var resposta=sendFormGET("formulario&layout=none&idEstilo="+idEstilo+"&page="+pagina);
	document.getElementById('dinamicSuperior').innerHTML = resposta;
	
	if(document.getElementById('dinamicSuperior').style.display=='none'){
		new Effect.BlindDown('dinamicSuperior');
	}
}

function saveEstilo(){
	var Nombre = document.getElementById('Nombre').value;
	var idEstilo = document.getElementById('idEstilo').value;
	
	if (Nombre != ""){
		if (idEstilo!=""){
			if(confirm("Seguro que quieres editar el nombre de este Estilo?")){
				document.getElementById("datos").submit();
			}
		}else{
			document.getElementById("datos").submit();
		}
	}else{
		alert("El nombre no puede estar vacio!");
	}
}

function deleteEstilo(idEstilo, Pagina){
	if(idEstilo!=''){
		if(confirm("Se va a eliminar el estilo, la información vinculada quedará como \"sin estilo\".\nDeseas continuar?")){
			var resposta = sendFormGET("eliminar&template=none&idEstilo="+idEstilo);
		}
		location.reload();
	}
}

function mostrarTemas(idEp,precios,rate){

	
	new Ajax.Request(BASEDIR + "estilos/temasEp&idEp="+idEp+"&precios="+precios+"&rate="+rate+"&layout=none", {
		  method: 'GET',
		  asynchronous: true,
		  onSuccess: function(res){
				
				$(idEp).update(res.responseText);
		
				var tr = substr_count(res.responseText, "<tr>");
				var _height = (40 * tr);
				
				$(idEp).setStyle({height:_height+'px'});
		
				if($(idEp).style.display=='none'){
					new Effect.BlindDown(idEp);
				}
				
				$("trigger"+idEp).href = "javascript: ocultarTemas('"+idEp+"')";
				$("img_"+idEp).src = BASEDIR+"webroot/img/up_ico.gif"
		  },
		  onFailure: function(err){ alert("Error: " + err.responseText); }
		});
	
	
	
	
	//var resposta = sendFormGET(BASEDIR + "estilos/temasEp&idEp="+idEp+"&layout=none");
	//document.getElementById(idEp).innerHTML = resposta;
	
	/*
	 * CON ESTE TROZO SE CALCULA LA ALTURA DE LA NUEVA CAPA, 
	 * SIN ESTO, AL DESPLEGARSE APARECIA UN ESPACIO BLANCO QUE LUEGO DESAPARECIA
	 
	
	var tr = substr_count(resposta, "<tr>");
	var _height = (40 * tr);
	
	$(idEp).setStyle({height:_height+'px'});
	*/
	/*
	 * ##########################################################################
	 */
	/*
	if(document.getElementById(idEp).style.display=='none'){
		new Effect.BlindDown(idEp);
	}
	
	document.getElementById("trigger"+idEp).href="javascript: ocultarTemas('"+idEp+"')";
	document.getElementById("img_"+idEp).src=BASEDIR+"webroot/img/up_ico.gif"
	*/
}

function ocultarTemas(idEp){
	new Effect.BlindUp(idEp);
	document.getElementById("trigger"+idEp).href="javascript: mostrarTemas('"+idEp+"')";
	document.getElementById("img_"+idEp).src=BASEDIR+"webroot/img/down_ico.gif"
}
