//----------------------------------------------------------------
function trimJS(cadena) { if(cadena) { cadena.value = cadena.value.replace(/^\s*|\s*$/g,""); } else { return cadena.replace(/^\s*|\s*$/g,""); } }
//----------------------------------------------------------------
function getElem(id) { if (window.parent.document.getElementById) { return document.getElementById(id); } else if (window.parent.document.all) { return document.all(id); } else if (window.parent.document.layers) { return document.layers(id); } }
//----------------------------------------------------------------
function SH(act,id) { var obj = getElem(id); if(obj) { if(act == "") { if(obj.style.visibility == "hidden" || obj.style.visibility == "") { obj.style.visibility = "visible"; if(obj.tagName != "TR") { obj.style.display = "block"; } else { obj.style.display = ""; } } else { obj.style.visibility = "hidden"; obj.style.display = "none"; } } else if(act.toUpperCase() == "S") { obj.style.visibility = "visible"; if(obj.tagName != "TR") { obj.style.display = "block"; } else { obj.style.display = ""; } } else if(act.toUpperCase() == "H") { obj.style.visibility = "hidden"; obj.style.display = "none"; } } }
//----------------------------------------------------------------
function checkAno(year) { return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) ? 1 : 0; }
function checkFecha(dia,mes,ano) { if(!checkAno(ano.value*1)) { var dias = 28; } else { var dias = 29; } if (((mes.value*1 == 4 || mes.value*1 == 6 || mes.value*1 == 9 || mes.value*1 == 11) && dia.value*1 > 30) || (mes.value*1 == 2 && dia.value*1 > dias)) { dia.focus(); alert("La fecha ingresada es incorrecta"); return false; } else { return true; } }
//----------------------------------------------------------------
function Left(str, n) { if(n <= 0) { return ""; } else if(n > String(str).length) { return str; } else { return String(str).substring(0,n); } }
function Right(str, n) { if(n <= 0) { return ""; } else if(n > String(str).length) { return str; } else { var iLen = String(str).length; return String(str).substring(iLen, iLen - n); } }
//----------------------------------------------------------------
function SClass(obj,CName) { if(!obj) { obj = getElem(obj); } obj.className = CName; }
//----------------------------------------------------------------
function OW(page,winName,width,height,options) { var posTop = screen.availHeight / 2 - (height / 2) - 30; var posLeft = screen.availWidth / 2 - (width / 2); var ventana = window.open(page,winName,"width=" + width + ", height=" + height + ", status=no, top=" + posTop + ", left=" + posLeft + ", " + options + ";"); ventana.focus(); }
//----------------------------------------------------------------

//----------------------------------------------------------------


//----------------------------------------------------------------
function menu(id,def) {
	var subMenu = getElem("menu2").getElementsByTagName("DIV");
	for(i=0; i<subMenu.length; i++) {
		if(Right(subMenu[i].id,2) == Right("0" + id,2)) {
			SH("S",subMenu[i].id);
		} else {
			SH("H",subMenu[i].id);
		}
	}
	if(getElem("M" + Right("0" + def,2))) { SClass(getElem("M" + Right("0" + def,2)),"act"); }
}
//----------------------------------------------------------------
function BandChange(obj) {
	var bands = getElem("bands").getElementsByTagName("DIV");
	for(i=0; i<bands.length; i++) { SClass(bands[i],''); }
	SClass(obj,'act');
}
//----------------------------------------------------------------
function changeNewsYear(obj) {
	var years = getElem("newsYears").getElementsByTagName("DIV");
	for(i=0; i<years.length; i++) { SClass(years[i],''); }
	SClass(obj,'act');
	var news = getElem("newsContents").getElementsByTagName("TABLE");
	for(i=0; i<news.length; i++) { if(Right(news[i].id,4)*1 == obj.id*1) { SH("S",news[i].id); } else { SH("H",news[i].id); } }
}
//----------------------------------------------------------------

//----------------------------------------------------------------












var d, dom, ns4, ie, ie4, ie5x, moz, mac, win, lin, old, ie5mac, ie5xwin, op;

d = document;
n = navigator;
na = n.appVersion;
nua = n.userAgent;
win = (na.indexOf('Win') != -1);
mac = (na.indexOf('Mac') != -1);
ns4 = d.layers
var calunits=document.layers? "" : "px"

if (!d.layers){
dom = (d.getElementById);
op = (nua.indexOf('Opera') != -1);
konq = (nua.indexOf('Konqueror') != -1);
saf = (nua.indexOf('Safari') != -1);
moz = (nua.indexOf('Gecko') != -1);
ie = (d.all && !op);
ie4 = (ie && !dom);
ie5x = (d.all && dom);
ie5mac = (mac && ie5x);
ie5xwin = (win && ie5x);
}

var vis="hide"; var vispais="hide";
//----------------------------------------------------------------
function validar(field) {
var valid = "abcdefghijklmnñopqrstuvwxyz ABCDEFGHIJKLMNÑOPQRSTUVWXYZ 0123456789 ().*&^%$#@!+-_][}{ áéíóúü"; var ok = "si"; var temp;
for (var i=0; i<field.value.length; i++) {temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";}
if (ok == "no") {alert("El nombre de usuario que ingresó\ncontiene caracteres inválidos!");
field.focus();
field.select();}}
//----------------------------------------------------------------
function showHideLayers() { //v6.0
var i,p,v,d,obj,args=showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { v=(v=='show')?'visible':(v=='hide')?'hidden':v; if(v=='visible'){d="block"}else{d="none"};}
obj.style.visibility=v;  obj.style.display=d;}
}
function findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function hide(id){
if (ns4) document.layers[id].visibility = "hide"
else if (ie4) document.all[id].style.display = "none"
}

function showL(id){
showHideLayers('empresa','','hide');
showHideLayers('productos','','hide');
showHideLayers('servicios','','hide');
showHideLayers('marketplace','','hide');
if (id!='')showHideLayers(id,'','show');
}

//----------------------------------------------------------------
function validaEmail(emails,al){
emails.value = emails.value.toLowerCase();
email=new String(emails.value.toLowerCase())
if(email== "" || email.indexOf("@", 0) == -1 || email.indexOf(".", 0) == -1 || email.length <= 9){
	alert(al);
	emails.focus();
	return false;
} else {
	ok=1
	var validos="abcdefghijklmnopqrstuvwxyz0123456789-_@.";
	for (i=0;i<email.length;i++){
		if (validos.indexOf(email.charAt(i)) == "-1") ok = 0;	
	}
	if (ok==0) {
		alert(al);
		emails.focus();
		return false;
	}
}
return true;
}

//----------------------------------------------------------------
function validaTelefonos(valor,texto,minimo){
numero=new String(valor.value)
ok=1
var validos="0123456789()-/ ";
for (i=0;i<numero.length;i++){
	if (validos.indexOf(numero.charAt(i)) == "-1") ok = 0;	
}
if (ok==0) {
	if (texto!="") alert(texto)
	valor.focus(); return false
}
if (numero.length<6){
	alert(minimo);
	valor.focus(); return false
}
return true
}
//----------------------------------------------------------------
function validaNumeros(valor,texto,minimo, minimotexto){
numero=new String(valor.value)
ok=1
var validos="0123456789";
for (i=0;i<numero.length;i++){
	if (validos.indexOf(numero.charAt(i)) == "-1") ok = 0;	
}
if (ok==0) {
	alert(texto);
	valor.focus(); return false
}
if (numero.length<minimo){
	alert(minimotexto);
	valor.focus(); return false
}
return true
}
//----------------------------------------------------------------
function estaVacio(s,texto){
var len=s.value.length
var i
for (i=0;i<len;++i){
	if (s.value.charAt(i)!=" ") {return false;}
}
alert(texto);s.focus();
return true
}

//----------------------------------------------------------------
function validaFecha(fechad){
fecha=fechad.value;
dia=new Number(fecha.substr(0,2))
mes=new Number(fecha.substr(3,2))
ano=new Number(fecha.substr(6,4))
var hoy = new Date();
if (dia<1 || dia>31 || isNaN(dia)){dia=hoy.getDate();}
if (mes<1 || mes>12 || isNaN(mes)){mes=hoy.getMonth()+1}
if (ano<hoy.getFullYear()-99 || isNaN(ano)){ano=hoy.getFullYear()}
if (parseInt(mes)==2 && parseInt(dia)>28) dia="28";
if ((parseInt(mes)==4 || parseInt(mes)==6 || parseInt(mes)==9 || parseInt(mes)==11) && parseInt(dia)==31) dia="30";
diad=new String(dia)
mesd=new String(mes)
if (diad.length!=2) dia="0"+dia
if (mesd.length!=2) mes="0"+mes
fechad.value=dia+"/"+mes+"/"+ano
if (ano>hoy.getFullYear()-13) {return false}
return true
return
}
//-----------------------------
function initbox(){
if (!dom&&!ie&&!ns4)
return
crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
crossobj.top=scroll_top-250+calunits
crossobj.visibility=(dom||ie)? "visible" : "show"
dropstart=setInterval("dropin()",50)
}

function dropin(){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
if (parseInt(crossobj.top)<100+scroll_top)
crossobj.top=parseInt(crossobj.top)+40+calunits
else{
clearInterval(dropstart)
bouncestart=setInterval("bouncein()",50)
}
}

function bouncein(){
crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
if (bouncelimit<0)
bouncelimit+=8
bouncelimit=bouncelimit*-1
if (bouncelimit==0){
clearInterval(bouncestart)
}
}

function dismissbox(){
if (window.bouncestart) clearInterval(bouncestart)
crossobj.visibility="hidden"
}

function redo(){
bouncelimit=32
direction="up"
initbox()
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


//abre ventanas 
function popPage(l, n, w, h, o) { posTop = screen.availHeight / 2 - (h / 2) - 30; posLeft = screen.availWidth / 2 - (w / 2); opts = "status=no, width=" + w + ", height=" + h + ",  top=" + posTop + ", left=" + posLeft + "," + o; window.open(l,n,opts); } 