// JavaScript Document

function fadeIn(objID,alpha) {
	var myObj = document.getElementById(objID);
	if (alpha < 0.0001) {
		myObj.style.top = null;
	}
	
	myObj.style.fontSize = alpha + "%";
	if (myObj.filters) {
		myObj.filters.alpha.opacity = alpha;
	} else {
		myObj.style.opacity = alpha / 100;
		myObj.style.MozOpacity = alpha / 100;
	}
	alpha += 10;
	if (alpha <= 100) {
		window.setTimeout("fadeIn('" + objID + "'," + alpha + ");",30);
	}

	// and make sure it is within the visible window...
	var screenHeight = document.documentElement.clientHeight;
	var screenScroll = document.body.scrollTop;
	if (screenScroll == 0) {
		if (window.pageYOffset) {
			screenScroll = window.pageYOffset;
		} else {
			screenScroll = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
		}
	}
	if (navigator.appVersion.indexOf("MSIE")!=-1) { // not happy... but works
			mainareaTop = myObj.parentNode.parentNode.parentNode.offsetTop;
	} else {
		var mainareaTop = 0;
	}
	var boxHeight = myObj.offsetHeight;
	var boxTop = myObj.parentNode.parentNode.offsetTop + mainareaTop + 20;

	//check if beyond top
	if (boxTop < screenScroll) {
		myObj.style.top = (screenScroll - boxTop) + 'px';
	} else {
		//check if beyond bottom
		if (boxTop + boxHeight > screenHeight + screenScroll) {
			myObj.style.top = (screenHeight + screenScroll - boxHeight - boxTop) + 'px';
		}
	}
}

function encodeCorreo(user_name,correo_container,domain_name,css_classname) {
	var at_char = String.fromCharCode(64);
	document.getElementById(correo_container).innerHTML = '<a href="mailto:' + user_name + at_char + domain_name +
								'" class="' + css_classname + '">' + user_name + at_char + domain_name + '</a>';
}
