// JavaScript Document

// JavaScript Document
function ingresar()
{
	//document.sample.action="accion.asp";
	document.sample.submit();
}

 function openWin2(url,titulo,width,height) {

  popupWin = window.open(url,titulo,'width='+width+',height='+height+',scrollbars=no,toolbars=no,menubar=no,resizable=no')
  popupWin.focus();
  popupWin.moveTo( 80, 50 );
  return popupWin;
  
  
}

 function abrirVentana(url,titulo,width,height) {
		
		var wOpen;
		var sOptions;
		
		sOptions = 'directories=no,status=no,toolbar=no,menubar=no,scrollbars=no';
		sOptions = sOptions + ',resizable=no,location=no,maximize=no';
		//sOptions = sOptions + ',width=' + (screen.availWidth - 12).toString();
		sOptions = sOptions + ',width=' + width;
		sOptions = sOptions + ',height=' + height;/*(screen.availHeight - 122).toString();*/
		sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';
		
		wOpen = window.open( '', titulo, sOptions );
		wOpen.location = url;
		wOpen.focus();
		wOpen.moveTo( 60, 40 );
		//wOpen.resizeTo( screen.availWidth, screen.availHeight );
		return wOpen;
  
  
  
 /* 
  popupWin = window.open(url,titulo,'width='+width+',height='+height+',scrollbars=no,toolbars=no,menubar=no,resizable=no')
  popupWin.focus();
  //popupWin.moveTo( 80, 50 );
  return popupWin;
  */
  
}


function limpiar(){
	document.sample.username.value = "ad";
	document.sample.password.value = "ad";
	document.sample.reset();
	document.sample.username.focus();
}

//->scripts para trabajos en ajax

	function retorno(valor){
	 document.getElementById("opcion2").value = valor;
	 }
	 
//->funciones para carga de divs [con la imagen preload].
 /**
 * actualizar:  adaptación de ejemplo basico de AJAX (2)
 */
  function actualizar(capa,url) {

	//var gopage = document.getElementById("gopage").value;
	 // Creamos el objeto, segun el navegador
	 if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
 	   xmlhttprequest = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
	    xmlhttprequest = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	
	// PREPARANDOSE PARA LA RESPUESTA
	// establecemos un handler para cuando llegue la respuesta,
	xmlhttprequest.onreadystatechange = function() { procesa(xmlhttprequest,capa); };
	
	
	// HACIENDO LA PETICION
	// Open(metodo, url, y si queremos la peticion asincrona o no)
	xmlhttprequest.open('POST', url, true);
	 
	// Preparamos el POST. Hay que establecer esta cabecera
	// para poder enviar variables por post
	xmlhttprequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	 
	 // Send es necesario si queremos pasar variables por POST
	 // asi que construimos una especie de query string con variables=valores
	 xmlhttprequest.send(null);

}

/**
 * procesa
 * parametros: el objeto xmlhttprequest
 * Es la funcion handler que procesa el archivo recibido a traves
 * de la peticion. Es igual que la funcion anterior pero en este caso parseamos el XML
 */
 function procesa(xhr,capa) {

 	// primermo comprobamos el estado de la respuesta
	 if (xhr.readyState == 4) {
			// A continuacion comprobamos el codigo de respuesta HTTP del servidor
	 		if (xhr.status == 200) {
	 			//alert(xhr.responseText);
				contenedor = window.document.getElementById(capa);
				contenedor.innerHTML = xhr.responseText;
	 	 	} else {
		 	 	alert("No se recibio una respuesta correcta. Respuesta HTTP: " + xhr.status);
	 		}
	  } else {
	    // Todavia no hay respuesta...
		contenedor = window.document.getElementById(capa);
		contenedor.innerHTML = "<img src=\"images/indicator_medium.gif\" width=\"32\" height=\"32\" border= \"0\" aling=\"absmiddle\"><br><font style=\"font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#003366;\">Cargando contenido</font>";
	  }
 }



 /**
 * actualizar:  adaptación de ejemplo basico de AJAX (2)
 */
  function actualizar2(capa,url) {

	//var gopage = document.getElementById("gopage").value;
	 // Creamos el objeto, segun el navegador
	 if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
 	   xmlhttprequest2 = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
	    xmlhttprequest2 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	
	// PREPARANDOSE PARA LA RESPUESTA
	// establecemos un handler para cuando llegue la respuesta,
	xmlhttprequest2.onreadystatechange = function() { procesa2(xmlhttprequest2,capa); };
	
	
	// HACIENDO LA PETICION
	// Open(metodo, url, y si queremos la peticion asincrona o no)
	xmlhttprequest2.open('POST', url, true);
	 
	// Preparamos el POST. Hay que establecer esta cabecera
	// para poder enviar variables por post
	xmlhttprequest2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	 
	 // Send es necesario si queremos pasar variables por POST
	 // asi que construimos una especie de query string con variables=valores
	 xmlhttprequest2.send(null);

}

/**
 * procesa
 * parametros: el objeto xmlhttprequest
 * Es la funcion handler que procesa el archivo recibido a traves
 * de la peticion. Es igual que la funcion anterior pero en este caso parseamos el XML
 */
 function procesa2(xhr,capa) {

 	// primermo comprobamos el estado de la respuesta
	 if (xhr.readyState == 4) {
			// A continuacion comprobamos el codigo de respuesta HTTP del servidor
	 		if (xhr.status == 200) {
	 			//alert(xhr.responseText);
				contenedor = window.document.getElementById(capa);
				contenedor.innerHTML = xhr.responseText;
	 	 	} else {
		 	 	alert("No se recibio una respuesta correcta. Respuesta HTTP: " + xhr.status);
	 		}
	  } else {
	    // Todavia no hay respuesta...
		contenedor = window.document.getElementById(capa);
		contenedor.innerHTML = "<img src=\"images/indicator_medium.gif\" width=\"32\" height=\"32\" border= \"0\" aling=\"absmiddle\"><br><font style=\"font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#003366;\">Cargando contenido</font>";
	  }
 }








//->INICIO ::: AJAX PARA ACTUALIZAR CAPA SUPERIOR A UN IFRAME / considerando la existencia de mas de un iframe


 /**
 * actualizar:  adaptación de ejemplo basico de AJAX (2)
 */
  function actualizar_div_top(capa,url) {

	//var gopage = document.getElementById("gopage").value;
	 // Creamos el objeto, segun el navegador
	 if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
 	   xmlhttprequest = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
	    xmlhttprequest = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	
	// PREPARANDOSE PARA LA RESPUESTA
	// establecemos un handler para cuando llegue la respuesta,
	xmlhttprequest.onreadystatechange = function() { procesa_div_top(xmlhttprequest,capa); };
	
	
	// HACIENDO LA PETICION
	// Open(metodo, url, y si queremos la peticion asincrona o no)
	xmlhttprequest.open('POST', url, true);
	 
	// Preparamos el POST. Hay que establecer esta cabecera
	// para poder enviar variables por post
	xmlhttprequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	 
	 // Send es necesario si queremos pasar variables por POST
	 // asi que construimos una especie de query string con variables=valores
	 xmlhttprequest.send(null);

}

/**
 * procesa
 * parametros: el objeto xmlhttprequest
 * Es la funcion handler que procesa el archivo recibido a traves
 * de la peticion. Es igual que la funcion anterior pero en este caso parseamos el XML
 */
 function procesa_div_top(xhr,capa) {

 	// primermo comprobamos el estado de la respuesta
	 if (xhr.readyState == 4) {
			// A continuacion comprobamos el codigo de respuesta HTTP del servidor
	 		if (xhr.status == 200) {
	 			//alert(xhr.responseText);
				
				contenedor_old = window.parent.document.getElementById('preaviso');
				contenedor_old.style.display=(contenedor_old.style.display=="none")? "none" : "none";
				
				contenedor = window.parent.document.getElementById(capa);
				contenedor.innerHTML = xhr.responseText;
	 	 	} else {
		 	 	alert("No se recibio una respuesta correcta. Respuesta HTTP: " + xhr.status);
	 		}
	  } else {
	    // Todavia no hay respuesta...
		contenedor = window.parent.document.getElementById('preaviso');
		//alert(""+contenedor);
		contenedor.style.display=(contenedor.style.display=="block")? "block" : "block";
		contenedor.innerHTML = "<img src=\"images/indicator_medium.gif\" width=\"32\" height=\"32\" border= \"0\" aling=\"absmiddle\"><br><font style=\"font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#003366;\">Cargando contenido</font>";
	  }
 }



//->FIN ::: AJAX PARA ACTUALIZAR CAPA SUPERIOR A UN IFRAME
/*AJAX PARA EL VOTO EN ENCUESTA*/
 /**
 * votar :  Ejemplo basico de AJAX (2)
 * Invocado desde el boton de conversion, prepara el objeto de peticion 
 * e invoca una pagina php remota
 */
  function votar(capa,url) {
	var opcion2 = document.getElementById("opcion2").value;
	var idencuesta = document.getElementById("idencuesta").value;
	
	if(opcion2 == ""){ 
	alert ('debe escoger una opcion');
	return false;
	}
  
	 // Creamos el objeto, segun el navegador
	 if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
 	   xmlhttprequest = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
	    xmlhttprequest = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	
	// PREPARANDOSE PARA LA RESPUESTA
	// establecemos un handler para cuando llegue la respuesta,
	xmlhttprequest.onreadystatechange = function() { procesa(xmlhttprequest,capa); };
	
	
	// HACIENDO LA PETICION
	// Open(metodo, url, y si queremos la peticion asincrona o no)
	xmlhttprequest.open('POST', url, true);
	 
	// Preparamos el POST. Hay que establecer esta cabecera
	// para poder enviar variables por post
	xmlhttprequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	 
	 // Send es necesario si queremos pasar variables por POST
	 // asi que construimos una especie de query string con variables=valores
	 xmlhttprequest.send("opcion="+opcion2+"&idencuesta="+idencuesta);
 }

 /**
 * votar :  Ejemplo basico de AJAX (2)
 * Invocado desde el boton de conversion, prepara el objeto de peticion 
 * e invoca una pagina php remota
 */
  function detalle_encuesta(capa,url) {
	var opcion2 = document.getElementById("opcion2").value;
	var idencuesta = document.getElementById("idencuesta").value;
	
	/*if(opcion2 == ""){ 
	alert ('debe escoger una opcion');
	return false;
	}*/
  
	 // Creamos el objeto, segun el navegador
	 if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
 	   xmlhttprequest = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
	    xmlhttprequest = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	
	// PREPARANDOSE PARA LA RESPUESTA
	// establecemos un handler para cuando llegue la respuesta,
	xmlhttprequest.onreadystatechange = function() { procesa(xmlhttprequest,capa); };
	
	
	// HACIENDO LA PETICION
	// Open(metodo, url, y si queremos la peticion asincrona o no)
	xmlhttprequest.open('POST', url, true);
	 
	// Preparamos el POST. Hay que establecer esta cabecera
	// para poder enviar variables por post
	xmlhttprequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	 
	 // Send es necesario si queremos pasar variables por POST
	 // asi que construimos una especie de query string con variables=valores
	 xmlhttprequest.send("opcion="+opcion2+"&idencuesta="+idencuesta);
 }
 
 	function recoger_campos_formulario(){
		//var Menu = document.getElementById(menuId);
		var elemento = document.getElementsByTagName('input');
		//alert ("son: "+elemento.length);
		///*
		var postal = "";
		for (var i=0; i < elemento.length; i++) {
		  //var postal = "";
		  var nombre = elemento[i].name;
		  var indicador = nombre.charAt(5);
		  	if(indicador == '['){
				postal = postal+nombre+"="+limpiar_and(elemento[i].value)+"&";
				//postal = postal + "hola "
			}
		  //elemento[i].style.display='none';
		  //elemento[i].parentNode.style.listStyleImage = 'url(block.png)';
		  //elemento[i].parentNode.addEventListener('click', Accionar, 0);
		  }
		  
		  
		 var elemento2 = document.getElementsByTagName('textarea');
		//alert ("son: "+elemento.length);
		///*
		//var postal = "";
		for (var i=0; i < elemento2.length; i++) {
		  //var postal = "";
		  var nombre = elemento2[i].name;
		  var indicador = nombre.charAt(5);
			if(indicador == '['){
				postal = postal+nombre+"="+limpiar_and(elemento2[i].value)+"&";
				//postal = postal + "hola "
			}
		  //elemento[i].style.display='none';
		  //elemento[i].parentNode.style.listStyleImage = 'url(block.png)';
		  //elemento[i].parentNode.addEventListener('click', Accionar, 0);
		  }
		  
		  
		  //alert ("ind: "+postal);
		  return postal;
		//*/
	}
	
	
	 /**
 * actualizar:  adaptación de ejemplo basico de AJAX (2)
 */
  function enviar_formulario(capa,url) {
	var datosformulario = recoger_campos_formulario();
	//var valormail = document.getElementById("email").value;
	
	//var proseguir = emailCheck (valormail); //esta funcion esta en el script var.js
	var proseguir = validar();
	
	if(proseguir){
		//var gopage = document.getElementById("gopage").value;
		 // Creamos el objeto, segun el navegador
		  limpiar();
		 if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
		   xmlhttprequest = new XMLHttpRequest();
		} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
			xmlhttprequest = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		
		// PREPARANDOSE PARA LA RESPUESTA
		// establecemos un handler para cuando llegue la respuesta,
		xmlhttprequest.onreadystatechange = function() { procesa(xmlhttprequest,capa); };
		
		
		// HACIENDO LA PETICION
		// Open(metodo, url, y si queremos la peticion asincrona o no)
		xmlhttprequest.open('POST', url, true);
		 
		// Preparamos el POST. Hay que establecer esta cabecera
		// para poder enviar variables por post
		xmlhttprequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttprequest.setRequestHeader('charset', 'ISO-8859-1');
		//header('Content-Type: text/xml; charset=ISO-8859-1');
		 
		 // Send es necesario si queremos pasar variables por POST
		 // asi que construimos una especie de query string con variables=valores
		 //xmlhttprequest.send(null);
		 xmlhttprequest.send(datosformulario);
		
	}

}


function validar(){
	var valornombre = document.getElementById("nombre").value;
	var valoremail = document.getElementById("email").value;
	var valormensaje = document.getElementById("mensaje").value;
	var valormail = document.getElementById("email").value;
	var retorno = true;
	
	if(valornombre == ""){
		alert("el nombre se encuentra en blanco");
		retorno =  false;
		//break;
		}
	if(valoremail == "" && retorno == true){
		alert("el e-mail se encuentra en blanco");
		retorno =  false;
		}
	if(valormensaje == "" && retorno == true){
		alert("Escriba su mensaje");
		retorno =  false;
		}
	if(retorno == true){
			var retorno = emailCheck (valormail);//esta funcion esta en el script var.js
		}	
		
	return retorno;
}


	function limpiar(){
		document.getElementById("nombre").value = "";
		document.getElementById("email").value = "";
		document.getElementById("empresa").value = "";
		document.getElementById("telefono").value = "";
		document.getElementById("mensaje").value = "";
		
	}

	function mostrar_estadisticas( aURL, aWinName ){
		var wOpen;
		var sOptions;
		
		sOptions = 'directories=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes';
		sOptions = sOptions + ',resizable=yes,location=no,maximize=yes';
		sOptions = sOptions + ',width=' + (screen.availWidth - 12).toString();
		sOptions = sOptions + ',height=' + (screen.availHeight - 122).toString();
		sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';
		
		wOpen = window.open( '', aWinName, sOptions );
		wOpen.location = aURL;
		wOpen.focus();
		wOpen.moveTo( 0, 0 );
		wOpen.resizeTo( screen.availWidth, screen.availHeight );
		return wOpen;
	}
	
	
	 /**
 * actualizar:  adaptación de ejemplo basico de AJAX (2)
 */
  function actualizar_contactodominio(capa,url) {
	var datosformulario = recoger_campos_formulario();
	//var valormail = document.getElementById("email").value;
	
	//var proseguir = emailCheck (valormail); //esta funcion esta en el script var.js
	//var proseguir = validar();
	var proseguir = true;
	
	if(proseguir){
		//var gopage = document.getElementById("gopage").value;
		 // Creamos el objeto, segun el navegador
		 if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
		   xmlhttprequest = new XMLHttpRequest();
		} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
			xmlhttprequest = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		
		// PREPARANDOSE PARA LA RESPUESTA
		// establecemos un handler para cuando llegue la respuesta,
		xmlhttprequest.onreadystatechange = function() { procesa(xmlhttprequest,capa); };
		
		
		// HACIENDO LA PETICION
		// Open(metodo, url, y si queremos la peticion asincrona o no)
		xmlhttprequest.open('POST', url, true);
		 
		// Preparamos el POST. Hay que establecer esta cabecera
		// para poder enviar variables por post
		xmlhttprequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		 
		 // Send es necesario si queremos pasar variables por POST
		 // asi que construimos una especie de query string con variables=valores
		 //xmlhttprequest.send(null);
		 xmlhttprequest.send(datosformulario);
	}

}


function limpiar_and(cadena){
	var cadena_sin_and = cadena;
	var signo = "&";
	var car_uni = signo.charCodeAt(0);
	cadena_sin_and = cadena_sin_and.replace(/&/g,"@"+car_uni+"@");
	
	return cadena_sin_and;
}


function expandCollapse_render(capa,url) {
	var element= document.getElementById(capa);
	
	element.style.display = (element.style.display == "none") ? "block" : "none";
	//this.contentheight=this.crossobj.offsetHeight;
	
	//->invocando a función ajax para actualizar capa.
	if(element.style.display == "block"){
		//->invocando a función ajax para actualizar capa.
		actualizar(capa,url)
	}
}

function expandCollapse(capa) {
	var element= document.getElementById(capa);
	element.style.display = (element.style.display == "none") ? "block" : "none";
	//this.contentheight=this.crossobj.offsetHeight;
}

function reset_form(form){
	form.reset();
	
	}
//->funcionse adicionadas de libreria libre para manejo de capas (www.dynamicdrive.com)

/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
	var subobj=document.getElementById(subobjstr)
	subobj.style.display=(subobj.style.display!="block")? "block" : "none"
	var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : -580) 
	var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : -500)
	subobj.style.left=xpos+"px"
	subobj.style.top=ypos+"px"
	return false
}else{
	return true	
	}

}







function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}

//->overlay_render
function overlay_render(curobj, subobjstr, url, opt_position){
if (document.getElementById){
	var subobj=document.getElementById(subobjstr)
	subobj.style.display=(subobj.style.display!="block")? "block" : "none"
	var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : -290) 
	var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : -210)
	subobj.style.left=xpos+"px"
	subobj.style.top=ypos+"px"
		if(subobj.style.display =="block"){
			actualizar(subobjstr,url);
		} 
		
	
return false
}
else
return true
}

//->
//->overlay_render 2
function overlay_render2(curobj, subobjstr, url, opt_position){
if (document.getElementById){
	var subobj=document.getElementById(subobjstr)
	subobj.style.display=(subobj.style.display!="block")? "block" : "none"
	var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : -390) 
	var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : -310)
	subobj.style.left=xpos+"px"
	subobj.style.top=ypos+"px"
		if(subobj.style.display =="block"){
			actualizar(subobjstr,url);
		} 
		
	
return false
}
else
return true
}




//->funciones para actualizar las interfaces
function refrescar_root(url){
	//window.parent.frame1.focus();
	window.top.document.frames.root.location = url;
	//window.root.focus();
	//window.location = "root.php";
}
function refrescar_contenido(url){
	//window.parent.frame1.focus();
	window.top.document.frames.contenido.location = url;
	//window.root.focus();
	//window.location = "root.php";
}

//->funciones para opcion eliminar

function check_temas(check){
	
	replaceObj = document.getElementsByTagName("input");
	for (i = 0; i < replaceObj.length; i++ ) {
			if(replaceObj[i].getAttribute("type") == "checkbox"){
				if(replaceObj[i].getAttribute("name").substring(0,5) == "temas"){
					if(check.checked ==  true){
						replaceObj[i].checked = true;
					}else{
						replaceObj[i].checked = false;
					}
				}
			}
		}
		//alert("cantidad de checkbox/ estado check : "+ check.checked);
}
//-marcar las leyes
function check_leyes(check){
	
	replaceObj = document.getElementsByTagName("input");
	for (i = 0; i < replaceObj.length; i++ ) {
			if(replaceObj[i].getAttribute("type") == "checkbox"){
				if(replaceObj[i].getAttribute("name").substring(0,5) == "leyes"){
					if(check.checked ==  true){
						replaceObj[i].checked = true;
					}else{
						replaceObj[i].checked = false;
					}
				}
			}
		}
		//alert("cantidad de checkbox/ estado check : "+ check.checked);
}
//->overlay_render_delete (función para eliminar)
function overlay_render_delete(curobj, subobjstr, url, tipocheck, opt_position){
if (document.getElementById){
	var subobj=document.getElementById(subobjstr)
	//subobj.style.display=(subobj.style.display!="block")? "block" : "none"
	var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : -290) 
	var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : -210)
	subobj.style.left=xpos+"px"
	subobj.style.top=ypos+"px"
		//if(subobj.style.display =="block"){
			//actualizar(subobjstr,url);
	eliminar_check(subobjstr,tipocheck,url);
	subobj.style.display ="block";
		//} 
		
	
//return false
}
else
return true
}


//->version 2 de eliminar check
function eliminar_check(capa,tipocheck,url){
	var valorElemento = new Array();
	var indice_aux = 0;
	var muestra = "";
	
	var mensaje = "";
	//var capa2 = capa;
	replaceObj = document.getElementsByTagName("input");
	
	for(i = 0 ; i < replaceObj.length ;  i++){
		if(replaceObj[i].getAttribute("type") == "checkbox"){
			if(replaceObj[i].checked == true){
				//->tomo el valor  y lo agrego a un arreglo.
				valorElemento[indice_aux] =  replaceObj[i].getAttribute("name");
				if(valorElemento[indice_aux] == tipocheck){
					muestra = muestra + "delete_elemento["+indice_aux+"]=" + replaceObj[i].getAttribute("value") + "&";
					mensaje = mensaje + " - " + replaceObj[i].getAttribute("id")+ "\n";
					indice_aux++;
				}
			}
		}
	}
	//alert("muestra valores: " + indice_aux);

	if(indice_aux > 0){
		//->inicio ::: en caso que se seleccionen imagenes para eliminiar
	if(confirm("Esta seguro de eliminar las siguientes imagenes\n"+mensaje)){
		//->limpieza de la cadena.
		a = muestra.length - 1;
		muestra = muestra.substring(0,a);
		//alert("muestra valores: " + muestra);
		
		///*
		//->realizar envio de la informacion usando el httpxmlrequest (ajax).
		//-> Creamos el objeto, segun el navegador
			if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
				xmlhttprequest2 = new XMLHttpRequest();
			} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
				xmlhttprequest2 = new ActiveXObject("Microsoft.XMLHTTP");
			} 
		//-> PREPARANDOSE PARA LA RESPUESTA
		//-> establecemos un handler para cuando llegue la respuesta,
		xmlhttprequest2.onreadystatechange = function() { procesa_elimina(xmlhttprequest2,capa); }; //procesa_noticia(xhr, capa) 
			
			
		// HACIENDO LA PETICION
		// Open(metodo, url, y si queremos la peticion asincrona o no)
		xmlhttprequest2.open('POST',url, true);
		 
		// Preparamos el POST. Hay que establecer esta cabecera
		// para poder enviar variables por post
		xmlhttprequest2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		 
		 // Send es necesario si queremos pasar variables por POST
		 // asi que construimos una especie de query string con variables=valores
		 xmlhttprequest2.send(muestra);
		// return true;
		
		
		//*/
		
	}else{
		oxi = window.document.getElementById(capa);
		oxi.style.display=(oxi.style.display!="block")? "block" : "none";
	}
	
	}else{
		alert("No seleccionó ningun Elemento\nSeleccione algun(os) elemento(s) y luego presione este botón");
	}
	
}


 function procesa_elimina(xhr,capa) {

 	// primermo comprobamos el estado de la respuesta
	 if (xhr.readyState == 4) {
			// A continuacion comprobamos el codigo de respuesta HTTP del servidor
	 		if (xhr.status == 200) {
	 			//alert(xhr.responseText);
				
				//->contenedor = window.opener.document.getElementById(capa);
				contenedor = window.document.getElementById(capa);
				contenedor.innerHTML = xhr.responseText;
				
				contenedor.style.display="block";
				//actualizado = true;
	 	 	} else {
		 	 	alert("No se recibio una respuesta correcta. Respuesta HTTP: " + xhr.status);
	 		}
	  } else {
	    // Todavia no hay respuesta...
		contenedor = window.document.getElementById(capa);//window.opener.document.getE...
		contenedor.innerHTML = "<font class='small'>Cargando contenido...</font>";
	  }
 }



//->version 3 de overlay_render_delete
//->version 1 de overlay_render_delete_ley
//->overlay_render_delete (función para eliminar)
function overlay_render_delete_ley(curobj, subobjstr, url, tipocheck, opt_position){
if (document.getElementById){
	var subobj=document.getElementById(subobjstr)
	subobj.style.display=(subobj.style.display!="block")? "block" : "none"
	var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : -290) 
	var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : -210)
	subobj.style.left=xpos+"px"
	subobj.style.top=ypos+"px"
		if(subobj.style.display =="block"){
			//actualizar(subobjstr,url);
			eliminar_check_ley(subobjstr,tipocheck,url);
			//subobj.style.display ="block";
			//alert("la capa se muestra :-)");
		} 
		
	
//return false
}
else
return true
}


//->version 3 de eliminar check
function eliminar_check_ley(capa,tipocheck,url){
	var valorElemento = new Array();
	var indice_aux = 0;
	var muestra = "";
	
	var mensaje = "";
	//var capa2 = capa;
	replaceObj = document.getElementsByTagName("input");
	
	for(i = 0 ; i < replaceObj.length ;  i++){
		if(replaceObj[i].getAttribute("type") == "checkbox"){
			if(replaceObj[i].checked == true){
				//->tomo el valor  y lo agrego a un arreglo.
				valorElemento[indice_aux] =  replaceObj[i].getAttribute("name");
				if(valorElemento[indice_aux] == tipocheck){
					muestra = muestra + "delete_elemento["+indice_aux+"]=" + replaceObj[i].getAttribute("value") + "&";
					mensaje = mensaje + " - " + replaceObj[i].getAttribute("id")+ "\n";
					indice_aux++;
				}
			}
		}
	}
	//alert("muestra valores: " + indice_aux);
	if(indice_aux > 0){
		//->inicio ::: en caso que se seleccionen imagenes para eliminiar
		//->limpieza de la cadena.
		a = muestra.length - 1;
		muestra = muestra.substring(0,a);
		//alert("muestra valores: " + muestra);
		
		///*
		//->realizar envio de la informacion usando el httpxmlrequest (ajax).
		//-> Creamos el objeto, segun el navegador
			if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
				xmlhttprequest2 = new XMLHttpRequest();
			} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
				xmlhttprequest2 = new ActiveXObject("Microsoft.XMLHTTP");
			} 
		//-> PREPARANDOSE PARA LA RESPUESTA
		//-> establecemos un handler para cuando llegue la respuesta,
		xmlhttprequest2.onreadystatechange = function() { procesa_elimina(xmlhttprequest2,capa); }; //procesa_noticia(xhr, capa) 
			
			
		// HACIENDO LA PETICION
		// Open(metodo, url, y si queremos la peticion asincrona o no)
		xmlhttprequest2.open('POST',url, true);
		 
		// Preparamos el POST. Hay que establecer esta cabecera
		// para poder enviar variables por post
		xmlhttprequest2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		 
		 // Send es necesario si queremos pasar variables por POST
		 // asi que construimos una especie de query string con variables=valores
		 xmlhttprequest2.send(muestra);
		// return true;
		
		
		//*/
		
		//oxi = window.document.getElementById(capa);
		//oxi.style.display=(oxi.style.display!="block")? "block" : "none";
	
	}else{
		contenedor = window.document.getElementById(capa);//window.opener.document.getE...
		contenedor.innerHTML = "";
		contenedor.style.display="none";
		alert("No seleccionó ningun Elemento\nSeleccione algun(os) elemento(s) y luego presione este botón");
	}
	
}

//->función para consultar sobre reescritura de archivo
function validar_accion_archivo(curobj, subobjstr, opt_position){
	var estado_ubicacion;
	estado_ubicacion = overlay(curobj, subobjstr, opt_position);
	if(estado_ubicacion){
		alert("funciona");
		}
	}



/*Funciones heredadas de monark*/

//->funcion para el manejo de imágenes
//buffer = new Image(); 
function imageChange(nuevadireccion) { 
	//a  = window.document.getElementById(imagen);
	//a.src = nuevadireccion;
	//return true;
	//buffer = new Image(); 
	buffer = new Image(); 
	buffer.onload = imageChange//{ document.imagen.src = buffer.src; }; 
	buffer.src = nuevadireccion;
	//document.imagen.src = nuevadireccion;
	
	
}

function imageChange() { document.imagen.src = buffer.src; }

/*

<script language="javascript">
	periodo = 3; // segundos entre recargas 
	imgsrc = document.webcam.src; 
	buffer = new Image(); 
	buffer.onload = imageChange; 
	setTimeout("imageReload()", periodo * 1000); 
		function imageReload() { 
			buffer.src = imgsrc + "?d=" + new Date().getTime(); 
			setTimeout("imageReload()", periodo * 1000);
		 } 
		 
		 function imageChange() { document.webcam.src = buffer.src; }
	
	buffer.onerror = imageError; 
	function imageError() { setTimeout("imageReload()", 1000); } 
	

	</script>*/
	
	
	
	
function showPic (whichpic) {
 if (document.getElementById) {
  document.getElementById('placeholder').src = whichpic.href;
  document.getElementById('srcimg').value = whichpic.href;
  if (whichpic.title) {
   document.getElementById('desc').childNodes[0].nodeValue = whichpic.title;
  } else {
   document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
  }
  return false;
 }
 else {
  return true;
 }
}



function showImagen (whichpic) {
 if (document.getElementById) {
  document.getElementById('placeholder').src = whichpic.href;
  document.getElementById('srcimg').value = whichpic.href;
  if (whichpic.title) {
   document.getElementById('desc').childNodes[0].nodeValue = whichpic.title;
  } else {
   document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
  }
  return false;
 }
 else {
  return true;
 }
}
	
	
	function showImagen2 (whichpic) {
 if (document.getElementById) {
  document.getElementById('placeholder').src = whichpic.href;
  //document.getElementById('srcimg').childNodes[0].nodeValue = whichpic.title;
  if (whichpic.title) {
   document.getElementById('desc').childNodes[0].nodeValue = whichpic.title;
  } else {
   document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
  }
  
  return false;
 } else {
  return true;
 }
}


function retorna_valor(option){
	//document.actualizar_noticia.srcimg.value = option.value;
	 document.getElementById('srcimg').value = option.value;
}

//->func tom b-p-c

// nueva funcion para abrir ventana maximizada
var wOpen2;
function abreventanaUp( aURL, aWinName )
{
   //var wOpen;
   var sOptions;

   sOptions = 'directories=no,status=no,toolbar=no,menubar=no,scrollbars=no';
   sOptions = sOptions + ',resizable=no,location=no,maximize=no';
   sOptions = sOptions + ',width=' + 100;
   sOptions = sOptions + ',height=' + 30;
   sOptions = sOptions + ',screenX=0,screenY=0,left=350,top=110';

   wOpen2 = window.open( '', aWinName, sOptions );
   wOpen2.location = aURL;
   wOpen2.focus();
   wOpen2.moveTo( 250, 110 );
   wOpen2.resizeTo(435,480 );
   return wOpen2;
}
//->función que estoy usando la opcion de carga de archivos.
function abreventanaUpFile( aURL, aWinName )
{
   //var wOpen;
   var sOptions;

   sOptions = 'directories=no,status=no,toolbar=no,menubar=no,scrollbars=no';
   sOptions = sOptions + ',resizable=no,location=no,maximize=no';
   sOptions = sOptions + ',width=' + 100;
   sOptions = sOptions + ',height=' + 30;
   sOptions = sOptions + ',screenX=0,screenY=0,left=350,top=110';

   wOpen2 = window.open( '', aWinName, sOptions );
   wOpen2.location = aURL;
   wOpen2.focus();
   wOpen2.moveTo( 250, 110 );
   wOpen2.resizeTo(435,350 );
   return wOpen2;
}






//->funcion para actualizar lista de imagenes
 /**
 * actualizar:  adaptación de ejemplo basico de AJAX (2)
 */
  function actualizar_lista_imagenes(capa) {

	//var gopage = document.getElementById("gopage").value;
	 // Creamos el objeto, segun el navegador
	 if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
 	   xmlhttprequest = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
	    xmlhttprequest = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	
	// PREPARANDOSE PARA LA RESPUESTA
	// establecemos un handler para cuando llegue la respuesta,
	xmlhttprequest.onreadystatechange = function() { procesa_imagen_parent(xmlhttprequest,capa); };
	
	
	// HACIENDO LA PETICION
	// Open(metodo, url, y si queremos la peticion asincrona o no)
	xmlhttprequest.open('POST', 'listaimagenes.upd.ing.php?accionlista=0', true);
	 
	// Preparamos el POST. Hay que establecer esta cabecera
	// para poder enviar variables por post
	xmlhttprequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	 
	 // Send es necesario si queremos pasar variables por POST
	 // asi que construimos una especie de query string con variables=valores
	 xmlhttprequest.send(null);

}


//atencion
//window.opener.document.location.href='../prod_ing.php?accion=10&nombre_prod='+nombreprod+'&puntolista='+puntolista+'&tope='+tope
 






/**
 * procesa
 * parametros: el objeto xmlhttprequest
 * Es la funcion handler que procesa el archivo recibido a traves
 * de la peticion. Es igual que la funcion anterior pero en este caso parseamos el XML
 */
 function procesa_imagen_parent(xhr,capa) {

 	// primermo comprobamos el estado de la respuesta
	 if (xhr.readyState == 4) {
			// A continuacion comprobamos el codigo de respuesta HTTP del servidor
	 		if (xhr.status == 200) {
	 			//alert(xhr.responseText);
				
				contenedor = window.opener.document.getElementById(capa);
				contenedor.innerHTML = xhr.responseText;
	 	 	} else {
		 	 	alert("No se recibio una respuesta correcta. Respuesta HTTP: " + xhr.status);
	 		}
	  } else {
	    // Todavia no hay respuesta...
		contenedor = window.opener.document.getElementById(capa);
		contenedor.innerHTML = "Cargando contenido...";
	  }
 }




//->funcion para seleccionar todos los checkbox
function check_all(check){
	
	replaceObj = document.getElementsByTagName("input");
	for (i = 0; i < replaceObj.length; i++ ) {
			if(replaceObj[i].getAttribute("type") == "checkbox"){
				if(check.checked ==  true){
					replaceObj[i].checked = true;
				}else{
					replaceObj[i].checked = false;
				}
			}
		}
		//alert("cantidad de checkbox/ estado check : "+ check.checked);
}

//->eliminacion usando un formato Ajax

	//->variable sobre el estado de la actualizacion.
	//var actualizado = false;
function eliminar_check_imagen(capa){
	var valorArchivo = new Array();
	var indice_aux = 0;
	var muestra = "";
	var mensaje = "";
	replaceObj = document.getElementsByTagName("input");
	for(i = 0 ; i < replaceObj.length ;  i++){
		if(replaceObj[i].getAttribute("type") == "checkbox"){
			if(replaceObj[i].checked == true){
				//->tomo el valor  y lo agrego a un arreglo.
				valorArchivo[indice_aux] =  replaceObj[i].getAttribute("value");
				if(valorArchivo[indice_aux] != 'on'){
					muestra = muestra + "delete_imagenes["+indice_aux+"]=" + replaceObj[i].getAttribute("value") + "&";
					mensaje = mensaje + " - " + replaceObj[i].getAttribute("value")+ "\n";
					indice_aux++;
				}
			}
		}
	}
	//alert("muestra valores: " + indice_aux);
	if(indice_aux > 0){
		//->inicio ::: en caso que se seleccionen imagenes para eliminiar
	if(confirm("Esta seguro de eliminar las siguientes imagenes\n"+mensaje)){
		//->limpieza de la cadena.
		a = muestra.length - 1;
		muestra = muestra.substring(0,a);
		//->alert("muestra valores: " + muestra);
		
		//->realizar envio de la informacion usando el httpxmlrequest (ajax).
		//-> Creamos el objeto, segun el navegador
			if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
				xmlhttprequest2 = new XMLHttpRequest();
			} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
				xmlhttprequest2 = new ActiveXObject("Microsoft.XMLHTTP");
			} 
		//-> PREPARANDOSE PARA LA RESPUESTA
		//-> establecemos un handler para cuando llegue la respuesta,
		xmlhttprequest2.onreadystatechange = function() { procesa_elimina(xmlhttprequest2,capa); }; //procesa_noticia(xhr, capa) 
			
			
		// HACIENDO LA PETICION
		// Open(metodo, url, y si queremos la peticion asincrona o no)
		xmlhttprequest2.open('POST', 'upload.ing.php?accion=2', true);
		 
		// Preparamos el POST. Hay que establecer esta cabecera
		// para poder enviar variables por post
		xmlhttprequest2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		 
		 // Send es necesario si queremos pasar variables por POST
		 // asi que construimos una especie de query string con variables=valores
		 xmlhttprequest2.send(muestra);
		 return true;
		
		
		
		
	}
	
	}else{
		alert("No seleccionó ninguna imagen\nSeleccione alguna(s) imagen(es) y luego presione este botón");
	}
	
}


//->Procesar eliminacion de imagenes (ajax)

 function procesa_elimina(xhr,capa) {

 	// primermo comprobamos el estado de la respuesta
	 if (xhr.readyState == 4) {
			// A continuacion comprobamos el codigo de respuesta HTTP del servidor
	 		if (xhr.status == 200) {
	 			//alert(xhr.responseText);
				
				//->contenedor = window.opener.document.getElementById(capa);
				contenedor = window.document.getElementById(capa);
				contenedor.innerHTML = xhr.responseText;
				//actualizado = true;
	 	 	} else {
		 	 	alert("No se recibio una respuesta correcta. Respuesta HTTP: " + xhr.status);
	 		}
	  } else {
	    // Todavia no hay respuesta...
		contenedor = window.document.getElementById(capa);//window.opener.document.getE...
		contenedor.innerHTML = "<font class='small'>Cargando contenido...</font>";
	  }
 }




//->funcion mixta

function doble_update(capathis, capaparent){
	var sigue = eliminar_check_imagen(capathis); 
			if(sigue){
				actualizar_lista_imagenes(capaparent); 
				sigue =  false;
			}
		
	history.go(0);
		
}



function doble_update_open(capathis, capaparent, ruta1, ruta2){
	var sigue = eliminar_check_archivo(capathis,ruta1);
	//eliminar_check_imagen(capathis); 
	//eliminar_check_archivo(capa,ruta)
			if(sigue){
				actualizar_lista_archivos(capaparent,ruta2)
				//actualizar_lista_imagenes(capaparent); 
				sigue =  false;
				history.go(0);	
			}
		
	history.go(0);
	refrescar();
		
}



function refrescar()
   {
           //window.reload();
		   history.go(0)
   }
   


//->nueva función // buscando hacerla mas flexible.

//->funcion para actualizar lista de imagenes
 /**
 * actualizar:  adaptación de ejemplo basico de AJAX (2)
 */
  function actualizar_lista_archivos(capa,ruta) {

	//var gopage = document.getElementById("gopage").value;
	 // Creamos el objeto, segun el navegador
	 if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
 	   xmlhttprequest = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
	    xmlhttprequest = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	
	// PREPARANDOSE PARA LA RESPUESTA
	// establecemos un handler para cuando llegue la respuesta,
	xmlhttprequest.onreadystatechange = function() { procesa_lista_parent(xmlhttprequest,capa); };
	
	
	// HACIENDO LA PETICION
	// Open(metodo, url, y si queremos la peticion asincrona o no)
	xmlhttprequest.open('POST', ruta, true);
	 
	// Preparamos el POST. Hay que establecer esta cabecera
	// para poder enviar variables por post
	xmlhttprequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	 
	 // Send es necesario si queremos pasar variables por POST
	 // asi que construimos una especie de query string con variables=valores
	 xmlhttprequest.send(null);

}


//atencion
//window.opener.document.location.href='../prod_ing.php?accion=10&nombre_prod='+nombreprod+'&puntolista='+puntolista+'&tope='+tope
 






/**
 * procesa
 * parametros: el objeto xmlhttprequest
 * Es la funcion handler que procesa el archivo recibido a traves
 * de la peticion. Es igual que la funcion anterior pero en este caso parseamos el XML
 */
 function procesa_lista_parent(xhr,capa) {

 	// primermo comprobamos el estado de la respuesta
	 if (xhr.readyState == 4) {
			// A continuacion comprobamos el codigo de respuesta HTTP del servidor
	 		if (xhr.status == 200) {
	 			//alert(xhr.responseText);
				
				contenedor = window.opener.document.getElementById(capa);
				contenedor.innerHTML = xhr.responseText;
	 	 	} else {
		 	 	alert("No se recibio una respuesta correcta. Respuesta HTTP: " + xhr.status);
	 		}
	  } else {
	    // Todavia no hay respuesta...
		contenedor = window.opener.document.getElementById(capa);
		contenedor.innerHTML = "Cargando contenido...";
	  }
 }


//->eliminacion usando un formato Ajax

	//->variable sobre el estado de la actualizacion.
	//var actualizado = false;
function eliminar_check_archivo(capa,ruta){
	var valorArchivo = new Array();
	var indice_aux = 0;
	var muestra = "";
	var mensaje = "";
	valor = false;
	replaceObj = document.getElementsByTagName("input");
	for(i = 0 ; i < replaceObj.length ;  i++){
		if(replaceObj[i].getAttribute("type") == "checkbox"){
			if(replaceObj[i].checked == true){
				//->tomo el valor  y lo agrego a un arreglo.
				valorArchivo[indice_aux] =  replaceObj[i].getAttribute("value");
				if(valorArchivo[indice_aux] != 'on'){
					muestra = muestra + "delete_archivos["+indice_aux+"]=" + replaceObj[i].getAttribute("value") + "&";
					mensaje = mensaje + " - " + replaceObj[i].getAttribute("value")+ "\n";
					indice_aux++;
				}
			}
		}
	}
	//alert("muestra valores: " + indice_aux);
	if(indice_aux > 0){
		//->inicio ::: en caso que se seleccionen imagenes para eliminiar
	if(confirm("Esta seguro de eliminar las siguientes imagenes\n"+mensaje)){
		//->limpieza de la cadena.
		a = muestra.length - 1;
		muestra = muestra.substring(0,a);
		//->alert("muestra valores: " + muestra);
		
		//->realizar envio de la informacion usando el httpxmlrequest (ajax).
		//-> Creamos el objeto, segun el navegador
			if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
				xmlhttprequest2 = new XMLHttpRequest();
			} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
				xmlhttprequest2 = new ActiveXObject("Microsoft.XMLHTTP");
			} 
		//-> PREPARANDOSE PARA LA RESPUESTA
		//-> establecemos un handler para cuando llegue la respuesta,
		xmlhttprequest2.onreadystatechange = function() { procesa_elimina_archivo(xmlhttprequest2,capa);
		//if(xmlhttprequest2.readyState == 4){  alert("hola... es cuestion de tiempo"); }
		};
		//procesa_noticia(xhr, capa) 
			
			
		// HACIENDO LA PETICION
		// Open(metodo, url, y si queremos la peticion asincrona o no)
		xmlhttprequest2.open('POST', ruta, true);
		 
		// Preparamos el POST. Hay que establecer esta cabecera
		// para poder enviar variables por post
		xmlhttprequest2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		 
		 // Send es necesario si queremos pasar variables por POST
		 // asi que construimos una especie de query string con variables=valores
		 xmlhttprequest2.send(muestra);
		 //return true;
		//if(xmlhttprequest2.readyState == 4){  return true; }
		
		
		
	}
	
	}else{
		alert("No seleccionó ninguna imagen\nSeleccione alguna(s) imagen(es) y luego presione este botón");
	}
	
	//if(valor){ return true;} else{return false;}
}


//->Procesar eliminacion de imagenes (ajax)

 function procesa_elimina_archivo(xhr,capa) {

 	// primermo comprobamos el estado de la respuesta
	 if (xhr.readyState == 4) {
			// A continuacion comprobamos el codigo de respuesta HTTP del servidor
	 		if (xhr.status == 200) {
	 			//alert(xhr.responseText);
				
				//->contenedor = window.opener.document.getElementById(capa);
				contenedor = window.document.getElementById(capa);
				contenedor.innerHTML = xhr.responseText;
				//actualizado = true;
	 	 	} else {
		 	 	alert("No se recibio una respuesta correcta. Respuesta HTTP: " + xhr.status);
	 		}
	  } else {
	    // Todavia no hay respuesta...
		contenedor = window.document.getElementById(capa);//window.opener.document.getE...
		contenedor.innerHTML = "<font class='small'>Cargando contenido...</font>";
	  }
 }



function lanzar_conf2(id,x,y,w,h,pagina,titulo){
	I= id;                          //---- id de la ventana
	N= x;                              //---- posicion x
	n= y;                              //---- posicion y
	e= w;                            //---- ancho
	r= h;                             //---- alto
	d= pagina;                     //---- pagina de carga
	i= titulo;  //---- texto de la barra
	v=null;                              //---- indica si utiliza CSS
	//INNERDIV.newInnerDiv(I,N,n,e,r,d,i,v);
	
	var win = new Window(Application.getNewId(), //Application.getNewId()
											  {className: "alphacube", 
											  title: titulo, 
                                              top:x, 
											  left:y, 
											  width:w, 
											  height:h, 
                                              resizable: true, 
											  url: pagina, 
											  showEffectOptions: {duration:3}
											  }
											  )
	
	//var editorOnClose = { onClose: function(eventName, win) { alert(win.getId()); } }

	//Windows.addObserver(editorOnClose);
	
	//this.id =  win.getId();
	//this.win = win;
	win.show();                                            
    // win.setDestroyOnClose()   
		
		///->
		
}

//->funcion adaptada para proyectos futuros.
//->987500000->>>>>>>>>>>15FEB2007
/**
 * actualizar:  adaptación de ejemplo basico de AJAX (2)
 */
  function actualizar_capa_frame_padre(capa,url) {

	//var gopage = document.getElementById("gopage").value;
	 // Creamos el objeto, segun el navegador
	 if (window.XMLHttpRequest) { // Para los mozilla y los basados en gecko
 	   xmlhttprequest = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // Para Mordorsoft Exploiter
	    xmlhttprequest = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	
	// PREPARANDOSE PARA LA RESPUESTA
	// establecemos un handler para cuando llegue la respuesta,
	xmlhttprequest.onreadystatechange = function() { procesa_frame_padre(xmlhttprequest,capa); };
	
	
	// HACIENDO LA PETICION
	// Open(metodo, url, y si queremos la peticion asincrona o no)
	xmlhttprequest.open('POST', url, true);
	 
	// Preparamos el POST. Hay que establecer esta cabecera
	// para poder enviar variables por post
	xmlhttprequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	 
	 // Send es necesario si queremos pasar variables por POST
	 // asi que construimos una especie de query string con variables=valores
	 xmlhttprequest.send(null);

}

/**
 * procesa
 * parametros: el objeto xmlhttprequest
 * Es la funcion handler que procesa el archivo recibido a traves
 * de la peticion. Es igual que la funcion anterior pero en este caso parseamos el XML
 */
 function procesa_frame_padre(xhr,capa) {

 	// primermo comprobamos el estado de la respuesta
	 if (xhr.readyState == 4) {
			// A continuacion comprobamos el codigo de respuesta HTTP del servidor
	 		if (xhr.status == 200) {
	 			//alert(xhr.responseText);
				
				contenedor_old = window.parent.document.getElementById('preaviso');
				contenedor_old.style.display=(contenedor_old.style.display=="none")? "none" : "none";
				
				contenedor = window.parent.document.getElementById(capa);
				contenedor.innerHTML = xhr.responseText;
	 	 	} else {
		 	 	alert("No se recibio una respuesta correcta. Respuesta HTTP: " + xhr.status);
	 		}
	  } else {
	    // Todavia no hay respuesta...
		contenedor = window.parent.document.getElementById('preaviso');
		//alert(""+contenedor);
		contenedor.style.display=(contenedor.style.display=="block")? "block" : "block";
		contenedor.innerHTML = "<img src=\"images/indicator_medium.gif\" width=\"32\" height=\"32\" border= \"0\" aling=\"absmiddle\"><br><font style=\"font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#003366;\">Cargando contenido</font>";
	  }
 }




