// Liliwol Start of Hack
  var vote=1; // num max vote autorisé
  var url_radio="http://radio.mesbillets.com/inscription-radio.php" // url de la radio
  var autosu;
// LiliwoL EOH

// redir www
if(location.href.indexOf("http://mesbillets.com")!=-1){
	location.href="http://www.mesbillets.com";
}

// correction bug refferer
function blockError(){
	return true;
}

window.onerror=blockError;

function page_loaded(page_infos){

	if(page_infos!="accueil" && page_infos!="devenir_annonceur"){
		show_spec(); // nouveautés
		
		var url = document.URL;
		var urltest = document.URL.substring(url.indexOf(".com/",5),url.indexOf(".htm",0));
		
		if (urltest.indexOf('billet-',0) != -1){			
			urltest = urltest.substring(12);
			//console.log("urltest: " + urltest);
			switch (urltest){
				case "invitations":
					document.getElementById('lien_invitations').className = "selected";
					break;
				case "reduction":
					document.getElementById('lien_reductions').className = "selected";
					break;
				case "theatre":
					document.getElementById('lien_theatre').className = "selected";
					break;
				case "cafe-theatre":
					document.getElementById('lien_cafe_theatre').className = "selected";
					break;
				case "concerts":
					document.getElementById('lien_concerts').className = "selected";
					break;
				case "spectacle-enfants-famille":
					document.getElementById('lien_enfants').className = "selected";
					break;
				case "spectacle":
					document.getElementById('lien_spectacles').className = "selected";
					break;
				case "sport":
					document.getElementById('lien_sports').className = "selected";
					break;
				case "loisirs-musees":
					document.getElementById('lien_loisirs').className = "selected";
					break;
			}
		} else {
			if (urltest.indexOf('critique-spectacle-paris',0) != -1){
				document.getElementById('lien_critiques').className = "selected";
			}
			if (urltest.indexOf('interviews-theatre-paris',0) != -1){
				document.getElementById('lien_interviews').className = "selected";				
			}
		}
	}
	
	if(page_infos!="devenir_annonceur"){	
		show_coeur('pif'); // coups de coeurs
	}
	
	// Teste la bonne valeur
	if (document.body.scrollHeight > document.documentElement.scrollHeight){
		// Safari
		document.getElementById("centrage").style.height=eval((document.body.scrollHeight)+35)+"px"; // hauteur page
		document.getElementById("footer").style.top=eval((document.body.scrollHeight-35))+"px"; // hauteur page
	} else{
		// Autres
		document.getElementById("centrage").style.height=eval((document.documentElement.scrollHeight)+100)+"px"; // hauteur page
		document.getElementById("footer").style.top=eval((document.documentElement.scrollHeight-100))+"px"; // hauteur page
	}
	show_radio(0); // radio player ?
	//setTimeout("document.getElementById('waiter').style.display='none';document.getElementById('contenu').style.visibility='visible'",1000);
		document.getElementById('waiter').style.display='none';
		document.getElementById('contenu').style.visibility='visible';
	window.status="Bienvenue sur mesbillets.com !"
	
	if(page_infos=="accueil"){
		var inputR=document.getElementById("motcle");
		if(inputR){
			autosu=new AutoSuggest(document.getElementById("motcle"),null);
			//console.log("Autosu: " + autosu);
			/*document.forms.recherche.onsubmit=function(){return false};*/
		}
	}
	
	return true;
}


function show_radio(x){
	var tmp=location+"";	
  
	if(tmp.indexOf("radio=on")!=-1 || x==1){
		// On met en blanc l'onglet Radio et on désélecitonne les précédents
		var allHTMLTags = document.getElementsByTagName("a");
		for (var i=0; i<allHTMLTags.length; i++) {
			//Get all tags with the specified class name.
			if (allHTMLTags[i].className=="selected") {
				allHTMLTags[i].className = "";
			}
		}
		document.getElementById('lien_radio').className = "selected";
		
		window.open(url_radio,"radio","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=477,height=406,top=50,left=50");			
	}
	//return true;
}

function show_ads(type){

  var new_ad=new Array();
  var id_prio, id_ad;
  var p=0;
  var ext;
  
  for(var i=0;i<ad.length;i++){
    if(ad[i][1]==type){
      new_ad[p]=ad[i];
      p++;
    }
  } // keep only the type
  
  for(var i=0;i<new_ad.length;i++){
    if(new_ad[i].length>3){
      id_prio=i;
      break;
    }else{
      id_prio="none";
    }
  } // search priority
  
  if(id_prio=="none"){
    id_ad=Math.floor(new_ad.length * Math.random());
  }else{
    id_ad=id_prio;
  } // get priority or get random ad
  
  if (new_ad[id_ad]){
	  switch(new_ad[id_ad][2]){ // get extension
		case "0":
		  ext="gif";
		  break;
		case "1":
		  ext="jpg";
		  break;
		case "2":
		  ext="png";
		  break;
		case "3":
		  ext="swf";
		  break;
		}
		
		var ad_dim=ad_type[type].split(","); // get type dim
  
		  if(ext!="swf"){
			document.write("<img src='/img/ads/"+new_ad[id_ad][0]+"."+ext+"' width='"+ad_dim[0]+"' width='"+ad_dim[1]+"' onClick='get_ad("+new_ad[id_ad][0]+")' class='pub' alt=''/>")
		  }else{
			document.write("<object class='pub' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+ad_dim[0]+"' height='"+ad_dim[1]+"'><param name='movie' value='/img/ads/"+new_ad[id_ad][0]+".swf'><param name='quality' value='high'><embed src='/img/ads/"+new_ad[id_ad][0]+".swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+ad_dim[0]+"' height='"+ad_dim[1]+"'></embed></object>")
		  }
  }
  
}


function get_ad(id_ad){
	document.getElementById("helper").style.display="inline";
	document.getElementById("helper").innerHTML="<IFRAME SRC='ads.htm?id="+id_ad+"'></IFRAME>";
}


function visit_ad(url,target_type){
	switch(target_type){
		case 0:location.href=url;break
		case 1:window.open(url,"",",toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=750,height=550,top=50,left=50");break
		case 2:window.open(url,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=750,height=550,top=50,left=50");break
		}
}


function top(){
	document.body.scrollTo(0,0);
}


function getcontent(id){
	return document.getElementById(id).innerHTML;
}


function limit_char(id,limit){
	var temp=document.getElementById(id).value;
	if(temp.length>limit){
		document.getElementById(id).value=temp.substr(0,limit-3)+"...";
	}
}


function flush(){
	document.getElementById('helper').innerHTML="";
}


function popup(t,l,w,h,title,code_HTML){
	document.getElementById("popup_mb").innerHTML=""
		// titre popup
		+"<table width='"+w+"' border='0' cellpadding='0' cellspacing='0'><tr>"
		+"<td class='popup_c1'><img src='/img/pc1.gif' width='20' height='19' border='0' alt='' /></td>"
		+"<td width='"+(w-44)+"' class='popup_titre'>"+title+"</td>"
		+"<td><a href='javascript:popup_etat(0)'><img src='/img/pc2.gif' width='24' height='19' border='0' alt='' /></a></td>"
		+"</tr></table>"

		// contenu popup
		+"<table width='"+w+"' border='0' cellspacing='0' cellpadding='0' class='popup_fond'>"
		+"<tr><td style='height:"+(h-25)+"px;' align='center'>"+code_HTML+"</td></tr>"
		+"</table>"

		// bas popup
		+"<table border='0' cellspacing='0' cellpadding='0' style='height:6px;width:"+w+"px'><tr>"
		+"<td class='popup_c3'></td>"
		+"<td width='"+(w-12)+"' class='popup_c2'><img src='/img/pixel.gif'alt='' /></td>"
		+"<td class='popup_c4'></td>"
		+"</tr></table>";

	code_HTML+="<div id='popup_mb' style='position:absolute; left:"+l+"px; top:"+t+"px; width:"+w+"px; height:"+h+"px; z-index:9'>";
	document.getElementById("popup_mb").style.left=l+"px";
	document.getElementById("popup_mb").style.top=t+"px";
	popup_etat(1);	
}


function popup_etat(etat){
	var tmp=document.getElementById('popup_mb');
	
	if(etat==1){etat="visible"}else{
		document.getElementById("popup_mb").innerHTML="";
		etat="hidden";
	}
		
	/*if(navigator.appName.indexOf('Microsoft')!=-1){
		tmp.style.filter='blendTrans(duration=.7) progid:DXImageTransform.Microsoft.Shadow(direction=145,color=#777777,strength=5)';
		
		tmp.filters.blendTrans.apply();
		tmp.filters.blendTrans.play();
	}*/
	tmp.style.visibility=etat;
}


function sondage(r1,r2,r3){

	maxi=r1;
	if(r1>r2 && r1>r3){maxi=r1}
	if(r2>r1 && r2>r3){maxi=r2}
	if(r3>r1 && r3>r2){maxi=r3}

	var code_HTML="<div align='left'>";
	for(i=1;i<4;i++){
		code_HTML+="<b>"+document.getElementById("r"+i).innerHTML+" : </b>"+eval("r"+i)+" votes<br>"
		+"<img src='/img/pixel.gif' height='3' alt='' /><br /><img src='/img/red.gif' width='"+
		Math.round(((eval("r"+i)*200)/maxi))
		+"' height='5' class='sondage' alt='' />"
		if(i<3){
			code_HTML+="<br><img src='/img/pixel.gif' height='14' alt='' /><br/>"
		}
	}
	code_HTML+="</div>";

	popup(1106,206,225,140,"Résultats du sondage",code_HTML);

	r_user=1
	for(i=0;i<3;i++){
		if(document.form_sondage.reponse[i].status==true){
			r_user=i+1;
		}
	}

	if(vote>0){
		vote--;
		document.getElementById("helper").innerHTML="<IFRAME SRC='sondage.htm?r="+r_user+"'></IFRAME>";
	}
}


function check_fill(id){
	var def=document.getElementById(id).defaultValue;
	var val=document.getElementById(id).value;
	var txt;
	if(val==def){txt="";}
	if(val==""){txt=def;}
	if(val==def || val==""){
		document.getElementById(id).value=txt;
	}
	if(document.getElementById(id).value!=document.getElementById(id).defaultValue){
		document.getElementById(id).value=document.getElementById(id).value.toLowerCase();
	}
}


function quick_search(){
	var temp=document.getElementById("keyword").value;
	if(temp=="Saisir un mot clé !" || temp==""){
		popup(175,207,180,50,"Attention !","Vous devez saisir un mot-clé pour pouvoir effectuer une recherche rapide !");
	}else{
		submit_search();
	}
}


function submit_search(){
	if(document.getElementById("keyword").value==document.getElementById("keyword").defaultValue){
		document.getElementById("keyword").value="";
	}
	document.form_search.submit();
}


function newsletter(){
	var temp=document.getElementById("newsletter_email").value;
	if(temp=="Saisir une adresse email !" || temp==""){
		popup(665,206,180,50,"Attention !","Vous devez saisir une adresse email !");
	}else{
		document.getElementById("helper").innerHTML="<IFRAME SRC='newsletter.htm?email="+temp+"&from=fiche'></IFRAME>";
	}
}


function show_img(titre,target,ypos,w,h){
	popup(ypos,360,w+24,h+40,titre,"<img class='img_big' src='"+target+"' width='"+w+"' height='"+h+"' onClick='popup_etat(0)'");
}


function pass_lost(err){
	var pass_HTML="<table width='290' border='0' cellpadding='0' cellspacing='0' class='t11_nb'>"
	+"<tr><td height='30' colspan='2' class='t11_nb'>Recevez vos codes d'acc&egrave;s par e-mail :</td></tr>"
	+"<tr>"
	+"<td width='140'";

	if(err==1){pass_HTML+="class='t11_r'";}

	pass_HTML+=">Saisissez votre e-mail :</td>"
	+"<td><input name='receive_email' type='text' class='o_input' id='receive_email' maxlength='128' style='width:148px' onBlur='email_checker(this.id)'></td>"
	+"</tr>"
	+"<tr align='center' valign='bottom'>"
	+"<td height='35' colspan='3'><a href='javascript:pass_lost_send()'><img src='/img/send.gif' width='104' height='22' border='0' id='bt_lost_pass' onmouseover='roll(this.id,0)' onmouseout='roll(this.id,1)' alt='' /></a></td>"
	+"</tr>"
	+"</table>";

	popup(160,645,312,125,"Mot de passe égaré",pass_HTML);
	document.getElementById("receive_email").focus();
}


function pass_lost_send(){
    var temp=document.getElementById("receive_email").value;
    if(temp!=""){
        document.getElementById("helper").innerHTML="<IFRAME SRC='envoyer-codes-acces.htm?c="+temp+"'></IFRAME>";
    }else{
        pass_lost(1);
    }
}


function email_checker(id){
	var temp=document.getElementById(id).value;
	if(temp.indexOf("@")==-1 || temp.indexOf(".")==-1){
		document.getElementById(id).value="";
	}
}


function scroller(dir){
	direction=dir;
	scrolling=setInterval("do_scroll()",1);
}


function do_scroll(){
	texte_zone.scrollBy(0,5*direction);
}
	
	
function scroll_page(src,iframe_width){
	return "<div align=\'left\' style=\'position:absolute; left:12px; top:28px; width:355px; height:184px; z-index:1; overflow: hidden;\'>"
	+"<iframe scrolling=\'no\' frameborder=\'0\' width=\'"+(iframe_width-44)+"\' height=\'184\' src=\'"+src+"\' name=\'texte_zone\' alt=\'\' /></iframe>"
	+"</div>"
	+"<div style=\'position:absolute; left:"+(iframe_width-30)+"px; top:31px; width:30px; height:20px; z-index:3; overflow: hidden;\'>"
	+"<a href=\'#\' onMouseover=\'scroller(-1)\' onMouseout=\'clearInterval(scrolling)\'><img src=\'/img/up.gif\' border=\'0\'width=\'13\' height=\'20\' alt=\'\' />/a>"
	+"</div>"
	+"<div style=\'position:absolute; left:"+(iframe_width-30)+"px; top:188px; width:30px; height:20px; z-index:3; overflow: hidden;\'>"
	+"<a href=\'#\' onMouseover=\'scroller(1)\' onMouseout=\'clearInterval(scrolling)\'><img src=\'/img/down.gif\' border=\'0\'width=\'13\' height=\'20\' alt=\'\' />/a>"
	+"</div>";
}

// tire un id au pif dans la liste des spec
function get_random_id(){return ids_spec[Math.round((ids_spec.length-1)*Math.random())]}


// affiche liste spectacles
function show_spec(){

  var temp_rand=new Array(0);
  
  while(temp_rand.length<10){
  	var rand_id=get_random_id();
  	var err=0;
  	for(var p=0;p<temp_rand.length;p++){
      if(temp_rand[p]==rand_id[0]){err=1}
    }
  	if(err==0){
      temp_rand[temp_rand.length]=rand_id;
    }
  }
  
  var spec_HTML="<table cellpadding='0' cellspacing='0' border='0' style='width:100%;border: 1px solid #AAAAAA;padding:5px;padding-top:7px;padding-bottom:7px;background-color:#C9C9C9;'><tr><td>"
  
  	for(var i=1;i<10;i=i+3){
  	 spec_HTML+="<table cellpadding='0' cellspacing='0' border='0'><tr><td style='width:66px;padding-left:2px;'><a href='"+temp_rand[i][1]+"'><img src='/img/affiches/mini/a_"+temp_rand[i][0]+".png' width='42' height='63' border='0' class='affiche' id='bt_news_a_"+i+"' onmouseover='rollb(this.id)' onmouseout='rollb(this.id)' alt='' /></a></td><td style='width:10px;'>&nbsp;</td><td style='width:66px;'><a href='"+temp_rand[i+1][1]+"'><img src='/img/affiches/mini/a_"+temp_rand[i+1][0]+".png' width='42' height='63' border='0' class='affiche' id='bt_news_b_"+i+"' onmouseover='rollb(this.id)' onmouseout='rollb(this.id)' alt='' /></a></td><td style='width:10px;' alt='' />&nbsp;</td><td style='width:66px;'><a href='"+temp_rand[i+2][1]+"'><img src='/img/affiches/mini/a_"+temp_rand[i+2][0]+".png' width='42' height='63' border='0' class='affiche' id='bt_news_c_"+i+"' onmouseover='rollb(this.id)' onmouseout='rollb(this.id)' alt='' /></a></td></tr>";
  	 
     if(i<5) {
      spec_HTML+="<tr><td colspan='3' class='o_esp9'></td></tr>";
     }
  	}
  	
  	document.getElementById("liste_spec").innerHTML=spec_HTML+"</table></td></tr></table><img src='/img/pixel.gif' height='8' width='5' alt='' />";
}

// signaler critique qui pose problème
function report_abuse(id){
	document.getElementById("helper").innerHTML="<IFRAME SRC='signaler_critique.htm?id="+id+"'></IFRAME>";
}


// empêche la saisie de caractères spéciaux sauf -_.@
function no_special_chars(e){
	var code="";
	if(!e){
		e=window.event;
	}
	if(e.keyCode){
		code=e.keyCode;
	}else{
		code=e.which;
	}
	if(((code > 32 && code < 48) || (code > 57 && code < 65) || (code > 90 && code < 97)) && code!=45 && code!=46 && code!=64 && code!=95){return false}else{return true}
}

// passe en min
function lower_case(id){
	var tmp=document.getElementById(id);
	tmp.value=tmp.value.toLowerCase();
}

// passe en maj
function upper_case(id){
	var tmp=document.getElementById(id);
	tmp.value=tmp.value.toUpperCase();
}


// degrade de la zone critique
function show_degrade(){
	if(navigator.appName.indexOf("Microsoft")!=-1){
		document.getElementById("marquee_critique").style.height="115px";
		document.getElementById("deg_haut").style.backgroundColor="#C9C9C9";
		document.getElementById("deg_bas").style.backgroundColor="#C9C9C9";
		document.getElementById("deg_haut").style.filter="alpha(Opacity=100,FinishOpacity=0,Style=1,StartX=100,FinishX=100,StartY=0,FinishY=100)";
		document.getElementById("deg_bas").style.filter="alpha(Opacity=0,FinishOpacity=100,Style=1,StartX=100,FinishX=100,StartY=0,FinishY=100)";
	}else{
		document.getElementById("deg_haut").innerHTML="<img src='/img/deg_haut.png' width='160' height='15'>";
		document.getElementById("deg_bas").innerHTML="<img src='/img/deg_bas.png' width='160' height='15'>";
		document.getElementById("deg_bas").style.top="180px";
	}
}


// roll over alpha
function roll(id,etat){
  var tmp=document.getElementById(id).style;
	if(navigator.appName.indexOf("Microsoft")!=-1){
		if(etat==1){
      tmp.filter="alpha(opacity:100)";
    } else{
      tmp.filter="alpha(opacity:65)";
    } // ie
  }else{
    if(etat==1){
      tmp.opacity="1";
    }else{
      tmp.opacity=".65";
    }
  } // firefox
}


function rollb(id){
  var tmp=document.getElementById(id)
  if(tmp.className.indexOf("_b")==-1){tmp.className+="_b"}
	else{tmp.className=tmp.className.substr(0,tmp.className.length-2)}
}


// lecture d'une interview mp3
function play_mp3(id_zone,player_width,img_name){
  var ids=liste_ids_interview.split(";")
  for(var i=0;i<ids.length;i++){ // reste zones
  document.getElementById("mp3_zone_"+ids[i]).innerHTML="<a href=\"javascript:play_mp3("+ids[i]+","+player_width+",'"+img_name+"')\"><img src=\"/img/"+img_name+".gif\" border=\"0\" width=\""+player_width+"\" height=\"21\" id=\"bt_mini_i_"+ids[i]+"\" onmouseover=\"roll(this.id,0)\" onmouseout=\"roll(this.id,1)\"></a>"
  }
  
  document.getElementById("mp3_zone_"+id_zone).innerHTML="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='"+player_width+"' height='21' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab'><param name='movie' value='swf/player.swf?showDownload=false&songVolume=80&file=http://www.mesbillets.com/mp3/interviews/"+id_zone+".mp3&autoStart=true' /><param name='wmode' value='transparent' /><embed wmode='transparent' width='"+player_width+"' height='21' src='swf/player.swf?showDownload=false&songVolume=80&file=http://www.mesbillets.com/mp3/interviews/"+id_zone+".mp3&autoStart=true' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>"
}

function envoyer_email_ami(){ // envoi un message à un ami
	document.getElementById("helper").innerHTML="<IFRAME SRC='envoyer_a_un_ami.htm?message="+document.getElementById('message_ami').value+"&sujet="+document.getElementById('sujet_découverte').value+"&email="+document.getElementById('email_ami').value+"' name='send_frame'></IFRAME>";
}

/*var IE = document.all?true:false
// Liliwol Start of Hack
//if (!IE) document.captureEvents(Event.MOUSEMOVE)
if (!IE) {
	document.addEventListener(Event.MOUSEMOVE);
}
document.onmousemove = getMouseXY;
var xcpos = 0;
var ycpos = 0;

// Fonction stocke la position du curseur dans xcpos et ycpos
function getMouseXY(e) {	
	if (IE) {
		xcpos = event.clientX + document.body.scrollLeft;
		ycpos= event.clientY + document.body.scrollTop;
	}else{
		xcpos = e.pageX;ycpos = e.pageY;
	}  
	if (xcpos < 0){xcpos = 0;}
	if (ycpos < 0){ycpos = 0;}  
	return true;
}*/



