function showHideCurriculo(id,id2){
	var divSel = document.getElementById(id);
	var divSel2 = document.getElementById(id2);
        
		if (divSel.style.display == "none"){
            divSel.style.display = "block";
			divSel2.style.display = "none";
        } else {
            divSel.style.display = "none";
			divSel2.style.display = "block";
        }
}
function showHide(id){
	var divSel = document.getElementById(id);
        if (divSel.style.display == "none"){
            divSel.style.display = "block";
        } else {
            divSel.style.display = "none";
        }
}
function show(ids){
	var divSel = document.getElementById(ids);
        divSel.style.display = "block";
}
function hide(idh){
	var divSel = document.getElementById(idh);
        divSel.style.display = "none";
}

function MM_validar(idfrm) {

  if (document.getElementById){
  var errors='';
  var forma = document.getElementById(idfrm);
  
  var nombre = forma.nombre.value;
  if (nombre == ""){
  errors += 'El nombre es un campo requerido.\n';
  }
  
  var id_cont = forma.id_cont.options[forma.id_cont.selectedIndex].value;
  if (id_cont == "" || id_cont == "#"){
  errors += 'El contenido relacionado es un campo requerido.\n';
  }
    
  if (errors) alert('Los siguientes errores ocurrieron:\n'+errors);
  document.MM_returnValue = (errors == '');
} }


function borrar(dirRed,mensaje){
	if (mensaje != ''){
		mes = mensaje;
	} else {
		mes = 'confirme que desea borrar este registro?';
	}
	if (confirm(mes)){
		window.open(''+dirRed+'&delete=true','_self');
	}
}
function borraCat(idrec){
	if (confirm("confirme que desea borrar la categoria completa?")){
		window.open('adm_menu.php?idcat_cont='+idrec+'&delete=true','_self');
	}
}
function setValSel(idform, idsel, idinput){
	var forma = document.getElementById(idform);
	var sele = forma[idsel];
	var campo = forma[idinput];
	var valclte = sele.options[sele.selectedIndex].value;
	if (valclte != '#'){
	//alert(valclte);
	campo.value = valclte;
	}
}

function jumpMenu(targ,selObj,dir){
	var valor = selObj.options[selObj.selectedIndex].value;
	if (valor != "#"){
  eval(targ+".location='"+dir+valor+"'");
	}
}

function jumpPagina(targ,selObj){
	var valor = selObj.options[selObj.selectedIndex].value;
	if (valor != "#"){
  eval(targ+".location='"+valor+"'");
	}
}

function setFecha(idform,idDia,idMes,idAnio,idcampo,nombre_campo){
	var forma = document.getElementById(idform);
	var errors='';
	var MMDia = forma[idDia].options[forma[idDia].selectedIndex].value;
	if(MMDia == '#')
		{
		errors += 'El dia de la fecha de '+ nombre_campo +'.\n';
		}
	var MMMes = forma[idMes].options[forma[idMes].selectedIndex].value;
	if(MMMes == '#')
		{
		errors += 'El mes de la fecha de '+ nombre_campo +'.\n';
		}
	var MMAnio = forma[idAnio].options[forma[idAnio].selectedIndex].value;
	if(MMAnio == '#')
		{
		errors += 'El aņo de la fecha de '+ nombre_campo +'.\n';
		}
	if (MMDia != '#' && MMMes != '#' && MMAnio != '#')
		{
		forma[idcampo].value=MMAnio+'/'+MMMes+'/'+MMDia;
		}
if (errors) alert('Tiene los siguientes errores:\n'+errors);
document.MM_returnValue = (errors == '');
}

function calcFact(idform,campocant,camposalida,porcfact){
	var forma = document.getElementById(idform);
	var porcentaje = porcfact;
	var calculo = forma[campocant].value * porcentaje;
	forma[camposalida].value = calculo.toFixed(2);
}
function sumTotal(){
	var forma = document.getElementById('form2');
	var val1 = forma['cantidad'].value;
	var val2 = forma['iva'].value;
	var val3 = forma['otro_imp'].value;
	if (val3 == ""){
		forma['otro_imp'].value = "0";
	}
	var val4 = forma['propina'].value;
	if (val4 == ""){
		forma['propina'].value = "0";
	}
	//var val5 = forma[cantidad].value;
	var tot = Number(val1) + Number(val2) + Number(val3) + Number(val4);
	forma['total'].value = tot.toFixed(2);
	var moneda = forma['moneda'].options[forma['moneda'].selectedIndex].value;
	if (moneda == "MxP"){
		forma['tipo_cambio'].value = "1";
		calcFact('form2','total','total_mn','1');
	}
}
function calFinal(){
	sumTotal();
	var errors = '';
	var forma = document.getElementById('form2');
	var mon = forma['moneda'].options[forma['moneda'].selectedIndex].value;
	if (mon == "#"){
		errors += 'No has seleccionado la moneda del gasto.\n';
	}
	var tc = forma['tipo_cambio'].value;
	if (tc == "" || isNaN(tc)){
		errors += 'No has definido un tipo de cambio correcto.\n';
	} else {
		calcFact('form2','total','total_mn',tc);
	}
	if (errors) alert('Tiene los siguientes errores:\n'+errors);
	document.MM_returnValue = (errors == '');
}
function findPosition( oElement ) {
  if( typeof( oElement.offsetParent ) != 'undefined' ) {
    for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
      posX += oElement.offsetLeft;
      posY += oElement.offsetTop;
    }
    return [ posX, posY ];
  } else {
    return [ oElement.x, oElement.y ];
  }
}
function setPosition(oElement,x,y) {
    oElement.style.left = x + "px";
	oElement.style.top = y + "px";
}

// ----- funciones para diagrama de la aplicacion
function view_tip_dist(parId){
	var idform = 'cuadro_info_dist';
	var handObj = 'image_' + parId;
	var addx = 30;
	var addy = 13;
	//var parId
	var formaSel = document.getElementById(idform);
	var divSel = document.getElementById(idform);
	//formaSel.parentid.value = parId;
	var posglob = findPosition(document.getElementById(handObj));
	var x = posglob[0] + addx;
	var y = posglob[1] + addy;
	show('cuadro_info_dist');
	setPosition(divSel,x,y);
}



function viewtool(parId){
	var idform = 'cuadro_info2';
	var handObj = 'image_' + parId;
	var addx = 0;
	var addy = -175;
	var formaSel = document.getElementById(idform);
	var divSel = document.getElementById(idform);
	var posglob = findPosition(document.getElementById(handObj));
	var x = posglob[0] + addx;
	var y = posglob[1] + addy;
	show('cuadro_info2');
	setPosition(divSel,x,y);
}



////////////tooltip para info de mex en el index////////////////
function viewReserva(parId, obj){
	var idform = 'cuadro_info2';
	var handObj = obj.id;
	//alert(handObj);
	var addx = 0;
	var addy = -190;
	//var parId
	var formaSel = document.getElementById(idform);
	var divSel = document.getElementById(idform);
	//formaSel.parentid.value = parId;
	var posglob = findPosition(document.getElementById(handObj));
	var x = posglob[0] + addx;
	var y = posglob[1] + addy;
	var pag = "front/conttoolTipinfo_mex.php?id_contenido="+parId;
	loadSpecCont('cuadro_info2',pag);
	show('cuadro_info2');
	setPosition(divSel,x,y);
}
/////////////////////////////////////////////////////////////////

function viewReserva2(parId, obj){
	var idform = 'cuadro_info2';
	var handObj = obj.id;
	//alert(handObj);
	var addx = 0;
	var addy = -175;
	//var parId
	var formaSel = document.getElementById(idform);
	var divSel = document.getElementById(idform);
	//formaSel.parentid.value = parId;
	var posglob = findPosition(document.getElementById(handObj));
	var x = posglob[0] + addx;
	var y = posglob[1] + addy;
	var pag = "front/conttoolTipExtra.php?id_contenido="+parId;
	loadSpecCont('cuadro_info2',pag);
	show('cuadro_info2');
	setPosition(divSel,x,y);
}

function viewReserva3(parId, obj){
	var idform = 'cuadro_info2';
	var handObj = obj.id;
	//alert(handObj);
	var addx = 0;
	var addy = -175;
	//var parId
	var formaSel = document.getElementById(idform);
	var divSel = document.getElementById(idform);
	//formaSel.parentid.value = parId;
	var posglob = findPosition(document.getElementById(handObj));
	var x = posglob[0] + addx;
	var y = posglob[1] + addy;
	var pag = "front/conttoolTipEscuela.php?id_contenido="+parId;
	loadSpecCont('cuadro_info2',pag);
	show('cuadro_info2');
	setPosition(divSel,x,y);
}

// Dynamic Iframe loader
function loadIframe(theURL) {
	document.getElementById("Icontenido").src=theURL;
}

// resizes Iframe according to content
function resizeMe(obj){ 
docHeight = Icontenido.document.body.scrollHeight
 obj.style.height = docHeight + 'px'
 } 

//Get Input obtenie el valor
function getInput(idval){
	var selObj = document.getElementById(idval);
	var valor = selObj.value;
	return valor;
}

function aceptaHide(idObj){
	var divSel = document.getElementById(idObj);
        divSel.style.display = "none";
	return true;	
}

function viewLicencia(parId, divName){
	var status = document.getElementById(divName);
    if(status.style.display == "none"){
	document.getElementById('id_descarga').value = parId;	
	var idform = divName;
	var handObj = "descarga_"+parId;

	if(divName == 'div_info_descarga'){
		var addx = 85;
		var addy = -18;
	}

	var divSel = document.getElementById(divName);
	
	var posglob = findPosition(document.getElementById(handObj));
	var x = posglob[0] + addx;
	var y = posglob[1] + addy;
	show(divName);
	setPosition(divSel,x,y);
    } else { status.style.display = "none";}
}

function viewLicenciaWallpaper(parId, divName,resolucion){
	var status = document.getElementById(divName);
    if(status.style.display == "none"){
	document.getElementById('id_wallpaper').value = parId;
	document.getElementById('resolucion').value = resolucion;
	var idform = divName;
	var handObj = "descarga_"+parId;

	if(divName == 'div_info_descarga_wallpaper'){
		var addx = -120;
		var addy = 20;
	}

	var divSel = document.getElementById(divName);
	
	var posglob = findPosition(document.getElementById(handObj));
	var x = posglob[0] + addx;
	var y = posglob[1] + addy;
	show(divName);
	setPosition(divSel,x,y);
    } else { status.style.display = "none";}
}