var http;

function createRequestObject()
{
    var http;
    if(window.XMLHttpRequest)
    { // Mozilla, Safari, ...
        http = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    { // Internet Explorer
        http = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return http;
}


function handleAJAXReturn()
{
    if(http.readyState == 4)
    {
        if(http.status == 200)
        {
            document.getElementById('nbr_clics').innerHTML = http.responseText;
        }
        else
        {
            document.getElementById('nbr_clics').innerHTML = "<strong>N/A</strong>";
        }
    }
}


$(document).ready(
			function(){
				$('ul#portfolio').innerfade({
					speed: 1000,
					timeout: 2000,
					type: 'sequence',
					containerheight: '220px'
				});

			$("div#overview").css('opacity', 0);
			$("div#overview").fadeTo(2000,1); 

			$('#real a, .bulle').tooltip({ 
				track: true, 
				delay: 0, 
				showURL: false, 
				showBody: "|", 
				fade: 250 
			});
			
			$(".travaux").fadeTo("slow", 0.3);
			$(".travaux").hover(function(){
			$(".travaux").fadeTo("slow", 1.0);
			},function(){
			$(".travaux").fadeTo("slow", 0.3);
			});		
			
});


$(document).ready(function(){

	$(".sousrubriques p").hide();

	$(".sousrubriques li img").click(function(){
		$(this).parent().parent().children("li").find("p.montre").slideToggle("").removeClass("montre").addClass("matched");
		$(this).parent().children("p").not(".matched").addClass("montre").slideToggle("slow");
		$(this).parent().parent().children("li").find("p.matched").removeClass("matched");
	});

});

function mail()
{
	var mailteste = document.getElementById('email').value;
	var lien	= document.location.href;
	var reg = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]­{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i');

	if(reg.test(mailteste))
	{
		document.getElementById('mes').innerHTML = '<em>Chargement...</em>';
		http = createRequestObject();
		http.open('get', 'include/ajax/envoi_mail.php?email='+mailteste+'&lien='+lien, true);
		http.onreadystatechange = handleAJAXReturn;
		http.send(null);
		setTimeout($.unblockUI, 4000); 
		return(true);
	}
	else
	{
		document.getElementById('email').style.borderColor = '#FF0000';
		return(false);
	}
}
	
$(document).ready(function() { 
	$('#ami').click(function() {
		if(document.getElementById('email').style.borderColor == '#FF0000'){
			document.getElementById('email').style.borderColor = '#000000';	}
		else { document.getElementById('email').style.borderColor = '#000000' }
		document.getElementById('mes').innerHTML = '<h2>Parlez-en &agrave; vos Amis</h2>';
		document.getElementById('email').value =""
		$.blockUI({ message: $('#loginForm') });
	}); 
	
	$("#Fermer").click(function() { 
		$.unblockUI();
	}); 
}); 


function check() {
	
	msg = "";
	
	if (document.getElementById('mail').value != "")	{
		indexAroba = document.getElementById('mail').value.indexOf('@');
		indexPoint = document.getElementById('mail').value.indexOf('.');
		if ((indexAroba < 0) || (indexPoint < 0))		{
		document.getElementById('mail').style.borderColor = "#FF0000";
			msg += "Le mail est incorrect\n";
		}
	}
	else	{
		document.getElementById('mail').style.borderColor = "#FF0000";
		msg += "Veuillez saisir votre mail.\n";
	}
	
	if (tinyMCE.activeEditor.getContent() == "")
	{
		document.getElementById('elm1').style.borderColor = "#FF0000";
		msg += "Veuillez saisir votre commentaire.\n";
	}
	
	if (msg == "") return(true);
	else	{
		alert(msg);
		return(false);
	}


}

