function flash(tag){document.write(tag);}
function detect_flash1(version){var hasFlash = DetectFlashVer(8, 0, 0);if (hasFlash){flash('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="354" height="154"><param name="movie" value="/flash/'+version+'anim1.swf" /><param name="quality" value="high" /><embed src="/flash/'+version+'anim1.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="354" height="154"></embed></object>');}else{flash('<a title="Gagner Argent" href="/"><img alt="" src="http://static.web-gagnant.net/design/'+version+'header/anim1.gif"></a>');}}
function detect_flash2(version){var hasFlash = DetectFlashVer(8, 0, 0);if (hasFlash)flash('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="483" height="154"><param name="movie" value="/flash/'+version+'anim2.swf" /><param name="quality" value="high" /><embed src="/flash/'+version+'anim2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="483" height="154"></embed></object>');else{flash('<a title="Gagner Argent" href="/"><img alt="" src="http://static.web-gagnant.net/design/'+version+'header/anim2.gif"></a>');}}
function favoris(){if(navigator.appName!='Microsoft Internet Explorer'){window.sidebar.addPanel("Web-Gagnant","http://www.web-gagnant.net","");}
else{window.external.AddFavorite("http://www.web-gagnant.net","Web-Gagnant");}}
function MM_swapImgRestore(){var i,x,a=document.MM_sr;for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)x.src=x.oSrc;}
function MM_preloadImages(){var d=document;if(d.images){if(!d.MM_p)d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preloadImages.arguments;for(i=0;i<a.length;i++)
if(a[i].indexOf("#")!=0){d.MM_p[j]=new Image;d.MM_p[j++].src=a[i];}}}
function MM_findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);if(!x&&d.getElementById)x=d.getElementById(n);return x;}
function MM_swapImage(){var i,j=0,x,a=MM_swapImage.arguments;document.MM_sr=new Array;for(i=0;i<(a.length-2);i+=3)
if((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;if(!x.oSrc)x.oSrc=x.src;x.src=a[i+2];}}
function loadURL(url,mydiv){var xhr_object=null;document.getElementById(mydiv).innerHTML='<div align="center"><img src="/images/loading.gif"></div>';if(window.XMLHttpRequest){xhr_object=new XMLHttpRequest();}
else if(window.ActiveXObject){xhr_object=new ActiveXObject('Microsoft.XMLHTTP');}
var method='GET';xhr_object.open(method,url,true);xhr_object.onreadystatechange=function(){if(xhr_object.readyState==4){var result=xhr_object.responseText;document.getElementById(mydiv).innerHTML=result;initShowHideDivs();}}
xhr_object.send(null);}
function postCommentAjax(url,id_article,pseudo,email,commentaire,mydiv){var xhr_object=null;commentaire=addslashes(commentaire);document.getElementById(mydiv).innerHTML='<div align="center"><img src="/images/loading.gif"></div>';if(window.XMLHttpRequest){xhr_object=new XMLHttpRequest();}
else if(window.ActiveXObject){xhr_object=new ActiveXObject('Microsoft.XMLHTTP');}
var method='POST';xhr_object.open(method,url,true);xhr_object.onreadystatechange=function(){if(xhr_object.readyState==4){var result=xhr_object.responseText;document.getElementById(mydiv).innerHTML=result;}}
xhr_object.setRequestHeader('Content-type','application/x-www-form-urlencoded');xhr_object.send('id_article='+id_article+'&pseudo='+pseudo+'&email='+email+'&commentaire='+commentaire);}
function postCommentNewsAjax(url,id_news,pseudo,email,commentaire,mydiv){var xhr_object=null;commentaire=addslashes(commentaire);document.getElementById(mydiv).innerHTML='<div align="center"><img src="/images/loading.gif"></div>';if(window.XMLHttpRequest){xhr_object=new XMLHttpRequest();}
else if(window.ActiveXObject){xhr_object=new ActiveXObject('Microsoft.XMLHTTP');}
var method='POST';xhr_object.open(method,url,true);xhr_object.onreadystatechange=function(){if(xhr_object.readyState==4){var result=xhr_object.responseText;document.getElementById(mydiv).innerHTML=result;}}
xhr_object.setRequestHeader('Content-type','application/x-www-form-urlencoded');xhr_object.send('id_news='+id_news+'&pseudo='+pseudo+'&email='+email+'&commentaire='+commentaire);}
function postNoteAjax(url,id_article,note,mydiv){var xhr_object=null;document.getElementById(mydiv).innerHTML='<div align="center"><img src="/images/loading.gif"></div>';if(window.XMLHttpRequest){xhr_object=new XMLHttpRequest();}
else if(window.ActiveXObject){xhr_object=new ActiveXObject('Microsoft.XMLHTTP');}
var method='POST';xhr_object.open(method,url,true);xhr_object.onreadystatechange=function(){if(xhr_object.readyState==4){var result=xhr_object.responseText;document.getElementById(mydiv).innerHTML=result;}}
xhr_object.setRequestHeader('Content-type','application/x-www-form-urlencoded');xhr_object.send('id_article='+id_article+'&note='+note);}
function postAstuceAjax(url,id_article,pseudo,email,titre,astuce,mydiv){var xhr_object=null;titre=addslashes(titre);astuce=addslashes(astuce);document.getElementById(mydiv).innerHTML='<div align="center"><img src="/images/loading.gif"></div>';if(window.XMLHttpRequest){xhr_object=new XMLHttpRequest();}
else if(window.ActiveXObject){xhr_object=new ActiveXObject('Microsoft.XMLHTTP');}
var method='POST';xhr_object.open(method,url,true);xhr_object.onreadystatechange=function(){if(xhr_object.readyState==4){var result=xhr_object.responseText;document.getElementById(mydiv).innerHTML=result;}}
xhr_object.setRequestHeader('Content-type','application/x-www-form-urlencoded');xhr_object.send('id_article='+id_article+'&pseudo='+pseudo+'&email='+email+'&titre='+titre+'&astuce='+astuce);}
function postNewsAjax(url,id_article,pseudo,email,titre,news,mydiv){var xhr_object=null;titre=addslashes(titre);news=addslashes(news);document.getElementById(mydiv).innerHTML='<div align="center"><img src="/images/loading.gif"></div>';if(window.XMLHttpRequest){xhr_object=new XMLHttpRequest();}
else if(window.ActiveXObject){xhr_object=new ActiveXObject('Microsoft.XMLHTTP');}
var method='POST';xhr_object.open(method,url,true);xhr_object.onreadystatechange=function(){if(xhr_object.readyState==4){var result=xhr_object.responseText;document.getElementById(mydiv).innerHTML=result;}}
xhr_object.setRequestHeader('Content-type','application/x-www-form-urlencoded');xhr_object.send('id_article='+id_article+'&pseudo='+pseudo+'&email='+email+'&titre='+titre+'&news='+news);}
function postTestAjax(url,texte,mydiv){var xhr_object=null;texte=addslashes(texte);document.getElementById(mydiv).innerHTML=texte;}
function addslashes(ch){ch=ch.replace(/\\/g,"\\\\");ch=ch.replace(/\'/g,"\\'");ch=ch.replace(/\"/g,"\\\"");ch=ch.replace(/\n/g,"<br>");ch=ch.replace(/\&/g,"\&");ch=ch.replace(/\€/g,"\&euro;");return ch}
function OpenPopup(url,nom,largeur,hauteur){popup=window.open(url,nom,"top=0,left=0,width="+largeur+",height="+hauteur+",menubar=no,scrollbars=yes,statusbar=no");}
//Sliding
var dhtmlgoodies_slideSpeed=30;var dhtmlgoodies_timer=10;var objectIdToSlideDown=false;var dhtmlgoodies_activeId=false;var dhtmlgoodies_slideInProgress=false;function showHideContent(e,inputId)
{if(dhtmlgoodies_slideInProgress)return;dhtmlgoodies_slideInProgress=true;if(!inputId)inputId=this.id;inputId=inputId+'';var numericId=inputId.replace(/[^0-9]/g,'');var answerDiv=document.getElementById('dhtmlgoodies_a'+numericId);var questionDiv=document.getElementById('dhtmlgoodies_q'+numericId);objectIdToSlideDown=false;if(!answerDiv.style.display||answerDiv.style.display=='none'){if(dhtmlgoodies_activeId&&dhtmlgoodies_activeId!=numericId){objectIdToSlideDown=numericId;slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1));}else{answerDiv.style.display='block';answerDiv.style.visibility='visible';questionDiv.style.background='transparent url(/design/news/bt-ranger.gif) no-repeat scroll right center';slideContent(numericId,dhtmlgoodies_slideSpeed);}}else{slideContent(numericId,(dhtmlgoodies_slideSpeed*-1));dhtmlgoodies_activeId=false;questionDiv.style.background='transparent url(/design/news/bt-deroulement.gif) no-repeat scroll right center';}}
function slideContent(inputId,direction)
{var obj=document.getElementById('dhtmlgoodies_a'+inputId);var contentObj=document.getElementById('dhtmlgoodies_ac'+inputId);height=obj.clientHeight;if(height==0)height=obj.offsetHeight;height=height+direction;rerunFunction=true;if(height>contentObj.offsetHeight){height=contentObj.offsetHeight;rerunFunction=false;}
if(height<=1){height=1;rerunFunction=false;}
obj.style.height=height+'px';var topPos=height-contentObj.offsetHeight;if(topPos>0)topPos=0;contentObj.style.top=topPos+'px';if(rerunFunction){setTimeout('slideContent('+inputId+','+direction+')',dhtmlgoodies_timer);}else{if(height<=1){obj.style.display='none';if(objectIdToSlideDown&&objectIdToSlideDown!=inputId){document.getElementById('dhtmlgoodies_a'+objectIdToSlideDown).style.display='block';document.getElementById('dhtmlgoodies_a'+objectIdToSlideDown).style.visibility='visible';slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed);}else{dhtmlgoodies_slideInProgress=false;}
document.getElementById('dhtmlgoodies_q'+inputId).style.background='transparent url(/design/news/bt-deroulement.gif) no-repeat scroll right center';document.getElementById('dhtmlgoodies_q'+objectIdToSlideDown).style.background='transparent url(/design/news/bt-ranger.gif) no-repeat scroll right center';}else{dhtmlgoodies_activeId=inputId;dhtmlgoodies_slideInProgress=false;}}}
function initShowHideDivs()
{var divs=document.getElementsByTagName('DIV');var divCounter=1;for(var no=0;no<divs.length;no++){if(divs[no].className=='dhtmlgoodies_question'){divs[no].onclick=showHideContent;divs[no].id='dhtmlgoodies_q'+divCounter;var answer=divs[no].nextSibling;while(answer&&answer.tagName!='DIV'){answer=answer.nextSibling;}
answer.id='dhtmlgoodies_a'+divCounter;var questionDiv=document.getElementById('dhtmlgoodies_q'+divCounter);questionDiv.style.background='transparent url(/design/news/bt-deroulement.gif) no-repeat scroll right center';contentDiv=answer.getElementsByTagName('DIV')[0];contentDiv.style.top=0-contentDiv.offsetHeight+'px';contentDiv.className='dhtmlgoodies_answer_content';contentDiv.id='dhtmlgoodies_ac'+divCounter;answer.style.display='none';answer.style.height='1px';divCounter++;}}}
function SendAlertForm(id,mail){var xhr_object=null;mail=addslashes(mail);document.getElementById('alert_form_'+id).innerHTML='<div align="center"><img src="/images/loading.gif"></div>';if(window.XMLHttpRequest){xhr_object=new XMLHttpRequest();}
else if(window.ActiveXObject){xhr_object=new ActiveXObject('Microsoft.XMLHTTP');}
var method='POST';xhr_object.open(method,'/alert_mail.php',true);xhr_object.onreadystatechange=function(){if(xhr_object.readyState==4){var result=xhr_object.responseText;document.getElementById('alert_form_'+id).innerHTML=result;}}
xhr_object.setRequestHeader('Content-type','application/x-www-form-urlencoded');xhr_object.send('mail='+mail+'&id='+id);}

// All part of the Dynamic Star Rating by Jordan Boesch!
// http://creativecommons.org/licenses/by-nc-nd/2.5/ca/
// PRE-LOAD IMAGES -----------------------------

if (document.images){
  pic1 = new Image(220,19); 
  pic1.src = "/images/rating_loading.gif"; 

  pic2 = new Image(25,75); 
  pic2.src = "/images/rating_star.gif"; 

  pic3 = new Image(25,75); 
  pic3.src = "/images/rating_star_2.gif"; 
  
  pic4 = new Image(16,13); 
  pic4.src = "/images/rating_tick.gif";
  
  pic5 = new Image(14,14); 
  pic5.src = "/images/rating_warning.gif";
}

// AJAX ----------------------------------------

var xmlHttp

function GetXmlHttpObject(){

var xmlHttp = null;

	try {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp = new XMLHttpRequest();
	  }
	catch (e) {
	  // Internet Explorer
	  try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e){
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	  
	return xmlHttp;

}

// Calculate the rating
function rate(rating,id,show5,showPerc,showVotes){

	xmlHttp = GetXmlHttpObject()
	
	if(xmlHttp == null){
		alert ("Your browser does not support AJAX!");
		return;
	  }

	xmlHttp.onreadystatechange = function(){
		
	var loader = document.getElementById('loading_'+id);
	var uldiv = document.getElementById('ul_'+id);
	
		if (xmlHttp.readyState == 4){ 
			
			//loader.style.display = 'none';
			var res = xmlHttp.responseText;
			
			//alert(res);
			
			if(res == 'already_voted'){
				
				loader.style.display = 'block';
				loader.innerHTML = '<div class="voted_twice">Vous avez d&eacute;j&agrave; vot&eacute;!</div>';
				
			} else {
				
				loader.style.display = 'block';
				loader.innerHTML = '<div class="voted">Merci d\'avoir vot&eacute;!</div>';

				if(show5 == true){
					var out = document.getElementById('outOfFive_'+id);
					var calculate = res/20;
					out.innerHTML = Math.round(calculate*100)/100; // 3.47;
					//out.innerHTML = Math.round((calculate*2),0)/2; // 3.5;
				} 
				
				if(showPerc == true){
					var perc = document.getElementById('percentage_'+id);
					//var newPerc = Math.round(Math.ceil(res/5))*5;
					var newPerc = res;
					perc.innerHTML = newPerc+'%';
				}
				
				else if(showPerc == false){
					var newPerc = res;
				}
				
				if(showVotes == true){
					var votediv = document.getElementById('showvotes_'+id).firstChild.nodeValue;
					var splitted = votediv.split(' ');
					var newval = parseInt(splitted[0]) + 1;
					if(newval == 1){
						document.getElementById('showvotes_'+id).innerHTML = newval+' Vote';
					} else {
						document.getElementById('showvotes_'+id).innerHTML = newval+' Votes';
					}
				}
				
				var ulRater = document.getElementById('rater_'+id);
				ulRater.className = 'star-rating2';
				
				var all_li = ulRater.getElementsByTagName('li');
				
				// start at 1 because the first li isn't a star
				for(var i=1;i<all_li.length;i++){
					
					all_li[i].getElementsByTagName('a')[0].onclick = 'return false;';
					all_li[i].getElementsByTagName('a')[0].setAttribute('href','#');
					
				}
				
				if(navigator.appName == 'Microsoft Internet Explorer'){
					uldiv.style.setAttribute('width',newPerc+'%'); // IE
				 } else {
					uldiv.setAttribute('style','width:'+newPerc+'%'); // Everyone else
				 }
				
			}
		} else {
			loader.innerHTML = '<img src="/images/rating_loading.gif" alt="loading" />';	
		}
	
	}
	var url = "/rating_process.php";
	var params = "id="+id+"&rating="+rating;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);

} 

function DisplayAlertForm(id) {
	document.getElementById('alert_form_'+id).innerHTML = '<form name="alertform" id="alertform"><img style="vertical-align: middle" src="/images/bell.png">&nbsp;Votre mail : <input type="text" id="alertmail" name="alertmail">&nbsp;<input id="alertmail-button" type="button" value="OK" onclick="javascript:SendAlertForm('+id+', alertmail.value);">&nbsp;<font color="red"><b>(&eacute;vitez les adresses hotmail)</b></font></form>';
}

$(document).ready(function() {
	jtip();
});