/**
 * JS
 * (c) 2008 Darío G. Ruellan / ecimTech
 */


var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

window.onload = function()
{
	tooltips();
	
	$S('img').each(function(a){
		if ( a.className == "fixPNG" )
			fixPNG(a);
	});
	
	// Muestra 'Mainbody'

	var main_fx = new Fx.Style('mainframe', 'opacity');
	main_fx.custom(0,1);
	
	var header_fx = new Fx.Style('mainheader', 'top');
	header_fx.custom(-200,0);

	$('loading').setStyle('opacity',0);
	
	// Veamos si hay un formulario
	
	if ( $('emailForm') )
	{
		$('emailForm').addEvent( 'submit', function()
		{
			return form_send();
		});
	}

	
};


// ** Preload ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** 


function preload() {
	$('mainframe').setStyle('opacity',0);
}


// ** Tooltips ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** 


function tooltips () {
	var as = [];
	$S('a').each(function(a){
		if (a.getAttribute('title')) as.push(a);
	});
	new Tips(as, {maxOpacity: 0.9});
}


// ** Form Send ** ** ** ** ** ** ** ** ** ** ** ** ** **


function form_send() {
	var email_filter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var email=document.emailForm.mm.value;

	if ( email_filter.test(email) ) {
		$('send').setHTML('<img src="images/enviando.gif" alt="Enviando..." /> Enviando...');
		return true;
	} else {
		alert("Por favor, ingrese un Correo Electrónico");
		return false;
	}
}


// ** PNG Fix ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **


function fixPNG(myImage) 
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML
    }
}