
// JavaScript Document
//esta funcion me hace un llamdo ajax para refrescar una region del sitio 
//subseccion(1,1,2,'no',1,0);
///// codigo para desactivar el boton derecho del mouse
var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
try{
$(document).ready(function(){ $('#topmenu').find('a').each(function(){ if(this.innerHTML.indexOf('Correo') == -1) this.target = '_self'; }); });
}catch(e){}
document.oncontextmenu=new Function("return false")
function subseccion(Id_Master,Id_Division,Id_Seccion,Id_Subseccion,Tip_Seccion,OpciVerm_Subseccion,Tipo_Subseccion,Ids_Master,Idioma,front)
{	
	///esta parte me pone de color amarillo el menu y glotemp  es una variable global que lleva el control de  numero de secciones activas
	entrar=0;
	if(Id_Subseccion=='no')
	{	
		if(Tip_Seccion==0)
		{
			entrar=1;			
		}
		else
		{
			entrar=0;
		}
	}
	else
	{
		entrar=1;
	}
	
	if(entrar==1)
	{	
		if(Id_Seccion==1)
		{	
			if(front==0)
			{												
				//document.getElementById('subseccion').innerHTML ="";
				//document.getElementById('subsecciont').innerHTML ="Usted se encuentra en Inicio";	
				document.getElementById('subseccioninicio').style.display ="";					
				document.getElementById('front').style.display ="none";
			}
			else
			{					
				document.getElementById('front').style.display ="";
				document.getElementById('subseccioninicio').style.display ="none";						
			}	
			$(document).ready(
								function()
								{				
									$.post("funciones/ajaxmenu.php",{Id_Master:Id_Master,Id_Division:Id_Division,Id_Seccion:Id_Seccion,Id_Subseccion:Id_Subseccion,Tip_Seccion:Tip_Seccion,OpciVerm_Subseccion:OpciVerm_Subseccion,Idioma:Idioma},
												function(data)
												{ 																			
												$("#subseccion").html(data);
												
												}
											);						
								}
					);
		}
		else
		{	
			if(Tipo_Subseccion!=2)
			{							
				document.getElementById('front').style.display ="none";
				document.getElementById('subseccioninicio').style.display ="";
				document.getElementById('subseccion').style.display ="";
				document.getElementById('subsecciont').style.display ="";					
				
				$(document).ready(
								function()
								{				
									$.post("funciones/ajaxmenu.php",{Id_Master:Id_Master,Id_Division:Id_Division,Id_Seccion:Id_Seccion,Id_Subseccion:Id_Subseccion,Tip_Seccion:Tip_Seccion,OpciVerm_Subseccion:OpciVerm_Subseccion,Idioma:Idioma},
												function(data)
												{ 																			
												$("#subseccion").html(data);
												
												}
											);						
								}
					);
				
					$(document).ready(
								function()
								{				
									$.post("funciones/ajaxmenu2.php",{Id_Master:Id_Master,Id_Division:Id_Division,Id_Seccion:Id_Seccion,Id_Subseccion:Id_Subseccion,Tip_Seccion:Tip_Seccion,OpciVerm_Subseccion:OpciVerm_Subseccion,Idioma:Idioma},
												function(data)
												{ 																			
												$("#subsecciont").html(data);									
												}
											);						
								}
					);	
			}
			else
			{	
				document.frmdatospagina.target="_self";
				//document.getElementById('Id_Master').value=Ids_Master;	
				//document.getElementById('Id_Seccions').value=Id_Seccion;
				document.frmdatospagina.action="index2.php?Id_Master="+Ids_Master+"&Id_Seccions="+Id_Seccion+"&OpciVerm="+OpciVerm_Subseccion;
				document.frmdatospagina.submit();		
			}
		
		}
	}

}
function subseccion2(Id_Master,Id_Division,Id_Seccion,Id_Subseccion,Tip_Seccion,OpciVerm_Subseccion,Tipo_Subseccion,Ids_Master,Idioma,front,Ord_Seccion,seccionactiva,secciones)
{	
	//var enlacepagina="";
	//esta parte me pone de color amarillo el menu y glotemp  es una variable global que lleva el control de  numero de secciones activas
	entrar=0;
	if(Id_Subseccion=='no'){
		if(Tip_Seccion==0){ entrar=1; }
		else{ entrar=0; }
	}
	else{ entrar=1; }
	
	var enlacepagina="index2.php?Id_Master="+Id_Master+"&Id_Division="+Id_Division+"&Id_Seccions="+Id_Seccion+"&Id_Subseccion="+Id_Subseccion+"&Tip_Seccion="+Tip_Seccion+"&Tip_Seccion="+Tip_Seccion+"&OpciVerm="+OpciVerm_Subseccion+"&Idioma="+Idioma+"&front="+front+"&Ord_Seccion="+Ord_Seccion+"&Tipo_Subseccion="+Tipo_Subseccion+"&Ids_Master="+Ids_Master+"&seccionactiva="+seccionactiva+"&secciones="+secciones+"&sesion=view";
	//alert(enlacepagina);
	//index2.php?Id_Master=4&Id_Division=1&Id_Seccions=1&Id_Subseccion=no&Tip_Seccion=0&Tip_Seccion=0&OpciVerm=0&Idioma=0&front=0&Ord_Seccion=15&Tipo_Subseccion=no&Ids_Master=no&seccionactiva=undefined&seccionesundefined&sesion=view
	/*
	document.location.href=enlacepagina;
	*/
	entrar=1;//CUIDADO CON ESTA VARIABLE PUES NOS SIRVE PARA QUE SE EXPANDA UN SUBSECCION APENAS SE LE DA CLIC EN LA SECCION
	
	if(entrar==1){	
		if(Ord_Seccion==1 ){	
			if(front==0){
				//document.getElementById('subseccion').innerHTML ="";
				//document.getElementById('subsecciont').innerHTML ="Usted se encuentra en Inicio";	
				try{
					document.getElementById('subseccioninicio').style.display ="";					
					document.getElementById('subseccioninicio2').style.display =""
					document.getElementById('subsecciont').style.display ="";	
					document.getElementById('front').style.display ="none";
				}catch(e){}
				$(document).ready(
					function(){				
						$.post("funciones/ajaxmenu2.php",{Id_Master:Id_Master,Id_Division:Id_Division,Id_Seccion:Id_Seccion,Id_Subseccion:Id_Subseccion,Tip_Seccion:Tip_Seccion,OpciVerm_Subseccion:OpciVerm_Subseccion,Idioma:Idioma},
							function(data){ $("#subsecciont").html(data); }
						);						
					}
				);
			}
			else{
				try{
					document.getElementById('front').style.display ="";
					document.getElementById('subseccioninicio').style.display ="";						
					document.getElementById('subsecciont').style.display ="";	
					document.getElementById('subsecciont').innerHTML ="Usted se encuentra en > Inicio";	
					document.getElementById('subseccioninicio2').style.display ="none";
				}catch(e){}
			}	
			$(document).ready(
				function(){				
					$.post("funciones/ajaxmenu.php",{Id_Master:Id_Master,Id_Division:Id_Division,Id_Seccion:Id_Seccion,Id_Subseccion:Id_Subseccion,Tip_Seccion:Tip_Seccion,OpciVerm_Subseccion:OpciVerm_Subseccion,Idioma:Idioma,front:front,Ord_Seccion:Ord_Seccion,Tipo_Subseccion:Tipo_Subseccion,Ids_Master:Ids_Master},
						function(data){ $("#subseccion").html(data); }
					);						
				}
			);
		}
		else{	
			if(Tipo_Subseccion!=2){			
				//alert(Ord_Seccion+"::"+front+"::"+Tipo_Subseccion);
				try{
					document.getElementById('front').style.display ="none";			
					document.getElementById('subseccion').innerHTML ="";									
					document.getElementById('subseccioninicio').style.display ="";
					document.getElementById('subseccion').style.display ="";
					document.getElementById('subseccioninicio2').style.display =""
					document.getElementById('subsecciont').style.display ="";					
				}catch(e){}
				$(document).ready(
					function(){	
						iniciar();			
						$.post("funciones/ajaxmenu.php",{Id_Master:Id_Master,Id_Division:Id_Division,Id_Seccion:Id_Seccion,Id_Subseccion:Id_Subseccion,Tip_Seccion:Tip_Seccion,OpciVerm_Subseccion:OpciVerm_Subseccion,Idioma:Idioma,front:front,Ord_Seccion:Ord_Seccion,Tipo_Subseccion:Tipo_Subseccion,Ids_Master:Ids_Master},
							function(data){
								$("#subseccion").html(data); 
							}
						);						
					}
				);
				
				$(document).ready(
					function(){				
						$.post("funciones/ajaxmenu2.php",{Id_Master:Id_Master,Id_Division:Id_Division,Id_Seccion:Id_Seccion,Id_Subseccion:Id_Subseccion,Tip_Seccion:Tip_Seccion,OpciVerm_Subseccion:OpciVerm_Subseccion,Idioma:Idioma},
							function(data){ $("#subsecciont").html(data); }
						);						
					}
				);
			}
			else{	
				document.frmdatospagina.target="_self";
				document.frmdatospagina.action="index2.php?Id_Master="+Ids_Master+"&Id_Seccions="+Id_Seccion;
				document.frmdatospagina.submit();		
			}		
		}
	}
	
}
//esta funcion me permite mostar los submenus al dar clic en  un menu
function mostrar(seccionactiva,secciones)
{
	CadenaSecciones = secciones.split('-');
	if(secciones!=""){	
		for (i=0;i<CadenaSecciones.length;i++)
		{	
			if(CadenaSecciones[i] != seccionactiva)
			{
				try{document.getElementById(CadenaSecciones[i]).style.display ="none";	}catch(e){}
				if(pagina!=1)
				{
					try{document.getElementById('xx'+CadenaSecciones[i]).style.display ="none";	}catch(e){}
					//document.getElementById('zz'+CadenaSecciones[i]).style.display ="";	
				}
			}
			else
			{
				if(document.getElementById(seccionactiva).style.display=="none")
				{
					document.getElementById(seccionactiva).style.display ="";
					if(pagina!=1)
					{
						document.getElementById('xx'+seccionactiva).style.display ="";	
						//document.getElementById('zz'+seccionactiva).style.display ="";	
					}
				}
				else
				{
					document.getElementById(seccionactiva).style.display ="none";				
					if(pagina!=1)
					{
						document.getElementById('xx'+seccionactiva).style.display ="none";	
						//document.getElementById('zz'+seccionactiva).style.display ="none";	
					}
				}
			}
			
			if(pagina!=1)
			{			
				if(CadenaSecciones[i] != seccionactiva)
				{			
					try{document.getElementById('xx'+CadenaSecciones[i]).style.display ="";	
					document.getElementById('zz'+CadenaSecciones[i]).style.display ="none";		}catch(e){}							
				}
				else
				{						
					if(document.getElementById('xx'+seccionactiva).style.display=="")
					{	
						document.getElementById('zz'+seccionactiva).style.display ="";
						document.getElementById('xx'+seccionactiva).style.display ="none";					
					}
					else
					{										
						document.getElementById('zz'+seccionactiva).style.display ="none";	
						document.getElementById('xx'+seccionactiva).style.display ="";						
					}				
				}							
			}		
		} 
	}
}

function fcadsuseccion2(nivel)
{
	var cadena="";
	cadena="editarruta.php?"+cadurl+"&f1="+cadf1+"&f2="+cadf2+"&f3="+cadf3+"&nivel="+nivel;
	secondwindow=open(cadena,'Editar','height=150,width=800,scrollbars=no,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);	
}


function fcadsuseccion2desc(archivo,nivel)
{
	if(nivel==2)
	{
		cadf2="descargar2('"+archivo+"');";	
	}
	else if(nivel==3)
	{
		cadf3="descargar2('"+archivo+"');";	
	}
	
	fcadsuseccion2(nivel)
}

function editarseccion()
{ 
	estado="0";
	tipo="0";
	if(document.getElementById('estadoseccion0').checked)
	{
		estado="0";	
	}
	else if(document.getElementById('estadoseccion1').checked)
	{
		estado="1";	
	}
	if(document.getElementById('tiposeccion0').checked)
	{
		tipo="0";	
	}
	else if(document.getElementById('tiposeccion1').checked)
	{
		tipo="1";	
	}
	$(document).ready(
				function()
				{	
			$.post("../../funciones/ajaxeditarseccion.php",{estado:estado,IdMaster:$("#IdMaster").val(),idseccion:$("#idseccion").val(),iddivision:$("#iddivision").val(),nombreseccion:$("#nombreseccion").val(),nombreseccioning:$("#nombreseccioning").val(),tipo:tipo},
								function(data)
								{ 	
								
								//$("#subseccion").html(data);							
								//alert("Datos Editados Correctamente");
								//alert(data);
								cargar_pagina();
								}
							);						
				}
	);					
}

function cargar_pagina(){
//opener.location = 'otrapagina.php';si deseamos cargar otra pagina en lugar de la padre colocamos el codigo de esta linea
cargar();
setTimeout("salir()",4500);
}
function salir(){
window.opener.location.reload();
window.close();
}
function popupeditarseccion(IdMaster,iddivision,idseccion)
{
	var cadena="";
	cadena="editarseccion.php?iddivision="+iddivision+"&idseccion="+idseccion+"&IdMaster="+IdMaster;
	secondwindow=open(cadena,'Editar','height=275,width=580,scrollbars=no,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
}
function cargar(){
document.getElementById('qq').innerHTML="<table border='0' align='center'><tr><td>&nbsp;</td><td><strong>--------------Guardando-------------</strong></td><td>&nbsp;</td></tr><tr><td>0%</td><td><dl><dd><span><em style='left:200px'>100%</em></span></dd></dl></td><td>100%</td></tr></table>";
}



function creardivision(IdMaster)
{
	document.getElementById('IdMaster').value=IdMaster;
	document.frmdatos.action='creardivision.php';
	document.frmdatos.submit();		
}
function eliminardivision(IdMaster,IdentificadorDivision,TipoDivision)
{
	if(confirm("Realmente desea eliminar la Division"))
	{
		document.frmdatos.action='eliminardivision.php';
		document.getElementById('iddivision').value=IdentificadorDivision;
		document.getElementById('IdMaster').value=IdMaster;
		document.getElementById('tipodivision').value=TipoDivision;
		document.frmdatos.submit();		
	}	
}
function popupeditardivision(IdMaster,iddivision)
{
	var cadena="";
	cadena="editardivision.php?iddivision="+iddivision+"&IdMaster="+IdMaster;
	secondwindow=open(cadena,'Editar','height=320,width=880,scrollbars=no,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
}
function popupeditardivision1(IdMaster,iddivision)
{
	var cadena="";
	cadena="editardivision1.php?iddivision="+iddivision+"&IdMaster="+IdMaster;
	secondwindow=open(cadena,'Editar','height=230,width=880,scrollbars=no,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
}
function editardivision()
{ 
	tipo=document.getElementById('tipodivision').value;
	archivo=document.getElementById('archivo').value;
	if(tipo==1)
	{	
		estado=verificarcamposdiv(1);		
		if(estado==0)
		{
			alert("Ingrese los valores correspondientes en los campos marcados con rojo"); 
		}
		else
		{	if(archivo!="")
			{
				document.frmdatos.action='guardardivision.php';
				document.frmdatos.submit();	
			}
			else
			{
				alert("Ingrese un archivo a subir"); 
			}
		}		
	}
	if(tipo==2 || tipo==3)
	{
		estado=verificarcamposdiv(2);
		
		if(estado==0)
		{
			alert("Ingrese los valores correspondientes en los campos marcados con rojo"); 
		}
		else
		{	
			document.frmdatos.action='guardardivision.php';
			document.frmdatos.submit();				
		}
	}	
	
}
function editardivision1()
{ 
	
	document.frmdatos.action='guardardivision1.php';
	document.frmdatos.submit();					
}
function eliminarimamaster(IdMaster,IdentificadorDivision,IdentificadorImamaster)
{
	if(confirm("Realmente desea eliminar Eeste elemento"))
	{
		document.frmdatos.action='eliminarimamaster.php';		
		document.getElementById('iddivision').value=IdentificadorDivision;
		document.getElementById('IdMaster').value=IdMaster;
		document.getElementById('idimamaster').value=IdentificadorImamaster;
		
		document.frmdatos.submit();		
	}	
}
function popupeditarimamaster(IdMaster,IdentificadorDivision,IdentificadorImamaster)
{
	var cadena="";
	cadena="editarimamaster.php?idimamaster="+IdentificadorImamaster+"&IdMaster="+IdMaster+"&IdentificadorDivision="+IdentificadorDivision;
	secondwindow=open(cadena,'Editar','height=320,width=880,scrollbars=no,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
}
function editarimamaster()
{ 	
	archivo=document.getElementById('archivo').value;	
	estado=verificarcamposima();		
	if(estado==0)
	{
		alert("Ingrese los valores correspondientes en los campos marcados con rojo"); 
	}
	else
	{	/*if(archivo!="")
		{
			document.frmdatos.action='guardarimamaster.php';
			document.frmdatos.submit();	
		}
		else
		{
			alert("Ingrese un archivo a subir"); 
		}*/
			document.frmdatos.action='guardarimamaster.php';
			document.frmdatos.submit();	
	}				
}

function visualizarimamaster(IdMaster,IdentificadorDivision,IdentificadorImamaster,Ancho_Imamaster,Alto_Imamaster)
{
	var cadena="";
	cadena="visualizarimamaster.php?idimamaster="+IdentificadorImamaster+"&IdMaster="+IdMaster+"&IdentificadorDivision="+IdentificadorDivision;
	valores='height='+Alto_Imamaster+',width='+Ancho_Imamaster+',scrollbars=no,directories=NO,location=NO,alwaysRaised';
	secondwindow=open(cadena,'Editar',valores);
    secondwindow.moveTo(150,120);
}

function verificarcamposima()
{	
		cont=4;
		cont2=4;
		vec=new Array ('nombre','ancho','alto','descripcion');
//		vec=new Array ('nombredivision','estructuradivision','nombre','ancho','alto');
	
	for (i=0;i<vec.length;i++)
	{
		if(Trim(document.getElementById(vec[i]).value)=="")
		{
			document.getElementById(vec[i]).style.background="red";
			document.getElementById(vec[i]).value =Trim(document.getElementById(vec[i]).value);
			cont=cont-1;
		}
		else
		{
			document.getElementById(vec[i]).style.background="";
			document.getElementById(vec[i]).value =Trim(document.getElementById(vec[i]).value);
		}					
	}
	if(cont==cont2)
	{
		return 1;
	}
	else
	{
		return 0;
	}	
}
	
function cargar_paginadiv(valor)
{
//opener.location = 'otrapagina.php';si deseamos cargar otra pagina en lugar de la padre colocamos el codigo de esta linea
	if(valor==0){cargar();setTimeout("salir()",4500);}
}
function cambiotipodivision()
{		
		modulo=document.getElementById('tipodivision').value;
		if(modulo==1)
		{
			document.getElementById('banner').style.display ="";
			document.getElementById('mod').style.display ="none";
			document.getElementById('rotar').style.display ="";
			document.getElementById('divisiones').style.display ="none";
			document.getElementById('idioma').style.display ="";	
		}
		if(modulo==2)
		{
			document.getElementById('banner').style.display ="none";
			document.getElementById('mod').style.display ="none";
			document.getElementById('rotar').style.display ="none";
			document.getElementById('divisiones').style.display ="none";	
			document.getElementById('idioma').style.display ="none";				
		}		
		if(modulo==3)
		{
			document.getElementById('banner').style.display ="none";
			document.getElementById('mod').style.display ="";
			document.getElementById('rotar').style.display ="none";
			document.getElementById('divisiones').style.display ="none";			
			document.getElementById('idioma').style.display ="none";				
		}
}
function mostrardivisiones(valor)
{
	if(valor==1)
	{
		document.getElementById('divisiones').style.display ="";			
	}
	else
	{
		document.getElementById('divisiones').style.display ="none";			
	}
}
function crearseccion(IdMaster,iddivision)
{	
		document.getElementById('IdMaster').value=IdMaster;
		document.getElementById('iddivision').value=iddivision;
		document.frmdatos.action='crearseccion.php';
		document.frmdatos.submit();		
}
function eliminarseccion(IdMaster,iddivision,IdentificadorSeccion)
{
	if(confirm("Realmente desea eliminar la seccion"))
	{
		document.frmdatos.action='eliminarseccion.php';
		document.getElementById('IdMaster').value=IdMaster;
		document.getElementById('idseccion').value=IdentificadorSeccion;
		document.getElementById('iddivision').value=iddivision;
		document.frmdatos.submit();		
	}	
}
function crearsubseccion(IdMaster,iddivision,IdentificadorSeccion)
{
		document.frmdatos.action='../subseccion/crearsubseccion.php';
		document.getElementById('IdMaster').value=IdMaster;
		document.getElementById('idseccion').value=IdentificadorSeccion;
		document.getElementById('iddivision').value=iddivision;
		document.frmdatos.submit();		
}
function eliminarsubseccion(IdMaster,iddivision,IdentificadorSeccion,IdentificadorSubseccion)
{
	if(confirm("Realmente desea eliminar la subseccion"))
	{
		document.frmdatos.action='../subseccion/eliminarsubseccion.php';
		document.getElementById('IdMaster').value=IdMaster;
		document.getElementById('iddivision').value=iddivision;
		document.getElementById('idseccion').value=IdentificadorSeccion;
		document.getElementById('idsubseccion').value=IdentificadorSubseccion;
		document.frmdatos.submit();		
	}	
}
function cambiaestado()
{
	if(document.getElementById('estadosubseccion0').checked)
	{
		document.getElementById('estado').value="0";
	}
	else if(document.getElementById('estadosubseccion1').checked)
	{
		document.getElementById('estado').value="1";
	}
}

function cambiaopcvermas()
{
	if(document.getElementById('opcvermas0').checked)
	{
		document.getElementById('vermas').value="0";
	}
	else if(document.getElementById('opcvermas1').checked)
	{
		document.getElementById('vermas').value="1";
	}
}
function nivelseccion(IdMaster,iddivision,IdentificadorSeccion,OrdenSeccion,Opcion)
{
	document.frmdatos.action='nivelseccion.php';
	document.getElementById('IdMaster').value=IdMaster;
	document.getElementById('iddivision').value=iddivision;
	document.getElementById('idseccion').value=IdentificadorSeccion;
	document.getElementById('ordseccion').value=OrdenSeccion;
	document.getElementById('opcion').value=Opcion;
	document.frmdatos.submit();		
}
function nivelsubseccion(IdMaster,iddivision,IdentificadorSeccion,IdentificadorSubseccion,OrdenSubseccion,Opcion)
{
	document.frmdatos.action='../subseccion/nivelsubseccion.php';
	document.getElementById('IdMaster').value=IdMaster;
	document.getElementById('iddivision').value=iddivision;
	document.getElementById('idseccion').value=IdentificadorSeccion;
	document.getElementById('idsubseccion').value=IdentificadorSubseccion;	
	document.getElementById('ordsubseccion').value=OrdenSubseccion;
	document.getElementById('opcion').value=Opcion;
	document.frmdatos.submit();		
}
function menuprincipal()
{	
	document.frmdatos.action='../menu.php';
	document.frmdatos.submit();		
}

function showLightbox(id)
{
	document.getElementById(id).style.display='block';
		
/*$(function()  {  
		   $("#mostrar").click(function(event) {         
			event.preventDefault();         
			$("#"+id).slideToggle();  
			});  		   
		});  
	
*/
}
function hideLightbox(id)
{
	document.getElementById(id).style.display='none';
}

function mostraryocultar(valor)
{	
if(valor==1)
	{
		document.getElementById('manejoesp').style.display ="";
		document.getElementById('manejoing').style.display ="none";
	}
	else if(valor==0)
	{
		document.getElementById('manejoesp').style.display ="none";
		document.getElementById('manejoing').style.display ="";
	}
}
function mostraryocultararchivo(valor)
{	
	if(valor==0 || valor==1)
	{
		document.getElementById('archivo').style.display ="";
	}
	else 
	{
		document.getElementById('archivo').style.display ="none";
	}
}
function opcionmenu(id)
{
	if(id==1)
	{
		document.getElementById('1').style.display ="";
		document.getElementById('2').style.display ="none";
		document.getElementById('3').style.display ="none";
	}
	else if(id==2)
	{
		document.getElementById('1').style.display ="none";
		document.getElementById('2').style.display ="";
		document.getElementById('3').style.display ="none";
	}
	else if(id==3)
	{
		document.getElementById('1').style.display ="none";
		document.getElementById('2').style.display ="none";
		document.getElementById('3').style.display ="";
	}
}

function chequear()
{	
	IdentificadorPerfil=document.getElementById('perfil').value;
	
	if(IdentificadorPerfil==1)
	{
		for (i=0;i<document.frmDatos.checkbox.length;i++)
		  if(document.frmDatos.checkbox[i].type == "checkbox")
		  {
			 if(document.frmDatos.checkbox[i].value=="1") 
			 {
			 	document.frmDatos.checkbox[i].checked=1 ;
 			 	document.frmDatos.checkbox[i].disabled="disabled";
			 }
			 else
			 {
				document.frmDatos.checkbox[i].checked=0 ;	 
			 }			 
		  }
	}
	else 
	{
		for (i=0;i<document.frmDatos.checkbox.length;i++)
		  if(document.frmDatos.checkbox[i].type == "checkbox")
		  {
			 document.frmDatos.checkbox[i].checked=0 ;
 			 document.frmDatos.checkbox[i].disabled="";
		  }
	}
}

function insertarusuario()
{
	estado=verificarcampos();	
	if(document.getElementById('opcion').value!=1){
		valpass=1;
		vallog=1;
	}
	else{
		vallog=ValidaCampo('loginu');
		valpass=ValidaCampo('password');
	}
	if(estado==1)
	{
		if(vallog==1 && valpass==1)
		{
				cad="";
				for (i=0;i<document.frmDatos.checkbox.length;i++)
				{
				  if(document.frmDatos.checkbox[i].checked)
				  {
					  cad=cad+"1-";
				  }
				  else
				  {
					  cad=cad+"0-";
				  }
				}

				document.getElementById('cadena').value =cad.substring(0,cad.length-1);	
				document.frmDatos.action='crearusuarioguardad.php';								
				if(document.getElementById('opcion').value=='3')
				{
					if(confirm("Realmente desea eliminar este usuario"))
					{
						document.frmDatos.submit();			
					}
				}	
				else	
				{
					document.frmDatos.submit();					
				}
		}
		else
		{
			alert("Por favor verifique loa campos de Login y Clave ya que posee caracteres que no son permitidos");	
		}
	}
	else
	{
		alert('rellene los campos de color rojo');	
	}
}
function ValidaCampo(ident)
{  
   campo=document.getElementById(ident).value;
   caract_extra =""; 
   var ubicacion  
   var enter = "\n"  
   var caracteres = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" + String.fromCharCode(13) + enter + caract_extra  
   
   var contador = 0  
   for (var i=0; i < campo.length; i++)
   {  
     ubicacion = campo.substring(i, i + 1)  
     if (caracteres.indexOf(ubicacion) != -1)
	 {  
       contador++  
     } 
	 else
	 {  
    //   alert("ERROR: No se acepta el caracter '" + ubicacion + "'.")  
       return 0;  
     }  
   }  
   
  // alert("Datos correctos.")  
   return 1;  
 }  
function checkearmenu(cadena)
{
	vectopcionesmenu=cadena.split('-');
	for (i=0;i<vectopcionesmenu.length;i++)
	{	
		if(vectopcionesmenu[i]==0)
		document.getElementById(i+1).style.display ="none";
	}
}
function operacion(opcion)
{
	if(opcion==1)
	{
		document.getElementById('oper').style.display ="none";
		document.getElementById('nombre').value ="";
		document.getElementById('loginu').value ="";
		document.getElementById('password').value ="";
		document.getElementById('perfil').value ="";
		document.getElementById('email').value ="";
		
		document.getElementById('opcion').value =opcion;
		 chequear();
 		document.getElementById('button').value ="Guardar";
		 
//		document.getElementById('oper').value ="";
//		document.getElementById('oper').value ="";		
		
	}
	else if(opcion==2)
	{
		document.getElementById('oper').style.display ="";
		document.getElementById('opcion').value =opcion;
 		document.getElementById('button').value ="Editar";
	}
	else if(opcion==3)
	{
		document.getElementById('oper').style.display ="";
		document.getElementById('opcion').value =opcion;
		document.getElementById('button').value ="Eliminar";
	}
	
}
function recargar()
{
	document.frmDatos.method="post";
	document.frmDatos.submit();
}
function checkearmenu2(cadena)
{
	vectopcionesmenu=cadena.split('-');
	for (i=0;i<vectopcionesmenu.length;i++)
	{	
		if(vectopcionesmenu[i]==0)
		document.frmDatos.checkbox[i].checked =0;
		else
		document.frmDatos.checkbox[i].checked =1;
	}
}
//funcion para validar campos de laplantilla creasusuario
function verificarcampos()
{	
	cont=5;
	if(Trim(document.getElementById('nombre').value) =="")
	{
		document.getElementById('nombre').style.background="red";
		document.getElementById('nombre').value =Trim(document.getElementById('nombre').value);
		cont=cont-1;
	}
	else
	{
		document.getElementById('nombre').style.background="";
		document.getElementById('nombre').value =Trim(document.getElementById('nombre').value);
	}
	if(document.getElementById('opcion').value==1){
		if( Trim(document.getElementById('loginu').value) =="")
		{
			document.getElementById('loginu').style.background="red";
			document.getElementById('loginu').value =Trim(document.getElementById('loginu').value);
			cont=cont-1;
		}
		else
		{
			document.getElementById('loginu').style.background="";	
			document.getElementById('loginu').value =Trim(document.getElementById('loginu').value);
		}
	}
	if( Trim(document.getElementById('password').value) =="" && document.getElementById('opcion').value==1)
	{
		document.getElementById('password').style.background="red";
		document.getElementById('password').value =Trim(document.getElementById('password').value);
		cont=cont-1;		
	}
	else
	{
		document.getElementById('password').style.background="";
		document.getElementById('password').value =Trim(document.getElementById('password').value);
	}
	if( Trim(document.getElementById('perfil').value) =="")
	{
		document.getElementById('perfil').style.background="red";
		document.getElementById('perfil').value =Trim(document.getElementById('perfil').value);
		cont=cont-1;		
	}
	else
	{
		document.getElementById('perfil').style.background="";	
		document.getElementById('perfil').value =Trim(document.getElementById('perfil').value);
	}
	if( Trim(document.getElementById('email').value) =="" ||  valEmail(document.getElementById('email').value)==false)
	{
		document.getElementById('email').style.background="red";
		document.getElementById('email').value =Trim(document.getElementById('email').value);
		cont=cont-1;		
	}
	else
	{
		document.getElementById('email').style.background="";	
		document.getElementById('email').value =Trim(document.getElementById('email').value);
	}
	
	if(cont==5)
	{
		return 1;
	}
	else
	{
		return 0;
	}	
}
//funcion para validar espacios 
function Trim( str )
{
	var resultStr = "";
	
	resultStr = TrimLeft(str);
	resultStr = TrimRight(resultStr);
	
	return resultStr;
}
//funcion para validar espacios por izquierda
function TrimLeft( str )
{
	var resultStr = "";
	var i = len = 0;
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null)	
		return null;
	// Make sure the argument is a string
	str += "";
	if (str.length == 0) 
		resultStr = "";
	else {	
  		// Loop through string starting at the beginning as long as there
  		// are spaces.
//	  	len = str.length - 1;
		len = str.length;
		
  		while ((i <= len) && (str.charAt(i) == " "))
			i++;
   	// When the loop is done, we're sitting at the first non-space char,
 		// so return that char plus the remaining chars of the string.
  		resultStr = str.substring(i, len);
  	}
  	return resultStr;
}
//funcion para validar espacios por derecha
function TrimRight( str )
{
	var resultStr = "";
	var i = 0;
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null)	
		return null;
	// Make sure the argument is a string
	str += "";
	
	if (str.length == 0) 
		resultStr = "";
	else {
  		// Loop through string starting at the end as long as there
  		// are spaces.
  		i = str.length - 1;
  		while ((i >= 0) && (str.charAt(i) == " "))
 			i--;
 			
 		// When the loop is done, we're sitting at the last non-space char,
 		// so return that char plus all previous chars of the string.
  		resultStr = str.substring(0, i + 1);
  	}  	
  	return resultStr;  	
}
//funcion para validar correo
function valEmail(valor)
{
//	re  = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; 
	re  =/^\w+([\.\-\_]?\w+)*@\w+([\.-]?\w+)*(\.\D{2,4})+$/;	
    if(!re.exec(valor))
	{
        return false;
    }else
	{
        return true;
    }
}
function vermodulo(valor)
{
	if(valor==0)
	{
		document.getElementById('seccion').style.display ="";
		document.getElementById('idmodulo').style.display ="none";
		document.getElementById('idmaster').style.display ="none";		
		document.getElementById('idenlaceexterno').style.display ="none";		
		document.getElementById('tiposubseccion').value="0";
		
	}
	else if(valor==1)
	{
		document.getElementById('idmodulo').style.display ="";
		document.getElementById('seccion').style.display ="none";
		document.getElementById('idmaster').style.display ="none";		
		document.getElementById('idenlaceexterno').style.display ="none";		
		document.getElementById('tiposubseccion').value="1";
	}
	else if(valor==2)
	{
		document.getElementById('idmaster').style.display ="";		
		document.getElementById('idmodulo').style.display ="none";
		document.getElementById('seccion').style.display ="none";
		document.getElementById('idenlaceexterno').style.display ="none";
		document.getElementById('tiposubseccion').value="2";
	}
	else if(valor==3)
	{
		document.getElementById('idenlaceexterno').style.display ="";		
		document.getElementById('idmaster').style.display ="none";		
		document.getElementById('idmodulo').style.display ="none";
		document.getElementById('seccion').style.display ="none";
		document.getElementById('tiposubseccion').value="3";
	}

}

function verificarcamposdiv(opc)
{	
	if(opc==1)
	{
		cont=6;
		cont2=6;
		vec=new Array ('nombredivision','estructuradivision','descripciondivision','nombre','ancho','alto');
//		vec=new Array ('nombredivision','estructuradivision','nombre','ancho','alto');
	}
	else
	{
		cont=3;
		cont2=3;
		vec=new Array ('nombredivision','estructuradivision','descripciondivision');
	}	
	for (i=0;i<vec.length;i++)
	{
		if(Trim(document.getElementById(vec[i]).value)=="")
		{
			document.getElementById(vec[i]).style.background="red";
			document.getElementById(vec[i]).value =Trim(document.getElementById(vec[i]).value);
			cont=cont-1;
		}
		else
		{
			document.getElementById(vec[i]).style.background="";
			document.getElementById(vec[i]).value =Trim(document.getElementById(vec[i]).value);
		}					
	}
	if(cont==cont2)
	{
		return 1;
	}
	else
	{
		return 0;
	}	
}
function OnOff(campo,valor,elemento)
{
	cadena=document.getElementById(elemento).value;
	if(document.getElementById(campo).checked)
	{
		cadena=valor+","+cadena;
	}
	else
	{	
		VectorCadena=cadena.split(',');
		cadena="";
		for($i=0;$i<VectorCadena.length;$i++)
		{
			if(VectorCadena[$i]!=valor && VectorCadena[$i]!="")
			{
				cadena+=VectorCadena[$i]+",";
			}
		}
	}
	if(cadena.substr(cadena.length-1,cadena.length)==",")
	{
		cadena=cadena.substr(0,cadena.length-1);
	}				
	document.getElementById(elemento).value=cadena;
}
/*function crearcategoriadescargas()
{
	cadena="listarcategoriasdescargas.php";
	secondwindow=open(cadena,'Editar','height=300,width=580,scrollbars=yes,directories=NO,location=NO,alwaysRaised');
}
*/
function popupcrearcategoriadescargas(Identificador_Descargas_Categoria)
{
	cadena="listarcategoriasdescargas.php?Identificador_Descargas_Categoria="+Identificador_Descargas_Categoria;
	secondwindow=open(cadena,'Editar','height=180,width=600,scrollbars=yes,directories=NO,location=NO,alwaysRaised');
}

function crearcategoriasdescargas()
{
	document.frmdatos.action='crearcategoriasdescargas.php';
	document.frmdatos.submit();		
}

function popupeditarcategoriasdescargas(Identificador_Descargas_categoria,nombre)
{
	var cadena="";
	document.getElementById('identificadorcategoriasdescargas').value=Identificador_Descargas_categoria;	
	document.getElementById('Nombre').value=nombre;	
//	secondwindow=open(cadena,'Editar','height=10,width=400,scrollbars=no,directories=NO,location=NO,alwaysRaised');
}
function eliminarcategoriasdescargas(Identificador_Descargas_categoria)
{
	if(confirm("Realmente desea eliminar la categoria"))
	{
		document.getElementById('identificadorcategoriasdescargas').value=Identificador_Descargas_categoria;
		document.frmdatos.action='eliminarcategoriasdescargas.php';
		document.frmdatos.submit();			
	}	
}

function editarcategoriasdescargas(valor)
{
	if(valor==0){cargar();setTimeout("salir()",4500);}	
}

function creararchivodescargas(Identificador_Descargas_categoria)
{
	document.getElementById('identificadorcategoriasdescargas').value=Identificador_Descargas_categoria;	
	document.frmdatos.action='creararchivodescargas.php';
	document.frmdatos.submit();	
}

function popupeditararchivodescargas(Identificador_Descargas_Categoria,Identificador_Descargas)
{
	var cadena="";
	cadena="editararchivodescargas.php?iddescargascategoria="+Identificador_Descargas_Categoria+"&iddescargas="+Identificador_Descargas;
	secondwindow=open(cadena,'Editar','height=200,width=600,scrollbars=no,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
}

function editardescargas(valor)
{
	if(valor==0){cargar();setTimeout("salir()",4500);}	
}
function eliminararchivosdescargas(Identificador_Descargas_Categoria,Identificador_Descargas)
{
	document.getElementById('identificadorcategoriasdescargas').value=Identificador_Descargas_Categoria;	
	document.getElementById('identificadordescargas').value=Identificador_Descargas;		
	document.frmdatos.action='eliminararchivodescargas.php';
	document.frmdatos.submit();	
}
function descargar(nombre)
{
	document.getElementById('descarga').value=nombre;	
	document.frmdatos.action='descarga.php';
	document.frmdatos.submit();	
}
function descargarpru(nombre)
{
	document.getElementById('descarga').value=nombre;	
	document.frmdatospru.action='descarga.php';
	document.frmdatospru.submit();	
}


function descargardesc(nombre)
{
	document.getElementById('descarga').value=nombre;	
	document.frmdatosdesc.action='administrador/descargas/descarga.php';
	document.frmdatosdesc.submit();	
}

function descargar2(nombre)
{
	document.getElementById('descarga').value=nombre;	
	document.frmdatos.action='administrador/descargas/descarga.php';
	document.frmdatos.submit();	
}
function eliminarusuariodescargas(Identificador_Descargas_Usuario)
{
	document.getElementById('identificadordescargasusuario').value=Identificador_Descargas_Usuario;	
	document.frmdatos.action='eliminarusuariodescargas.php';
	document.frmdatos.submit();	
}

function popupcrearusuariodescargas(Identificador_Descargas_Usuario)
{
	var cadena="";
	cadena="editarusuariodescargas.php?iddescargasusuario="+Identificador_Descargas_Usuario;
	secondwindow=open(cadena,'Editar','height=400,width=550,scrollbars=no,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
}
function guardarusuariodescargas()
{
	valusuario=ValidaCampo('usuario');
	valclave=ValidaCampo('clave');
	if(valusuario==1 && valclave==1)
	{
		sexo=document.getElementById('sexo').value;
		
		$(document).ready(
					function()
					{	
				$.post("ajaxguardarusuariodescargas.php",{nombre:$("#nombre").val(),usuario:$("#usuario").val(),clave:$("#clave").val(),perfil:$("#perfil").val(),iddescargasusuario:$("#iddescargasusuario").val(),correo:$("#correo").val(),direccion:$("#direccion").val(),barrio:$("#barrio").val(),ciudad:$("#ciudad").val(),telefono:$("#telefono").val(),sexo:sexo},
									function(data)
									{ 																			
										//$("#subseccion").html(data);							
										//alert("Datos Editados Correctamente");
										if(data=="")
										{
											cargar_pagina();	
										}
										else
										{
											alert(data);	
										}
									}
								);						
					}
		);
	}
	else
	{
		alert("Por favor verifique loa campos de Login y Clave ya que posee caracteres que no son permitidos");		
	}
}
var temp=1;
function seltodos()
{	
	if(temp==1)
	{
		temp=0;
		n=document.frmdatos.checkboxd.length;
		m=document.frmdatos.checkboxa.length;
		if(n>1)
		{
			for (i=0;i<n;i++)		  
			{
				  document.frmdatos.checkboxd[i].checked=1 ;		 
			}
		}
		else{document.frmdatos.checkboxd.checked=1;}
		if(m>1)
		{
			for (i=0;i<m;i++)
			{
				  document.frmdatos.checkboxa[i].checked=1 ;		 
			}		
		}
		else{ document.frmdatos.checkboxa.checked=1;}
	}		
	else
	{
		temp=1;
		if(n>1)
		{
			for (i=0;i<n;i++)		  
			{
				  document.frmdatos.checkboxd[i].checked=0 ;		 
			}
		}
		else{document.frmdatos.checkboxd.checked=0;}
		if(m>1)
		{
			for (i=0;i<m;i++)
			{
				  document.frmdatos.checkboxa[i].checked=0 ;		 
			}		
		}
		else{ document.frmdatos.checkboxa.checked=0;}
	}
}

function enviarmensajemiembros()
{		
	n=document.frmdatos.checkboxd.length;
	if(n==null){n=1;}
	m=document.frmdatos.checkboxa.length;
	if(m==null){m=1;}
	
	cada="";
	cadd="";
	if(n>1)
	{
		for (i=0;i<n;i++)
		{
		  if(document.frmdatos.checkboxd[i].checked)
		  {
			  cadd=cadd+document.frmdatos.checkboxdd[i].value+"-";
		  }
		}
	}
	else
	{ 
		   if(document.frmdatos.checkboxd.checked==true)
		   {
			  cadd=cadd+document.frmdatos.checkboxdd.value+"-";			  
			}
	}
	
	if(m>1)
	{
		for (i=0;i<m;i++)
		{
		  if(document.frmdatos.checkboxa[i].checked)
		  {
			  cada=cada+document.frmdatos.checkboxaa[i].value+"-";			
		  }
		}
	}
	else
	{ 
		    if(document.frmdatos.checkboxa.checked==true)
		   {			 
			  cada=cada+document.frmdatos.checkboxaa.value+"-";			  	
		   }
	}	
	if(cada.substr(cada.length-1,cada.length)=="-")
	{
		cada=cada.substr(0,cada.length-1);
	}
	if(cadd.substr(cadd.length-1,cadd.length)=="-")
	{
		cadd=cadd.substr(0,cadd.length-1);
	}
	document.getElementById('cadenausudescargas').value=cadd;
//	document.getElementById('cadenausualmacenes').value=cada;
	document.getElementById('cadenausualmacenes').value="";
	document.frmdatos.action='guardaenviarmensajes.php';
	document.frmdatos.submit();	
}

function eliminaralmacenmensaje(Id_Almacen_Mensaje)
{
	if(confirm("Realmente desea eliminar este mensaje"))
	{
		document.getElementById('idalmacenmensaje').value=Id_Almacen_Mensaje;	
		document.frmdatos.action='eliminaralmacenmensaje.php';
		document.frmdatos.submit();	
	}
}
function popupalmacenmensaje(codigo_De_Almacen_Mensaje,Id_Almacen_Perfil_Mensaje,Id_Almacen_Mensaje)
{
	var cadena="";
	cadena="editaralmacenmensaje.php?codigodealmacenmensaje="+codigo_De_Almacen_Mensaje+"&Idalmacenperfilmensaje="+Id_Almacen_Perfil_Mensaje+"&Id_Almacen_Mensaje="+Id_Almacen_Mensaje;
	secondwindow=open(cadena,'Editar','height=300,width=420,scrollbars=no,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);	
}
function crearusuariodescargas()
{
	document.frmdatos.action='crearusuariodescargas.php';
	document.frmdatos.submit();	
}


function actualizardatos()
{
		$(document).ready(
				function()
				{				
					$.post("administrador/descargas/ajaxeditarusuarios.php",{},
								function(data)
								{ 										
									$("#subseccion").html(data);										
								}
							);						
				}
		);	
}
function centromensajeria()
{
	
	$(document).ready(
				function()
				{				
					$.post("administrador/descargas/ajaxmensajes.php",{},
								function(data)
								{ 										
									$("#subseccion").html(data);										
								}
							);						
				}
		);	
}
function iniciar()
{
	document.getElementById('frontxx').style.display ="";	
	setTimeout("parar()",5000);		 
}  
function parar()
{ 
	document.getElementById('frontxx').style.display ="none";			
}
function verificar2()
{
	//alert(document.getElementById('usu').value);
	usu1=document.getElementById('usucliente').value;
	cla1=document.getElementById('clacliente').value;

	if(usu1!="" && cla1!="")
	{	//conteo(2);
		
		$(document).ready(
				function()
				{				
					$.post("verificar/verifica2.php",{usuario:usu1,clave:cla1},
								function(data)
								{ 	
									//document.getElementById('usu').value="";
									//document.getElementById('cla').value="";
									
									if(data==2)
									{
										/*document.getElementById('usu').value="";
										document.getElementById('cla').value="";*/
										alert("Ingrese un usuario y clave validos");										
									}
									else if(data==0)
									{
									cadena="xmod_almacen/ingresoinformacionalmacen.php";
									secondwindow=open(cadena,'Editar','height=900,width=1200,scrollbars=yes,directories=NO,location=NO,alwaysRaised');
									document.frmpost.method='post';
									document.frmpost.action='index.php';
									document.frmpost.submit();	
									}
									else
									{
										//data="En proceso";
										$("#subseccion").html(data);	
											document.getElementById('front').style.display ="none";
											document.getElementById('subseccioninicio').style.display ="";
											document.getElementById('subseccion').style.display ="";
											document.getElementById('subsecciont').style.display ="";	
									}
								}
							);						
				}
		);	
	}
}
function actualizardatos2()
{
	valclave=ValidaCampo('clave2');
	if(valclave==1)
	{
		$(document).ready(
						function()
						{				
							$.post("administrador/descargas/ajaxeditarusuariosguardar.php",{nombre:$("#nombre").val(),usuario:$("#usuario2").val(),clave:$("#clave2").val(),correo:$("#correo").val(),direccion:$("#direccion").val(),barrio:$("#barrio").val(),ciudad:$("#ciudad").val(),telefono:$("#telefono").val()},
										function(data)
										{ 	
											//alert(data);	
											//$("#subseccion").html(data);
											alert("Los datos se guardaron satisfactoriamente");
											verificar2()
										}
									);						
						}
				);
	}
	else
	{
		alert("Por favor verifique el campo de Clave ya que posee caracteres que no son permitidos");		
	}
}

function enviarmensaje()
{	
	$(document).ready(
				function()
				{				
					$.post("administrador/descargas/ajaxmensajesguardar.php",{asunto:$("#asunto").val(),mensaje:$("#mensaje").val(),idmensaje:$("#idmensaje").val()},
								function(data)
								{ 																			
									//$("#subseccion").html(data);
									alert("Los datos se guardaron satisfactoriamente");
									centromensajeria();
								}
							);						
				}
		);
}
function eliminamensaje(valor)
{
	if(confirm("Realmente desea eliminar este mensaje"))
	{
		$(document).ready(
					function()
					{				
						$.post("administrador/descargas/ajaxmensajeseliminar.php",{idmensaje:valor},
									function(data)
									{ 																			
										//$("#subseccion").html(data);
										//alert(data);
										alert("Los datos se eliminaron satisfactoriamente");
										centromensajeria();
									}
								);						
					}
			);
	}
}

function verdescargas(Identificador_Descargas_Categoria)
{
	$(document).ready(
				function()
				{				
					$.post("administrador/descargas/ajaxdescargas.php",{Identificador_Descargas_Categoria:Identificador_Descargas_Categoria},
								function(data)
								{ 										
									$("#subseccion").html(data);										
								}
							);						
				}
		);	
}

function cargarflash1(divisiones)
{

	$(document).ready(
				function()
				{						
					vectdiv=divisiones.split(',');
					var n=vectdiv.length;
					for(i=1;i<=n;i++)
					{	
						var rango_superior = 10;  
						var rango_inferior = 5;  
						var aleatorio = Math.random()
						while(aleatorio>rango_inferior && aleatorio<rango_superior)
						{
							aleatorio = Math.random();
						}
						$.post("funciones/ajaxcargarflash.php",{Opcion:i,divisiones:divisiones},
									function(data)
									{ 
										vetdata=data.split(',');
										dato=vetdata[0];
										opc=vetdata[1];
										id="#flash1";
										$(id).html(data);							
									}
								);						
					}			
				}
	);					
}
function cargarflash2(divisiones)
{

	$(document).ready(
				function()
				{						
					vectdiv=divisiones.split(',');
					var n=vectdiv.length;
					for(i=1;i<=n;i++)
					{	
						var rango_superior = 10;  
						var rango_inferior = 5;  
						var aleatorio = Math.random()
						while(aleatorio>rango_inferior && aleatorio<rango_superior)
						{
							aleatorio = Math.random();
						}
						$.post("funciones/ajaxcargarflash.php",{Opcion:i,divisiones:divisiones},
									function(data)
									{ 
										vetdata=data.split(',');
										dato=vetdata[0];
										opc=vetdata[1];
										id="#flash2";
										$(id).html(data);							
									}
								);						
					}			
				}
	);					
}

function cargarflash3(divisiones)
{

	$(document).ready(
				function()
				{						
					vectdiv=divisiones.split(',');
					var n=vectdiv.length;
					for(i=1;i<=n;i++)
					{	
						var rango_superior = 10;  
						var rango_inferior = 5;  
						var aleatorio = Math.random()
						while(aleatorio>rango_inferior && aleatorio<rango_superior)
						{
							aleatorio = Math.random();
						}
						$.post("funciones/ajaxcargarflash.php",{Opcion:i,divisiones:divisiones},
									function(data)
									{ 
										vetdata=data.split(',');
										dato=vetdata[0];
										opc=vetdata[1];
										id="#flash3";
										$(id).html(data);							
									}
								);						
					}			
				}
	);					
}
function conteo(division)
{
	/*$.post("funciones/ajaxconteo.php",{division:division},
		function(data)
		{ 
//		alert("hizo clic");
		}
	);*/			
	//alert(division);
}
function contar(Conteo_Imamaster)
{
		alert("El numero tolal  de clic echos en el baner son de "+ Conteo_Imamaster);	
}
temestado=1
function ocultar()
{
/*	if(temestado==1)
	{	
		document.getElementById('flash1').style.display ="none";
		document.getElementById('flash2').style.display ="none";
		temestado=0;		
	}
	else
	{
		document.getElementById('flash1').style.display ="";
		document.getElementById('flash2').style.display ="";
		temestado=1;				
	}*/
}

function popupeditarfondoestilos(Id_Fondo_Estilo)
{
	var cadena="";
	IdMaster=document.getElementById('master').value;
	cadena="editarfondoestilos.php?idfondoestilo="+Id_Fondo_Estilo+"&IdMaster="+IdMaster;
	secondwindow=open(cadena,'Editar','height=220,width=580,scrollbars=no,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
}
function editarfondoestilo(valor)
{
	if(valor==0){cargar();setTimeout("salir()",4500);}	
}


function eliminarfondoestilos(Id_Fondo_Estilo)
{
	if(confirm("Realmente desea eliminar esta imagen de estilo "))
	{
		document.frmdatos.action='eliminarfondoestilos.php';
		document.getElementById('Identificador_Fondo_Estilo').value=Id_Fondo_Estilo;
		document.frmdatos.submit();			
	}	
}

function popupverfondoestilos(Id_Fondo_Estilo)
{
	var cadena="";
	IdMaster=document.getElementById('master').value;
	cadena="vereditarfondoestilos.php?idfondoestilo="+Id_Fondo_Estilo+"&IdMaster="+IdMaster;
	secondwindow=open(cadena,'Editar','height=400,width=430,scrollbars=no,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);	
}
function cargarestilosfondo()
{			
	$(document).ready(
				function()
				{				
					$.post("administrador/fondos_estilos/ajax_estilos.php",{},
								function(data)
								{ 
									$("#estilofondo").html(data);										
								}
							);						
				}
	);	
}
function regusuarios()
{
alert("aqui va el lamado al modulo de usuarios");	
}

function frontal()
{

document.getElementById('DIV6-7').style.display ="";	
$(document).ready(
				function()
				{				
					$.post("funciones/ajaxfront.php",{},
								function(data)
								{ 																			
								$("#subseccion").html(data);									
								}
							);						
				}
	);	
}

function imagenes()
{
cadena="http://www.sintramites.com/camaradirectav2/FCKeditor/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=http://www.sintramites.com/camaradirectav2/FCKeditor/FCKeditor/editor/filemanager/connectors/php/connector.php";
secondwindow=open(cadena,'Editar','height=500,width=800,scrollbars=no,directories=NO,location=NO,alwaysRaised');
}

function salida()
{
/*	cadena='index.php?est='+1;
	secondwindow=open(cadena,'Editar','');*/
//	document.frmdatospru.target='_blanck';
	document.frmdatospru.action='index.php';
	document.frmdatospru.submit();	
//	window.close()
}
function recargarsecc()
{	
	iddivision=document.getElementById('division').value;
	document.frmdatos.method='get';
	document.frmdatos.action='listaseccion.php?iddivision='+iddivision;
	document.frmdatos.submit();	
}

function recargarmaster()
{	
	IdMaster=document.getElementById('master').value;
	document.frmdatos.method='get';
	document.frmdatos.action='listadivision.php?IdMaster='+IdMaster;
	document.frmdatos.submit();	
}
function recargarmaster2()
{	
	IdMaster=document.getElementById('master').value;
	document.frmdatos.method='get';
	document.frmdatos.action='listaseccion.php?IdMaster='+IdMaster;
	document.frmdatos.submit();	
}
function NoticiasFrontEnlace(valor,n)
{
	for(i=0;i<n;i++)
	{			
		if(valor==i)
		{
			document.getElementById('not'+i).style.display ="";								
		}
		else
		{
			document.getElementById('not'+i).style.display ="none";								
		}
	}
}

function creaitem()
{
	document.frmdatos.action='crearitemmenu.php';
	document.frmdatos.submit();		
}

function popupeditaritemmenu(Id_Menu)
{
	var cadena="";
	cadena="editarmenu.php?Id_Menu="+Id_Menu;
	secondwindow=open(cadena,'Editar','height=150,width=430,scrollbars=no,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);	

}

function eliminaritemmenu(Id_Menu)
{
	document.getElementById('Id_Menu').value=Id_Menu;
	document.frmdatos.action='eliminarmenu.php';
	document.frmdatos.submit();	
}

function editarmenu()
{	
	estado="0";
	if(document.getElementById('estado_0').checked)
	{
		estado="0";	
	}
	else if(document.getElementById('estado_1').checked)
	{
		estado="1";	
	}
	$(document).ready(
				function()
				{	
					$.post("ajaxeditarmenu.php",{estado:estado,nombre:$("#nombre").val(),tipo:$("#tipo").val(),Id_Menu:$("#Id_Menu").val()},
								function(data)
								{ 																			
								//$("#subseccion").html(data);							
								//alert("Datos Editados Correctamente");
								//alert(data);
								cargar_pagina();
								}
							);						
				}
	);					
}

function nivelmenu(Id_Menu,Ord_Menu,Tipo_Menu,Opcion)
{
	document.frmdatos.action='nivelmenu.php';
	document.getElementById('Ord_Menu').value=Ord_Menu;
	document.getElementById('Id_Menu').value=Id_Menu;
	document.getElementById('opcion').value=Opcion;
	document.getElementById('Tipo_Menu').value=Tipo_Menu;
	document.frmdatos.submit();		
}

function activarcliente(valor)
{	
	if(valor==1)
	{
		document.getElementById('datos').style.display ="";	
		document.getElementById('mensajeria').style.display ="none";		
		document.getElementById('subseccion').style.display ="none";		
		document.getElementById('noticia').style.display ="none";		
		document.getElementById('chat').style.display ="none";			
	}
	if(valor==2)
	{
		document.getElementById('datos').style.display ="none";	
		document.getElementById('mensajeria').style.display ="";		
		document.getElementById('subseccion').style.display ="none";		
		document.getElementById('noticia').style.display ="none";		
		document.getElementById('chat').style.display ="none";			
	}
	if(valor==3)
	{
		document.getElementById('datos').style.display ="none";	
		document.getElementById('mensajeria').style.display ="none";		
		document.getElementById('subseccion').style.display ="";		
		document.getElementById('noticia').style.display ="none";		
		document.getElementById('chat').style.display ="none";			
	}
	if(valor==4)
	{
		document.getElementById('datos').style.display ="none";	
		document.getElementById('mensajeria').style.display ="none";		
		document.getElementById('subseccion').style.display ="none";		
		document.getElementById('noticia').style.display ="";		
		document.getElementById('chat').style.display ="none";			
	}
	if(valor==5)
	{
		document.getElementById('datos').style.display ="none";	
		document.getElementById('mensajeria').style.display ="none";		
		document.getElementById('subseccion').style.display ="none";		
		document.getElementById('noticia').style.display ="none";		
		document.getElementById('chat').style.display ="";			
	}
}
function buscadoratras(palabras,Idioma)
{
//	palabra=document.getElementById('busqueda').value;
//	alert(palabra);
	$(document).ready(
				function()
				{				
					$.post("xmod_noticias/ajaxbuscarnoticiascliente.php",{palabras:palabras,Idioma:Idioma},
								function(data)
								{ 	
									$("#subseccion").html(data);
								}
							);						
				}
	);	
}


function popupeditarmaster(Id_Master)
{
	var cadena="";
	cadena="editarmaster.php?Id_Master="+Id_Master;
	secondwindow=open(cadena,'Editar','height=200,width=600,scrollbars=yes,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
}
function eliminarmaster(Id_Master)
{
	if(confirm("Realmente desea eliminar este nombre "))
	{
		document.frmdatos.action='eliminarmaster.php';
		document.getElementById('Id_Master').value=Id_Master;
		document.frmdatos.submit();			
	}	
}
function recargarmasterfondos()
{	
	IdMaster=document.getElementById('master').value;
	document.frmdatos.method='get';
	document.frmdatos.action='listafondoestilos.php?IdMaster='+IdMaster;
	document.frmdatos.submit();	
}
function creafondos(IdMaster)
{
	document.getElementById('IdMaster').value=IdMaster;
	document.frmdatos.action='creaefondoestilos.php';
	document.frmdatos.submit();		
}

function popupvideoservicios()
{
	/*	
	var cadena="";
	cadena="videoservicios.html";
	secondwindow=open(cadena,'Editar','height=480,width=640,scrollbars=NO,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
	*/
	document.getElementById('idmodal').style.display ="";		
	$(document).ready(
				function()
				{				
					$.post("videoservicios.php",{},
								function(data)
								{ 	
									$("#idmodalinterior").html(data);
								}
							);						
				}
	);		
}
function popupvideoregistro()
{
	/*var cadena="";
	cadena="videoregistro.html";
	secondwindow=open(cadena,'Editar','height=480,width=640,scrollbars=NO,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);*/
	document.getElementById('idmodal').style.display ="";		
	$(document).ready(
				function()
				{				
					$.post("videoregistro.php",{},
								function(data)
								{ 	
									$("#idmodalinterior").html(data);
								}
							);						
				}
	);		
}

function popupvideodesarrollo()
{
	/*
	var cadena="";
	cadena="videodesarrollo.html";
	secondwindow=open(cadena,'Editar','height=480,width=640,scrollbars=NO,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
	*/	
	document.getElementById('idmodal').style.display ="";		
	$(document).ready(
				function()
				{				
					$.post("videodesarrollo.php",{},
								function(data)
								{ 	
									$("#idmodalinterior").html(data);
								}
							);						
				}
	);		
}
function popupvideoregional()
{
	/*
	var cadena="";
	cadena="videoregional.html";
	secondwindow=open(cadena,'Editar','height=480,width=640,scrollbars=NO,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
	*/
	
	document.getElementById('idmodal').style.display ="";		
	$(document).ready(
				function()
				{				
					$.post("videoregional.php",{},
								function(data)
								{ 	
									$("#idmodalinterior").html(data);
								}
							);						
				}
	);		
}
function ocultarmodal()
{	
	document.getElementById('idmodal').style.display ="none";
	document.getElementById('idmodalinterior').innerHTML ="";
}
function buscador2esp(pagina,opcion,id1,id2,id3)
{
	$(document).ready(
				function()
				{				
					$.post("administrador/buscador/buscadorvermas2.php",{pagina:pagina,opcbuscar:opcion,id1:id1,id2:id2,id3:id3},
								function(data)
								{ 												
									$("#frontbuscador0").html(data);																								
								}
							);						
				}
			);	
}
function buscador2(pag,Idioma)
{	
	palbuscar=Trim(document.getElementById('palabra').value);	
	for(i=1;i<=5;i++)
	{	
		if(document.getElementById('opcion_'+i).checked)
		{
			opcbuscar=i;
		}
	}	
	if(palbuscar!="")
	{									
		$(document).ready(
				function()
				{				
					$.post("administrador/buscador/buscador2.php",{_pagi_pg:pag,Idioma:Idioma,palbuscar:$("#palabra").val(),opcbuscar:opcbuscar},
								function(data)
								{ 	
									document.getElementById('frontbuscador0').style.display ="";															
									$("#frontbuscador0").html(data);											
									document.getElementById('frontbuscador').style.display ="none";
									document.getElementById('opcionesconsulta').style.display ="none";
									scrollBy(0,550);		
								}
							);						
				}
			);					
	}
	else
	{
		alert("Por favor ingrese una palabra a buscar");
		document.getElementById('palabra').value="";
		document.getElementById('opcionesconsulta').style.display ="none";
	}		
}

function descargasmodulo(nombre)
{ 
	document.getElementById('descarga1').value=nombre;	
	document.frmdatosbuscador.action='xmod_descargas/descarga.php';
	document.frmdatosbuscador.submit();	
}
function veropciones()
{ 
	document.getElementById('opcionesconsulta').style.display ="";
}
function ocultaropciones()
{
	document.getElementById('opcionesconsulta').style.display ="none";
}
function buscadorcultar()
{
	document.getElementById('frontbuscador0').style.display ="none";
	document.getElementById('frontbuscador').style.display ="";
}
