		function validar(nombre, correo, asunto)
		{
			if(nombre=="")	
			{
				alert("Debe ingresar el nombre");
				return false;				
			}	
			
			if(asunto=="")	
			{
				alert("Debe ingresar el asunto");
				return false;				
			}	
			
			if(!validar_correo_e(correo))
			{	
				alert("Debe ingresar un correo electrónico válido");
				return false;		
			}

			window.open('', 'enviar_correo', 'top=200px,width=350px,height=100px');
			return true;
		}
		
		function validar_i(nombre, pais, correo)
		{
			if(nombre=="")	
			{
				alert("Input your name");
				return false;				
			}	
			
			if(pais=="")	
			{
				alert("Input your country");
				return false;				
			}	
			
			if(!validar_correo_e(correo))
			{	
				alert("Input your e-mail");
				return false;		
			}

			window.open('', 'enviar_correo', 'top=200px,width=350px,height=100px');
		}
		
		
		
		
		function validar_g(nombre, ciudad, correo)
		{
			if(nombre=="")	
			{
				alert("Debe ingresar el nombre");
				return false;				
			}	
			
			if(ciudad=="")	
			{
				alert("Debe ingresar la ciudad");
				return false;				
			}	
			
			if(!validar_correo_e(correo))
			{	
				alert("Debe ingresar un correo electrónico válido");
				return false;		
			}
			return true;
		//	window.open('', 'enviar_correo', 'top=200px,width=350px,height=100px');
		}
		


function validar_contra(c, c1)
{
	if(c==c1)
		return true;
	else
		alert("Las constraseñas ingresadas son diferentes");
	return false;	
}

function validar_correo_e(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)

	if (str.indexOf(at)==-1)   return false
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)	   return false
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)  return false
	if (str.indexOf(at,(lat+1))!=-1) return false
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)   return false
	if (str.indexOf(dot,(lat+2))==-1)   return false
	if (str.indexOf(" ")!=-1)   return false
	return true					
}


function createRequestObject() 
{
     var ro;
     var browser = navigator.appName;
     if(browser == "Microsoft Internet Explorer")
	 {
          ro = new ActiveXObject("Microsoft.XMLHTTP");
     }
	 else
	 {
          ro = new XMLHttpRequest();
     }
     return ro;
}

var http = createRequestObject();


function validar_codigo()
{	
	if(document.getElementById('textfield').value)
	{ 
		http.open('get', 'consultas_ajax.php?id='+cedula);
		http.onreadystatechange = handleResponse;
    	http.send(null);
		
		window.close(); 
		return true;
	} 
	else
	{ 
		alert('Por favor, ingrese el código del cliente'); 
		return  false; 
	}
}	

function mostrar_datos(cedula) 
{
	
}

function mostrar_select(ciudad,comuna) 
{
	//alert("llego: "+ciudad);
	http.open('get', 'consultas_ajax.php?ciudad='+ciudad+'&sector='+comuna);
	//alert('consultas_ajax.php?ciudad='+ciudad+'&comuna='+comuna);
	http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() 
{
     if(http.readyState == 4)
	 {
          var response = http.responseText;
		  var update = new Array();

          if(response.indexOf('|' != -1)) 
		  {
 			  update = response.split('|');


			  if(update[0]=='2')
				{
			//alert("va a poner sel");
			document.getElementById('1').innerHTML = update[1];		   
				}
          }
		
		
     }
}

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_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_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];
		}
	}
}

var win = null;
function nueva_ventana(mypage,myname,w,h,scroll)
{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=yes'
	win = window.open(mypage,myname,settings)
}

function popup(theURL, winName,features)
{
	window.open(theURL, winName,features);
}


function validar_correo(nombre, email, mensaje)
{
	if(nombre=="")
	{
		alert("Debe ingresar el nombre");
		return false;
	}
	if(!validar_correo_e(email))
	{
		alert("Debe ingresar un correo electrónico válido");
		return false;
	}
	if(mensaje=="")
	{
		alert("Debe ingresar el mensaje");
		return false;
	}
	return true;
}

function validar_email(correo)
{
	if(!validar_correo_e(correo))
	{
		alert("Debe ingresar un correo electrónico válido");
		return false;
	}
	return true;
}


function validar_imagen(grafico)
{
	if(grafico=='')
	{
		alert("Debe seleccionar una imagen");
		return false;
	}
	return true;
}

function validar_producto()
{
	if(document.getElementById('nombre').value=="")	
	{
		alert("Debe ingresar el nombre");	
		return false;
	}
	return true;
}


