var message="Función no permitida.\n nutrimente.com ©2008.";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

function showHide(box,id)
{
if(document.getElementById(box).checked)
  { document.getElementById(id).style.display = ""; }
else
  { document.getElementById(id).style.display = "none"; }
} 

function show(id)
{
   document.getElementById(id).style.display = "block";
}

function hide(id)
{
   document.getElementById(id).style.display = "none"; 
} 

function selecciona_boxes(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function confirmarBaja(item)
{
var name=confirm('¿ Desea confirmar la baja de la '+item+' ?')
}

function passlista(ventana, REQ) 
{
var newwindow = ''
if (!newwindow.closed && newwindow.location)
	{
		newwindow.location.href = ventana;
	}
	else
	{
		newwindow=window.open(ventana,'popup'+ventana,'left=300, top=100, width=500, height=280, toolbar=0,resizable=0, menubar=0, status=0, location=0, alwaysRaised');
		if (!newwindow.opener) newwindow.opener = self;                
	}
	if (window.focus) {newwindow.focus()}
	return false;
}

function datostoformasubmit(forma,campo,valor) {

for (var i=0; i<document.forma.codigo_add.length; i++)
{if (document.forma.codigo_add[i].checked)
{resultado = document.forma.codigo_add[i].value}};
window.opener.document[forma][campo].value=resultado;
window.opener.document[forma].submit();
window.close();
return true;
}

function dtof(forma,campo,valor) 
{ 
resultado=valor;
window.opener.document[forma][campo].value=resultado;
window.opener.document[forma].submit();
window.close();
return true;
}

function confirma_baja (item,mensaje,forma)
{
var name=confirm(mensaje)
if (name==true)
  {
  document[forma].elimina_item.value =  item;
  document[forma].submit() ;
  }
}

function passdata(ventana,campo_popup,valor_campoforma,nombre_forma,campo_forma,campo_eval,cantidad,unidad) {
var newwindow = '';
if (!newwindow.closed && newwindow.location)
	{
		newwindow.location.href = ventana;
	}
	else
	{
		newwindow=window.open(ventana + '?' + campo_popup + '=' + valor_campoforma + '&nombre_forma=' + nombre_forma + '&campo_forma=' + campo_forma + '&campo_eval=' + campo_eval + '&cantidad=' + cantidad + '&unidad=' + unidad,'popup','left=300, top=100, width=500, height=280, toolbar=0 ,scrollbars=1 ,resizable=0, menubar=0, status=0, location=1, alwaysRaised');
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
	return false;
}

function passdata2(ventana,campo_popup,valor_campoforma,nombre_forma,campo_forma,campo_eval,cantidad,unidad,campo_extra,clasificacion,ubicacion) {
var newwindow = '';
if (!newwindow.closed && newwindow.location)
	{
		newwindow.location.href = ventana;
	}
	else
	{
		newwindow=window.open(ventana + '?' + campo_popup + '=' + valor_campoforma + '&nombre_forma=' + nombre_forma + '&campo_forma=' + campo_forma + '&campo_eval=' + campo_eval + '&cantidad=' + cantidad + '&unidad=' + unidad+ '&campo_extra=' + campo_extra + '&clasificacion=' + clasificacion + '&ubicacion=' + ubicacion,'popup','left=300, top=100, width=780, height=320, toolbar=0, resizable=0, menubar=0, status=0, location=0, alwaysRaised');
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
	return false;
}

function passdataradio(ventana,campo_popup,valor_campoforma,nombre_forma,campo_forma,campo_eval,cantidad,unidad) 
{
var newwindow = '';
for (var i=0; i<document.tab_forma.articulo_xx.length; i++)
    {if (document.tab_forma.articulo_xx[i].checked)
        {resultado = document.tab_forma.articulo_xx[i].value};
    };
if (!newwindow.closed && newwindow.location)
	{
		newwindow.location.href = ventana;
	}
	else
	{
		newwindow=window.open(ventana + '?' + campo_popup + '=' + resultado + '&nombre_forma=' + nombre_forma + '&campo_forma=' + campo_forma,'popup','left=300, top=100, width=780, height=480, toolbar=0,resizable=0, menubar=0, status=0, location=no, alwaysRaised');
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
	return false;
}

function datostoforma(forma,campo,valor,campo2,valor2) {
window.opener.document[forma][campo].value=valor;
if (campo2) {
   window.opener.document[forma][campo2].value=valor2;
} 
window.close();
return false;
}

function datostotabla(forma,campo,valor) {
window.opener.document[forma].submit();
window.close();
return true;
}

function validCantidad(x) {
  var y=document.getElementById(x).value;
    if (y.length < 1) {
       alert('El campo no puede quedar vacio.');
       document.getElementById(x).value=0; }
    if (isNaN(y)) {
       alert("Por favor ingrese un número.");
       document.getElementById(x).value=0; }
    if (y < 0) {
       alert("Por favor ingrese un número mayor a 0.");
       document.getElementById(x).value=0; }
    for (var i = 0; i < y.length; i++) {
          var ch = y.substring(i, i + 1);
          if (ch == ' ') {
              alert("No se pueden ingresar espacios en blanco"); 
              document.getElementById(x).value=0; }
      }
}

/*
Para evitar el que se ingrese la forma mas de una vez
*/


var form_submitted = false;

function submit_form ( )
{
  if ( form_submitted )
  {
    alert ( "La forma ya esta siendo procesada. Por favor espere..." );
    return false;
  }
  else
  {
    form_submitted = true;
    return true;
  }
}
