// JavaScript Document
function enviar()
	{
	  var id=$("#selectdpto").attr("value");
	  $.ajax({
			   async:true,
			   type: "POST",
			   dataType: "html",
			   contentType: "application/x-www-form-urlencoded",
			   url:"/registro/obtenerprov/",
			   data:'id='+id,
			   beforeSend:inicio,
			   success:llegada,
			   timeout:4000,
			   error:problemas
			 }); 
	  return false;
	}
function inicio()
	{
	  var x=$("#divprovincia");
	  x.html('<img src="/images/cargando.gif">');
	}
function llegada(datos)
	{
	 $("#divprovincia").html(datos);
	}
function problemas()
	{
	  $("#diviniciosecion").text('Problemas en el servidor.');
	}
function enviardist()
	{
	  var id=$("#selectprov").attr("value");
	  $.ajax({
			   async:true,
			   type: "POST",
			   dataType: "html",
			   contentType: "application/x-www-form-urlencoded",
			   url:"/registro/obtenerdist/",
			   data:'id='+id,
			   beforeSend:iniciod,
			   success:llegadad,
			   timeout:4000,
			   error:problemasd
			 }); 
	  return false;
	}
function iniciod()
	{
	  var x=$("#divdistrito");
	  x.html('<img src="/images/cargando.gif">');
	}
function llegadad(datos)
	{
	 $("#divdistrito").html(datos);
	}
function problemasd()
	{
	  $("#divdistrito").text('Problemas en el servidor.');
	}
function enviarcorreo(correo)
	{
	correo=correo.toLowerCase();
	if(valEmail(correo)==1)
		{
			// alert("La dirección de email es incorrecta.");
			//document.getElementById("texmail").focus();
		}
		else
		{
		  if(correo.length>0)
			{
			$.ajax({
					   async:true,
					   type: "POST",
					   dataType: "html",
					   contentType: "application/x-www-form-urlencoded",
					   url:"/registro/validarcorreo/",
					   data:'id='+correo,
					   beforeSend:iniciocorreo,
					   success:llegadacorreo,
					   timeout:4000,
					   error:problemascorreo
					 }); 
			  return false;
			}
		}
	}
function iniciocorreo()
	{
	  var x=$("#divmail");
	  x.html('<img src="/images/cargando.gif">');
	}
function llegadacorreo(datos)
	{
	 $("#divmail").html(datos);
	}
function problemascorreo()
	{
	  $("#divmail").text('Problemas en el servidor.');
	  document.getElementById("hiddencorreo").value
	}
function menusalto(targ,selObj,restore)
	{ //v3.0
  	eval(targ+".location='/admin/createlist/ide/"+selObj.options[selObj.selectedIndex].value+"/t/2'");
  	if (restore) selObj.selectedIndex=0;
	}
function menusaltogtar(targ,selObj,restore,state)
	{ //v3.0
	//alert(state)
  	eval(targ+".location='/cart/registrocompra/id/"+selObj.options[selObj.selectedIndex].value+"/"+state+"'");
  	if (restore) selObj.selectedIndex=0;
	}
function menusaltom(targ,selObj,restore)
	{ //v3.0
  	eval(targ+".location='/admin/createlist/id/"+selObj.options[selObj.selectedIndex].value+"/t/1/p/"+document.getElementById("name").value+"'");
  	if (restore) selObj.selectedIndex=0;
	}
function menuextens()
	{ 
 	location.href='/cart/default/s/1/iddist/'+ document.getElementById("iddistrito").value;
	}
function validacheck()
	{	  
	  if(!document.getElementById("chech1"))
	  {
		  return false;
	  }
	  
	  var checkboxes = document.getElementById("formcreate");
	  //alert(checkboxes)
	  var cont = 0;
	  for (x=0; x < checkboxes.length; x++) 
	  {
		 if (checkboxes[x].checked) 
		  {  
		  	cont = cont + 1;
		  }
		}
	  
	  if(cont<1)
	  {
		  alert("Seleccionar por lo menos un Producto");
		  return false;
	  }
	  return true;
	}
function eliminar(id,pag)
	{
		 confirmacion=confirm("Realmente desea eliminar el Registro");
		 if(confirmacion)
		 {
			location.href="/admin/verlist/id/"+id;
		 }
		/*var v=$("#contenido").attr("value");
		var tem=$("#texttema").attr("value");
		$.post("post/visualizar.php",{post:v,tema:tem},llegadaDatos); */
	}
function abrir(direccion, pantallacompleta, herramientas, direcciones, estado, barramenu, barrascroll, cambiatamano, ancho, alto, izquierda, arriba, sustituir)
	{
     var opciones = "fullscreen=" + pantallacompleta +
                 ",toolbar=" + herramientas +
                 ",location=" + direcciones +
                 ",status=" + estado +
                 ",menubar=" + barramenu +
                 ",scrollbars=" + barrascroll +
                 ",resizable=" + cambiatamano +
                 ",width=" + ancho +
                 ",height=" + alto +
                 ",left=" + izquierda +
                 ",top=" + arriba;
     var ventana = window.open(direccion,"venta",opciones,sustituir);

	}       
function enviarvpos()
{ 
  var divOverlay = document.getElementById("overlayvpos"); 
  var divImgLoad = document.getElementById("imgloadvpos"); 
  var divModal = document.getElementById("modalvpos"); 
   
  divOverlay.style.visibility="visible"; 
  divImgLoad.style.visibility="visible"; 
  divModal.style.visibility="visible"; 
 
  document.frm_registro.target="iframevpos"; 
  document.frm_registro.submit(); 
  return false;
}


