function emailContact(lang) {
	var a = new Array(115,97,108,101,115,64,107,101,114,108,97,98,115,46,99,111,109);
	var b = '';
	for (var i=0; i < a.length; i++) {
		b += String.fromCharCode(a[i]);
	}
	var salesMail = b;
	a = new Array(112,114,111,100,117,99,116,115,64,107,101,114,108,97,98,115,46,99,111,109);
	b = '';
	for (var i=0; i < a.length; i++) {
		b += String.fromCharCode(a[i]);
	}
	var productsMail = b;
	var a = new Array(114,104,64,107,101,114,108,97,98,115,46,99,111,109);
	var b = '';
	for (var i=0; i < a.length; i++) {
		b += String.fromCharCode(a[i]);
	}
	var rhMail = b;
	var info = "";
	var salesLabel = "";
	var productsLabel = "";
	if (lang=='FR') {
		info = "?subject=contact sur le site kerlabs.com\" title=\"Envoyer un email\">";
		salesLabel = "Informations commerciales :";
		productsLabel = "Informations produits :";
		rhLabel = "Ressources humaines : ";
	}
	else {
		info = "?subject=contact on kerlabs.com website\" title=\"Send an email\">";
		salesLabel = "Sales informations:";
		productsLabel = "Products informations:";
	        rhLabel = "Careers: ";
	}
		
	document.write('<p>' + salesLabel + ' <a href="mailto:' + salesMail + info + salesMail + '</a><br />' + productsLabel + ' <a href="mailto:' + productsMail + info + productsMail + '</a><br />' + rhLabel + '<a href="mailto:' + rhMail + info + rhMail + '</a></p>');
}

function emailSupport(lang) {
    a = new Array(105,110,102,111,64,107,101,114,108,97,98,115,46,99,111,109);
	b = '';
	for (var i=0; i < a.length; i++) {
		b += String.fromCharCode(a[i]);
	}
	var supportMail = b;
	var info = "";
	if (lang=='FR') {
		info = "?subject=support sur le site kerlabs.com\" title=\"Envoyer un email\">";
	}
	else {
		info = "?subject=support on kerlabs.com website\" title=\"Send an email\">";
	}
		
	document.write('<a href="mailto:' + supportMail + info + supportMail + '</a>');
}

function emailSummit(lang) {
	a = new Array(82,101,110,97,117,100,46,76,111,116,116,105,97,117,120,64,107,101,114,108,97,98,115,46,99,111,109);
	b = '';
	for (var i=0; i < a.length; i++) {
		b += String.fromCharCode(a[i]);
	}
	var summitMail = b;
	if (lang=='FR') {
		intro = "L&lsquo;inscription est obligatoire. Veuillez remplir le formulaire ci-dessous et envoyez-le &agrave; ";
		info = "?subject=Inscription au sommet Kerrighed\" title=\"Envoyer un email\">";
	}
	else {
		intro = "Registration is mandatory. Please fill the form below and send it back to ";
		info = "?subject=Kerrighed summit registration\" title=\"Send an email\">";
	}
		
	document.write('<p>' + intro + '<a href="mailto:' + summitMail + info + summitMail + '</a>.</p>');
}


function addEvent(obj, evType, fn){ 
	if (obj.addEventListener){ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} else if (obj.attachEvent){ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} else { 
		return false; 
	} 
}

addEvent(window,'load', checkHomePage);

var partnersArray = new Array();
var partnerInfo = new Array();

function checkHomePage() {
	if (document.getElementById('home')) {
		partnerNumber = 0;
		partnersArray[0]="inria|Institut National de Recherche en Informatique et Automatique, www.inria.fr";
/*		to add partners, add an array item with first the image name before .gif, a pipe | and the info related to the partner */
/* 		partnersArray[1]="test1|Partenaire 1, www.test1.fr"; */
/* 		partnersArray[2]="test2|Partenaire 2, www.test2.fr"; */
		
		partnerTotal = partnersArray.length - 1;
		
		if (partnerTotal>0) {
			setTimeout('rotatePartners()',5000);
		}
	}
}

function rotatePartners() {

	partnerString = partnersArray[partnerNumber];
	partnerInfo = partnerString.split("|");
	document.getElementById('partnerLogo').title = partnerInfo[1];
	imageUrl = "url('images/partners/"+partnerInfo[0]+".gif');";
	document.getElementById('partnerLogo').style.backgroundImage = imageUrl;

	if (partnerNumber<partnerTotal) {
	partnerNumber = partnerNumber + 1;
	}
	
	else {
	partnerNumber = 0;
	}

	setTimeout('rotatePartners()',5000);
}

var tabLinks = new Array();
var contentDivs = new Array();

function initOnglets() {
    // Grab the tab links and content divs from the page
    var tabListItems = document.getElementById('onglets').childNodes;
    for ( var i = 0; i < tabListItems.length; i++ ) {
        if ( tabListItems[i].nodeName == "LI" ) {
	    var tabLink = getFirstChildWithTagName( tabListItems[i], 'A' );
	    var id = getHash( tabLink.getAttribute('href') );
	    tabLinks[id] = tabLink;
	    contentDivs[id] = document.getElementById( id );
        }
    }

    // Assign onclick events to the tab links, and
    // highlight the first tab
    var i = 0;

    for ( var id in tabLinks ) {
        tabLinks[id].onclick = showTab;
        tabLinks[id].onfocus = function() { this.blur() };
        if ( i == 0 ) tabLinks[id].className = 'selected';
        i++;
    }

    // Hide all content divs except the first
    var i = 0;

    for ( var id in contentDivs ) {
        if ( i != 0 ) contentDivs[id].className = 'onglet hide';
        i++;
    }
}

function showTab() {
    var selectedId = getHash( this.getAttribute('href') );

    // Highlight the selected tab, and dim all others.
    // Also show the selected content div, and hide all others.
    for ( var id in contentDivs ) {
        if ( id == selectedId ) {
	    tabLinks[id].className = 'selected';
	    contentDivs[id].className = 'onglet';
        } else {
	    tabLinks[id].className = '';
	    contentDivs[id].className = 'onglet hide';
        }
    }

    // Stop the browser following the link
    return false;
}

function getFirstChildWithTagName( element, tagName ) {
    for ( var i = 0; i < element.childNodes.length; i++ ) {
        if ( element.childNodes[i].nodeName == tagName ) return element.childNodes[i];
    }
}

function getHash( url ) {
    var hashPos = url.lastIndexOf ( '#' );
    return url.substring( hashPos + 1 );
}

