// JavaScript Document
//	temUrl = "http://"+location.hostname+'/439/';	
	temUrl = "http://"+location.hostname+'/';	

function InstanciarXMLHttpRequest(){
var aVersions = [ 'MSXML2.XMLHttp.5.0',
'MSXML2.XMLHttp.4.0','MSXML2.XMLHttp.3.0',
'MSXML2.XMLHttp','Microsoft.XMLHttp'
];
	if (window.XMLHttpRequest){
		// para IE7, Mozilla, Safari, etc: que usen el objeto nativo
		return new XMLHttpRequest();
		}else if (window.ActiveXObject){
			// de lo contrario utilizar el control ActiveX para IE5.x y IE6.x
			for (var i = 0; i < aVersions.length; i++) {
				try {
					var oXmlHttp = new ActiveXObject(aVersions[i]);
					return oXmlHttp;
				}catch (error) {
				//no necesitamos hacer nada especial
				}
			}
	}
}
function funMostrarPrincipal(opcion){
	if(opcion == 'Pauta'){
		funRegistrarse();
	}else{
		refEleH = document.getElementById('hCatSel');
		if(refEleH.value != ''){
			refElemAnterior = document.getElementById(refEleH.value);
			refElemAnterior.className = '';
		}
		funPonerBusquedaGeneral();
		opcion = opcion.toUpperCase();
		values = 'opcion='+opcion;
		_URL_ = temUrl+"web/controlador/cCargaPrincipal.php?";
		xmlreq = new InstanciarXMLHttpRequest();	
		xmlreq.open("POST", _URL_, true);
		xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlreq.onreadystatechange = function(){
			if(xmlreq.readyState == 4){	
				if(xmlreq.status == 200){			
					var datosxml = '';	
					datosxml = xmlreq.responseText;	
					funCargarXHTML(datosxml, 'divPrincipal');
				}
				else{
					if(xmlreq.status==404){
						alert("La URL NO existe");
					}
					else{
						alert("Error: "+xmlreq.status);
					}
				}			
			}
		}
		xmlreq.send(values);
	}
}
function funMostrarCategorias(){
	opcion = 'menuCategoria';
	values = 'opcion='+opcion;

	_URL_ = temUrl+"web/controlador/cCargaPrincipal.php?";

	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){	
			if(xmlreq.status == 200){			
				var datosxml = '';	
				datosxml = xmlreq.responseText;	
				funCargarXHTML(datosxml, 'divCategory');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}
function funPonerBusquedaGeneral(){
	var cadena = '<div><a href="javascript:funMostrarBusqueda();">Buscar</a></div>'+
	'<div><input type="text" id="txtFind" name="txtFind" onkeyup="funMostrarBusqueda();"/></div>'+
	'<div id="divFindResult"></div>';

	refEle = document.getElementById('divFind');
	refEle.innerHTML = cadena;
}
function funCargarXHTML(datosxml, divOld){
	refDiv = document.getElementById(divOld); 
	refDiv.innerHTML = datosxml; 
}
function funCargarCategoria(idCategoria, idElem){	
setClassMenu(idElem)
	values = 'opcion='+idCategoria;
	_URL_ = temUrl+"web/controlador/cCargaCategoria.php?";

	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){	
			if(xmlreq.status == 200){	
				var datosxml = '';	
				datosxml = xmlreq.responseText;	
				funQuitarBusquedaGeneral();
	vCat = document.getElementById('hCat');
	vCity = document.getElementById('hCity');
	vCat.setAttribute('value', '-1');
	vCity.setAttribute('value', '-1');
				funCargarXHTML(datosxml, 'divPrincipal');
				funMostrarListEmpresas(idCategoria, 'A');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}

function setClassMenu(id){
	refEle = document.getElementById(id);
	refEleH = document.getElementById('hCatSel');
	if(refEleH.value != ''){
		refElemAnterior = document.getElementById(refEleH.value);
		refElemAnterior.className = '';
	}
	refEleH.value = id;
	refEle.className = 'catSeleccionada';
}
function funQuitarBusquedaGeneral(){
	refEle = document.getElementById('divFind');
	refEle.innerHTML = '';
}

function funMostrarBannerTop(){
	SLIDES1 = new slideshow("SLIDES1");
	SLIDES1.timeout = 5000;
	SLIDES1.add_slide(new slide("images/banner/banner-creativos.jpg"));
//	SLIDES1.add_slide(new slide("images/banner/pic10i.jpg"));
//	SLIDES1.add_slide(new slide("images/banner/pic11i.jpg"));
}

function funMostrarBannerTopRight(){
	SLIDES2 = new slideshow("SLIDES2");
	SLIDES2.timeout = 5000;
	SLIDES2.add_slide(new slide("images/banner/mrbooks.gif"));
//	SLIDES2.add_slide(new slide("images/banner/bannermm.jpg"));
//	SLIDES2.add_slide(new slide("images/banner/pic08i.jpg"));
}

function funMostrarBannerRight(){
	SLIDES3 = new slideshow("SLIDES3");
	SLIDES3.timeout = 5000;
	SLIDES3.add_slide(new slide("images/banner/bannermark.jpg"));
	SLIDES3.add_slide(new slide("images/banner/bannermm.jpg"));
//	SLIDES3.add_slide(new slide("images/banner/pic08i.jpg"));
}

function funMostrarBannerRightBotton(){
}

function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}
/*	Cargamos el cuadro de información de la empresa en la búsqueda	*/
function funMostrarInfoEmpresa(nombre, idEmpresa){
    funCargaImagenLoad('divInfoEmpresa');			
//	temUrl = location.host;	
    //alert("OBJETO"+idEmpresa);
	values = 'opcion='+idEmpresa;
	_URL_ = temUrl+"web/controlador/cCargaInfoEmpresa.php?";

	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){	
			if(xmlreq.status == 200){	
				var datosxml = '';	
				datosxml = xmlreq.responseText;	
if(datosxml.indexOf('Unknown column ') >= 0){
	datosxml = 'Seleccione una coincidencia'
}
				funCargarXHTML(datosxml, 'divInfoEmpresa');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}
function funCargaImagenLoad(div){
	refDiv = document.getElementById(div);
	refDiv.innerHTML = '<img src="images/loading.gif" alt=""/>'; 
}


/*	Cargamos las empresas de la categoria seleccionada por orden alfabética	*/
function funMostrarListEmpresas(idEmpresa, letra){
//	temUrl = location.host;	
	values = 'opcion='+idEmpresa+'&letra='+letra;
	_URL_ = temUrl+"web/controlador/cCargaListaEmpresa.php?";
	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){	
			if(xmlreq.status == 200){	
				var datosxml = '';	
				datosxml = xmlreq.responseText;	
				funCargarXHTML(datosxml, 'divListOrdenEmpresas');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}

function funCargarAviso(idEmpresa){
//	temUrl = location.host;	
	values = 'opcion='+idEmpresa;
	_URL_ = temUrl+"web/controlador/cCargaGalery.php?";
	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){	
			if(xmlreq.status == 200){	
				funSetGalery();
				var datosxml = '';	
				datosxml = xmlreq.responseText;	
				funCargarXHTML(datosxml, 'divCenterGalery');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}


function funSetGalery(){
//alert('maximo height='+screen.availHeight+'\nmaximo width='+screen.availWidth+'\nOuter height='+window.outerHeight+'\nOuter Width='+window.outerWidth+'\ninner height='+window.innerHeight+'\ninner Width='+window.innerWidth+'\nResolucion de pantalla height='+screen.height+'\nResolucion de pantalla width='+screen.width);
//	if (window.innerHeight){
//		//navegadores basados en mozilla
//		var heightVentana = window.innerHeight;
//	}else{
//		//navegadores basados en IExplorer
//		var heightVentana = document.documentElement.clientHeight;
//	}	
//	refDivPage = document.getElementById('divPage');
	refDivGalery = document.getElementById('divGalery');
	refDivGalery.className = 'fondoTransparente';
	refDivCenterGalery = document.getElementById('divCenterGalery');
	refDivCenterGalery.className = 'center';

//	refDiv.height = heightVentana;
//	alto = refDivPage.offsetHeight;
}

function funUnSetGalery(){
	refDivGalery = document.getElementById('visorGaleria');
	refDivGalery.innerHTML = '<div id="divGalery"></div><div id="divCenterGalery"></div>';
}

function loadImg(img){
	refDiv = document.getElementById('contentGalery');
	if(  (img.indexOf('.swf') -1) || (img.indexOf('.SWF') -1)  ){
		refDiv.innerHTML = '';
	}else{
		refDiv.innerHTML = '<img alt="" src="'+img+'" name=""/>';
	}
	//Setear el onclick con loadImg del div flechaIzq y flechaDer
	refFleIzq = document.getElementById('flechaIzq');
	refFleDer = document.getElementById('flechaDer');
	refPath = document.getElementById('hPath');
	var path = String(refPath.value).split("|");
	var pathPrevio = '';
	var pathNext = '';

	for(var i = 0; i<path.length; i++){	
		if(String(path[i]).indexOf(img) != -1){
			if(i > 0){
				pathPrevio = String(path[i-1]);
			}
			if( (i+1) < (path.length ) ){
				pathNext = String(path[i+1]);
			}else{
				pathPrevio = String(path[i]);
			}
		}
	}
	
	if(pathPrevio != ''){
		refFleIzq.setAttribute("onclick", "loadImg('"+pathPrevio+"')")
	}
	refFleIzq.setAttribute("id", "flechaIzq")
	if(pathNext != ''){
		refFleDer.setAttribute("onclick", "loadImg('"+pathNext+"')")
	}
	refFleDer.setAttribute("id", "flechaDer")
}

function funCargarCampos(){
	values = '';

	_URL_ = temUrl+"web/controlador/cCargaAvanzada.php?";
	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){	
			if(xmlreq.status == 200){	
				var datosxml = '';	
				datosxml = xmlreq.responseText;	
				funCargarXHTML(datosxml, 'divBusquedaAvanzada');
				funCargarXHTML('<a href="javascript:funQuitarCampos()">Desactivar B&uacute;squeda Avanzada</a></span>', 'aFind');
				
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(null);
}
function funQuitarCampos(){
	funCargarXHTML('', 'divBusquedaAvanzada');
	funCargarXHTML('<a href="javascript:funCargarCampos()">Activar B&uacute;squeda Avanzada</a></span>', 'aFind');
	vCat = document.getElementById('hCat');
	vCity = document.getElementById('hCity');
	vCat.setAttribute('value', '-1');
	vCity.setAttribute('value', '-1');
}

//Llamada desde el onChange del select
function funSetCombo1(idSelectOrigen, opc){
	//opc: 1=Categoria; 2=Ciudad
	if(opc == 1){	
		var vCat = document.getElementById('hCat');
		var idCat = document.getElementById('selCat').options[idSelectOrigen].id;	
		vCat.setAttribute('value', idCat);
	}
}
function funSetCombo2(idSelectOrigen, opc){
	//opc: 1=Categoria; 2=Ciudad
	if(opc == 2){	
		var vCity = document.getElementById('hCity');
		var idCity = document.getElementById('selCity').options[idSelectOrigen].alt;	
		vCity.setAttribute('value', idCity);
	}
}

function funMostrarBanners(){	
//	funGetBanners(1, 'divBannerTop');
	funGetBanners(2, 'divBannerCenterRight');
	funGetBanners(3, 'divBannerCenterBotton');
}
function funGetBanners(op, divId){		
//alert(temUrl+"web/controlador/cCargaBanners.php?")
	values = 'opcion='+op;
	_URL_ = temUrl+"web/controlador/cCargaBanners.php?";
	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	xmlreq.onreadystatechange = function(){			
		if(xmlreq.readyState == 4){			
			if(xmlreq.status == 200){	
				var datosxml = '';	
				datosxml = xmlreq.responseText;	
				funCargarXHTML(datosxml, divId);
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}
function funMostrarBannerTop(){
	values = 'opcion=1';
	_URL_ = temUrl+"web/controlador/cCargaBanners.php?";

	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){	
			if(xmlreq.status == 200){			
				var datosxml = '';	
				datosxml = xmlreq.responseText;	
				funCargarXHTML(datosxml, 'divBannerTop');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}

/* Busqueda */
function funMostrarBusqueda(){
	valFind = document.getElementById('txtFind').value;
	valor = 'valor='+valFind;
	if(valFind.length > 0)	{
		_URL_ = temUrl+"web/controlador/cCargaResultados.php?";
		xmlreq = new InstanciarXMLHttpRequest();	
		xmlreq.open("POST", _URL_, true);
		xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlreq.onreadystatechange = function(){
			if(xmlreq.readyState == 4){	
				if(xmlreq.status == 200){	
					var datosxml = '';	
					datosxml = xmlreq.responseText;	
					if(valor.length > 0){
						funCargarXHTML(datosxml, 'divPrincipal');
					}else{
						alert('no hay dato')
					}
				}
				else{
					if(xmlreq.status==404){
						alert("La URL NO existe");
					}
					else{
						alert("Error: "+xmlreq.status);
					}	
				}			
			}
		}
		xmlreq.send(valor);
	}else{
		funMostrarPrincipal('Inicio');
	}
}

function funRegistrarse(){
	values = 'opcion=0';	
	_URL_ = temUrl+"web/controlador/cLogin.php?";

	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){	
			if(xmlreq.status == 200){			
				var datosxml = '';	
				datosxml = xmlreq.responseText;
				funCargarXHTML(datosxml, 'divPrincipal');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}
function funModificarRegistro(){
	_URL_ = temUrl+"web/controlador/cEditLogin.php?";

	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){	
			if(xmlreq.status == 200){			
				var datosxml = '';	
				datosxml = xmlreq.responseText;
				funCargarXHTML(datosxml, 'divPrincipal');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(null);
}
function funLoguear(){
	values = 'user='+document.getElementById('user').value+'&pass='+document.getElementById('pass').value
	_URL_ = temUrl+"web/modelo/mValidarLogin.php?";

	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){	
			if(xmlreq.status == 200){			
				var datosxml = '';	
				datosxml = xmlreq.responseText;
				if( datosxml.indexOf('Admin/index')!=-1 ){
					window.location.href = temUrl+datosxml;
				}else{
					if(datosxml.indexOf('El usuario')!=-1 || datosxml.indexOf('La Empresa')!=-1 || datosxml.indexOf('El password')!=-1 ){
						alert(datosxml);
					}else{
						funCargarXHTML(datosxml, 'divPrincipal');
					}
				}
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}
function funInsertarFila(opcion){	//10 para telefono, 11 para mail
	values = 'opcion='+opcion;	
	_URL_ = temUrl+"web/controlador/cLogin.php?";

	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){	
			if(xmlreq.status == 200){			
				var datosxml = '';	
				datosxml = xmlreq.responseText;	
				funCargarXHTML(datosxml, 'divAddItem');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}
function funAgregarItem(idSel, idSrc, idDes, op){	//op=1, telefonos.... op=2, mail
	textSel = document.getElementById(idSel).options[document.getElementById(idSel).selectedIndex].text;
	
	textInp = document.getElementById(idSrc).value;
	refTxtInput = document.getElementById(idSrc);
	if(textSel.indexOf('Seleccione')!=-1){
		alert('Debe seleccionar un tipo')
	}else if(textInp != ''){
		ndiv = document.createElement('div');
		nlab = document.createElement('label');
		if(op == 1){
//			ValEmail(textSel);
			cont = document.getElementById('hCountTel');
			hTel = document.getElementById('hValTel');
			nlab.setAttribute('id', 'tel_'+parseInt(cont.value));	//puede no ir ?
			newval = parseInt(cont.value)+1;
			cont.setAttribute('value', newval);
			if(textSel.indexOf('Celular')!=-1){
				if(hTel.value == '|'){
					hTel.setAttribute('value', 'c_'+textInp+'|');
				}else{
					hTel.setAttribute('value', hTel.value+'c_'+textInp+'|');
				}
			}
			if(textSel.indexOf('Convencional')!=-1){
				if(hTel.value == '|'){
					hTel.setAttribute('value', 'o_'+textInp+'|');
				}else{
					hTel.setAttribute('value', hTel.value+'o_'+textInp+'|');
				}
			}
			if(textSel.indexOf('Fax')!=-1){
				if(hTel.value == '|'){
					hTel.setAttribute('value', 'f_'+textInp+'|');
				}else{
					hTel.setAttribute('value', hTel.value+'f_'+textInp+'|');
				}
			}
		}
		if(op == 2){
			cont = document.getElementById('hCountMail');
			hMail = document.getElementById('hValMail');
			nlab.setAttribute('id', 'mai_'+parseInt(cont.value));		//puede no ir ? 
			newval = parseInt(cont.value)+1;
			cont.setAttribute('value', newval);
			if(textSel.indexOf('Administraci')!=-1){
				if(hMail.value == '|'){
					hMail.setAttribute('value', 'a_'+textInp+'|');
				}else{
					hMail.setAttribute('value', hMail.value+'a_'+textInp+'|');
				}
			}
			if(textSel.indexOf('Venta')!=-1){
				if(hMail.value == '|'){
					hMail.setAttribute('value', 'v_'+textInp+'|');
				}else{
					hMail.setAttribute('value', hMail.value+'v_'+textInp+'|');
				}
			}
			if(textSel.indexOf('Web')!=-1){
				if(hMail.value == '|'){
					hMail.setAttribute('value', 'w_'+textInp+'|');
				}else{
					hMail.setAttribute('value', hMail.value+'w_'+textInp+'|');
				}
			}
		}
		ntex = document.createTextNode(textInp);
		nlab.appendChild(ntex);
		ndiv.appendChild(nlab);
		refDiv = document.getElementById(idDes);
		refDiv.appendChild(ndiv);
//		refTxtSrcMail = document.getElementById('txtNumMail');
//		refTxtSrcMail.setAttribute('value', '');
		refTxtInput.setAttribute('value', '');
	}else{
		if(op == 1)
			alert('Ingrese un número de teléfono')
		else
			alert('Ingrese una dirección de e-mail')
	}
}

//function validarEmail(valor)
//{
//	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))
//	{
////		alert(”La dirección de email ” + valor + ” es correcta.”);
//		return (true);
//	} else
//	{
//		alert(”La dirección de email es incorrecta.”);
//		return (false);
//	}
//}

function validarEmail(valor){    // Cortesía de http://www.ejemplode.com
    re=/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/
    if(!re.exec(valor))    {
		alert("Debe ingresar un email valido");
		document.getElementById('email').focus();
	
        return false;
    }else{
		return true;
	}
}

//Formulario de Separa tu espacio
function funReservarEspacio(){
	var empresa = document.getElementById('empresa').value;
	var director = document.getElementById('director').value;
	var direccion = document.getElementById('direccion').value;
	var telefono = document.getElementById('telefono').value;
	var email = document.getElementById('email').value;
	var ciudad = document.getElementById('ciudad').value;
	var categoria_banner = document.getElementById('categoria_banner').options[document.getElementById('categoria_banner').selectedIndex].text;
	valor_banner = document.getElementById('categoria_banner').options[document.getElementById('categoria_banner').selectedIndex].index;


	if(empresa == ''){
		alert('Debe ingresar el nombre de la empresa'); 
		document.getElementById('empresa').focus();
		return false;
	}
	if(director == ''){
		alert('Debe ingresar el nombre del director');
		document.getElementById('director').focus();
		return false;
	}
	if(direccion == ''){
		alert('Debe ingresar la direccion de la empresa');
		document.getElementById('direccion').focus();
		return false;
	}
	if(telefono == ''){
		alert('Debe ingresar un numero de telefono');
		document.getElementById('telefono').focus();
		return false;
	}
	if(email == ''){
		alert('Debe ingresar algun e-mail');
		document.getElementById('email').focus();
		return false;
	}
	

	
	if(ciudad == ''){
		alert('Debe ingresar una ciudad');
		document.getElementById('ciudad').focus();
		return false;
	}
	if (valor_banner <= 0){
		alert('Debe ingresar una categoria');
		document.getElementById('categoria_banner').focus();
		return false;
	}
	
	if(validarEmail(email))
	{
		
	
		values = 'empresa='+empresa+'&director='+director+'&direccion='+direccion+'&telefono='+telefono+'&email='+email+'&ciudad='+ciudad+'&categoria_banner='+categoria_banner+'&valor_banner='+valor_banner;	
			_URL_ = temUrl+"web/controlador/cReservarEspacio.php?";
			xmlreq = new InstanciarXMLHttpRequest();	
			xmlreq.open("POST", _URL_, true);
			xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlreq.onreadystatechange = function(){
				if(xmlreq.readyState == 4){	
					if(xmlreq.status == 200){			
						var datosxml = '';	
						datosxml = xmlreq.responseText;	
						funCargarXHTML(datosxml, 'divPrincipal');
					}
					else{
						if(xmlreq.status==404){
							alert("La URL NO existe");
						}
						else{
							alert("Error: "+xmlreq.status);
						}
					}			
				}
			}
			xmlreq.send(values);
	}
		

	
}

function funEnviarContacto(){
	var nombres = document.getElementById('nombres').value;
	var apellidos = document.getElementById('apellidos').value;
	var direccion = document.getElementById('direccion').value;
	var telefono = document.getElementById('telefono').value;
	var email = document.getElementById('email').value;
	var ciudad = document.getElementById('ciudad').value;
	var mensaje = document.getElementById('mensaje').value;

	if(nombres == ''){
		alert('Debe ingresar el nombre de la persona');
		document.getElementById('nombres').focus();
		return false;
	}
	if(apellidos == ''){
		alert('Debe ingresar el apellido de la persona');
		document.getElementById('apellidos').focus();
		return false;
	}
	if(direccion == ''){
		alert('Debe ingresar la direccion de la persona');
		document.getElementById('direccion').focus();
		return false;
	}
	if(telefono == ''){
		alert('Debe ingresar un numero de telefono');
		document.getElementById('telefono').focus();
		return false;
	}
	if(email == ''){
		alert('Debe ingresar algun e-mail');
		document.getElementById('email').focus();
		return false;
	}
	if(ciudad == ''){
		alert('Debe ingresar una ciudad');
		document.getElementById('ciudad').focus();
		return false;
	}
	
	if(validarEmail(email))
	{	
		values = 'nombres='+nombres+'&apellidos='+apellidos+'&direccion='+direccion+'&telefono='+telefono+'&email='+email+'&ciudad='+ciudad+'&mensaje='+mensaje;	
			_URL_ = temUrl+"web/controlador/cEnviarContacto.php?";
			xmlreq = new InstanciarXMLHttpRequest();	
			xmlreq.open("POST", _URL_, true);
			xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlreq.onreadystatechange = function()
			{
				if(xmlreq.readyState == 4)
				{	
					if(xmlreq.status == 200)
					{			
						var datosxml = '';	
						datosxml = xmlreq.responseText;	
						funCargarXHTML(datosxml, 'divPrincipal');
					}
					else
					{
						if(xmlreq.status==404){
							alert("La URL NO existe");
						}
						else
						{
							alert("Error: "+xmlreq.status);
						}
					}			
				}
			}
			xmlreq.send(values);
	}
}


function funEnviarActualizacion(){
	var empresa = document.getElementById('empresa').value;
	var director = document.getElementById('director').value;
	var direccion = document.getElementById('direccion').value;
	var telefono = document.getElementById('telefono').value;
	var email = document.getElementById('email').value;
	var ciudad = document.getElementById('ciudad').value;

	if(empresa == ''){
		alert('Debe ingresar el nombre de la empresa');
		document.getElementById('empresa').focus();
		return false;
	}
	if(director == ''){
		alert('Debe ingresar el nombre del director');
		document.getElementById('director').focus();
		return false;
	}
	if(direccion == ''){
		alert('Debe ingresar la direccion de la empresa');
		document.getElementById('direccion').focus();
		return false;
	}
	if(telefono == ''){
		alert('Debe ingresar un numero de telefono');
		document.getElementById('telefono').focus();
		return false;
	}
	if(email == ''){
		alert('Debe ingresar algun e-mail');
		document.getElementById('email').focus();
		return false;
	}
	if(ciudad == ''){
		alert('Debe ingresar una ciudad');
		document.getElementById('ciudad').focus();
		return false;
	}
	
	if(validarEmail(email))
	{
		values = 'empresa='+empresa+'&director='+director+'&direccion='+direccion+'&telefono='+telefono+'&email='+email+'&ciudad='+ciudad;	
			_URL_ = temUrl+"web/controlador/cActualizaciones.php?";
			xmlreq = new InstanciarXMLHttpRequest();	
			xmlreq.open("POST", _URL_, true);
			xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlreq.onreadystatechange = function()
			{
				if(xmlreq.readyState == 4)
				{	
					if(xmlreq.status == 200)
					{			
						var datosxml = '';	
						datosxml = xmlreq.responseText;	
						funCargarXHTML(datosxml, 'divPrincipal');
					}
					else
					{
						if(xmlreq.status==404){
							alert("La URL NO existe");
						}
						else
						{
							alert("Error: "+xmlreq.status);
						}
					}			
				}
			}
		xmlreq.send(values);
	}
	
}
	


function funRegistrar(){
	nomEmp = document.getElementById('txtNombre').value.toUpperCase();
	conEmp = document.getElementById('txtContacto').value.toUpperCase();
	dirEmp = document.getElementById('txtDireccion').value.toUpperCase();
	catEmp = document.getElementById('selCat').options[document.getElementById('selCat').selectedIndex].text;
	var catEmpId = document.getElementById('selCat').options[document.getElementById('selCat').selectedIndex].value;
//alert(catEmpId+' '+document.getElementById('selCat').selectedIndex)	
	ciuEmp = document.getElementById('selCiudad').options[document.getElementById('selCiudad').selectedIndex].text;
	paiEmp = document.getElementById('selPais').options[document.getElementById('selPais').selectedIndex].text;
	telEmp = document.getElementById('hValTel').value;
	maiEmp = document.getElementById('hValMail').value;
	nomUsu = document.getElementById('txtNomUsu').value.toUpperCase();
	nomNick = document.getElementById('txtNick').value;
	nomKey = document.getElementById('txtClave').value;
	nomConKey = document.getElementById('txtClaveConfir').value;

//	Validar campos obligatorios
	if(nomEmp == ''){
		alert('Debe ingresar el nombre de la empresa'); return false;
	}
	if(catEmp.indexOf('Seleccione')!=-1){
		alert('Debe seleccionar una categoria'); return false;
	}
	if(conEmp == ''){
		alert('Debe ingresar el nombre del contacto'); return false;
	}
	if(dirEmp == ''){
		alert('Debe ingresar la direccion de la empresa'); return false;
	}
	if(paiEmp.indexOf('Seleccione')!=-1){
		alert('Debe seleccionar un pais'); return false;
	}
	if(ciuEmp.indexOf('Seleccione')!=-1){
		alert('Debe seleccionar una ciudad'); return false;
	}
	if(telEmp == '|'){
		alert('Debe ingresar algun numero de telefono'); return false;
	}
	if(maiEmp == '|'){
		alert('Debe ingresar algun e-mail'); return false;
	}
	if(nomUsu == ''){
		alert('Debe ingresar el nombre del usuario'); return false;
	}
	if(nomNick == ''){
		alert('Debe ingresar el nick para el usuario'); return false;
	}

//	Validar clave
	if((nomKey != '') && (nomKey == nomConKey)){
		values = 'nomEmp='+nomEmp+'&catEmp='+catEmp+'&conEmp='+conEmp+'&dirEmp='+dirEmp+'&ciuEmp='+ciuEmp+'&paiEmp='+paiEmp+'&telEmp='+telEmp+'&maiEmp='+maiEmp+'&nomUsu='+nomUsu+'&nomNick='+nomNick+'&nomKey='+nomKey+'&catEmpId='+catEmpId;	
		_URL_ = temUrl+"web/controlador/cRegistrar.php?";
		xmlreq = new InstanciarXMLHttpRequest();	
		xmlreq.open("POST", _URL_, true);
		xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlreq.onreadystatechange = function(){
			if(xmlreq.readyState == 4){	
				if(xmlreq.status == 200){			
					var datosxml = '';	
					datosxml = xmlreq.responseText;	
					funCargarXHTML(datosxml, 'divPrincipal');
				}
				else{
					if(xmlreq.status==404){
						alert("La URL NO existe");
					}
					else{
						alert("Error: "+xmlreq.status);
					}
				}			
			}
		}
		xmlreq.send(values);
	}else{
		if(nomKey == ''){
			alert('Debe ingresar una clave');	return false;
		}else{
			alert('La clave no concuerda');	return false;
		}
	}
}
function funActualizarRegistro(){
	nomEmp = document.getElementById('txtNombre').value;	//.toUpperCase();
	catEmp = document.getElementById('txtCategoria').value;	//.toUpperCase();
	conEmp = document.getElementById('txtContacto').value;	//.toUpperCase();
	dirEmp = document.getElementById('txtDireccion').value;	//.toUpperCase();
	paiEmp = document.getElementById('txtPais').value;
	ciuEmp = document.getElementById('txtCiudad').value;
//FilaTel	-> recorrer 'div id tel5' -> div ->	'input id inpTel5' (value y name
	var inputs = document.getElementsByTagName("input");
	var telefonos = '';
	var mails = '';
	// Recorremos cada uno de los elementos,
	for (var i = 0; i < inputs.length; i++) {
		// y analizamos el "id" que sea de la forma 'inpTel5'
		if ((inputs[i].id).indexOf('inpTel') != -1) {
			// Guardo el value y el name
			telefonos = telefonos + inputs[i].name + '_' + inputs[i].value+'|';
		}

//FilaMail-> recorrer 'div id mail0' -> div ->	'input id inpMail0' (value y name
		if ((inputs[i].id).indexOf('inpMail') != -1) {
			// Guardo el value y el name
			mails = mails + inputs[i].name + '_' + inputs[i].value+'|';
		}
	}  														 
	nomUsu = document.getElementById('txtNomUsu').value.toUpperCase();
	nomNick = document.getElementById('txtNick').value;
	nomKey = document.getElementById('txtClave').value;
	nomConKey = document.getElementById('txtClaveConfir').value;

//	Validar campos obligatorios
	if(nomEmp == ''){
		alert('Debe ingresar el nombre de la empresa'); return false;
	}
	if(catEmp.indexOf('Seleccione')!=-1){
		alert('Debe seleccionar una categoria'); return false;
	}
	if(conEmp == ''){
		alert('Debe ingresar el nombre del contacto'); return false;
	}
	if(dirEmp == ''){
		alert('Debe ingresar la direccion de la empresa'); return false;
	}
	if(paiEmp.indexOf('Seleccione')!=-1){
		alert('Debe seleccionar un pais'); return false;
	}
	if(ciuEmp.indexOf('Seleccione')!=-1){
		alert('Debe seleccionar una ciudad'); return false;
	}
	if(nomUsu == ''){
		alert('Debe ingresar el nombre del usuario'); return false;
	}
	if(nomNick == ''){
		alert('Debe ingresar el nick para el usuario'); return false;
	}

//alert(telefonos+' - '+mails)

//	Validar clave
	if((nomKey != '') && (nomKey == nomConKey)){
		values = 'nomEmp='+nomEmp+'&catEmp='+catEmp+'&conEmp='+conEmp+'&dirEmp='+dirEmp+'&ciuEmp='+ciuEmp+'&paiEmp='+paiEmp+'&telEmp='+telefonos+'&maiEmp='+mails+'&nomUsu='+nomUsu+'&nomNick='+nomNick+'&nomKey='+nomKey;	
		_URL_ = temUrl+"web/controlador/cModificarRegistrar.php?";
		xmlreq = new InstanciarXMLHttpRequest();	
		xmlreq.open("POST", _URL_, true);
		xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlreq.onreadystatechange = function(){
			if(xmlreq.readyState == 4){	
				if(xmlreq.status == 200){			
					var datosxml = '';	
					datosxml = xmlreq.responseText;	
					funCargarXHTML(datosxml, 'divPrincipal');
				}
				else{
					if(xmlreq.status==404){
						alert("La URL NO existe");
					}
					else{
						alert("Error: "+xmlreq.status);
					}
				}			
			}
		}
		xmlreq.send(values);
	}else{
		if(nomKey == ''){
			alert('Debe ingresar una clave');	return false;
		}else{
			alert('La clave no concuerda');	return false;
		}
	}
}

function funSetCiudad(){
	textSel = document.getElementById('selPais').options[document.getElementById('selPais').selectedIndex].text;
	if(textSel.indexOf('Seleccione')!=-1){
		alert('Debe seleccionar un pais')
		xhtml = '<select id="selCiudad" name="selCiudad" size="1" >';
		xhtml = xhtml+'<option>- Seleccione aqui -</option>';
		xhtml =	xhtml+'</select>';	
		funCargarXHTML(xhtml, 'divFilaCiudad');
	}else{
		values = 'id='+document.getElementById('selPais').options[document.getElementById('selPais').selectedIndex].value;	
		_URL_ = temUrl+"web/controlador/cIdTable.php?";
		xmlreq = new InstanciarXMLHttpRequest();	
		xmlreq.open("POST", _URL_, true);
		xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlreq.onreadystatechange = function(){
			if(xmlreq.readyState == 4){	
				if(xmlreq.status == 200){			
					var datosxml = '';	
					datosxml = xmlreq.responseText;	
					funCargarXHTML(datosxml, 'divFilaCiudad');
				}
				else{
					if(xmlreq.status==404){
						alert("La URL NO existe");
					}
					else{
						alert("Error: "+xmlreq.status);
					}
				}			
			}
		}
		xmlreq.send(values);
	}
}

/*******************/
//	VALIDACIONES
/*******************/

function validateLetras(e){
    tecla_codigo = (document.all) ? e.keyCode : e.which;
    if(tecla_codigo==8)return true;
    patron =/[a-zA-Z]/;
//    patron =/[\w\ ]/;
    tecla_valor = String.fromCharCode(tecla_codigo);
    return patron.test(tecla_valor);
}

function ValNumero(e){
    tecla_codigo = (document.all) ? e.keyCode : e.which;
    if(tecla_codigo==8)return true;
    patron =/[0-9\t]/;
    tecla_valor = String.fromCharCode(tecla_codigo);
    return patron.test(tecla_valor);
}
//function ValEmail(email){
//    patron =/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;
//    return patron.test(email);
//}

function ValAlfaNum(e){
    tecla_codigo = (document.all) ? e.keyCode : e.which;
    if(tecla_codigo==8)return true;
    patron =/[A-Za-z0-9\- ]/;
//    patron =/[\w\ ]/;
    tecla_valor = String.fromCharCode(tecla_codigo);
    return patron.test(tecla_valor);
}
function funCancelRegistro(){
}
function funSetCategoria(){
	textSel = document.getElementById('selCat').options[document.getElementById('selCat').selectedIndex].text;
	ele = document.getElementById('txtCategoria');
	ele.setAttribute('value', textSel); 
}

function funSetPais(){
	textSel = document.getElementById('selPais').options[document.getElementById('selPais').selectedIndex].text;
	ele = document.getElementById('txtPais');
	eleCiu = document.getElementById('txtCiudad');
	if(textSel.indexOf('Seleccione')!=-1){
		alert('Debe seleccionar un pais')
		xhtml = '<select onchange="funSetCiudad2()" id="selCiudad" name="selCiudad" size="1" >';
		xhtml = xhtml+'<option>- Seleccione aqui -</option>';
		xhtml =	xhtml+'</select>';	
		funCargarXHTML(xhtml, 'divFilaCiudad');
		ele.setAttribute('value', ''); 
		eleCiu.setAttribute('value', ''); 		
	}else{
		ele.setAttribute('value', textSel); 
		eleCiu.setAttribute('value', ''); 		
		values = 'id='+document.getElementById('selPais').options[document.getElementById('selPais').selectedIndex].value+'&par=ed';	
		_URL_ = temUrl+"web/controlador/cIdTable.php?";
		xmlreq = new InstanciarXMLHttpRequest();	
		xmlreq.open("POST", _URL_, true);
		xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlreq.onreadystatechange = function(){
			if(xmlreq.readyState == 4){	
				if(xmlreq.status == 200){			
					var datosxml = '';	
					datosxml = xmlreq.responseText;	
					funCargarXHTML(datosxml, 'divFilaCiudad');
				}
				else{
					if(xmlreq.status==404){
						alert("La URL NO existe");
					}
					else{
						alert("Error: "+xmlreq.status);
					}
				}			
			}
		}
		xmlreq.send(values);
	}
}
function funSetCiudad2(){
	textSel = document.getElementById('selCiudad').options[document.getElementById('selCiudad').selectedIndex].text;
	ele = document.getElementById('txtCiudad');
	if(textSel.indexOf('Seleccione')!=-1){
		alert('Debe seleccionar una ciudad')
		ele.setAttribute('value', ''); 
	}else{
		ele.setAttribute('value', textSel); 
	}
}
function funDelNodo(id){
	var ele = document.getElementById(id);
	ele.parentNode.removeChild(ele);
	if(id.indexOf('tel') != -1){
		elHid = document.getElementById('hCountTel');
		elHid.setAttribute('value', (elHid.value)-1);
	}
	if(id.indexOf('mai') != -1){
		elHid = document.getElementById('hCountMail');
		elHid.setAttribute('value', (elHid.value)-1);
	}
}
function funDelContentNodo(id){
	ele = document.getElementById(id);
	ele.innerHTML = '';
}
function funEditTel(id){
	valEle = document.getElementById(id).value;
	values = 'idInp='+id+'&op=telefono'+'&num='+valEle;
	_URL_ = temUrl+"web/controlador/cEdit.php?";
	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){
			if(xmlreq.status == 200){
				var datosxml = '';
				datosxml = xmlreq.responseText;	
				funCargarXHTML(datosxml, 'divEditTel');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}
function funEditMail(id){
	valEle = document.getElementById(id).value;
	values = 'idInp='+id+'&op=email'+'&num='+valEle;
	_URL_ = temUrl+"web/controlador/cEdit.php?";
	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){
			if(xmlreq.status == 200){
				var datosxml = '';
				datosxml = xmlreq.responseText;	
				funCargarXHTML(datosxml, 'divEditMail');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}
function funEditarItem(sel, idDes, idSrc){	//idDes en el panel principal, idSrc en el cuadro de editar
	textSel = document.getElementById(sel).options[document.getElementById(sel).selectedIndex].text;
	eleSrc = document.getElementById(idSrc);
	eleDes = document.getElementById(idDes);
	var prefijo = textSel;
	if(prefijo.indexOf('Cel') != -1){
		prefijo = 'c'
	}
	if(prefijo.indexOf('Con') != -1){
		prefijo = 'o'
	}
	if(prefijo.indexOf('Fax') != -1){
		prefijo = 'f'
	}

	if(prefijo.indexOf('Ad') != -1){
		prefijo = 'a'
	}
	if(prefijo.indexOf('Ve') != -1){
		prefijo = 'v'
	}
	if(prefijo.indexOf('We') != -1){
		prefijo = 'w'
	}

	eleDes.setAttribute('value', eleSrc.value);
	eleDes.setAttribute('name', prefijo);
	funDelContentNodo('divEditTel');
	funDelContentNodo('divEditMail');
}
function funAddTel(id){
	valEle = document.getElementById(id).value;
	values = 'idInp='+id+'&op=addtelefono'+'&num='+valEle;
	_URL_ = temUrl+"web/controlador/cEdit.php?";
	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){
			if(xmlreq.status == 200){
				var datosxml = '';
				datosxml = xmlreq.responseText;	
				funCargarXHTML(datosxml, 'divEditTel');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}
function funPonerNuevoTel(sel, idSrc){	// idSrc en el id del padre
	textSel = document.getElementById(sel).options[document.getElementById(sel).selectedIndex].text;	//al name del input
	
	refPadre = document.getElementById('FilaTel');
	divFilaTe = document.createElement('div')
	cont = ((document.getElementById('hCountTel').value));
	if(isNaN(cont)){
		alert(cont)
	}else{
		cont = parseInt(cont) + 1;
		document.getElementById('hCountTel').value = cont;
	}
	divFilaTe.setAttribute('id', 'tel'+cont)
	divFilaTe.setAttribute('class', 'filaEdit')
	divInp = document.createElement('div')
	inp = document.createElement('input')
	var prefijo = textSel;
	if(prefijo.indexOf('Celu') != -1){
		prefijo = 'c'
	}
	if(prefijo.indexOf('Conven') != -1){
		prefijo = 'o'
	}
	if(prefijo.indexOf('Fax') != -1){
		prefijo = 'f'
	}
	inp.setAttribute('value', document.getElementById('txtNumTel').value)
	inp.setAttribute('name', prefijo)
	inp.setAttribute('class', 'inputText')
	inp.setAttribute('id', 'inpTel'+cont);
	divInp.appendChild(inp)
	
	divDel = document.createElement('div')
	divDel.setAttribute('class', 'imgButton');	
	imgDel = document.createElement('img')
	imgDel.setAttribute('src', 'web/vista/images/b_delete.png');	
	imgDel.setAttribute('onclick', 'funDelNodo("tel'+cont+'")');	
	divDel.appendChild(imgDel)

	divEdi = document.createElement('div')
	divEdi.setAttribute('class', 'imgButton');	
	imgEdi = document.createElement('img')
	imgEdi.setAttribute('src', 'web/vista/images/b_edit.png');	
	imgEdi.setAttribute('onclick', 'funEditTel("inpTel'+cont+'")');	
	divEdi.appendChild(imgEdi)

	divAdd = document.createElement('div')
	divAdd.setAttribute('class', 'imgButton');	
	imgAdd = document.createElement('img')
	imgAdd.setAttribute('src', 'web/vista/images/add.gif');	
	imgAdd.setAttribute('onclick', 'funAddTel("inpTel'+cont+'")');	
	divAdd.appendChild(imgAdd)
	
	divFilaTe.appendChild(divInp)
	divFilaTe.appendChild(divDel)
	divFilaTe.appendChild(divEdi)
	divFilaTe.appendChild(divAdd)
	refPadre.appendChild(divFilaTe)
	
	document.getElementById('divEditTel').innerHTML = '';
}
function funAddMail(id){
	valEle = document.getElementById(id).value;
	values = 'idInp='+id+'&op=addmail'+'&num='+valEle;
	_URL_ = temUrl+"web/controlador/cEdit.php?";
	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){
			if(xmlreq.status == 200){
				var datosxml = '';
				datosxml = xmlreq.responseText;	
				funCargarXHTML(datosxml, 'divEditMail');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}
function funPonerNuevoMail(sel, idSrc){	// idSrc en el id del padre
	textSel = document.getElementById(sel).options[document.getElementById(sel).selectedIndex].text;	//al name del input
	
	refPadre = document.getElementById('FilaMail');
	divFilaTe = document.createElement('div')
	cont = ((document.getElementById('hCountMail').value));
	if(isNaN(cont)){
		alert(cont)
	}else{
		cont = parseInt(cont) + 1;
		document.getElementById('hCountMail').value = cont;
	}
	divFilaTe.setAttribute('id', 'mail'+cont)
	divFilaTe.setAttribute('class', 'filaEdit')
	divInp = document.createElement('div')
	inp = document.createElement('input')
	var prefijo = textSel;
	if(prefijo.indexOf('Ad') != -1){
		prefijo = 'a'
	}
	if(prefijo.indexOf('Ve') != -1){
		prefijo = 'v'
	}
	if(prefijo.indexOf('We') != -1){
		prefijo = 'w'
	}
	inp.setAttribute('value', document.getElementById('txtNumMail').value)
	inp.setAttribute('name', prefijo)
	inp.setAttribute('class', 'inputText')
	inp.setAttribute('id', 'inpMail'+cont);
	divInp.appendChild(inp)

	divDel = document.createElement('div')
	divDel.setAttribute('class', 'imgButton');	
	imgDel = document.createElement('img')
	imgDel.setAttribute('src', 'web/vista/images/b_delete.png');	
	imgDel.setAttribute('onclick', 'funDelNodo("mail'+cont+'")');		
	divDel.appendChild(imgDel)

	divEdi = document.createElement('div')
	divEdi.setAttribute('class', 'imgButton');	
	imgEdi = document.createElement('img')
	imgEdi.setAttribute('src', 'web/vista/images/b_edit.png');	
	imgEdi.setAttribute('onclick', 'funEditMail("inpMail'+cont+'")');		
	divEdi.appendChild(imgEdi)

	divAdd = document.createElement('div')
	divAdd.setAttribute('class', 'imgButton');	
	imgAdd = document.createElement('img')
	imgAdd.setAttribute('src', 'web/vista/images/add.gif');	
	imgAdd.setAttribute('onclick', 'funAddMail("inpMail'+cont+'")');	
	divAdd.appendChild(imgAdd)
	
	divFilaTe.appendChild(divInp)
	divFilaTe.appendChild(divDel)
	divFilaTe.appendChild(divEdi)
	divFilaTe.appendChild(divAdd)
	refPadre.appendChild(divFilaTe)
	
	document.getElementById('divEditMail').innerHTML = '';
}

function funMostrarEditRegistro(nomUsu, nomNick, emId){
	values = 'nomUsu='+nomUsu+'&nomNick='+nomNick+'&emId='+emId;
	_URL_ = temUrl+"web/controlador/cEditLoginEmpresa.php?";
	xmlreq = new InstanciarXMLHttpRequest();	
	xmlreq.open("POST", _URL_, true);
	xmlreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlreq.onreadystatechange = function(){
		if(xmlreq.readyState == 4){
			if(xmlreq.status == 200){
				var datosxml = '';
				datosxml = xmlreq.responseText;	
				funCargarXHTML(datosxml, 'divPrincipal');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);	
}

function IngresarBanner(emId, tipo){
	_URL_ = temUrl+"web/cIngresar_Banner.php?";

	win1=window.open(_URL_ +'emId='+emId+'&tipo='+tipo, "Nuevo_Banner" ,	"width=360,height=220,left=400,top=300,scrollbars=YES,resizable=NO,location=NO,directories=YES"); 

}
function funObtenerAreaID(){
	id_area = document.getElementById('ar_id').options[document.getElementById('ar_id').selectedIndex].value;

	if (id_area == 1){
		document.formbanner.alto.value="Alto = 90px  Ancho = 728px";
//		ref_ancho.innerHTML = " Ancho = 728px";
	}
	if (id_area == 2){
		document.formbanner.alto.value="Alto = 173px  Ancho = 728px";
//		ref.innerHTML = "Alto = 173px";
//		ref_ancho.innerHTML = " Ancho = 728px";
	}
	if (id_area == 3){
		document.formbanner.alto.value="Alto = 90px  Ancho = 728px";
//		ref.innerHTML = "Alto = 90px";
//		ref_ancho.innerHTML = " Ancho = 728px";
	}
	if (id_area == 4){
		document.formbanner.alto.value="Alto = 600px  Ancho = 180px";
//		ref.innerHTML = "Alto = 600px";
//		ref_ancho.innerHTML = " Ancho = 180px";
	}
	if (id_area == 5){
		document.formbanner.alto.value="Alto = 150px  Ancho = 180px";
//		ref.innerHTML = "Alto = 150px";
//		ref_ancho.innerHTML = " Ancho = 180px";
	}

	refHidden1 = document.getElementById('id_area_enviar');
	refHidden1.setAttribute('value', id_area);
}

