// JavaScript Document
//temUrl ='http://' +location.hostname+'/Respaldo Pintuco/'; 		
//temUrl ='http://' +location.hostname+'/Wise/Respaldo Pintuco/'; 	
temUrl ='http://' +location.hostname+'/'; 	

function funPaginacion(){
	var opcion = document.getElementById('paginas').options[document.getElementById('paginas').selectedIndex].value;
	total_pag = document.getElementById('total_pag').value;
	cadena = document.getElementById('cadena').value;
	boletin = document.getElementById('boletin').value;
	orden = document.getElementById('orden').value;
	mostrar = document.getElementById('mostrar').value;	
	ocupacion = document.getElementById('ocupacion').value;	
	genero = document.getElementById('genero').value;
	pais = document.getElementById('pais').value;
	ciudad = document.getElementById('ciudad').value;
//	alert(opcion+cadena+" "+ocupacion);
	values = 'pagina='+opcion+'&ocupacion='+ocupacion+'&boletin='+boletin+'&orden='+orden+'&mostrar='+mostrar+'&genero='+genero+'&pais='+pais+'&ciudad='+ciudad;
//	alert (cadena);
//	values = 'pagina='+opcion;
	_URL_ = temUrl + "mCargarDatosTabla.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 = xmlreq.responseText;	

				funCargarXHTML(datosxml, 'tabla');				
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	
	xmlreq.send(values);
//	alert (opcion);

}

function ChequearTodos(chkbox)
{
  	for (var i=0;i < document.forms[0].elements.length;i++)
	{
		
	  var elemento = document.forms[0].elements[i];
	  if (elemento.type == "checkbox")
	  {
		  elemento.checked = chkbox.checked
	  }
  	}
}
//temUrl = "http://"+location.hostname+"/";
function fg_objetus() {

      var http_request = false;

      if (window.XMLHttpRequest) { // Mozilla, Safari,...

         http_request = new XMLHttpRequest();

      } else if (window.ActiveXObject) { // IE

         try {

            http_request = new ActiveXObject("Msxml2.XMLHTTP");

         } catch (e) {

            try {

               http_request = new ActiveXObject("Microsoft.XMLHTTP");

            } catch (e) {}

         }

      }

      if (!http_request) {

         alert('Cannot create XMLHTTP instance');

         return false;

      }

	  if (http_request.overrideMimeType) {

            http_request.overrideMimeType('text/xml');

      }

      return http_request;

   }
   
function fg_loadContainer(ps_pagehtml,po_method,po_div,po_objects){

	var lo_container;

	if(po_div==undefined){

	   lo_container = document.getElementById('id_container');		

	} else {

	   lo_container = document.getElementById(po_div);			

	}

	var lo_ajax=fg_objetus();

	lo_container.innerHTML = "Processing...";

	if(po_method==undefined){

		po_method="GET";

	} 
//	alert (po_method);
	lo_ajax.open(po_method, ps_pagehtml,true);

	lo_ajax.onreadystatechange=function() {

			if (lo_ajax.readyState==4) {

				  lo_container.innerHTML = lo_ajax.responseText;
//				  alert (lo_container);

			} 

	}

	if(po_method=="GET"){

		lo_ajax.send(null);

	} else {

		lo_ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

		//alert(po_objects);

		lo_ajax.send(po_objects);

	}

}

function showpanel(indice, posicion){

   for (var i=1;i<posicion+1;i++){

	   var objeto = document.getElementById('bloque'+(i));

	   if((i)==indice){

	     objeto.style.display = 'block';


	   }else{

	     objeto.style.display = 'none';

	   }

   }

} 


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}



function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);
}

//Para cargar todos los banners de las Empresas
function CargarForm(){ 
	opcion = 'menuCategoria';
	tipo='registro';
//	values = 'fecing='+fecing;
//Web
//	_URL_ = temUrl+"Admin/controlador/cCargaBanners.php?";
	_URL_=temUrl+"controlador/cCargaHome.php";
//	alert(_URL_);
	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 = xmlreq.responseText;	
				funCargarXHTML(datosxml, 'div_home_centro');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");

				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(null);
}
function funCargarXHTML(datosxml, divOld){
	refDiv = document.getElementById(divOld);
	refDiv.innerHTML = datosxml; 
}

function funCargarXHTMLbanner(datosxml, divOld){
	refDiv = document.getElementById(divOld);
	refDiv.innerHTML = datosxml; 
}
function requestHtmlPage(domainPage){
	
	var url=domainPage;
	var datosxml = null;
	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 = xmlreq.responseXML;
				datosxml = xmlreq.responseText;	
//				alert(datosxml);
				funCargarXHTML(datosxml, 'div_cuerpo');
				

//				if(banner == 1){
//					
//					datosxmlbanner=xmlreq.responseText;
//					alert(datosxmlbanner);
//					funCargarXHTMLBanner(datosxmlbanner, 'div_cabecera');	
				
//				}
				//alert(datosxml);
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");

				}
				else{
					alert("Error: "+xmlreq.status);

				}
			}			
		}
	}
	
	
	xmlreq.send();
}

function funMostrarColecc0(id,tipo){ 
	opcion = 'menuCategoria';
	values = 'id='+id+'&tipo='+tipo;

//	_URL_=temUrl+"controlador/CCargacolecc0.php";
	_URL_=temUrl+"controlador/CCargacolecc0.php";

//	_URL_=temUrl+"hola.xml";
	var datosxml = null;
	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 = xmlreq.responseXML;
				datosxml = xmlreq.responseText;	
//				alert(datosxml);
				funCargarXHTML(datosxml, 'div_cuerpo');
				

//				if(banner == 1){
//					
//					datosxmlbanner=xmlreq.responseText;
//					alert(datosxmlbanner);
//					funCargarXHTMLBanner(datosxmlbanner, 'div_cabecera');	
				
//				}
				//alert(datosxml);
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");

				}
				else{
					alert("Error: "+xmlreq.status);

				}
			}			
		}
	}
	
	
	xmlreq.send(values);
}

function funMostrarBanner(id,tipo){ 
	banner="http://www.pintuco.com.ec/swf/";

	//Banner VIVE
//	refDiv = document.getElementById('div_cabecera').getAttribute("swfUrl");
//	document.getElementById("myDiv").getAttribute("id");
//	refDiv.innerHTML = datosxml; 

	refDiv="div_cabecera";
	//Alto y ancho para los banner
	ancho="889";
	alto="185";
	var attributes = {
  		wmode: "transparent"
	};
	var params = {wmode:'transparent'}; 

	if (id == 1){
		banner=banner+"banner_vive.swf";
	}
	//Banner COLECCIONES
	if (id == 2){
		banner=banner+"banner_colecciones.swf";	
	}
	//Banner Color Tips
	if (id == 3){
		banner=banner+"banner_color_tips.swf";	
	}
	if (id == 4){
		banner=banner+"banner_servicio_tecnico.swf";	
	}
	if (id == 5){
		banner=banner+"banner_momentos.swf";	
	}
	if (id == 6){
		banner=banner+"banner_centro_color.swf";	
	}

//Novedades --> Color Click -->Video Comercial	
	if (id == 10){
		setTimeout("funMostrarBanner(11)", 1500);
	}
	if (id == 11){
		banner1=banner+"comercial.swf";
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="363";
		ancho1="442";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",false,params,attributes);
	}
	
//Servicios --> Sistema del Color	
	if (id == 20 ){
		setTimeout("funMostrarBanner(21)", 1500);
	}
//Servicios --> Sistema del Color	
	if (id == 21){
		banner1=banner+"sistema_color/intro sistema.swf";
		banner=banner+"banner_sistema.swf";
		refDiv1="div_video";
		alto1="290";
		ancho1="889";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",false,params,attributes);
	}
//Color Tips --> Calcular Pintura
	if (id == 30){
		setTimeout("funMostrarBanner(31)", 1500);
	}
	if (id == 31){
		banner1=banner+"calcular_pintura.swf";
		banner=banner+"banner_color_tips.swf";
		refDiv1="div_video";
		alto1="310";
		ancho1="889";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",false,params,attributes);
	}
	
	//Nuestros Distribuidores
	if (id == 40){
		setTimeout("funMostrarBanner(41)", 1500);
	}
	if (id == 41){
		banner1=banner+"distribuidores.swf";
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="450";
		ancho1="889";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",false,params,attributes);
	}
	//Portafolio de Productos
	if (id == 50){
		setTimeout("funMostrarBanner(51)", 1500);
	}
	if (id == 51){
		banner1=banner+"portafolio/portafolio.swf";
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="380";
		ancho1="889";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",false,params,attributes);
	}
	//Portafolio de Productos
	if (id == 60){
		setTimeout("funMostrarBanner(61)", 1500);
	}
	if (id == 61){
		banner1=banner+"carta_colores/carta_de_colores.swf";
//		banner1=banner+"portafolio/portafolio.swf";
//		alert(banner1);
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="327";
		ancho1="889";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",false,params,attributes);
	}
		//Videos Momentos de Hogar
	if (id == 70){
		if(tipo == 1){
		setTimeout("funMostrarBanner(71)", 1500);
		}
		if(tipo == 2){
		setTimeout("funMostrarBanner(72)", 1500);
		}
		if(tipo == 3){
		setTimeout("funMostrarBanner(73)", 1500);
		}
		if(tipo == 4){
		setTimeout("funMostrarBanner(74)", 1500);
		}
		if(tipo == 5){
		setTimeout("funMostrarBanner(75)", 1500);
		}
		if(tipo == 6){
		setTimeout("funMostrarBanner(76)", 1500);
		}
		if(tipo == 7){
		setTimeout("funMostrarBanner(77)", 1500);
		}
		if(tipo == 8){
		setTimeout("funMostrarBanner(78)", 1500);
		}
		if(tipo == 9){
		setTimeout("funMostrarBanner(79)", 1500);
		}

	}

	if (id == 71){
		banner1="http://www.pintuco.com.ec/contenido/momentos_hogar/videos/video1.swf";
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="282";
		ancho1="345";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",false,params,attributes);
	}
	if (id == 72){

		banner1="http://www.pintuco.com.ec/contenido/momentos_hogar/videos/video2.swf";
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="282";
		ancho1="345";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",false,params,attributes);
	}
	if (id == 73){
		banner1="http://www.pintuco.com.ec/contenido/momentos_hogar/videos/video3.swf";
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="282";
		ancho1="345";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",false,params,attributes);
	}
	if (id == 74){
		banner1="http://www.pintuco.com.ec/contenido/momentos_hogar/videos/video4.swf";
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="282";
		ancho1="345";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",false,params,attributes);
	}
	if (id == 75){
		banner1="http://www.pintuco.com.ec/contenido/momentos_hogar/videos/video5.swf";
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="282";
		ancho1="345";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",false,params,attributes);
	}
	if (id == 76){
		banner1="http://www.pintuco.com.ec/contenido/momentos_hogar/videos/video6.swf";
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="282";
		ancho1="345";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",undefined,undefined,attributes);
	}
	if (id == 77){
		banner1="http://www.pintuco.com.ec/contenido/momentos_hogar/videos/video7.swf";
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="282";
		ancho1="345";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",undefined,undefined,attributes);
	}
	if (id == 78){
		banner1="http://www.pintuco.com.ec/contenido/momentos_hogar/videos/video8.swf";
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="282";
		ancho1="345";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",undefined,undefined,attributes);
	}
	if (id == 79){
		banner1="http://www.pintuco.com.ec/contenido/momentos_hogar/videos/video9.swf";
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="282";
		ancho1="345";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",undefined,undefined,attributes);
	}
// Para mostrar el home
	if (id == 100){
		setTimeout("funMostrarBanner(101)", 2500);
	}
	if (id == 101){
		banner1=banner+"medio_ambiente.swf";
		banner=banner+"banner_vive.swf";
		refDiv1="div_video";
		alto1="230";
		ancho1="889";
		swfobject.embedSWF(banner1, refDiv1, ancho1, alto1, "9.0.0", "expressInstall.swf",false,params,attributes);
	}

//	alert (banner);
	swfobject.embedSWF(banner, refDiv, ancho, alto, "9.0.0", "expressInstall.swf");
	//banner="";
//	banner1="";
}






function funMostrarHome(){ 
	opcion = 'menuCategoria';
//	values = 'fecing='+fecing;
//Web
//	_URL_ = temUrl+"Admin/controlador/cCargaBanners.php?";
	_URL_=temUrl+"controlador/cCargaHome.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 = xmlreq.responseText;	
				funCargarXHTML(datosxml, 'div_home_centro');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");

				}
				else{
					alert("Error: "+xmlreq.status);

				}
			}			
		}
	}
	xmlreq.send(null);
}

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 InstanciarXMLHttpRequest2(){
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 funRegistrar(){

	user = document.getElementById('user2').value;
	pass = document.getElementById('clave2').value;	
	apellido = document.getElementById('apellido2').value;
	nombre = document.getElementById('nombre2').value;
	email = document.getElementById('email2').value;	
	telefono = document.getElementById('telefono2').value;	
	genero = document.getElementById('genero2').options[document.getElementById('genero2').selectedIndex].text;
	anio = document.getElementById('anio2').options[document.getElementById('anio2').selectedIndex].text;	
	mes = document.getElementById('mes2').options[document.getElementById('mes2').selectedIndex].text;	
	dia = document.getElementById('dia2').options[document.getElementById('dia2').selectedIndex].text;
	pais =document.getElementById('pais2').options[document.getElementById('pais2').selectedIndex].text;
	ciudad = document.getElementById('ciudad2').value;	
	ocupacion =document.getElementById('ocupacion2').options[document.getElementById('ocupacion2').selectedIndex].text;
//	Validar campos obligatorios
	if(user == ''){
		alert('Debe ingresar el usuario de la persona'); return false;
	}
	if(pass == ''){
		alert('Debe ingresar la fecha de nacimiento'); return false;
	}
	if(nombre == ''){
		alert('Debe ingresar los nombres de la persona'); return false;
	}
	if(apellido == ''){
		alert('Debe ingresar los apellidos de la persona'); return false;
	}
	if(email == ''){
		alert('Debe ingresar el correo de la persona'); return false;
	}
	if(telefono == ''){
		alert('Debe ingresar el telefono de la persona'); return false;
	}
	if(genero == ''){
		alert('Debe ingresar el genero de la persona'); return false;
	}
	if(anio == ''){
		alert('Debe escoger un anio de nacimiento para la persona'); return false;
	}
	if(mes == ''){
		alert('Debe escoger un mes de nacimiento para la persona'); return false;
	}
	if(dia == ''){
		alert('Debe escoger un dia de nacimiento para la persona'); return false;
	}
	if(pais == ''){
		alert('Debe ingresar el pais de origen de la persona'); return false;
	}
	if(ciudad == ''){
		alert('Debe escoger una ciudad para la persona'); return false;
	}
	if(ocupacion == ''){
		alert('Debe escoger una ocupacion para la persona'); return false;
	}

	_URL_=temUrl+"controlador/cInsertarDatos.php?";
//	alert(_URL_);
	values = 'user='+user+'&pass='+pass+'&nombre='+nombre+'&apellido='+apellido+'&email='+email+'&telefono='+telefono+'&genero='+genero+'&anio='+anio+'&mes='+mes+'&dia='+dia+'&pais='+pais+'&ciudad='+ciudad+'&ocupacion='+ocupacion;

	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 = '';	
				//alert (values);
				datosxml = xmlreq.responseText;	
				//alert(datosxml);
				funCargarXHTML(datosxml, 'div_cuerpo');
			}
			else{
				if(xmlreq.status==404){
					alert("La URL NO existe");
				}
				else{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
	
}

function mensaje_mundo()
{
	alert('Hola mundo');

}

/*-FORMULARIO DE SERVICIO TECNICO-*/
function MM_validateFormTecnico()
{ //v4.0

//  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormTecnico.arguments;
//
//  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
//
//    if (val) { nm=val.name; if ((val=val.value)!="") {
//
//      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
//
//        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una dirección válida de E-mail.\n';
//
//      } else if (test!='R') { num = parseFloat(val);
//
//        if (isNaN(val)) errors+='- '+nm+' debe contener un valor numérico.\n';
//
//        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
//
//          min=test.substring(8,p); max=test.substring(p+1);
//
//          if (num<min || max<num) errors+='- '+nm+' debe estar entre '+min+' y '+max+'.\n';
//
//    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es un campo requerido.\n'; }
//
//  } if (errors) alert('Ocurrieron los siguientes errores:\n'+errors);

  
  	nombre = document.getElementById('nombre').value; //son los nombres y apellidos
	mailuser = document.getElementById('mailuser').value;	
	ciudad = document.getElementById('ciudad').value;
	asunto = document.getElementById('asunto').value;
	consulta = document.getElementById('consulta').value;
	categoria = document.getElementById('categoria').value;
	correo_destino = document.getElementById('correo_destino').value;
	copia = document.getElementById('copia').value;

  	_URL_=temUrl+"controlador/cEnviarMailAsesoria.php?";

	
	values = 'nombre='+nombre+'&mailuser='+mailuser+'&ciudad='+ciudad+'&asunto='+asunto+'&consulta='+consulta+'&categoria='+categoria+'&correo_destino='+correo_destino+'&copia='+copia;
		
	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 = '';	
				alert (values);
				datosxml = xmlreq.responseText;	
				alert(datosxml);
				funCargarXHTML(datosxml, 'div_cuerpo');
			}
			else
			{
				if(xmlreq.status==404)
				{
					alert("La URL NO existe");
				}
				else
				{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}

function Enviar_Sugerencia()
{   
  	nombre = document.getElementById('nombre').value; //son los nombres y apellidos
	mailuser = document.getElementById('mailuser').value;	
	ciudad = document.getElementById('ciudad').value;
	asunto = document.getElementById('asunto').value;
	consulta = document.getElementById('consulta').value;
	categoria = document.getElementById('categoria').value;
	correo_destino = document.getElementById('correo_destino').value;
	copia = document.getElementById('copia').value;

  	_URL_=temUrl+"controlador/cEnviarMailAsesoria.php?";

	
	values = 'nombre='+nombre+'&mailuser='+mailuser+'&ciudad='+ciudad+'&asunto='+asunto+'&consulta='+consulta+'&categoria='+categoria+'&correo_destino='+correo_destino+'&copia='+copia;
		
	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 = '';	
//				alert (values);
				datosxml = xmlreq.responseText;	
//				alert(datosxml);
				funCargarXHTML(datosxml, 'div_cuerpo');
			}
			else
			{
				if(xmlreq.status==404)
				{
					alert("La URL NO existe");
				}
				else
				{
					alert("Error: "+xmlreq.status);
				}
			}			
		}
	}
	xmlreq.send(values);
}

function Enviar_Contrasenia()
{
	var mailuser = document.getElementById('mailuser').value;	
	if (mailuser.length == 0){
		alert("Debe ingresar una direccion de Email");
	}
	else{
		validar=1;
	}
//      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
//        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una dirección válida de E-mail.\n';
//      } 
//
//		validar=1;

  	_URL_=temUrl+"controlador/cEnviarRecuperarContrasenia.php?";
//	if ()
	if (validar == 1){
		values = 'mailuser='+mailuser;
			
		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 = '';	
	//				alert (values);
					datosxml = xmlreq.responseText;	
	//				alert(datosxml);
					funCargarXHTML(datosxml, 'div_cuerpo');
				}
				else
				{
					if(xmlreq.status==404)
					{
						alert("La URL NO existe");
					}
					else
					{
						alert("Error: "+xmlreq.status);
					}
				}			
			}
		}
		xmlreq.send(values);
	}else{
		alert ("No fue posible realizar la operaci&oacute;n de recuperaci&oacute;n de la contrase&ntilde;a.");
		}

}

function Ingresar_Usuario()
{

	var mailuser = document.getElementById('mail_user').value;
	var clave = document.getElementById('clave').value;	
	if (mailuser.length == 0 || mailuser == '@'){
		alert("Debe ingresar una direccion de Email");
	}else{
		validar=1
	}
	if (clave.length == 0){
		alert("Debe ingresar su clave de usuario");
	}
	else{
		validar=validar+1;
	}
	if (isEmailAddress()){
		validar=validar+1;
	}
  	_URL_=temUrl+"controlador/cIngresoUsuario.php?";

	if (validar == 3){
		values = 'mailuser='+mailuser+'&clave='+clave;
			
		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;
					//para validar debe buscar el mail que exista dentro de la base antes d enviar a mostrar el mensaje de Bienvenido con los respectivos nombres y apellidos
					if(datosxml.indexOf('correo no se encuentra registrado')<=0){
						Borrar_Div_Login(mailuser,clave);
					}else{
						document.getElementById('mail_user').value="@";

					}
					
					funCargarXHTML(datosxml, 'div_cuerpo');
				}
				else
				{
					if(xmlreq.status==404)
					{
						alert("La URL NO existe");
					}
					else
					{
						alert("Error: "+xmlreq.status);
					}
				}			
			}
		}
		document.getElementById('clave').value="";
		xmlreq.send(values);
	}else{
		alert ("No fue posible realizar la operación de ingreso con el mail ingresado.");
		}

}
function Borrar_Div_Login(mail,clave){
	  	_URL_=temUrl+"controlador/cBorrarDivLogin.php?";

		values = 'mailuser='+mail+'&clave='+clave;

		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, 'div_login');
				}
				else
				{
					if(xmlreq.status==404)
					{
						alert("La URL NO existe");
					}
					else
					{
						alert("Error: "+xmlreq.status);
					}
				}			
			}
		}
//		document.getElementById('clave').value="";
		xmlreq.send(values);
		
}

function Carga_Div_Login(){
		_URL_=temUrl+"modelo/mCargaDivLogin.php?";
		values = "";
			
		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;	
					//alert(datosxml);
					funSalidaUsuario();
					funCargarXHTML(datosxml, 'div_login');

				}
				else
				{
					if(xmlreq.status==404)
					{
						alert("La URL NO existe");
					}
					else
					{
						alert("Error: "+xmlreq.status);
					}
				}			
			}
		}
//		document.getElementById('clave').value="";

		xmlreq.send(null);
}
function funSalidaUsuario(){
		_URL_=temUrl+"modelo/mSalidaUsuario.php?";
		values = "";
			
		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;	
					//alert(datosxml);
					funCargarXHTML(datosxml, 'div_cuerpo');
				}
				else
				{
					if(xmlreq.status==404)
					{
						alert("La URL NO existe");
					}
					else
					{
						alert("Error: "+xmlreq.status);
					}
				}			
			}
		}
//		document.getElementById('clave').value="";

		xmlreq.send(null);
}



function Actualizar_Datos(){
	var nombres = document.getElementById('nombres').value;	
	var apellidos = document.getElementById('apellidos').value;	
	var email = document.getElementById('email').value;	
	var telefono = document.getElementById('telefono').value;
	var ciudad = document.getElementById('ciudad').value;
	var user = document.getElementById('user').value;		
	var ocupacion = document.getElementById('ocupacion2').options[document.getElementById('ocupacion2').selectedIndex].value;	
;		

	if (nombres.length == 0){
		alert("Debe ingresar el nombre del usuario");
		validar=0;
	}
	if (apellidos.length == 0){
		alert("Debe ingresar al menos un apellido del usuario");
		validar=0;
	}
	if (email.length == 0){
		alert("Debe ingresar una direccion de Email");
		validar=0;	
	}
	if (telefono.length == 0){
		alert("Debe ingresar un telefono del usuario");
		validar=0;
	}
	if (ciudad.length == 0){
		alert("Debe ingresar la ciudad de origen del usuario");
		validar=0;
	}
	if (ocupacion.length == 0){
		alert("Debe escoger una profesion de la lista");
		validar=0;		
	}
	else{
		validar=1;
	}
  	_URL_=temUrl+"controlador/cActDatos.php?";
//	if ()
	if (validar == 1){
	values = 'nombres='+nombres+'&apellidos='+apellidos+'&email='+email+'&telefono='+telefono+'&ciudad='+ciudad+'&ocupacion='+ocupacion+'&user='+user;
			
		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 = '';	
	//				alert (values);
					datosxml = xmlreq.responseText;	
	//				alert(datosxml);
					Carga_Div_Login();
					funCargarXHTML(datosxml, 'div_cuerpo');
				}
				else
				{
					if(xmlreq.status==404)
					{
						alert("La URL NO existe");
					}
					else
					{
						alert("Error: "+xmlreq.status);
					}
				}			
			}
		}
		xmlreq.send(values);
	}else{
		alert ("No fue posible realizar la operaci&oacute;n de actualizaci&oacute;n de los datos.");
		}

}
function validarmail(e)
{
    tecla = (document.all) ? e.keyCode : e.which;
    if(tecla!=0)
    {
	
       if(tecla==8) return true;
       if(tecla==9) return true;
//	   patron = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;
  //     patron =/[\w-\.]{3,}(@[\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}/;
//		patron =/^(.+\@.+\..+)$/;
//		patron=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
		patron =/([\w-\.]{3})/;
       te = String.fromCharCode(tecla);
       return patron.test(te);
   }

}

function isEmailAddress()
{
var s = document.getElementById('mail_user').value;
//alert(s);
//var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
var filter =/[\w-\.]{3,}(@[\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}/;
if (s.length == 0 ) return true;
if (filter.test(s))
return true;
else
alert("Ingrese una dirección de correo válida");
//theElement.focus();
return false;
}
//function validarEmail(valor) {
//
//	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
//	
//		alert("La dirección de email " + valor + " es correcta.");
//	
//	} else {
//
//		alert("La dirección de email es incorrecta.");
//	
//	}
//
//}