var webtelePath="webtele";var vrakAge=0;function openList(listId){$("#listContent"+listId).removeClass("invisible");$("#listHolder"+listId).addClass("grisfbg");$("#listHolder"+listId).removeClass("grisbg");$("#listBotSep"+listId).addClass("invisible");$("#listButton"+listId).attr("src","/"+webtelePath+"/_img/icone_moins.gif");$("#listLink"+listId).attr("href","javascript:closeList("+listId+");removeFromOpenedLists("+listId+");");}
function closeList(listId){$("#listContent"+listId).addClass("invisible");$("#listHolder"+listId).addClass("grisbg");$("#listHolder"+listId).removeClass("grisfbg");$("#listBotSep"+listId).removeClass("invisible");$("#listButton"+listId).attr("src","/"+webtelePath+"/_img/icone_plus.gif");$("#listLink"+listId).attr("href","javascript:openList("+listId+");addToOpenedLists("+listId+");");}
function addToOpenedLists(listId){var identifier="-"+listId+"-";var openedListsCookie=$.cookie("webteleOpenedLists");var previousCookieValue="";if(openedListsCookie)previousCookieValue=openedListsCookie;if(previousCookieValue.indexOf(identifier)==-1){$.cookie("webteleOpenedLists",previousCookieValue+identifier,{path:'/',expires:1});}}
function removeFromOpenedLists(listId){var identifier="-"+listId+"-";var openedListsCookie=$.cookie("webteleOpenedLists");var previousCookieValue="";if(openedListsCookie)previousCookieValue=openedListsCookie;if(previousCookieValue.indexOf(identifier)>-1){$.cookie("webteleOpenedLists",previousCookieValue.replace(identifier,""),{path:'/',expires:1});}}
function getPlaylistsToAdd(videoId){hideAllBoxes();var playlistsToAddHtml="<option value=\"\">Choisissez une liste</option>\n";checkLogin();if(memberLogged){if(playlistArray.length>0){var availableListCount=0;for(i=0;i<playlistArray.length;i++){var listId=playlistArray[i][0];var listName=playlistArray[i][1];var videoIdsInPlaylist=playlistArray[i][2];if(videoIdsInPlaylist.indexOf("-"+videoId+"-")==-1){playlistsToAddHtml+="<option value=\""+listId+"\">"+listName+"</option>\n";availableListCount++;}}
if(availableListCount!=0){$("#select_playlistsToAdd"+videoId).html(playlistsToAddHtml);$("#btn_liste_ajouter"+videoId+"_content").removeClass("invisible");$("#btn_liste_ajouter"+videoId+"_saved").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_erreur1").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_erreur2").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_erreur3").addClass("invisible");$("#btn_liste_ajouter"+videoId).removeClass("invisible");}else{$("#btn_liste_ajouter"+videoId+"_content").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_saved").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_erreur1").removeClass("invisible");$("#btn_liste_ajouter"+videoId+"_erreur2").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_erreur3").addClass("invisible");$("#btn_liste_ajouter"+videoId).removeClass("invisible");}}else{$("#btn_liste_ajouter"+videoId+"_content").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_saved").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_erreur1").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_erreur2").removeClass("invisible");$("#btn_liste_ajouter"+videoId+"_erreur3").addClass("invisible");$("#btn_liste_ajouter"+videoId).removeClass("invisible");}}else{$("#btn_liste_ajouter"+videoId+"_content").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_saved").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_erreur1").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_erreur2").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_erreur3").removeClass("invisible");$("#btn_liste_ajouter"+videoId).removeClass("invisible");}}
function addVideoToList(listId,videoId){var ieRant=Math.floor(Math.random()*1000001);$.ajax({type:"POST",url:"/"+webtelePath+"/_dyn/addVideoToList.jsp",data:"listId="+listId+"&videoId="+videoId+"&ieRant="+ieRant,dataType:"xml",success:function(xml){$("#btn_liste_ajouter"+videoId+"_content").addClass("invisible");$("#btn_liste_ajouter"+videoId+"_saved").removeClass("invisible");addToOpenedLists(listId);getMemberPlaylists();}});}
function checkOpenedLists(){var openedListsCookie=$.cookie("webteleOpenedLists");if(openedListsCookie){var listIds=openedListsCookie.split("-");for(i=0;i<listIds.length;i++)openList(listIds[i]);}
$("#listBox1").removeClass("invisible");$("#listBox2").removeClass("invisible");}
function showInfo(divId){$("#"+divId).removeClass("invisible");}
function toggleFaveType(listType){if(listType=="enVedette"){$("#enVedette").css("display","block");$("#listeLecture").css("display","none");}else{$("#enVedette").css("display","none");$("#listeLecture").css("display","block");}}
function toggleVideoType(listType){if(listType=="plusAimees"){$("#plusAimees").css("display","block");$("#plusCommentees").css("display","none");}else{$("#plusAimees").css("display","none");$("#plusCommentees").css("display","block");}}
function getVotes(){var ieRant=Math.floor(Math.random()*1000001);$.ajax({type:"GET",url:"/"+webtelePath+"/_dyn/getVoteCountForVideo.jsp",data:"videoId="+videoId+"&ieRant="+ieRant,dataType:"xml",success:function(xml){var points=$(xml).find("points").text();$("#voteCount").html(points+" personne"+(points>1?"s":"")+" l'aime"+(points>1?"nt":"")+"");}});}
function checkIfVoted(){var voteCookie="";var alreadyVoted=false;if($.cookie("webteleVote")!=null){voteCookie=$.cookie("webteleVote");alreadyVoted=voteCookie.indexOf("-"+videoId+"-")>-1;}
if(alreadyVoted){$("#voteLoading").removeClass();$("#voteLoading").addClass("invisible");$("#voteOff").removeClass();$("#voteOff").addClass("block");}else{$("#voteLoading").removeClass();$("#voteLoading").addClass("invisible");$("#voteOn").removeClass();$("#voteOn").addClass("block");}}
function addVote(){var ieRant=Math.floor(Math.random()*1000001);$.ajax({type:"POST",url:"/"+webtelePath+"/_dyn/addVoteForVideo.jsp",data:"videoId="+videoId+"&ieRant="+ieRant,dataType:"xml",success:function(xml){$("#voteOn").removeClass();$("#voteOn").addClass("invisible");$("#voteDone").removeClass();$("#voteDone").addClass("block");getVotes();}});}
function saveComment(commentTitle,commentText){var commentError="";if($.trim(commentTitle)==""||$.trim(commentTitle)=="Inscrivez un titre..."){commentError+="<div class=\"bold rouge\">Vous devez entrer un titre.</div>";}
if($.trim(commentText)==""){commentError+="<div class=\"bold rouge\">Vous devez entrer un texte.</div>";}else if(commentText.length>990){commentError+="<div class=\"bold rouge\">Votre texte doit faire 1000 caractères maximum.</div>";}
if(commentError==""){$("#commentBox").removeClass("block");$("#commentBox").addClass("invisible");$("#commentBoxLoading").removeClass("invisible");$("#commentBoxLoading").addClass("block");var ieRant=Math.floor(Math.random()*1000001);$.ajax({type:"POST",url:"/"+webtelePath+"/_dyn/saveCommentForVideo.jsp",data:"videoId="+videoId+"&commentTitle="+commentTitle+"&commentText="+commentText+"&ieRant="+ieRant,dataType:"xml",error:function(){$("#commentBox").html("Une erreur c'est produite en soumettant le commentaire, envoyez un message au webmestre avec le plus de détails possible. Merci!");$("#commentBox").removeClass("invisible");$("#commentBox").addClass("block");$("#commentBoxLoading").removeClass("block");$("#commentBoxLoading").addClass("invisible");},success:function(xml){var ajaxError=$(xml).find("error").text();if(ajaxError==''){$("#commentBoxDone").removeClass("invisible");$("#commentBoxDone").addClass("block")
$("#commentBoxLoading").removeClass("block");$("#commentBoxLoading").addClass("invisible");}else{$("#commentBox").html("Erreur : "+ajaxError);$("#commentBox").removeClass("invisible");$("#commentBox").addClass("block");$("#commentBoxLoading").removeClass("block");$("#commentBoxLoading").addClass("invisible");}}});}else{$("#commentError").html(commentError);$("#commentError").css("display","block");}
return false;}
function flagAsInappropriate(commentId){$("#bouton_achtung_"+commentId).html("<img src='/_img/loading_flash.gif' width='18' height='18' alt='Loading...' />");var ieRant=Math.floor(Math.random()*1000001);$.ajax({type:"POST",url:"/"+webtelePath+"/_dyn/flagCommentAsInappropriate.jsp",data:"commentId="+commentId+"&ieRant="+ieRant,dataType:"xml",error:function(){$("#message_achtung_"+commentId).html("Doh! Some kind of error occured on the server side!");},success:function(xml){var ajaxError=$(xml).find("error").text();if(ajaxError==''){$("#message_achtung_"+commentId).removeClass("invisible");$("#message_achtung_"+commentId).addClass("block");$("#bouton_achtung_"+commentId).removeClass("block");$("#bouton_achtung_"+commentId).addClass("invisible");$("#commentText_"+comment.id).addClass("invisible");}else{$("#message_achtung_"+commentId).html("Erreur : "+ajaxError);}}});}
var memberLogged=false;var memberId=0;var memberUsername="";function checkLoginForComments(){$.ajax({type:"GET",url:"/"+webtelePath+"/_dyn/checkLogin.jsp",dataType:"xml",success:function(xml){memberLogged=($(xml).find("logged").text()=="true");if(memberLogged){memberId=Number($(xml).find("id").text());memberUsername=$(xml).find("username").text();$("#loginOrCommentLoader").removeClass("block");$("#loginOrCommentLoader").addClass("invisible");$("#commentBox").removeClass("invisible");$("#commentBox").addClass("block");}else{$("#loginOrCommentLoader").removeClass("block");$("#loginOrCommentLoader").addClass("invisible");$("#commentLoginBox").removeClass("invisible");$("#commentLoginBox").addClass("block");}}});}
function checkLogin(){$.ajax({type:"GET",url:"/"+webtelePath+"/_dyn/checkLogin.jsp",dataType:"xml",success:function(xml){memberLogged=($(xml).find("logged").text()=="true");if(memberLogged){memberId=Number($(xml).find("id").text());memberUsername=$(xml).find("username").text();}}});}
function loadEpisodeSelect(programId,episodeId){var maxChar=25;if(programId>0){$.ajax({type:"GET",url:"/webtele/_dyn/getEpisodesWithVideosXml.jsp",data:"programId="+programId+"&episodeId="+episodeId,dataType:"xml",success:function(xml){var _select=document.getElementById('episodeId');for(var i=_select.length-1;i>-1;i--)_select.options[i]=null;$(xml).find('episode').each(function(){var _id=$(this).attr('id');var _selected=$(this).attr('selected');var _name=$(this).text();if(_name.length>maxChar){_name=_name.substring(0,maxChar)+'...';}
var _option;if(_selected=='1')_option=new Option(_name,_id,false,true);else _option=new Option(_name,_id,false,false);_select.options[_select.length]=_option;});}});}else{$("#episodeId").removeOption(/./);$("#episodeId").addOption("0","Choisissez une émission avant");}}
function goThickBox(title,url){$(document).ready(function(){tb_show(title,url,null);});}
function printPlayer(divId,flashSource,width,height,playerParameters)
{var flashParams={bgColor:"#000000",quality:"high",wmode:"transparent",swliveconnect:"true",allowScriptAccess:"always",allowFullScreen:true};var flashHtmlAttributes={id:"playerZ"};swfobject.embedSWF(flashSource,divId,width,height,"9.0.115","/_img/expressInstall.swf",playerParameters,flashParams,flashHtmlAttributes);}
function showPreRoll(){var preRollInterval=3;if((parseInt(getPreRollCookieValue())%preRollInterval)==0){incPreRollCookieValue();return true;}else{incPreRollCookieValue();return false;}}
function getPreRollCookieValue(){var value=0;var preRollCookie=$.cookie("preRollCookie");if(preRollCookie)value=parseInt(preRollCookie);return value;}
function incPreRollCookieValue(){var previousValue=0;var preRollCookie=$.cookie("preRollCookie");if(preRollCookie){previousValue=parseInt(preRollCookie);}else{previousValue=0;}
var newValue=previousValue+1;var date=new Date();date.setTime(date.getTime()+(1*24*60*60*1000));date.setHours(0);date.setMinutes(0);date.setSeconds(0);$.cookie("preRollCookie",newValue,{path:'/',expires:date});}
function getUserTimeZone()
{var timeZone=new Date().getTimezoneOffset()/60*-1;return(timeZone);}
function multiTagSyncRoadBlock(div,adTag){a=adTag.split(';');if(a.length>0){for(x=0;x<=a.length-1;x++)
{if(a[x].indexOf('sz=')==0)
{size=a[x].substring(3);dims=size.split('x');height=dims[0];width=dims[1];loadRBs(div,height,width,adTag);}}}}
function syncRoadBlock(adTag){multiTagSyncRoadBlock('myAd1',adTag);}
function loadRBs(s,w,h,adTag){document.getElementById(s).innerHTML='<iframe src="'+adTag+'" id="ifr_companion" width="'+w+'" height="'+h+'" marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no>'+'</iframe>';}
function printBandeauCompteur(div,totalVideos,sourceSwf,swfWidth,swfHeight){$(div).flash({src:sourceSwf,width:swfWidth,height:swfHeight,bgcolor:'#ffffff',quality:'high',menu:false,wmode:'transparent',swliveconnect:'true',allowScriptAccess:'always',allowFullScreen:true,flashvars:{videoCount:totalVideos}},{version:'9.0.115'});}