$(document).ready(function(){
	// *************************************
	// section_index
	if ($("#section_index").html() != null) {
		$("#user").focus();
	}
	// *************************************
	// section_upload
	if ($("#section_upload").html() != null){
		// cargar subgrupos 
		$("#selectGrupos").change(function(){
			var padre = $(this).val();
			$.ajax({
				type: "GET",
				url: "php/controlador.php?seccion=LOAD_COMBO_HIJOS&padre="+padre,
				success: function(msg){
					$("#selectGruposHijo").html(msg);
					$("#selectGruposHijo")[0].disabled = false;
				}
			});
		});
		
		$("#selectGrupos").change(function(){
			if ($(".name_pre").html() != null){
				var selectGrupos = $($("#selectGrupos")[0].childNodes[$("#selectGrupos")[0].selectedIndex]).attr("name_slug");
				$(".name_pre").html(selectGrupos+"_selecciona_grupo_hijo_");
			}
		});
		$("#selectGruposHijo").change(function(){
			crearNombre("");
		});
		$("#name").change(function(){
			//crearNombre($(this).val());
		});
	}
	// *************************************
	// section_verImg
	if ($("#section_editImg").html() != null) {
		$("#selectGruposHijo").change(function(){
			crearNombre("");
		});
	}
	// *************************************
	// section_verImg
	if ($("#section_verImg").html() != null) {
		$('#verImagenes a.lightbox').lightBox();
		$(".inputImg").focus(function(){
			 $(this).select();
		});
	}
});

function crearNombre(cadena){
	var selectGrupos = $($("#selectGrupos")[0].childNodes[$("#selectGrupos")[0].selectedIndex]).attr("name_slug");
	var selectGruposHijo = $($("#selectGruposHijo")[0].childNodes[$("#selectGruposHijo")[0].selectedIndex]).attr("name_slug");
		
	var grupos = selectGrupos+"_"+selectGruposHijo+"_";
	$(".name_pre").html(grupos);
}

