// JavaScript Document

function recommander(){
	mail_str = "mailto:?subject=%C0 voir sur le site www.tds-expert.fr"
	mail_str += "&body=Bonjour, le site internet TDS-Experts.fr pourrait t'int%E9resser.Voici le lien pour le visiter  www.tds-expert.fr"
	location.href = mail_str;
	return false;
}

function majScores(cache){
	$("#highScoresDiv").addClass('loading');
	$.ajax({
	  url: "majScores.php",
	  async:true,
	  cache: cache,
	  success: function(html){
		$("#highScoresDiv").removeClass('loading');
		$("#highScoresDiv").html(html);
	  }
	});	
	return false;
}

var flashSound = 100;

function toogleSound(btn){
	//alert(flashSound);
	if(flashSound == 100){
		flashSound = 0;
		//$('#jeu').setVolumeGen(0);	
		document.getElementById('jeu').setVolumeGen(flashSound);	
		btn.src = "images/mep/btn_son_off.png";
		$('#imgBtn').ifixpng();
	}else{
		flashSound = 100;
		//$('#jeu').setVolumeGen(100);	
		document.getElementById('jeu').setVolumeGen(flashSound);
		btn.src = "images/mep/btn_son_on.png";
		$('#imgBtn').ifixpng();
	}
}

function goDepRisque(codeDep){
	//var codeDep2 = $('#selDep option:selected').val();
	if(confirm("goDep => "+codeDep+" ?")){
		window.location = "/observatoire/risque/departement/"+codeDep;
	}
	return false;	
}

function goGraph(code, slug){
	openShadowbox("/observatoire/"+slug+"/graphique/"+code+".html", "iframe", "");
	return false;	
}
function goCulture(slug){
	window.location = "/observatoire/"+slug+".html";	
}

function goCultureAgri(slug){
	window.location = "/observatoireAgri/"+slug+".html";	
}


function openShadowbox(content, player, title){
    Shadowbox.open({
        content:    content,
        player:     player,
        title:      title,
		width:		800,
		height:		510
    });
}

function openShadowboxLH(content, player, title, l, h){
    Shadowbox.open({
        content:    content,
        player:     player,
        title:      title,
		width:		l,
		height:		h
    });
}

function ouvrirShadowVideo(mp4, titre){
	Shadowbox.open({
		content:    mp4,
		player:     "flv",
		title:      titre,
		height:     272,
		width:      480
	});
	return false;   
}
function alertCGU(elt){
	if(!elt.is(':checked')){
		alert("Vous devez accepter les conditions d'utilisations afin de pouvoir accéder à l'observatoire");
		if($("#formInscriptionStep2").length > 0 ){
			openConditions();
		}
	}
}
function accepterConditions(){
	chkbx = window.parent.$("#contact_acceptation_cgu, #inscriptionAgriPiegeur_acceptation_cgu");
	window.parent.Shadowbox.close();
	
	chkbx.attr('checked', true);
	return false;	
}

function getPdf(url){
	//alert("URL demandée : "+url);
	$.ajax({
		   type:"GET",
		   url:url,
		   success: function(data) {
				//alert(data);
				if(data != "false"){
					//window.open(data);
					Shadowbox.open({
						content:    data,
						player:		"iframe"
					});
				}else{
					Shadowbox.open({
						content:    '<div id="error">Pas de relevé pour cette région</div>',
						player:     "html",
						title:      "Information",
						height:     175,
						width:      300
					});
	
				}
				//$('.result').html(data);
				//alert('Load was performed.');
			}
		   });
	
}
