// JavaScript Document
//EL	Funcion para validar correo electronico
function IsEmail(elem){
	var valor=elem.value;
	var id=elem.id;
	if(valor!=""){
		var em = valor;
		//var ca =/([a-zA-Z0-9_.-])+@+([a-zA-Z0-9-])+([.])+([a-zA-Z0-9])/;
		var ca  = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		var comparacion= ca.test(em)
		/*
		//validando terminacion en punto
		var pos = valor.length-1;
		//alert("ultimo:"+valor.charAt(pos))
		if(valor.charAt(pos)=='.')
			comparacion=false;
		//validando cantidad de puntos 
		ca =/([a-zA-Z])/;
		var contando=0;
		var email = valor.split('.');
		while(email[contando] && comparacion){
			if(contando>0)
				comparacion= ca.test(email[contando]);
			contando++;
		}
		if(contando>3 || contando<1)
			comparacion=false;
		//validando cantidad de @
		contando=0;
		var email = valor.split('@');
		while(email[contando]){
			contando++;
		}
		if(contando>2 || contando<1)
			comparacion=false;
		*/
		//verificando si es valido
		if (comparacion==false) {
			alert ("Please, type a valid e-mail address");
			document.getElementById(id).focus();
			document.getElementById(id).value="";
			return (false);
		}
	}
}
function limpia(obj){
	obj.value="";
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = true;
function preloadImages() {
	if (document.images) {
		softwared = newImage("img/softwared.jpg");
		preloadFlag = true;
	}
}

// not animated collapse/expand
function togglePannelStatus(content)
{
    var expand = (content.style.display=="none");
    content.style.display = (expand ? "block" : "none");
    toggleChevronIcon(content);
}

// current animated collapsible panel content
var currentContent = null;

function togglePannelAnimatedStatus(content, interval, step, name)
{
    // wait for another animated expand/collapse action to end
    if (currentContent==null)
    {
        currentContent = content;
        var expand = (content.style.display=="none");
        if (expand){
            content.style.display = "block";
			changeImages(name, 'img/'+name+'d.jpg');
		}
		else{
			changeImages(name, 'img/'+name+'.jpg');
		}
        var max_height = content.offsetHeight;

        var step_height = step + (expand ? 0 : -max_height);
	
       // toggleChevronIcon(content);
                
        // schedule first animated collapse/expand event
        content.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
}

function togglePannelAnimatingStatus(interval,
    step, max_height, step_height)
{
    var step_height_abs = Math.abs(step_height);

    // schedule next animated collapse/expand event
    if (step_height_abs>=step && step_height_abs<=(max_height-step))
    {
        step_height += step;
        currentContent.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
    // animated expand/collapse done
    else
    {
        if (step_height_abs<step)
            currentContent.style.display = "none";
        currentContent.style.height = "";
        currentContent = null;
    }
}

// change chevron icon into either collapse or expand
function toggleChevronIcon(content)
{
    var chevron = content.parentNode
        .firstChild.childNodes[1].childNodes[0];
    var expand = (chevron.src.indexOf("expand.gif")>0);
    chevron.src = chevron.src
        .split(expand ? "expand.gif" : "collapse.gif")
        .join(expand ? "collapse.gif" : "expand.gif");
}

function mo(content,name){
	 var expand = (content.style.display=="none");
	 if(expand)
	 	changeImages(name, 'img/'+name+'.jpg');
}
	 
