

var ie5=document.all && !window.opera
var ns6=document.getElementById




function existe_banners()
 {
  var oDiv = document.getElementById("div_banner");
  if (oDiv) { return 1; } else { return 0; }
 }

function abrir_ventana(URL,titulo,h,w)
 {
  window.open(URL,'','menubar=0,resizable=0,scrollbars=yes,width='+w+',height='+h);
 }

function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new checkBrowser()
var speed=50
var loop, timer


function entrada_teclado(campo,tecla,solo_numero)
 {
  var ok = false;
  if(tecla=='DELETE')
    {campo.value = campo.value.substr(0,campo.value.length-1);}
   else
    {
     if(solo_numero)
       {
       	switch(tecla)
       	 {
          case '1': ok = true;
       	  case '2': ok = true;
       	  case '3': ok = true;
       	  case '4': ok = true;
       	  case '5': ok = true;
       	  case '6': ok = true;
       	  case '7': ok = true;
       	  case '8': ok = true;
       	  case '9': ok = true;
       	  case '0': ok = true;
       	 }
       }
      else
       { ok = true; }
     if(ok) { campo.value = campo.value + tecla; }
    }
 }


function makeObj(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
	this.up=goUp;this.down=goDown;
	this.moveIt=moveIt; this.x; this.y;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}

function makeObj2(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
	this.up=goUp2;this.down=goDown2;
	this.moveIt=moveIt; this.x; this.y;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}

function makeObj3(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
	this.up=goUp3;this.down=goDown3;
	this.moveIt=moveIt; this.x; this.y;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}



function moveIt(x,y){
	this.x=x;this.y=y
	this.css.left=this.x
	this.css.top=this.y
}

//Makes the object go up
function goDown(move){
	if(this.y>-this.scrollHeight+oCont.clipHeight){
		this.moveIt(0,this.y-move)
			if(loop) setTimeout(this.obj+".down("+move+")",speed)
	}
}
//Makes the object go down
function goUp(move){
	if(this.y<0){
		this.moveIt(0,this.y-move)
		if(loop) setTimeout(this.obj+".up("+move+")",speed)
	}
}

function goDown2(move){
	if(this.y>-this.scrollHeight+oCont2.clipHeight){
		this.moveIt(0,this.y-move)
			if(loop) setTimeout(this.obj+".down("+move+")",speed)
	}
}

//Makes the object go down
function goUp2(move){
	if(this.y<0){
		this.moveIt(0,this.y-move)
		if(loop) setTimeout(this.obj+".up("+move+")",speed)
	}
}

//Makes the object go down
function goDown3(move){
	if(this.y>-this.scrollHeight+oCont3.clipHeight){
		this.moveIt(0,this.y-move)
			if(loop) setTimeout(this.obj+".down("+move+")",speed)
	}
}


function goUp3(move){
	if(this.y<0){
		this.moveIt(0,this.y-move)
		if(loop) setTimeout(this.obj+".up("+move+")",speed)
	}
}




//Calls the scrolling functions. Also checks whether the page is loaded or not.
function scroll(speed){
	if(loaded){
		loop=true;
		if(speed>0) oScroll.down(speed)
		else oScroll.up(speed)
	}
}

function scrollb(speed){
	if(loaded2){
		loop=true;
		if(speed>0) oScroll2.down(speed)
		else oScroll2.up(speed)
	}
}

function scrollc(speed){
	if(loaded3){
		loop=true;
		if(speed>0) oScroll3.down(speed)
		else oScroll3.up(speed)
	}
}
function scrolld(speed){
	if(loaded4){
		loop=true;
		if(speed>0) oScroll4.down(speed)
		else oScroll4.up(speed)
	}
}


//Stops the scrolling (called on mouseout)
function noScroll(){
	loop=false
	if(timer) clearTimeout(timer)
}
//Makes the object
var loaded;
var loaded2;
var loaded3;
var loaded4;

function comprueba_scroll(obj,nest)
 {
  var x;
  nest=(!nest) ? '':'document.'+nest+'.'
  x = bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  if(x==null)
   {return 0;}
  else
   {return 1;}
 }

function scrollInita(a,b)
 {
  if(comprueba_scroll(a,b))
   {
    oCont=new makeObj(b)
    oScroll=new makeObj(a,b)
    oScroll.moveIt(0,0)
    oCont.css.visibility='visible'
    loaded=true;
   }
}

function scrollInitb(a,b)
 {
  if(comprueba_scroll(a,b))
   {
	oCont2=new makeObj2(b)
	oScroll2=new makeObj2(a,b)
	oScroll2.moveIt(0,0)
	oCont2.css.visibility='visible'
	loaded2=true;
   }
 }

function scrollInitc(a,b)
 {
  if(comprueba_scroll(a,b))
   {
	
	oCont3=new makeObj3(b)
	oScroll3=new makeObj3(a,b)
	oScroll3.moveIt(0,0)
	oCont3.css.visibility='visible'
	loaded3=true;
   }
 }
<!-- this is scroll of INDUSTRY BILLBOARD  -->
function scrollInitd(a,b)
 {
  if(comprueba_scroll(a,b))
   {
	oCont4=new makeObj4(b)
	oScroll4=new makeObj4(a,b)
	oScroll4.moveIt(0,0)
	oCont4.css.visibility='visible'
	loaded4=true;
   }
 }
 function makeObj4(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
	this.up=goUp4;this.down=goDown4;
	this.moveIt=moveIt; this.x; this.y;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}
function goDown4(move){
	if(this.y>-this.scrollHeight+oCont4.clipHeight){
		this.moveIt(0,this.y-move)
			if(loop) setTimeout(this.obj+".down("+move+")",speed)
	}
}


function goUp4(move){
	if(this.y<0){
		this.moveIt(0,this.y-move)
		if(loop) setTimeout(this.obj+".up("+move+")",speed)
	}
}
 
 
<!-- //this is scroll of INDUSTRY BILLBOARD  -->
function scrollInit_ambos(a,b,c,d)
 {
  scrollInita(a,b);
  scrollInitb(c,d);
  if (existe_banners()) {banners();}
 }

<!--  This  is the common portion    -->
function scrollInit_triple(a,b,c,d,e,f,g,h)
 {
  scrollInita(a,b);
  scrollInitb(c,d);
  scrollInitc(e,f);
  scrollInitd(g,h); /* This is for industry billboard  */
  if (existe_banners()) {banners();}
 }

<!--  //This  is the common portion    -->

function getbrowserwidth()
 {
  if (navigator.userAgent.indexOf("MSIE") > 0)
    { return(document.body.clientWidth);}
   else
    { return window.outerWidth;}
 }

function getbrowserheight()
 {
  if (navigator.userAgent.indexOf("MSIE") > 0)
    { return(document.body.clientHeight); }
   else
    { return(window.outerHeight); }
 }

function valida_fecha_inicial(dia,mes,ano,inicial)
 {
  var fecha;
  if(dia<10) {dia = "0" + dia;}
  if(mes<10) {mes = "0" + mes;}
  fecha = ano + "-" + mes + "-" + dia;
  if(fecha<inicial)
    {return;}
   else
    {return 1;}
 }


function acceptNumDec(evt,campo,decimales)
 {
  var punto =  campo.value.indexOf('.',0);
  var dec   = campo.value.length - punto;
  if(punto==-1) {dec = 0;}
  var key = nav4 ? evt.which : evt.keyCode;
  if(key!=46)
     return ((((key <= 13)||((key>=48)&&(key <= 57))))&&(dec<=decimales));
   else
    {return ((key == 46)&&(punto<=0));}
 }

function acceptNum(evt)
 {
  var key = nav4 ? evt.which : evt.keyCode;
  return (key <= 13 || (key >= 48 && key <= 57));
 }

function Trim( str ) {
	var resultStr = "";

	resultStr = TrimLeft(str);
	resultStr = TrimRight(resultStr);

	return resultStr;
}

function TrimRight( str ) {
	var resultStr = "";
	var i = 0;

	if (str+"" == "undefined" || str == null)
		return null;

	str += "";

	if (str.length == 0)
		resultStr = "";
	else {
  		i = str.length - 1;
  		while ((i >= 0) && (str.charAt(i) == " "))
 			i--;

  		resultStr = str.substring(0, i + 1);
  	}

  	return resultStr;
}

function TrimLeft( str ) {
	var resultStr = "";
	var i = len = 0;


	if (str+"" == "undefined" || str == null)
		return null;

	str += "";

	if (str.length == 0)
		resultStr = "";
	else {
		len = str.length;

  		while ((i <= len) && (str.charAt(i) == " "))
			i++;

  		resultStr = str.substring(i, len);
  	}

  	return resultStr;
}

function uppercase(campo)
 {
  campo.value = campo.value.toUpperCase();
  campo.value = Trim(campo.value);
 }

function lowercase(campo)
 {
  campo.value = campo.value.toLowerCase();
  campo.value = Trim(campo.value);
 }



if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}

function showmenu(e, which, optWidth){
if (!document.all&&!document.getElementById)
return
clearhidemenu()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
menuobj.innerHTML=which
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
menuobj.contentwidth=menuobj.offsetWidth
menuobj.contentheight=menuobj.offsetHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
menuobj.style.visibility="visible"
return false
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.menuobj)
menuobj.style.visibility="hidden"
}

function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}

if (ie5||ns6)
document.onclick=hidemenu

function completa_fecha(dia,mes,ano)
 {
  var fecha;
  if(dia<10) {dia = "0" + dia;}
  if(mes<10) {mes = "0" + mes;}
  fecha = ano + "-" + mes + "-" + dia;
  return fecha;
 }

function finMes(nMes, nAno) 
 {
  var nRes = 0;
  if (nMes == 2) 
   {
    nRes  = ((nAno % 400 == 0) || ((nAno % 4 == 0) && (nAno % 100 !=0))) ? 29 : 28;
   } 
 else
  {
   switch (nMes)
    {
     case 1: nRes = 31; break;
     case 3: nRes = 31; break;
     case 4: nRes = 30; break;
     case 5: nRes = 31; break;
     case 6: nRes = 30; break;
     case 7: nRes = 31; break;
     case 8: nRes = 31; break;
     case 9: nRes = 30; break;
     case 10: nRes = 31; break;
     case 11: nRes = 30; break;
     case 12: nRes = 31; break;  
    }
  }
 return nRes;
}


function valDia(nDia, nMes, nAno)
{
 var bOk = ((nDia >= 1) && (nDia <= finMes(nMes, nAno)));
 return bOk;
}

function valMes(nMes)
 {
  var bOk = ((nMes >= 1) && (nMes <= 12));
  return bOk;
 }

function valAno(nAno)
{
 var bOk = nAno > 1970;

 return bOk;
}

function valFecha(nDia, nMes, nAno)
{
 var bOk = true;
 bOk = bOk && (valAno(nAno));
 bOk = bOk && (valMes(nMes));
 bOk = bOk && (valDia(nDia, nMes, nAno));
 return bOk;
}

function validar_entero(valor)
{
 valor = parseInt(valor);
 if(isNaN(valor)){ valor = 0; }
 return valor;
}

function validar_float(valor)
{
 valor = parseFloat(valor);
 if(isNaN(valor)){ valor = 0; }
 return valor;
}

