﻿// JScript File
var _originalColor; //Holds the original color before the MouseOver affect

function GridMouseOver(source)
//Create the MouseOver affect
{
    _originalColor = source.style.backgroundColor;
    source.style.backgroundColor = '#824E00';
}

function GridMouseOut(source)
//Create the MouseOut affect
{
    source.style.backgroundColor = _originalColor;
}

function positionInfo(object) {

	var p_elm = object;

	this.getElementLeft = getElementLeft;
	function getElementLeft() {
		var x = 0;
		var elm;
		if(typeof(p_elm) == "object"){
		elm = p_elm;
		} else {
		elm = document.getElementById(p_elm);
		}
		while (elm != null) {
		x+= elm.offsetLeft;
		elm = elm.offsetParent;
		}
		return parseInt(x);
	}

	this.getElementWidth = getElementWidth;
	function getElementWidth(){
		var elm;
		if(typeof(p_elm) == "object"){
		elm = p_elm;
		} else {
		elm = document.getElementById(p_elm);
		}
		return parseInt(elm.offsetWidth);
	}

	this.getElementRight = getElementRight;
	function getElementRight(){
		return getElementLeft(p_elm) + getElementWidth(p_elm);
	}

	this.getElementTop = getElementTop;
	function getElementTop() {
		var y = 0;
		var elm;
		if(typeof(p_elm) == "object"){
		elm = p_elm;
		} else {
		elm = document.getElementById(p_elm);
		}
		while (elm != null) {
		y+= elm.offsetTop;
		elm = elm.offsetParent;
		}
		return parseInt(y);
	}

	this.getElementHeight = getElementHeight;
	function getElementHeight(){
		var elm;
		if(typeof(p_elm) == "object"){
		elm = p_elm;
		} else {
		elm = document.getElementById(p_elm);
		}
		return parseInt(elm.offsetHeight);
	}

	this.getElementBottom = getElementBottom;
	function getElementBottom(){
		return getElementTop(p_elm) + getElementHeight(p_elm);
	}
}

function setElementProperty(p_property, p_value, p_elmId){
	var p_elm = p_elmId;
	var elm = null;

	if(typeof(p_elm) == "object"){
	elm = p_elm;
	} else {
	elm = document.getElementById(p_elm);
	}
	if((elm != null) && (elm.style != null)){
	elm = elm.style;
	elm[ p_property ] = p_value;
	}
}

function ShowDiv( controlDivName, controlTxtName, positionX, positionY )
{	
        document.getElementById( controlDivName ).style.display = ''; 								

        var fieldPos = new positionInfo( controlTxtName );

        var x = fieldPos.getElementLeft() - positionX;
        var y = fieldPos.getElementBottom() + positionY;
        				
        setElementProperty( 'left', x + " px", controlDivName );
        setElementProperty( 'top', y + " px", controlDivName );												
}

function HideDiv( controlDivName, controlSearchTxtName )
{			
        document.getElementById( controlDivName ).style.display = 'none';
}

function numberFormat(campo, valor, e){
	var key = '';
	var strCheck = '0123456789.';
	var whichCode = e.keyCode;
	
	if(whichCode == 0){
        whichCode = e.which;
    }
	
	if (whichCode == 8 || whichCode == 9){
		return true;  // Enter
	}
	key = String.fromCharCode(whichCode);  // Get key value from key code
	
	if (strCheck.indexOf(key) == -1){
		return false;
	}
}

function numberFormat2(campo, valor, e){
	var key = '';
	var strCheck = '0123456789';
	var whichCode = e.keyCode;
	
	if(whichCode == 0){
        whichCode = e.which;
    }
	if (whichCode == 8 || whichCode == 9){
		return true;  // Enter
	}
	key = String.fromCharCode(whichCode);  // Get key value from key code
	
	if (strCheck.indexOf(key) == -1){
		return false;
	}
}

var pos = 0
var texto = "PEF: Pending Farm, FSH: Farm Shipped, REC: Received, NOE: Not Expected, INW: In Warehouse, APP: Appeared, MIS: Missed Shipment, PES: Pending Shipment, INC: Incorrect, INS: Invalid Shipment"
    
function mueve_texto(){
   //incremento la posicion en 1 y extraigo el texto a mostrar en este momento.
   pos = pos + 1
   textoActual = texto.substring(0,pos)
   //pongo el texto que quiero mostrar en la barra de estado del navegador
   window.status = textoActual
   //Llamamos otra vez a esta funcion para que continue    mostrando texto
   if (pos == texto.length){
      //si hemos llegado al final, vuelvo al principio y hago un retardo superior
      pos = 0
      setTimeout("mueve_texto()",1500)
   } else{
      //si no hemos llegado al final, sigo con la funcion con un retardo minimo.
      setTimeout("mueve_texto()",70)
   }
   
}
