function addmailing(email, lang){
	if(validMail(email.value)){
		killAjax();
		ret = function() {
			if(ajaxOk()){
				document.getElementById('liste').innerHTML = objAjax.responseText;
			}
		}
		callAjax('/script/ajax.php?what=mailing&courriel='+email.value+'&lang='+lang,ret,null);
	}
	else{
		email.focus();
		email.select();
		alert('Veuillez entrer une adresse de courriel valide.');
	}
}

function addcomment(lang, post){
	if(validForm(post)){
		killAjax();
		ret = function(){
			if(ajaxOk()){
				document.getElementById('comment_form').innerHTML = objAjax.responseText;
			}
		}
		callAjax('/script/ajax.php?what=comment&lang='+lang,ret,null,post);
	}
}

function SelectAllCheckboxes()
{
    var inputs = document.getElementsByTagName("input");
    for (var i=0;i<inputs.length;i++)
    {
        chk = inputs[i];
        if(chk.type=='checkbox')
        {
            chk.checked=true;
        }
    }
}

function UnselectAllCheckboxes()
{
    var inputs = document.getElementsByTagName("input");
    for (var i=0;i<inputs.length;i++)
    {
        chk = inputs[i];
        if(chk.type=='checkbox')
        {
            chk.checked=false;
        }
    }
}

// Dropdown menu ...
var currMenu = null;
function mainmenu(sender,classe){
	sender = document.getElementById(sender);
	if(sender){
		sender = (sender.tagName=="UL") ? sender : sender.childNodes[0];
		sender = (sender && sender.tagName=="UL") ? sender : sender.nextSibling;
		if(sender){
			if(sender.tagName=="UL"){
				if(classe!=""){
					var uls = sender.getElementsByTagName("UL");
					for(i=0;i<uls.length;i++){
						if(uls[i].className==classe) currMenu = uls[i].parentNode;
					}
					if(currMenu) currMenu.className+=" shover";
				}
				var lis = sender.getElementsByTagName("LI");
				for(i=0;i<lis.length;i++){
					if(lis[i].className!="vide"){
						lis[i].onmouseover=function() {
							if(currMenu) currMenu.className=currMenu.className.replace("shover", "");
							this.className+=" shover";
							//if(document.all) this.style.zIndex=100;
						}
						lis[i].onmouseout=function() {
							this.className=this.className.replace("shover", "");
							if(currMenu) if(currMenu.className.indexOf("shover")==-1) currMenu.className+=" shover";
							//if(document.all) this.style.zIndex=1;
						}
					}
				}
			}else{
				alert("Le sender n\'est pas un UL");
			}
		}
	}
}

function changeSizeTxt(plus){
	if(document.getElementById("contenu") && document.getElementById("msize") && document.getElementById("psize")){
		var cH = (document.getElementById("contenu"));
		var mA = document.getElementById("msize");
		var pA = document.getElementById("psize");
		
		if(!cH.style.fontSize) cH.style.fontSize = "12px";
		var fSize = parseInt(cH.style.fontSize.replace("px",""));
		
		mA.className = "";
		pA.className = "";
		
		if(plus){
			if(fSize<17){
				fSize++;
				cH.style.fontSize = fSize+"px";
			}
		}else{
			if(fSize>10){
				fSize--;
				cH.style.fontSize = fSize+"px";
			}
		}
		
		if(fSize>=17) pA.className = "hidden";
		if(fSize<=10) mA.className = "hidden";
	}
	return false;
}

function printPage(){
	window.print();
	return false;
}

function showstreetview(geodata){
	if(geodata.latitude!='' && geodata.longitude!=''){
		var adn_myplace = new google.maps.LatLng(geodata.latitude, geodata.longitude);
			var panoramaOptions = {
			  position: adn_myplace,
			  pov: {
				heading: parseFloat(geodata.heading),
				pitch: parseFloat(geodata.pitch),
				zoom: parseFloat(geodata.zoom)
			  },
			  visible: true
			};
			var panorama = new google.maps.StreetViewPanorama(document.getElementById("map"), panoramaOptions);
			
		//affichage de la map standard
		var myOptions = {
		  zoom: 14,
		  center: adn_myplace,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		}
		var map = new google.maps.Map(document.getElementById("map2"), myOptions);
		var marker = new google.maps.Marker({
			position: adn_myplace, 
			map: map
		});   



	}else{
		$("#map").css("display","none");
		$("#map2").css("display","none");
		$("#positionmap").remove();
	}
}


//mailing
$(document).ready(function(){
	$("#mailAdress").focus(function(){if($(this).val()=='Votre adresse électronique'){$(this).val('');}});
	$("#mailAdress").blur(function(){if($(this).val()==''){$(this).val('Votre adresse électronique');}});
});

function mailingInscription(el){
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(el.val())){
		$.post("/scripts/addMailing.php",{email : el.val()},function(data){mercimailing();});
	}else{
		alert("Veuillez entrer une adresse courriel valide");
	}
}

function mercimailing(){
	$("#mailingbtn").hide();
	$("#mailAdress").hide();
	$("#boxmail").html("Merci!");
}

