function appendOptionLast()
	{
 
	  var elOptNew = document.createElement('option');
      var combo1 = document.getElementById("lstProductos");
	  var porcent1 = document.getElementById("porcent1");
	  
	  var valor = combo1.options[combo1.selectedIndex].text + ' - ' + porcent1.value + '%';

	  if (existeOptionSelected(valor)) return false;

	  elOptNew.text = valor;
	  elOptNew.value = valor;
	  var elSel = document.getElementById('selectX');
	
	  try {
		elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
	  }
	  catch(ex) {
		elSel.add(elOptNew); // IE only
	  }
   
	
	}

function removeOptionSelected()
	{
	  var elSel = document.getElementById('selectX');
	  var i;
	  
	  
	  for (i = elSel.length - 1; i>=0; i--) {

		  elSel.remove(i);

	  }
	}
function existeOptionSelected(valor)
	{
	  var elSel = document.getElementById('selectX');
	  
	  var ArrayA;
	  var ArrayB;
	  var cadenaAux;
	  var i;
	  var porcentTotal;
	  
	  cadenaAux=valor.substring(0,valor.length-1);	  
	  ArrayA=cadenaAux.split(" - ");
	  ArrayA[1]=ArrayA[1].substring(0,ArrayA[1].length-1);
 	  
	  porcentTotal=0;
	 
	  if ((ArrayA[0]=="") && (ArrayA[1]=="")){
		  	alert("Por favor indique producto y porcentaje");
		  	return true;
	  }
	  if (ArrayA[1]==""){
			alert("Lo sentimos. Debe indicar un porcentaje");
		  	return true;
	  }
	  if (ArrayA[0]==""){
			alert("Lo sentimos. Debe indicar un producto");
		  	return true;
	  }
	 
	  for (i = elSel.length - 1; i>=0; i--) {
		  ArrayB=elSel.options[i].text.split(" - ");
		  if (elSel.options[i].text == cadenaAux ){
		   alert("Lo sentimos. El producto y porcentaje ya estan asociados al evento");
		   return true;
		  }
		  if (ArrayA[0] == ArrayB[0]) {
 		    alert("Lo sentimos. El producto ya esta asociado al evento");
		  	return true;
		  }
		  ArrayB[1]=ArrayB[1].substring(0,ArrayB[1].length-1);
		  porcentTotal=porcentTotal+parseInt(ArrayB[1]);
		  if ((porcentTotal+parseInt(ArrayA[1])) > 100) {
 		    alert("Lo sentimos. El porcentaje total supera el 100%");
			return true;
		  }
		 
	  }
	  return false;
	}
		
		
function objetoAjax(){
 var xmlhttp=false;
  try{
   xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  }catch(e){
   try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }catch(E){
    xmlhttp = false;
   }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
   xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

function lstGente(nropagina){

divContenido = document.getElementById('lstGente'); 

t1p=document.getElementById('queryGente').value; 

ajax=objetoAjax(); 
ajax.open("GET", "modules.php?name=sqls&op=lstGente&numpagina="+nropagina+"&query="+t1p,true); 
divContenido.innerHTML= '<img src="images/loading.gif"> Cargando .......';
ajax.onreadystatechange=function() { 
	if (ajax.readyState==4) { 
	divContenido.innerHTML = ajax.responseText 
	} 
} 
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
ajax.send(null);	
}

function lstartista(artista){

	if(artista!=""){	
		divContenido = document.getElementById('lstEncontradoArtista'); 
			
		ajax=objetoAjax(); 
		ajax.open("GET", "modules.php?name=sqls&op=lstArtista&artista="+artista,true); 
		divContenido.innerHTML= '<img src="images/loading.gif"> Cargando .......';
		ajax.onreadystatechange=function() { 
			if (ajax.readyState==4) { 
			divContenido.innerHTML = ajax.responseText 
			} 
		} 
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
		ajax.send(null);
	}
}

function altatodo(nroevento){

	cnombre='geositioNombre'+nroevento;
	cchecksitio='geocheck'+nroevento;
	ccheckevento='eventoCheck'+nroevento;
	cpaissitio='geopais'+nroevento;
	cprovinciasitio='geoprovincia'+nroevento;
	cmunicipiositio='geomunicipio'+nroevento;
	cdireccionsitio='geodireccion'+nroevento;
	clatitudsitio='geolatitud'+nroevento;
	clongitudsitio='geolongitud'+nroevento;
	cwebsitio='geoweb'+nroevento;
	ctipositio='geoSitioTipo'+nroevento;
	cfechaevento='fecha'+nroevento;
	ccanalevento='eventoTipo'+nroevento;
	cimagenevento='eventoimagen'+nroevento;
	ceventotitulo='eventoTitulo'+nroevento;
	ceventodesc='eventoDescripcion'+nroevento;
	cproductoid='TDProductId'+nroevento;
	curlevento='eventoUrl'+nroevento;
	
	pnombresitio=document.getElementById(cnombre).value;
	ppaissitio=document.getElementById(cpaissitio).value;
	pprovinciasitio=document.getElementById(cprovinciasitio).value;
	
	pmunicipiositio=document.getElementById(cmunicipiositio).value;
	pdireccionsitio=document.getElementById(cdireccionsitio).value;
	platitudSitio=document.getElementById(clatitudsitio).value;
	plongitudSitio=document.getElementById(clongitudsitio).value;
	pwebsitio=document.getElementById(cwebsitio).value;
	ptipositio=document.getElementById(ctipositio).value;
	pfechaevento=document.getElementById(cfechaevento).value;
	pcchecksitio=document.getElementById(cchecksitio).checked
	pccheckevento=document.getElementById(ccheckevento).checked
	pcanalevento=document.getElementById(ccanalevento).value;
	pimagenevento=document.getElementById(cimagenevento).value;
	pproductoid=document.getElementById(cproductoid).value;
	peventotitulo=document.getElementById(ceventotitulo).value;
	peventodesc=document.getElementById(ceventodesc).value;
	purlevento=document.getElementById(curlevento).value;
		
	divContenido = document.getElementById('l'+nroevento);

	ajax=objetoAjax(); 
	ajax.open("GET", "modules.php?name=sqls&op=altaProductos&chkSitio="+pcchecksitio+"&chkEvento="+pccheckevento+"&nombreSitio="+pnombresitio+"&paisSitio="+ppaissitio+"&provinciaSitio="+pprovinciasitio+"&municipioSitio="+pmunicipiositio+"&direccionSitio="+pdireccionsitio+"&geolatSitio="+platitudSitio+"&geolonSitio="+plongitudSitio+"&webSitio="+pwebsitio+"&tipoSitio="+ptipositio+"&fechaEvento="+pfechaevento+"&canalEvento="+pcanalevento+"&imagenEvento="+pimagenevento+"&productoTrade="+pproductoid+"&tituloEvento="+peventotitulo+"&descEvento="+peventodesc+"&urlEvento="+purlevento,true); 
	divContenido.innerHTML= '<img src="images/loading.gif"> Cargando .......';
	ajax.onreadystatechange=function() { 
		if (ajax.readyState==4) { 
		divContenido.innerHTML = ajax.responseText 
		}
	} 
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	ajax.send(null);		
}
	