// JavaScript Document

var lastFocus = "";
function getFocusBorder(elt) {
	if(lastFocus != ""){
		lastFocus.style.border='1px solid #00642e';
	}
	elt.style.border='1px solid #8d2000';
	lastFocus = elt;
}


function maj_liste() {
	
	
	var id = document.getElementById('je_suis').options[document.getElementById('je_suis').selectedIndex].value;
	//alert (id);
	$.ajax({
		type: "POST",
		url: "copine.php",
		data: "id="+id,
		success: function(msg){
			$(".plus_egal").empty();
			//$("#copine").html(msg);
			//$("#image1").attr("src", "images/legumes/" + id + ".jpg").fadeIn("slow");
			$("#image1").fadeOut("normal", function (){
													 
				imgOk = true;
				var cheminImg = "images/vide.jpg";
				//testExists("images/legumes/" + id + ".jpg");
				if(imgOk){
					cheminImg = "images/legumes/" + id + ".jpg";
				}
				   
				$("#image1").attr("src", cheminImg).fadeIn("normal", function(){
					$("#copine").fadeOut("normal", function (){
						$("#copine").html(msg).fadeIn("normal");
						$("#phrase").fadeOut("normal");
						$("#egal").fadeOut("normal");
					});
				});
			});
			
			
		}
	});
	
}

function maj_phrase() {
	
	var id2;
	
	if(document.getElementById('cop')){
		id2 = document.getElementById('cop').options[document.getElementById('cop').selectedIndex].value;
	}else{
		id2 = document.getElementById('copHidden').value;
	}
	var id1 = document.getElementById('je_suis').options[document.getElementById('je_suis').selectedIndex].value;
	
	//alert(id2 +" "+id1);
	
	$.ajax({
		type: "POST",
		url: "phrase.php",
		data: "id1="+id1+"&id2="+id2,
		success: function(msg){
			$("#image2").fadeOut("normal", function (){
				$("#image2").attr("src", "images/legumes/" + id2 + ".jpg").fadeIn('normal', function(){
					$("#phrase").fadeOut("normal", function (){
						$("#phrase").html(msg).fadeIn('normal');
						$("#egal").fadeIn('normal');
					});
				});
			});
			
		}
	});
	
}

function confirmation(msg, url) {
	if(confirm(msg)) {
		document.location.href = url;
	}
}
function popupcentre(adresse, nomFenetre, largeur, hauteur, scroll){



	var largeurEcran = (screen.width - largeur) / 2;

	

	var hauteurEcran = (screen.height - hauteur) / 2;

	

	window.open(adresse, nomFenetre, 'height=' + hauteur + ', width=' + largeur + ', top=' + hauteurEcran + ', left=' + largeurEcran + ', scrollbars=' + scroll + ', resizable=no');


}

function chargerLiensChroniques(page) {
	
	$.ajax({
		type: "GET",
		data:"f=liste&p="+page,
		url: "ajaxRadio.php",
		success: function(msg){
			
			$("#chroniques").html(msg);
			$("#chroniques").fadeIn("normal");
			
		}
	});
	
}
function chargerLienDuJour(page) {
	
	$.ajax({
		type: "GET",
		data:"f=jour&p="+page,
		url: "ajaxRadio.php",
		success: function(msg){
			$("#sonDuJour").html(msg);
			$("#sonDuJour").fadeIn("normal");
		}
	});
	
}
function chargerEmission(page) {
	
	$.ajax({
		type: "GET",
		data:"f=emission&p="+page,
		url: "ajaxRadio.php",
		success: function(msg){
			if(msg == ""){
				$(".titre_derniere_emission").hide();
				$(".vous_ecoutez").hide();
			}else{
				
				$("#emissionDuJour").html(msg);
				$("#emissionDuJour").fadeIn("normal");
			}
			
		}
	});
	
}








