/*
	funciones de proposito general del sitio elgusanillo.com
	Por estudiogotti.com
	ultmod: 2006/04/17
	ultmod: 2005/02/12
*/

// mini api para recuperar referencia a un objeto dado.
// es un nuevo obj así que debe inicializarse con 'new'
function getObj(id){
	if (document.getElementById){
		this.nombre= document.getElementById(id);
		this.style= document.getElementById(id).style;
	}
	else if (document.all){
		this.nombre= document.all[id];
		this.style= document.all[id].style;
	}
	else if (document.layers){
		this.nombre= document.layers[id];
		this.style= document.layers[id];
	}
}

//evitar error de redimension de pagina en NC4x
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

//ABRIR POPUP
function wopen(url, nombre, ancho, alto) {
window.open(url, nombre, "width= "+ ancho +", height= "+ alto +", top=20, left=20, scrollbars = no, menubar= no, toolbar = no")
}

function windowOpen(url, wName, ancho, alto, arriba, izq, ventana, bReturn){
	if(ventana.length > 0){
		a= new Array(ventana.length-1);
		for(i=0; i< ventana.length; i++){
			a(i)= new Boolean(ventana.charAt(i));
		}

		for(i=0; i< a.length; i++){
			if(a(i)==true){	a(i)="yes";	}else{	a(i)="no";	}
		}
	}

	window.open(url, wName, "width=" + ancho + ",height=" + alto + ",top=" + top + ",left=" + left +
		",scrollbars=" + a(0) +",menubar=" + a(1) + ",toolbar=" + a(2)); 
	if(bReturn!=true) { bReturn=false;	}
	return bReturn;
}

//camuflar correo en un atributo href.
//en nombre TODO lo anterior a la @ (no escribirla)
//en dominio lo posterior a la @ HASTA el primer punto (no escribirlo)
//en traspunto TODO lo posterior al primer punto.

function jemail(nombre, dominio, traspunto){
	window.location.href= nombre + '@' + dominio + '.' + traspunto;
}

// numero -- Si es null, undefined, 0, "", o NaN se usa defNumber. Se trunca a integer.
function randomNumber(numero){
	var defNumber = 100;
	if(numero){ numero = parseInt(numero,10); }else{ numero = defNumber; }
	return Math.floor(Math.random() * numero);
}

// genera una cadena numerica con la estructura: milisegundos desde now a epoch añadiendole alfinal un aleatorio generado por la funcion randomNumber()
function randomDt(){
	var dt= new Date();
	return dt.getTime() + "-" + randomNumber();
}

