// JavaScript Document
//------------------ Eliminar----------------------

function ver(page,dato){
	if(confirm("Esta seguro de eliminar el Distrito: "+dato)) {	
		location.href=page;
		//alert("ok");
	}
}

function ingresar(page,dato){
	$.ajax({
            async:true,
            type: "POST",
            dataType: "html",
            contentType: "application/x-www-form-urlencoded",
            url:page,
            data:"cod_cliente="+dato,
            beforeSend:inicioEnvio,
            success:llegadaDatos,
            timeout:4000,
            error:problemas
          });

}
//----------- Ingresar Cliente--------------------
function ingresar_cliente(page){
	var nom_cliente = $("#nom_cliente").val();
        var web_cliente = $("#web_cliente").val();
        var tecnologias = $("#tecnologias").val();
        var precio = $("#precio").val();
        var fech_entre = $("#fech_entre").val();
        var desc_cliente = $("#desc_cliente").val();
        var datos = $("#f1").serialize();

	if(nom_cliente==""){
		alert("Nombre Cliente");
		$("#nom_cliente").focus();
                return false;
	}
        if(web_cliente==""){
            alert("Ingresar URL del cliente");
            $("#web_cliente").focus();
            return false;
        }
        if(tecnologias==""){
            alert("IngGresar una descripcion de las Tecnnologias Usadas");
            $("#tecnologias").focus();
            return false;
        }
        if(precio==""){
            alert("Ingresar el Precio");
            $("#precio").focus();
            return false;
        }
        if(fech_entre==""){
            alert("Ingresar Fecha de de Entrega");
            $("#fech_entre").focus();
            return false;
        }
        if(desc_cliente==""){
            alert("Ingresar Descripcion del Cliente");
            $("#desc_cliente").focus();
            return false;
        }
	/*if(!terminos){
		alert("Aceptar los Terminos y condiciones");	
		$("#terminos").focus();
		return false;
	}*/
        /*$.ajax({
            async:true,
            type: "POST",
            dataType: "html",
            contentType: "application/x-www-form-urlencoded",
            url:page,
            data:"datos="+datos,
            beforeSend:inicioEnvio,
            success:llegadaDatos,
            timeout:4000,
            error:problemas
          });*/
	//window.top.opener.location.reload();
        //top.opener.window.parent.location.reload();
        //top.location= index.php;
       // top.window.location.reload();

        //window.top.document
        $("#f1").submit();
}
function elimina(page,dato){
	if(confirm("Esta seguro de Eliminar : "+dato)) {	
		location.href=page;
		//alert("ok");
	}
}
//---------- Funcion Abrir Ventana();
function ventana(){
	window.open('admin/validar.php','ventana', 'scrollbars=auto,width=580,height=400,top=180,left=230'); 
	
}
//---------- Funciones Ajax
function inicioEnvio(){
	var x=$("#data");
    x.html('Cargando...');
}
function llegadaDatos(datos){
    $("#data").html(datos);
}
function problemas(){
   $("#data").html('Problemas en el servidor.');
}
