function getXhr(){
var xhr = null; 
	if(window.XMLHttpRequest)
	   xhr = new XMLHttpRequest(); 
	else if(window.ActiveXObject){ 
	   try {
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
	}
	else {
	   alert("Veuillez changer de navigateur pour utiliser ce site."); 
	   xhr = false; 
	} 
					return xhr;
}
//--------------------------------------------
//--------------------------------------------
//--------------------------------------------

function player(id,version)
{
	window.open ("launch_player-"+id+"-"+version+".html", "player", config="height=390, width=900, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");

}


function videtextareaphoto(i)
{
	if (document.getElementById("comment"+i).value == "Votre commentaire ici") document.getElementById("comment"+i).value="";

}

function videinputsearch(i)
{
	if (document.getElementById("inputsearch").value == "Entrez votre recherche" && i == 0) document.getElementById("inputsearch").value="";
	if (document.getElementById("inputsearch").value == "" && i == 1) document.getElementById("inputsearch").value="Entrez votre recherche";
}

function encemoment(t,versionradio)
{
	if (t == 0) div = "encemoment";
	else if (t == 1) div = "encemoment_1";
	else if (t == 2) div = "encemoment_2";
	else if (t == 3) div = "encemoment_3";
	else if (t == 4) div = "encemoment_4";
	else if (t == 5) div = "player_aff";
	
	go("?p=encemoment&type="+t+"&version="+versionradio,div,div);
	
	window.setTimeout("encemoment('"+t+"','"+versionradio+"')",5000);
}

function ajaxplayer(versionradio)
{
	go("?p=player&version="+versionradio,"info","info");
	
	window.setTimeout("ajaxplayer('"+versionradio+"')",2000);
}

function titre_encemoment()
{
	go("?p=titre_encemoment","titre","titre");
	
	window.setTimeout("titre_encemoment()",5000);
}

function PulsMatch(i)
{
	go("?p=pulsmatch&i="+i,"boutons_puls_match","boutons_puls_match");
}

function voter_pulsprog(val)
{
	go("?p=voter&val="+val,"","");
}

function POD(version)
{
	go("?p=pod&version="+version,"ajax_diff","")
	window.setTimeout("POD('"+version+"')",5000);
}

function ChangeMoisAnnee(version,mois,annee)
{
	document.location="index.php?version="+version+"&op=top100&mois="+mois+"&annee="+annee;
}

function ChangePage(lim,page)
{
	document.location=page+lim+".html";
}

function PlusPhoto(n)
{
	document.location=page+lim;
}


function affiche(nbre)
{
texte = document.forms["msg"+nbre].msg.value;
	if(document.getElementById && document.getElementById("texte"+nbre).innerHTML != "")
	{
		texte = "";
	}
	else if(document.all && document.getElementById("texte"+nbre).innerHTML != "")
	{
		texte = "";
	}


	if(document.getElementById)
	{
		document.getElementById("texte"+nbre).innerHTML = texte;
	}
	else if(document.all)
	{
		document.all["texte"+nbre].innerHTML = texte;
	}

	
}


function go(page_get,pointer,loader)
{

var xhr = getXhr();
xhr.onreadystatechange = function(){
	if(xhr.readyState == 4 && xhr.status == 200)
	{
		rep = xhr.responseText;
		if (rep.substr(0, 7)=="[ALERT]") alert (rep.substr(7, rep.length-7));
		else if (rep != "nochange" && pointer != "titre" && pointer != "") document.getElementById(pointer).innerHTML = rep;
	}
}

xhr.open("POST","ajax.php"+page_get,true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

xhr.send(null);
}

function changestar(nb)
{
	var i=0;
	for (i=1;i<=5;i++)
	{
		if (i<=nb) var star="star";
		else var star="star-empty";
		
		document.getElementById("bt"+i).innerHTML = "<img src='starimages/"+star+".png' alt='img"+i+"' />";
	}

}

function voter(i)
{
	go("?p=voter&val="+i,"","");
}

function redirect(url)
{
	document.location = url;
}

function AddToFavorites()
{
title = "Puls'Radio";
url = "http://www.pulsradio.com/";

if (window.sidebar) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(title, url,"");
} else if( window.external ) { // IE Favorite
window.external.AddFavorite( url, title); }
else if(window.opera && window.print) { // Opera Hotlist
return true; }
}

// ----------------- PLAYER ----------------------

function mute()
{
	
	document.getElementById("nomute").style.visibility = "hidden";
	document.getElementById("mute").style.visibility = "visible";
}

function nomute()
{
	
	document.getElementById("mute").style.visibility = "hidden";
	document.getElementById("nomute").style.visibility = "visible";
}




