
$(function(){
	
	var winFormCmbPass=null
	winFormCmbPass=$("#formCambiaPass").window({
		width:'auto',  
		height:'auto',  
		modal:true,
		closed:true,
		collapsible:false,
		minimizable:false,
		maximizable:false, 
		resizable:false,
		onBeforeClose:function(){
			$("#formCmbPass").form('clear');
		},
		onOpen:function(){
			$("#txtpasant,#txtpasnew,#txtpasconfirm").valida({
				mincar:4,
				lcapital:false
			});
		},
	});
	
	$( "#addSavePass").button({
		icons: {
			primary: "ui-btn-save"
		},
		text: true
	}).click(function(e){
		e.preventDefault();
		var dts=$("#formCmbPass").serializeObject();
		if($("input","#formCmbPass").hasClass('campos_error')){
			jAlert(dtsLang['globals']['cmpobl'],dtsLang['project']['empresa'],'error')
			return false
		}
		if(dts['txtpasnew']!=dts['txtpasconfirm']){
			jAlert(dtsLang['mod_inicio']['msg_passdif'],dtsLang['project']['empresa'],'error')
			return false
		}
		
		dts['oper']='chpass';
		$.ajax({
			url:"mod_inicio/opera_inicio.php",
			type:"POST",
			dataType:"json",
			data:dts,
			beforeSend: function(){
				
			},
			success: function(rta){
				if(rta.error!=0){
					var mod;
					if(rta.error=='session'){
						mod='globals'
					}else{
						mod='mod_inicio';
					}
					jAlert(dtsLang[mod][rta.error],dtsLang['project']['empresa'],'error',function(){
						if(rta.error=='session'){
							location.reload();
						}
					});
					
				}else{
					notifica_ok(dtsLang['mod_inicio']['msg_chpas_ok']);
					$("#cancelPass").trigger("click");
				}
			},
		});
	});
	
	$( "#cancelPass").button({
		icons: {
			primary: "ui-btn-cancel"
		},
		text: true
	}).click(function(e){
		e.preventDefault();
		winFormCmbPass.window('close');
	});
	
$(document).ready(function(){
	
	$("#menu").kendoMenu({
		select:function(e){
			var menu_select=$("#"+e['item']['id']);
			if($.trim(menu_select.attr('dir'))!=''){
				$.blockUI({message: dtsLang.globals.msg_espera });
				document.title='Academia - '+ menu_select.attr('data-nom');
				$("*","#contenedor_general").remove().empty();
				$(".campos_error").remove().empty();
				$.ajax({
					url:menu_select.attr('dir'),
					type:'POST', 
					data:{privilegio:menu_select.attr('data-per')},
					cache:false,
					beforeSend: function(){
						$("#winNewEdtSaberes,#winNewEdtNotsSaber,#formNewEdt,#formNewEdtInd").window("destroy");
						$("*","#contenedor_general").remove().empty();	
						if(menu_select.attr('data-nom').toLowerCase().indexOf("nota")>-1){
							$("#dialos_add_observacion,#dgConfigNotas,#dgConfigDesem,#dialog_form_recupera,#dialog_detalles").window("destroy");
						}
					},
					success: function(pag){
						$("#contenedor_general").html(pag);
						$.unblockUI();	
					},
					error:function (response, textStatus, errorThrown){
						$.unblockUI();
						alert("Message: " + errorCode(response.StatusCode ,textStatus)); 
					}  
				});
			}								
		}
		
	});
	 
	$("#salir").click(function(){
		$.post("includes/salir.php",{},function(pag){
			document.location='index.php';
		});
	});
	 
	
	$("#cmbPass").click(function(e) {
		winFormCmbPass.window('open');
	});
}); 
}); 