function show_smenu(cat) {
	hide_all();
	if(cat!="false") {
		document.getElementById("sous_menu_"+cat).style.display="block";
	}
}

function hide_smenu() {
	window.setTimeout('hide_all()','60000');
}

function hide_all() {
	browserName = navigator.appName;
	if (browserName != "Microsoft Internet Explorer") {
		att_class="class";
	}else {
		att_class="className";
	}
	for(i=0;i<document.getElementById("sous_menu").childNodes.length;i++) {
		ele=document.getElementById("sous_menu").childNodes[i];
		try {
			if(ele.getAttribute(att_class)=="sous_menu") {
				ele.style.display="none";
			}
		}catch(e) {}
	}
}

function brille(max,item) {
	for(max;max>=0;max--) {
		document.getElementById("etoile_"+max+"_"+item).src='../images/etoile1.gif';
	}
}

function grise(item) {
	for(i=0;i<=4;i++) {
		document.getElementById("etoile_"+i+"_"+item).src='../images/etoile0.gif';
	}
}

function vote(item,vote,topic) {
	if(window.XMLHttpRequest) {
		xhr_object = new XMLHttpRequest();
	}
	else if(window.ActiveXObject) {
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
		return(false);
	}
	nocache = Math.floor(Math.random() * 10000); // permet simplement a IE de ne pas mettre le fichier appele par l'ajax en cache !!!
	vote++;
	var fichier = "../javascript/ajax_vote.php?item="+item+"&vote="+vote+"&topic="+topic+"&"+nocache;
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4) {
		vote = xhr_object.responseText;
		document.getElementById("vote_"+item).innerHTML=vote;
	}
}

function switch_search_topic(topic_nom,hf) {
	switch(topic_nom) {
		case "video":
			topic_trad="video";
			break;
		case "jeu":
			topic_trad="gioco";
			break;
		case "radio":
			topic_trad="radio";
			break;
		case "webcam":
			topic_trad="webcam";
			break;
		case "hd":
			topic_trad="sito";
			break;
		case "musique":
			topic_trad="musica";
			break;
	}
	document.getElementById("submit_search"+hf).value="ricerca "+topic_trad;
	document.getElementById("topic_search"+hf).value=topic_nom;
}

function send_search(nav,hf) {
	nom_topic=document.getElementById("topic_search"+hf).value;
	if(nom_topic=="") {
		nom_topic="video";
	}
	mc=document.getElementById("mc"+hf).value;
	if(nav==nom_topic) {
		url=window.location.href;
		pos=url.indexOf("?",0);
		if(pos>0) {
			url=url.substring(pos,url.length);
		}else {
			url="?";
		}
		if(nav!="live") {
			window.location.href="http://it.divertis.com/"+nav+"/"+nav+".search.php"+url+"&d=0&mc_recherche="+mc;
		}else {
			window.location.href="http://it.divertis.com/"+nav+"/"+nav+".index.php"+url+"&d=0&mc_recherche="+mc;
		}
	}else {
		if(nom_topic!="live") {
			window.location.href="http://it.divertis.com/"+nom_topic+"/"+nom_topic+".search.php?d=0&mc_recherche="+mc;
		}else {
			window.location.href="http://www.divertis.com/"+nom_topic+"/"+nom_topic+".index.php?d=0&mc_recherche="+mc;
		}
	}
}

function key_send_search(key,nav,hf) {
	if(key==13) {
		send_search(nav,hf);
	}
}

function ma0() {
	document.getElementById("where_continent").value="";
	document.getElementById("where_pays").value="";
	document.getElementById("where_theme").value="";
	document.getElementById("where_stheme").value="";
	document.getElementById("where_mc").value="";
	document.getElementById("d").value="";
	document.getElementById("navig_webtv").innerHTML="Web TVs & ";
	document.getElementById("navig_livetv").innerHTML="Live TVs ";
	document.getElementById("navig_continent").innerHTML="di tutti i continenti ";
	document.getElementById("navig_pays").innerHTML="";
	document.getElementById("navig_theme").innerHTML="e tutti i temi.";
	document.getElementById("navig_stheme").innerHTML="";
	document.getElementById("navig_mc").innerHTML="";
	document.getElementById("chck_webtv").checked=true;
	document.getElementById("chck_livetv").checked=true;
	document.getElementById("d").value="0";
	tab_themeid=new Array(1,3,5,8,9,10,11,12,13);
	size_tab=tab_themeid.length;
	for(i=0;i<size_tab;i++) {
		document.getElementById("st_t"+tab_themeid[i]).style.display="none";
	}
	for(i=1;i<9;i++) {
		document.getElementById("pays_continents"+i).style.display="none";
	}
	search_on();
}

function choose_live_by(by) {
	switch(by) {
		default:
		case "pays":
			document.getElementById("onglet_pays").style.background="#FFF url('../../images/onglet_ltv_on.gif') no-repeat top left";
			document.getElementById("onglet_pays").style.color="white";
			document.getElementById("onglet_theme").style.background="#FFF url('../../images/onglet_ltv_off.gif') no-repeat top left";
			document.getElementById("onglet_theme").style.color="black";
			document.getElementById("col_pays").style.display="block";
			document.getElementById("col_theme").style.display="none";
		break;
		case "theme":
			document.getElementById("onglet_theme").style.background="#FFF url('../../images/onglet_ltv_on.gif') no-repeat top left";
			document.getElementById("onglet_theme").style.color="white";
			document.getElementById("onglet_pays").style.background="#FFF url('../../images/onglet_ltv_off.gif') no-repeat top left";
			document.getElementById("onglet_pays").style.color="black";
			document.getElementById("col_theme").style.display="block";
			document.getElementById("col_pays").style.display="none";
		break;
	}
}

function add_exept(exept,on,idObj) {
	if(window.XMLHttpRequest) {
		xhr_object = new XMLHttpRequest();
	}
	else if(window.ActiveXObject) {
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}
	document.getElementById("d").value=0;
	switch(on) {
		case "continent":
			document.getElementById("where_pays").value="";
			document.getElementById("navig_continent").innerHTML="en "+idObj.innerHTML+" ";
			document.getElementById("navig_pays").innerHTML="";
			zone=idObj.id;
			for(i=1;i<9;i++) {
				if(i==zone) {
					document.getElementById("pays_continents"+zone).style.display="block";
				}else {
					document.getElementById("pays_continents"+i).style.display="none";
				}
			}
		break;
		case "pays":
			document.getElementById("navig_pays").innerHTML="> "+idObj.innerHTML+" ";
		break;
		case "theme":
			document.getElementById("where_stheme").value="";
			document.getElementById("navig_theme").innerHTML="de "+idObj.innerHTML+" ";
			document.getElementById("navig_stheme").innerHTML="";
			theme=idObj.id;
			tab_themeid=new Array(1,3,5,8,9,10,11,12,13);
			size_tab=tab_themeid.length;
			for(i=0;i<size_tab;i++) {
				if(tab_themeid[i]==theme) {
					document.getElementById("st_t"+theme).style.display="block";
				}else {
					document.getElementById("st_t"+tab_themeid[i]).style.display="none";
				}
			}
		break;
		case "stheme":
			document.getElementById("navig_stheme").innerHTML="> "+idObj.innerHTML+" ";
		break;
	}
	document.getElementById("where_"+on).value=exept;
	where=document.getElementById("where_continent").value+" "+document.getElementById("where_pays").value+" "+document.getElementById("where_theme").value+" "+document.getElementById("where_stheme").value;
	mc=document.getElementById("where_mc").value;
	dpage=document.getElementById("d").value;
	s_on="";
	if(document.getElementById("chck_livetv").checked) {
		s_on+="&live=y";
	}else {
		s_on+="&live=n";
	}
	if(document.getElementById("chck_webtv").checked) {
		s_on+="&web=y";
	}else {
		s_on+="&web=n";
	}
	nocache = Math.floor(Math.random() * 10000); // permet simplement a IE de ne pas mettre le fichier appele par l'ajax en cache !!!
	var fichier = "../../javascript/ajax_live_emission.php?where="+where+"&"+nocache+"&mc_recherche="+mc+"&d="+dpage+s_on;
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4) {
		col_live=xhr_object.responseText;
		document.getElementById("colonne_droit_live").innerHTML=col_live;
	}
}

function goto_page(page) {
	document.getElementById("d").value=page;
	search_on();
}

function search_on() {
	s_on="";
	if(document.getElementById("chck_livetv").checked) {
		s_on+="&live=y";
		document.getElementById("navig_webtv").innerHTML="Live TVs ";
		if(document.getElementById("chck_webtv").checked) {
			document.getElementById("navig_webtv").innerHTML="Live TVs & ";
		}
	}else {
		s_on+="&live=n";
		document.getElementById("navig_webtv").innerHTML="";
	}
	if(document.getElementById("chck_webtv").checked) {
		s_on+="&web=y";
		document.getElementById("navig_livetv").innerHTML="Web TVs ";
	}else {
		s_on+="&web=n";
		document.getElementById("navig_livetv").innerHTML="";
	}
	where=document.getElementById("where_continent").value+" "+document.getElementById("where_pays").value+" "+document.getElementById("where_theme").value+" "+document.getElementById("where_stheme").value;
	mc=document.getElementById("where_mc").value;
	dpage=document.getElementById("d").value;
	if(window.XMLHttpRequest) {
		xhr_object = new XMLHttpRequest();
	}
	else if(window.ActiveXObject) {
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}
	nocache = Math.floor(Math.random() * 10000); // permet simplement a IE de ne pas mettre le fichier appele par l'ajax en cache !!!
	var fichier = "../../javascript/ajax_live_emission.php?where="+where+"&"+nocache+"&d="+dpage+s_on+"&mc_recherche="+mc;
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4) {
		col_live=xhr_object.responseText;
		document.getElementById("colonne_droit_live").innerHTML=col_live;
	}
}

function choose_pays(idObj) {
	if(window.XMLHttpRequest) {
		xhr_object = new XMLHttpRequest();
	}else if(window.ActiveXObject) {
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}
	nocache = Math.floor(Math.random() * 10000); // permet simplement a IE de ne pas mettre le fichier appele par l'ajax en cache !!!
	var fichier = "../../javascript/ajax_pays.php?zone="+idObj.value;
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4) {
		pays=xhr_object.responseText;
		document.getElementById("select_pays").innerHTML=pays;
	}
}

function choose_theme(idObj,cat) {
	if(window.XMLHttpRequest) {
		xhr_object = new XMLHttpRequest();
	}
	else if(window.ActiveXObject) {
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}
	cat=cat.toLowerCase();
	nocache = Math.floor(Math.random() * 10000); // permet simplement a IE de ne pas mettre le fichier appele par l'ajax en cache !!!
	var fichier = "../../javascript/ajax_theme.php?theme="+idObj.value+"&cat="+cat;
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4) {
		t=xhr_object.responseText;
		document.getElementById("select_stheme").innerHTML=t;
	}








}





/*--------------------------- commentaires ---------------------------*/
function voir(item,topic,limit) {
	maj_commentaire(item,topic,limit);
	if(document.getElementById("voir").innerHTML=="Vedere") {
		document.getElementById("voir").innerHTML="Masquer";
		document.getElementById("item_comments").style.display="block";
	}else {
		document.getElementById("voir").innerHTML="Vedere";
		document.getElementById("item_comments").style.display="none";
	}
}

function rediger()
{
	if(document.getElementById("rediger").innerHTML=="Annullare") {
		document.getElementById("rediger").innerHTML="Commentare";
		document.getElementById("form_comment").style.display="none";
	}else {
		document.getElementById("rediger").innerHTML="Annullare";
		document.getElementById("form_comment").style.display="block";
	}
}

function ajout_comment(item,topic,limit)
{
	if(document.getElementById("pseudo").value=="") {
		document.getElementById("alert_pseudo").innerHTML="nick vuoto!<br />";
		ok=false;
	}else {
		document.getElementById("alert_pseudo").innerHTML="";
		ok=true;
	}
	if(document.getElementById("text").value=="") {
		document.getElementById("alert_text").innerHTML="commento vuoto !<br />";
		ok=false;
	}else {
		document.getElementById("alert_text").innerHTML="";
		if (ok) {
			ok=true;
		}
	}
	if (ok) {
		document.getElementById("ajout").value="Aggiunta...";
		insert_comment(item,topic, limit);
	}
}

function insert_comment(item,topic,limit)
{
	var fichier = "../javascript/ajax_insert_comment.php";
	var data = "id="+item+"&topic="+topic;
	data += "&pseudo="+document.getElementById("pseudo").value
	data += "&text="+document.getElementById("text").value
	if (typeof limit!="number") {
		limit=5;
	}
	if(window.XMLHttpRequest) {
		xhr_object = new XMLHttpRequest();
	}else if(window.ActiveXObject) {
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}else {
		return(false);
	}
	xhr_object.open("POST", fichier, false);
	xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr_object.send(data);
	if(xhr_object.readyState == 4) {
		request = xhr_object.responseText;
	}else {
		request = false;
	}
	document.getElementById("ajout").value="Ajouter";
	if(request==1) {
		document.getElementById("rediger").innerHTML="Redigere";
		document.getElementById("form_comment").style.display="none";
		document.getElementById("voir").innerHTML="Masquer";
		document.getElementById("item_comments").style.display="block";
		document.getElementById("text").value="";
		maj_commentaire(item,topic,limit);
	}else {
		document.getElementById("rediger").innerHTML="Redigere";
		document.getElementById("form_comment").style.display="block";
		document.getElementById("alert_insert").innerHTML="service momentanément indisponible.";
		setTimeout("efface_alert()",4000);
	}
}

function maj_commentaire(item,topic,limit)
{
	if(window.XMLHttpRequest) {
		xhr_object = new XMLHttpRequest();
	}else if(window.ActiveXObject) {
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}else {
		return(false);
	}
	nocache = Math.floor(Math.random() * 10000); // permet simplement à IE de ne pas mettre le fichier appelé par l'ajax en cache !!!
	if (typeof limit!="number"){
		limit=5;
	}
	var fichier = "../javascript/ajax_maj_comment.php?item="+item+"&comment&topic="+topic+"&limit="+limit+"&"+nocache;
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4) {
		comment = xhr_object.responseText;
		document.getElementById("item_comments").innerHTML=comment;
	}else {
		comment = false;
	}
	fichier = "../javascript/ajax_maj_comment.php?item="+item+"&topic="+topic+"&nb&"+nocache;
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4) {
		nb = xhr_object.responseText;
		document.getElementById("nb_comment").innerHTML=nb;
	}else {
		nb = false;
	}
}

function efface_alert()
{
	document.getElementById("alert_insert").innerHTML="";
}