

function isMail(mail) {
	var i;
	var atCount;
	i = 0;
	atCount = 0;
	if (mail.length > 0) {
		// If there is no . after the @ then email is invalid
		if (mail.indexOf(".",mail.indexOf("@")) == -1) {
			i = 0;
			return(false);
		}
		while (i < mail.length) {
			if ( (mail.charCodeAt(i) >= 48) && (mail.charCodeAt(i) <= 57) ||	// numbers 0-9
			(mail.charCodeAt(i) >= 65) && (mail.charCodeAt(i) <= 90)  ||		// A-Z
			(mail.charCodeAt(i) >= 97) && (mail.charCodeAt(i) <= 122) ||		// a-z
			(mail.charCodeAt(i) == 46) ||										// . char
			(mail.charCodeAt(i) == 95) ||										// _ char
			(mail.charCodeAt(i) == 45) );										// - char
			else if (mail.charCodeAt(i) == 64) {								// @ char
				// only one @ allowed
				atCount++; 
			} else {
				//alert("error at: "+(i+1));
				i = 0;
				return(false);
			}
			i++;
		}
	}
	// Also check length is >= 5 if len(mail)>0 [min email: a@b.c = 5 char]
	// and only one @ has been parsed
	if ( (i == 0) || ((mail.length > 0) && (mail.length < 5)) || (atCount > 1) || (atCount < 1) ) {
		return(false); //Bad char was found
	} else {
		return(true); //good email address
	}
}

function init(){
    if($('homeDiv')){
        homePage();
    }
    
    if($('selNewsletters')){
        $('selNewsletters').onchange = function(){
            document.location.href = $('selNewsletters').value
        }
    }
externalLinks();
downloadLinks();
}

var currentPara = 0

function homePage(){
    // First Para
    
    
    $('homePage1').hide();
    $('homePage2').hide();
    $('homePage3').hide();
    
    currentPara = parseInt(currentPara) + 1;
    
    if (parseInt(currentPara) > 3){
       
        
        Effect.Appear('homePage1', { duration: 2.0 });
        Effect.Appear('homePage2', { duration: 2.0 });
        Effect.Appear('homePage3', { duration: 2.0 });
        
         $('homePage1').addClassName('smallPara')
         $('homePage2').addClassName('smallPara')
         $('homePage3').addClassName('smallPara')
    }else{
        Effect.Appear('homePage'+currentPara, { duration: 1.0, afterFinish:textPause });
    }
}


function textPause(){
    var t=setTimeout(fadeOut,5000);
}

function fadeOut(){
    Effect.Fade('homePage'+currentPara, { duration: 1.0, afterFinish:homePage });

}
/* EXTERNAL LINKS */
function externalLinks(){
    
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
		    anchor.target = "_blank";
		    anchor.onclick = function(){
               pageTracker._trackEvent('Link', 'External', this.href)
		    }
		    
		}
	}

}
function downloadLinks(){
    
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "dowload"){
		    anchor.target = "_blank";
		    anchor.onclick = function(){
               pageTracker._trackEvent('Link', 'Download', this.href)
		    }
		    
		}
	}

}

//window.onload = init();
Event.observe(window,"load",function() { init();});

