function inicio(user,obse)
{
//var user = user.toUpperCase();
if (user=="")
{
document.getElementById("respuesta").innerHTML="<br /><p class='validacion'>Escriba una clave de registro de 3 caracteres<p>";
document.getElementById("user").focus();
return;
} 
	window.location='getLogin.php?user='+user+'&obs='+obse;
}

function ArticuloC(valor, valor2){
	var val = document.getElementById(valor).value;
        var val2 = document.getElementById(valor2).value;
	window.location='articulos.php?articulo='+val+'&Mod='+val2;
 }

function Descuentos(valor, valor2){
	var val = document.getElementById(valor).value;
	var val2 = document.getElementById(valor2).value;
	//window.location='descuentos.php?IdArt='+val+'&Idprod='+val2;
        
        $.ajax({
	type:"GET",
	url: "descuentos.php",
	data: 'IdArt='+val+'&Idprod='+val2,
	dataType: "html",
                        beforeSend: function(){
                                    $("#formulario_edicion").html('<div class="overlay"><i class="fa fa-refresh fa-spin"></i></div>');
                        },
			error: function(){
                                    alert("error consulta ajax usuarios");
                        },	
			success: function(data){                                                    
                                    $("#formulario_edicion").empty();
                                    $("#formulario_edicion").append(data);
			}									 							
					
    });  
        
}

function AbrirPopUp(){
     $('#btnBuscar').click();
}
 
function index(){
	window.location='index.php';
} 

function exit(){
	window.location='logout.php';
} 
 
 
function nuevo(){
	window.location='articulos.php';
} 

function seleccionar(obj){ 
    if(obj.nodeName.toLowerCase()=='textarea' || (obj.nodeName.toLowerCase()=='input' && obj.type=='text')){ 
        obj.select(); 
        return; 
    } 
    if (window.getSelection) {  
        var sel = window.getSelection(); 
        var range = document.createRange(); 
        range.selectNodeContents(obj); 
        sel.removeAllRanges(); 
        sel.addRange(range); 
    }  
    else if (document.selection) {  
        document.selection.empty(); 
        var range = document.body.createTextRange(); 
        range.moveToElementText(obj); 
        range.select(); 
    } 
} 

function Guardar(){
	var art = document.getElementById('articuloIDp').value;
        var valModCaptura = document.getElementById('valModCaptura').value;
        var val3 = document.getElementById('conteo2').value;
	window.location='articulos.php?Gart='+art+'&Mod='+valModCaptura+'&cta='+val3;;
} 

function Modalidad(val2){
    var val = document.getElementById('arti').value;
    //var val2 = document.getElementById('valModCaptura').value;
    var val3 = document.getElementById('conteo2').value;
    window.location='articulos.php?articulo='+val+'&Mod='+val2+'&cta='+val3;
}

function checkKey(key)
{
        
    var unicode
    if (key.charCode)
    {unicode=key.charCode;}
    else
    {unicode=key.keyCode;}
    
    
    if (unicode == 13){
       	var val = document.getElementById('arti').value;
		window.location='articulos.php?articulo='+val;
    }
    if (unicode == 27){
        alert('Presiono escape');
    }
}

function Suma(sumar){
var valor1 = document.getElementById(sumar).value;	
var valor2 = 1;
var resultado= (parseInt(valor1)+parseInt(valor2));

document.getElementById(sumar).value = resultado;
}

function Resta(sumar){
var valor1 = document.getElementById(sumar).value;	
if (valor1 > 0){
var valor2 = 1;
var resultado= (parseInt(valor1)-parseInt(valor2));
}else {
	resultado = 0;
	}
document.getElementById(sumar).value = resultado;
}

function number(e)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();

// control keys
if ((key===null) || (key===0) || (key===8) || 
    (key===9) || (key===13) || (key===27) )
   return true;

// alphas and numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;
else
   return false;
}