function updatePosition(){
	var a1=parseInt($('html').width())
	var a2=parseInt($('#origen').width());
	if(a1>a2){
		var margen=Math.floor((a1-a2)/2)-1;
	}else{
		var margen=0;
	}	

	var b1=parseInt($(document).height())
	var b2=parseInt($('#origen').height());
	if(b1>b2){
		var margen2=Math.floor((b1-b2)/2)-1;
	}else{
		var margen2=0;
	}
	$('#centro').css("left",margen);
	$('#origen').css("left",margen);
	$('#centro').css("top",0);
	$('#origen').css("top",0);
}

function enterPress(evento){
	var iKeyCode;
	iKeyCode = (evento.which) ? evento.which : evento.keyCode;
	if(iKeyCode==13){
		return true;
	}else{
		return false;
	}
}
function numeroEnter(e){
	if(solo_numeros(e)){
		return !enterPress(e);
	}else{
		return false;	
	}
}	
function solo_numeros(evento){
	var iKeyCode;
	iKeyCode = (evento.which) ? evento.which : evento.keyCode;
	if (iKeyCode > 31 && (iKeyCode < 46 || iKeyCode > 57 ) && iKeyCode != 39 || iKeyCode == 47 || iKeyCode == 37 || iKeyCode == 44 || iKeyCode == 46){
	  return false;
	}
return true;
}
var validation=0;
function habilitaAdd(obj,evento){
	if(solo_numeros(evento)==true){
		var mivalor=$(obj).attr("value");

		var iKeyCode;
		iKeyCode = (evento.which) ? evento.which : evento.keyCode;

		var keyValor=String.fromCharCode(iKeyCode);
		
		if(iKeyCode!=8){
			if(parseInt(mivalor+keyValor)>0){
				validation=1;
				$('#addtocar').css("opacity","1");
				return true;

			}else{
				validation=0;
				$('#addtocar').css("opacity","0.5");				
			}
		}else{			
			var temp=mivalor.substr(0,-1);
			if(parseInt(temp)>0){
				validation=0;
				$('#addtocar').css("opacity","1");

			}else{				
				validation=0;
				$('#addtocar').css("opacity","0.5");
			}				
		}	
	}else{
		return false;
	}	
	
}
function OnFormularioAdd(){
	if(validation==0){
		alert('Ingrese cantidad');
		return false;
	}else{
		return true;
	}	
}
function getValueSelect(obj){
	var uno=$(obj).attr('selectedIndex');
	var dos=obj.options[uno];
	var tres=$(dos).attr('value');
return tres;
}

var id_update='';
function getData(url,param,temp){
	id_update=temp;
	$.get(url,param,
	function(data){
		$('#'+id_update).html(data);
	});
}
function getDataEval(url,param){
	$.get(url,param,
	function(data){
		eval(data);
	});
}

function bloquea(id,valor){

	if(valor=='-1'){
		$('#'+id).attr('disabled','true');
	}else{
		$('#'+id).attr('disabled','');
	}

}
