

jQuery(document).ready(function(){



//hide the n2 with javascript
//jQuery("#n2").css({ display:"none"});

// Right column

jQuery("#right_column").html('');

//load right column content

//save the page title, to make set it inside the load, IE7 might otherwise add the anchor to each load call

document.originalTitle = document.title;

if (typeof rightColumnUri != 'undefined') {
jQuery("#right_column").load(rightColumnUri,'',function() {

document.title = document.originalTitle;

//set the right font-size
jQuery(".iframe").css({ fontSize:"1em"});

//we load the day date, the today trailer is the first one
manage_trailer_nav(0,"");

//be sure not to load the javascript each time the website is called

$.ajaxSetup({ cache: true });

jQuery.getScript("/de/2150256,templateId=renderJs,property=data,v=162,CmPart=com.arte-tv.www.js", function(){});

jQuery.getScript("/de/2150258,templateId=renderJs,property=data,v=23,CmPart=com.arte-tv.www.js", function(){});



$.ajaxSetup({cache: false});

openElements();

});

}

// AUDIO

//let's load a audio (autostart = true in coremedia editor in this case)

//if(typeof(audio_link) != "undefined" && audio_link.length>0) {

//  loadFile('id_article_audio_player',{file:audio_link[0],javascriptid:'audio_player',click_link:'',autostart:'false',width:'312',height:'0',volume:'80',usefullscreen:'false'});

//}

//load the first audio detail

if(typeof(audio_album_title) != "undefined" && audio_album_title.length>0) {
  jQuery("#id_article_audio .audio_album_title").html(audio_album_title[0]);

}

if(typeof(audio_track_title) != "undefined" && audio_track_title.length>0) {
  jQuery("#id_article_audio .audio_track_title").html(audio_track_title[0]);

}

if(typeof(audio_album_image) != "undefined" && audio_album_image.length>0 && audio_album_image[0] != "" &&

  typeof(audio_track_title) != "undefined" && audio_track_title.length>0)

{

  jQuery("#id_article_audio .audio_album_image").html('<img src="'+audio_album_image[0]+'" alt="'+audio_track_title[0]+'" />');

}

// VIDEO

//let's load a video (autostart = false in coremedia editor in this case)

//LOAD FIRST VIDEO IN VIDEO GALLERY (VIDEO REPORTAGE)
if(typeof(video_title) != "undefined" && video_title.length>0 &&
typeof(video_link_gallery) != "undefined" && video_link_gallery.length>0)
{



//set xiti var
xiti_a = video_xiti_a[0];
xiti_b = video_xiti_b[0];
xiti_c = video_xiti_c[0];


loadFile('video',{file:video_link_gallery[0],javascriptid:'video_player',click_link:'',autostart:'true',width:'610',height:'342',volume:'80',usefullscreen:'true'});



//and load the corresponding text
if(typeof(video_text) != "undefined" && video_text.length>0)
jQuery(".video_description").html(video_text[0]);



 //title
jQuery(".video_container h3").html(video_title[0]);
//and load the corresponding copyright

//was ultra buggy , updated by Thib.LION

var video_copyright_str = "";

if(typeof(video_copyright[0]) != "undefined" && video_copyright[0]!='')
jQuery(".video_container p.copyright").html(String.fromCharCode(0251)+" "+video_copyright[0]);
else
jQuery(".video_container p.copyright").html('');

//subtitle

if(typeof(video_subtitle) != "undefined" && typeof(video_subtitle[0]) != "undefined" && video_subtitle[0]!=''){
  jQuery(".video_container div.subtitle").html(video_subtitle[0]);

}

}

//VIDEO WITHOUT GALLERY, THAT IS DISPLAYED IN THE MAGAZIN LAYOUT

//There is only the video loaded by javascirpt, as there is no gallery with switching title, description....

if(typeof(simple_video_link) != "undefined" && simple_video_link!=""){



xiti_a = video_xiti_a;
xiti_b = video_xiti_b;
xiti_c = video_xiti_c;



loadFile('video',{file:simple_video_link,javascriptid:'video_player',click_link:'',autostart:'true',width:'610',height:'342',volume:'80',usefullscreen:'true'});

}



//new case 2012-02-09 for loadfile directly written in html

jQuery(".playerEmbed").each(function(i){

    

    var tab_id = jQuery(this).attr('id').split("_");

    var player_id = tab_id[2];

    

    //extract fileUrl

    if (jQuery("#player_"+player_id+"_jw").length != 0) { 

    var tab_file_url = jQuery("#player_"+player_id+"_jw").attr('flashVars').split("file=");

    tab_file_url = tab_file_url[1].split("&");

    file_url = tab_file_url[0];

   

    var xiti_c = player_id + "-" + file_url;



    //remove empty xiti_c

    jQuery("#player_"+player_id+"_jw").attr('flashVars',jQuery("#player_"+player_id+"_jw").attr('flashVars').replace('&xiti_arte.video_xiti_c=undefined',''));



    //add new one

    jQuery("#player_"+player_id+"_jw").attr('flashVars',jQuery("#player_"+player_id+"_jw").attr('flashVars')+'&xiti_arte.video_xiti_c='+xiti_c);



   //sbedelelelex
    var obj = jQuery("#player_"+player_id+"_jw");

    //aiiii t'as vu ?
    jQuery("#player_"+player_id+"_jw").remove();

    //then recreate it
    jQuery(this).append(obj);


    }

});





//VIDEO GALLERY IN ARTICLE

// the video shouldn't start automatically
if(typeof(video_link) != "undefined" && video_link.length>0)
{
//  destroy_all_players();

var autostart = false;

if(autostart)
loadFile('id_article_video_player',{file:video_link[0],javascriptid:'video_player',click_link:'',autostart:'true',width:'312',height:'177',volume:'80',usefullscreen:'true'});

else

{

jQuery('.article_video_player').html('<img src="/i18n/2150268,property=data,v=5.png" alt="" />');

jQuery(".article_video_player img").addClass('fake_player_image');

jQuery(".article_video_player img").bind("click",function(event){

destroy_all_players();

xiti_a = video_xiti_a[0];
xiti_b = video_xiti_b[0];
xiti_c = video_xiti_c[0];

loadFile('id_article_video_player',{file:video_link[0],javascriptid:'video_player',click_link:'',autostart:'true',width:'312',height:'177',volume:'80',usefullscreen:'true'});
});

}



}

//n2 appears
//setTimeout('jQuery(\'#n2\').show(\'slow\')', 1000);

//bind hiding video when rollover on main nav
if (!badBrowser)
{
jQuery('#main_nav ul li').bind("mouseover","",hide_video);
jQuery('#main_nav ul li').bind("mouseout","",show_video);

}

//ie7 : unbind all child DOM elements to avoid flickering
jQuery('#main_nav ul li *').unbind();

//bind click breadcrump "?"
jQuery("#what_is_it").bind("mouseover", function(event,data){
jQuery("#what_is_it_box").show();
});

//bind click breadcrump "?"
jQuery("#what_is_it").bind("mouseout", function(event,data){
jQuery("#what_is_it_box").hide();
});

//load the corresponding title

if(typeof(video_title) != "undefined" && video_title.length>0) {

  jQuery("#id_article_video h3").html(video_title[0]);

}

// the first video subtitle

if(typeof(video_text) != "undefined" && video_text.length>0) {

jQuery("#id_article_video div.subtitle").html(video_text[0]);

}

//load the first video copyright
if(typeof(video_copyright )!= 'undefined')

{

if(video_copyright[0]!= undefined && video_copyright[0]!="")
jQuery("#id_article_video p.copyright").html(String.fromCharCode(0169)+" "+video_copyright[0]);
else
jQuery("#id_article_video p.copyright").html('');

}

//apply the special class
jQuery("#video_0").addClass('selected');

//display the image (same id method than videos)

if(typeof(big_image_link) != "undefined" && big_image_link.length>0 &&
  typeof(image_link) != "undefined" && image_link.length>0)
{

  if (big_image_link[0] != "") {
    jQuery("#id_article_image_container").html('<a rel="lightbox" href="'+big_image_link[0]+'" title="'+image_title[0]+'"><img src="'+image_link[0]+'"/></a>');

  } else {

    jQuery("#id_article_image_container").html('<img src="'+image_link[0]+'"/>');

  }

}
//bind click on middle image to launch lightbox
jQuery('#id_article_image_container a[@rel*=lightbox]').lightBox();

//and load the corresponding subtitle

if(typeof(image_text) != "undefined" && image_text.length>0)
jQuery("#id_article_image p").html(image_text[0]);

///////////////////////////////video module and video reportage management

/**Video Reportage**/

jQuery('#tmb_nav_video').serialScroll({
items:'li',
prev:'a.prev_image',
next:'a.next_image',
axis:'x',
offset:-4, //when scrolling to photo, stop 230 before reaching it (from the left)
start:0, //as we are centering it, start at the 2nd
duration:600,
force:true,
stop:true,
lock:false,
cycle:true, //don't pull back once you reach the end
easing:'easeOutQuart', //use this easing equation for a funny effect
jump: false, //click on the images to scroll to them
onBefore:function( e, elem, $pane, $items, pos ){
 /**
  * 'this' is the triggered element
  * e is the event object
  * elem is the element we'll be scrolling to
  * $pane is the element being scrolled
  * $items is the items collection at this moment
  * pos is the position of elem in the collection
  * if it returns false, the event will be ignored
  */

                   // track the request
                   ajaxWeboTrack();
  //those arguments with a $ are jqueryfied, elem isn't.
 e.preventDefault();
 if( this.blur )
 this.blur();
},
onAfter:function( elem ){
 //'this' is the element being scrolled ($pane) not jqueryfied
}
});

/**Video Module**/

jQuery('#id_article_video_nav').serialScroll({
items:'li',
prev:'a.prev_video',
next:'a.next_video',
axis:'x',
offset:-4, //when scrolling to photo, stop 230 before reaching it (from the left)
start:0, //as we are centering it, start at the 2nd
duration:600,
force:true,
stop:true,
lock:false,
cycle:true, //don't pull back once you reach the end
easing:'easeOutQuart', //use this easing equation for a funny effect
jump: false, //click on the images to scroll to them
onBefore:function( e, elem, $pane, $items, pos ){
 /**
  * 'this' is the triggered element
  * e is the event object
  * elem is the element we'll be scrolling to
  * $pane is the element being scrolled
  * $items is the items collection at this moment
  * pos is the position of elem in the collection
  * if it returns false, the event will be ignored
  */

                   // track the request
                   ajaxWeboTrack();
  //those arguments with a $ are jqueryfied, elem isn't.
 e.preventDefault();
 if( this.blur )
 this.blur();
},
onAfter:function( elem ){
 //'this' is the element being scrolled ($pane) not jqueryfied
}
});

//bind click on video thumbnail
jQuery("#id_article_video_nav img").bind("click", function(event,data){

// track the request

ajaxWeboTrack();



xiti_a = video_xiti_a[this.id.substr(6)];

xiti_b = video_xiti_b[this.id.substr(6)];
xiti_c = video_xiti_c[this.id.substr(6)];



//now, let's play the corresponding video (we can retrieve the id by the thumbnail id)

loadFile('id_article_video_player',{file:video_link[this.id.substr(6)],javascriptid:'video_player',click_link:'',autostart:'true',width:'312',height:'177',volume:'80',usefullscreen:'true'});



//load the corresponding title
jQuery("#id_article_video h3").html(video_title[this.id.substr(6)]);

//and load the corresponding subtitle
jQuery("#id_article_video div.subtitle").html(video_text[this.id.substr(6)]);

//load the video copyright

if(typeof(video_copyright )!= 'undefined')

{

if(video_copyright[this.id.substr(6)]!= undefined && video_copyright[this.id.substr(6)]!="")
jQuery("#id_article_video p.copyright").html(String.fromCharCode(0169)+" "+video_copyright[this.id.substr(6)]);
else
jQuery("#id_article_video p.copyright").html('');

}

//apply the special class
jQuery("#id_article_video ul li img").removeClass('selected');
jQuery("#video_"+this.id.substr(6)).addClass('selected');

return false
 });

//bind click on image thumbnail with video_reportage
jQuery("div#video_reportage #tmb_nav_video ul li img").bind("click", "", gallery_video);
jQuery("div#video_reportage .prev_video_bottom img").bind("click", "", gallery_video);
jQuery("div#video_reportage .next_video_bottom img").bind("click", "", gallery_video);

//check if there is more than 3 videos elements, if yes, load the nav buttons
if(typeof(video_link_gallery) != "undefined" && video_link_gallery.length>0){
if(video_link_gallery.length>3 && jQuery("div.bottom_nav").html=='')
jQuery("div.bottom_nav").html('<a class="prev_video" href="#" ><img src="/i18n/2150938,property=data,v=2.png" alt="Previous image" /></a> <a class="next_video" href="#"><img src="/i18n/2150918,property=data,v=2.png" alt="Next video" /></a>');}

function gallery_video(){

originalTitle = document.title;

// track the request
ajaxWeboTrack();

//case click directly on thumbnail
if(this.className.indexOf("arrow-")==-1){
 id_current_pic = this.id.substring(this.id.indexOf("_")+1,this.id.length)

//stop all players in the right column

destroy_all_players();



xiti_a = video_xiti_a[this.id.substr(6)];
xiti_b = video_xiti_b[this.id.substr(6)];
xiti_c = video_xiti_c[this.id.substr(6)];



//loadfile...
loadFile('video',{file:video_link_gallery[this.id.substr(6)],javascriptid:'video_player',click_link:'',autostart:'true',width:'610',height:'342',volume:'80',usefullscreen:'true'});



//and load the corresponding text
if(typeof(video_text) != "undefined" && video_text.length>0)
jQuery(".video_description").html(video_text[id_current_pic]);



//title
jQuery(".video_container h3").html(video_title[id_current_pic]);

//and load the corresponding copyright

//was ultra buggy , updated by Thib.LION

var video_copyright_str = "";

if(typeof(video_copyright[id_current_pic]) != "undefined" && video_copyright[id_current_pic]!='')
jQuery(".video_container p.copyright").html(String.fromCharCode(0251)+" "+video_copyright[id_current_pic]);
else
jQuery(".video_container p.copyright").html('');

//subtitle

if(typeof(video_subtitle) != "undefined" && typeof(video_subtitle[id_current_pic]) != "undefined" && video_subtitle[id_current_pic]!='')
jQuery(".video_container div.subtitle").html(video_subtitle[id_current_pic]);

//apply the special class
jQuery("#tmb_nav_video ul li img").removeClass('selected');
jQuery("#tmb_nav_video ul li img#video_"+id_current_pic).addClass('selected');

}
else{

//cas click on bottom arrow
 jQuery('.next_video_bottom img').removeClass(this.className);
 jQuery('.prev_video_bottom img').removeClass(this.className);

 //set the correct classese to have the correct next and previous
 //case position and thumbnail are not sycnhronized
 if(this.parentNode.className=='next_video_bottom')
 {
 if( parseInt(id_current_pic)<video_link_gallery.length -1)
 id_current_pic=parseInt(id_current_pic)+1
 else
 id_current_pic=0
 jQuery('.next_video_bottom img').addClass('arrow-video_'+id_current_pic)
 i = current_pos
 while(i<id_current_pic)
 {
 jQuery(".next_video").click();
 i = i+1;
 }

//case last image
 if(id_current_pic==0)
 {
 jQuery(".next_video").click();
 }
 }
 if(this.parentNode.className=='prev_video_bottom')
 {
 if(parseInt(id_current_pic)>0)
 id_current_pic=parseInt(id_current_pic)-1
 else
 id_current_pic=video_link_gallery.length -1
 jQuery('.prev_video_bottom img').addClass('arrow-video_'+id_current_pic)
 i = current_pos
 while(i>id_current_pic)
 {
 jQuery(".prev_video").click();
 i = i-1;
 }
 //case last image
 if(id_current_pic==video_link_gallery.length -1)
 jQuery(".prev_video").click();

}
 if(id_current_pic!=current_pos)
 {
 i = current_pos
 while(i<=video_link_gallery.length -1)
 {
 jQuery(".next_video").click();
 i = i+1;
 }
 }
 jQuery("#video_"+id_current_pic).click();

}

document.title = originalTitle;

return false
 }

///////////////////////////////image module management

//LOAD FIRST IMAGE

if(typeof(image_title) != "undefined" && image_title.length>0 &&
  typeof(image_link) != "undefined" && image_link.length>0 &&
  typeof(big_image_link) != "undefined" && big_image_link.length>0)
{

//display the image (same id method than videos)
if (big_image_link[0] != "") {

//jQuery("#image").html('<a rel="lightbox_zoom" href="'+big_image_link[0]+'" title="'+image_title[0]+'"><img src="'+image_link[0]+'" alt="'+image_title[0]+'" /><div class="zoom"><img src="/i18n/2150288,property=data,v=3.jpg" alt="zoom" /></div></a>');

/////////////////////////////////////////////////////////////////////////////////////////////////////////////load the browseable gallery

i=0
while (i < big_image_link.length)
{
//test if it is the clicked image ?
if(i == 0)
{

//test if there is a description, if yes we load after the title
jQuery("#image").html(jQuery("#image").html() + '<a rel="lightbox_zoom" href="'+big_image_link[0]+'" title="'+image_title[0]+'" ><img src="'+image_link[0]+'" alt="'+image_title[0]+'" /><div class="zoom"><img src="/i18n/2150288,property=data,v=3.jpg" alt="zoom" /></div></a>');

}
else
{
 if(big_image_link[i]!='')
 {
 jQuery("#image").html(jQuery("#image").html() + '<a rel="lightbox_zoom" href="'+big_image_link[i]+'" title="'+image_title[i]+'" ></a>');
 }
}
i = i + 1;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

} else {

jQuery("#image").html('<img src="'+image_link[0]+'" alt="'+image_title[0]+'" />');

}

}

//bind click on middle image to launch lightbox
jQuery('#image a[@rel*=lightbox]').lightBox();

//and load the corresponding text

if(typeof(image_text) != "undefined" && image_text.length>0)
jQuery(".image_description").html(image_text[0]);

//title

if(typeof(image_title) != "undefined" && image_title.length>0)
jQuery(".image_container h3").html(image_title[0]);

//and load the corresponding copyright

if(typeof(image_copyright) != "undefined" && image_copyright.length>0 && image_copyright[0]!="")

jQuery(".image_container p.copyright").html(String.fromCharCode(0251)+" "+image_copyright[0]);

//subtitle

if(typeof(image_subtitle) != "undefined" && image_subtitle.length>0)
jQuery(".image_container div.subtitle").html(image_subtitle[0]);

//apply the special class
jQuery("#image_0").addClass('selected');

///////////////////////////////image module management

var current_pos = 0;

jQuery('#tmb_nav').serialScroll({
items:'li',
prev:'a.prev_image',
next:'a.next_image',
axis:'x',
offset:-4, //when scrolling to photo, stop 230 before reaching it (from the left)
start:0, //as we are centering it, start at the 2nd
duration:500,
force:true,
stop:true,
lock:false,
cycle:true, //pull back once you reach the end
easing:'easeOutQuart', //use this easing equation for a funny effect
jump: true, //click on the images to scroll to them
onBefore:function( e, elem, $pane, $items, pos ){
 /**
  * 'this' is the triggered element
  * e is the event object
  * elem is the element we'll be scrolling to
  * $pane is the element being scrolled
  * $items is the items collection at this moment
  * pos is the position of elem in the collection
  * if it returns false, the event will be ignored
  */
  //those arguments with a $ are jqueryfied, elem isn't.

                   // track the request
                  ajaxWeboTrack();
 e.preventDefault();
 if( this.blur )
 this.blur();
 current_pos = pos;
},
onAfter:function( elem ){
 //'this' is the element being scrolled ($pane) not jqueryfied
}
});

//bind click on image thumbnail
jQuery("#tmb_nav ul li img").bind("click", "", gallery);
jQuery(".prev_image_bottom img").bind("click", "", gallery);
jQuery(".next_image_bottom img").bind("click", "", gallery);

//check if there is more than 3 elements, if yes, load the nav buttons

if(typeof(image_link) != "undefined" && image_link.length>0){
  if(image_link.length>3 && jQuery("div.bottom_nav").html=='')
    jQuery("div.bottom_nav").html('<a class="prev_image" href="#" ><img src="" alt="Previous image" /></a> <a class="next_image" href="#"><img src="" alt="Next image" /></a>');

}

var id_current_pic = 0;

//add the regettred p.copyright

//jQuery(".image_container").append("<p class='copyright'></p>");

function gallery(){

// track the request
ajaxWeboTrack();

jQuery("#image").html('');

//case click directly on thumbnail
if(this.className.indexOf("arrow-")==-1){
 id_current_pic = this.id.substring(this.id.indexOf("_")+1,this.id.length)

//display the image (same id method than videos)
if(big_image_link[id_current_pic]!='')
{

//then construct the gallery browsable with "next" button
i=0
while (i < big_image_link.length)
{
//test if it is the clicked image ?
if(id_current_pic == i)
{

//test if there is a description, if yes we load after the title
jQuery("#image").html(jQuery("#image").html() + '<a rel="lightbox_zoom" href="'+big_image_link[id_current_pic]+'" title="'+image_title[id_current_pic]+'" ><img src="'+image_link[id_current_pic]+'" alt="'+image_title[id_current_pic]+'" /><div class="zoom"><img src="/i18n/2150288,property=data,v=3.jpg" alt="zoom" /></div></a>');

}
else
{
 if(big_image_link[i]!='')
 {
  jQuery("#image").html(jQuery("#image").html() + '<a rel="lightbox_zoom" href="'+big_image_link[i]+'" title="'+image_title[i]+'" ></a>');
 }
}
i = i + 1;
}

}
else
jQuery("#image").html('<img src="'+image_link[id_current_pic]+'" alt="'+image_title[id_current_pic]+'" />');

//bind click on middle image to launch lightbox
if(big_image_link[id_current_pic]!='')
jQuery('#image a[@rel*=lightbox_zoom]').lightBox();

//and load the corresponding text
if(typeof(image_text) != "undefined" && image_text.length>0)
jQuery(".image_description").html(image_text[id_current_pic]);

 //title
 jQuery(".image_container h3").html(image_title[id_current_pic]);
 //and load the corresponding copyright

//was ultra buggy , updated by Thib.LION

var image_copyright_str = "";

if(typeof(image_copyright[id_current_pic]) != "undefined" && image_copyright[id_current_pic]!='')

//jQuery(".image_container div.subtitle").html(String.fromCharCode(0251)+" "+image_copyright[id_current_pic]);
jQuery(".image_container p.copyright").html(String.fromCharCode(0251)+" "+image_copyright[id_current_pic]);

else

jQuery(".image_container p.copyright").html('');

 //subtitle
 jQuery(".image_container div.subtitle").html(image_subtitle[id_current_pic]);
 //apply the special class
 jQuery("#tmb_nav ul li img").removeClass('selected');
 jQuery("#tmb_nav ul li img#image_"+id_current_pic).addClass('selected');

}
else{//cas click on bottom arrow
 jQuery('.next_image_bottom img').removeClass(this.className);
 jQuery('.prev_image_bottom img').removeClass(this.className);
 //set the correct classese to have the correct next and previous
 //case position and thumbnail are not sycnhronized
 if(this.parentNode.className=='next_image_bottom')
 {
 if( parseInt(id_current_pic)<image_link.length -1)
 id_current_pic=parseInt(id_current_pic)+1
 else
 id_current_pic=0
 jQuery('.next_image_bottom img').addClass('arrow-image_'+id_current_pic)
 i = current_pos
 while(i<id_current_pic)
 {
 jQuery(".next_image").click();
 i = i+1;
 }
 //case last image
 if(id_current_pic==0)
 {
 jQuery(".next_image").click();
 }
 }
 if(this.parentNode.className=='prev_image_bottom')
 {
 if(parseInt(id_current_pic)>0)
 id_current_pic=parseInt(id_current_pic)-1
 else
 id_current_pic=image_link.length -1
 jQuery('.prev_image_bottom img').addClass('arrow-image_'+id_current_pic)
 i = current_pos
 while(i>id_current_pic)
 {
 jQuery(".prev_image").click();
 i = i-1;
 }
 //case last image
 if(id_current_pic==image_link.length -1)
 jQuery(".prev_image").click();

}
 if(id_current_pic!=current_pos)
 {
 i = current_pos
 while(i<=image_link.length -1)
 {
 jQuery(".next_image").click();
 i = i+1;
 }
 }
 jQuery("#image_"+id_current_pic).click();

}

return false
 }

///////////////////////////////audio module management

//bind click on audio link
jQuery("#id_article_audio ul li a").bind("click", function(event,data){



// track the request
ajaxWeboTrack();



//stop all players in the right column
destroy_all_players();



xiti_a = video_xiti_a[this.id];
xiti_b = video_xiti_b[this.id];
xiti_c = video_xiti_c[this.id];



//is it a wma ?
if(audio_link[this.id].indexOf(".wma")!=-1){
loadFile('id_article_audio_player',{file:audio_link[this.id],javascriptid:'audio_player',autostart:'true',width:'312',height:'0',volume:'80',usefullscreen:'false'},'wma');
}

//is it a real ? (I'm not sure there is all the possible extensions of realfiles)
if(audio_link[this.id].indexOf(".rm")!=-1){
loadFile('id_article_audio_player',{file:audio_link[this.id],javascriptid:'audio_player',autostart:'true',width:'312',height:'0',volume:'80',usefullscreen:'false'},'real');
}

//is it a mp3 ?
if(audio_link[this.id].indexOf(".mp3")!=-1){
loadFile('id_article_audio_player',{file:audio_link[this.id],javascriptid:'audio_player',click_link:'',autostart:'true',width:'312',height:'0',volume:'80',usefullscreen:'false'},'mp3');
}



//load the first audio detail

jQuery("#id_article_audio .audio_album_title").html(audio_album_title[this.id]);

jQuery("#id_article_audio .audio_track_title").html(audio_track_title[this.id]);

if (audio_album_image[this.id] != "") {

  jQuery("#id_article_audio .audio_album_image").html('<img src="'+audio_album_image[this.id]+'" alt="'+audio_track_title[this.id]+'" />');

} else {

  jQuery("#id_article_audio .audio_album_image").html('');

}

return false
});

///////////////////////////////////

var font_size = 1.15;

//bind click on plus button
jQuery("#plus").bind("click", function(event,data){

// track the request
ajaxWeboTrack();
  
if(font_size < 2.05)
font_size = font_size+0.3;

jQuery("#left_content div.text").css({ fontSize:font_size+"em"});
jQuery("h1.title").css({ fontSize:font_size+"em"});
jQuery("h2.top_title").css({ fontSize:font_size+"em"});
jQuery("p.intro").css({ fontSize:font_size+"em"});
jQuery(".n3 ul li").css({ fontSize:font_size+"em"});
jQuery("ul.playlist li").css({ fontSize:font_size+"em"});
jQuery("blockquote").css({ fontSize:font_size+"em"});
jQuery("div.link_box ul li").css({ fontSize:font_size+"em"});

jQuery("div#outlinks ul li").css({ fontSize:font_size+"em"});
jQuery("ul.horizontal_menu li").css({ fontSize:font_size+"em"});

/*special case for program_sheet*/
jQuery(".technical_sheet").css({ fontSize:"11px"});

return false
 });

//bind click on minus button
jQuery("#minus").bind("click", function(event,data){

// track the request
ajaxWeboTrack();
  
if(font_size > 1.15)
font_size = font_size-0.3;

jQuery("#left_content div.text").css({ fontSize:font_size+"em"});
jQuery("h1.title").css({ fontSize:font_size+"em"});
jQuery("h2.top_title").css({ fontSize:font_size+"em"});
jQuery("p.intro").css({ fontSize:font_size+"em"});
jQuery(".n3 ul li").css({ fontSize:font_size+"em"});
jQuery("ul.playlist li").css({ fontSize:font_size+"em"});
jQuery("blockquote").css({ fontSize:font_size+"em"});
jQuery("div.link_box ul li").css({ fontSize:font_size+"em"});

jQuery("div#outlinks ul li").css({ fontSize:font_size+"em"});
jQuery("ul.horizontal_menu li").css({ fontSize:font_size+"em"});

return false
 });

/////////////program sheet and so on

jQuery("a.details").bind("click", "", open_more);

function open_more(event) {

// track the request
ajaxWeboTrack();
if(exclude==false)
{
 var real_id;

//we must determine which element we have clicked on
 if(this.parentNode.id!='')
 {
 real_id = this.parentNode.id + "_overview";
 }
 else
 real_id = this.id;

jQuery("#"+real_id+'_more').animate({opacity: 'toggle' }, "slow");
 jQuery("#"+real_id+'_more').prev('tr').addClass('bronze');
}
else{
  return false;

}

return false;

}

/////////////////////////////////////////////services links /////////////////////////////////////////////////////////////

var exclude=false;
//var service_is_open=false;

//exclude roll over on div amigo,reminder and rebroadcaster
jQuery("table.program_grid tr td div.amigo").mouseover(function(){exclude = true})
jQuery("table.program_grid tr td div.amigo").mouseout(function(){exclude = false})
jQuery("table.program_grid tr td div.reminder").mouseover(function(){exclude = true})
jQuery("table.program_grid tr td div.reminder").mouseout(function(){exclude = false})
jQuery("table.program_grid tr td div.rebroadcaster").mouseover(function(){exclude = true})
jQuery("table.program_grid tr td div.rebroadcaster").mouseout(function(){exclude = false})

//rollover effect on program line

var obj_rollovered;//record the rollovered object

jQuery("table.program_grid tr td").mouseover(function(){

if( exclude==false && this.className != 'shadow' && jQuery(this).hasClass('more')==false)
{
var obj_rollovered = this

//right column
jQuery('table.program_grid').find("td").each(function(i) {

if(this.id=='')//on est sur la classe heure
{
 if(this == obj_rollovered)//on est sur le bon objet
 {
 jQuery(this.parentNode).addClass('bronze');
 jQuery(this.parentNode).next('tr').addClass('bronze');
 jQuery(".bronze .container").css({ display:"block"})
 }
}

if(this.id!='')//on est sur une des deux autres cellules
{
 if(this == obj_rollovered)//on est sur le bon objet
 {
 //we must determine which element we have clicked on

if(jQuery(this).hasClass('desc'))//cas cas desc
 {

if(this.id!='')
 real_id = this.id;
 jQuery(this.parentNode).addClass('bronze');
 jQuery(this.parentNode).next('tr').addClass('bronze');

 }
 else//cas barre tools
 {

 jQuery(this.parentNode).addClass('bronze');
 jQuery(this.parentNode).prev('tr').addClass('bronze');
 }
 }
}
});
}
jQuery(".bronze .service_container").css({ display:"block"})
})

//rollover effect on program line
jQuery("table.program_grid tr td").mouseout(function(){

jQuery(".bronze").removeClass('bronze');
jQuery(".service_container").css({ display:"none"});
jQuery(".service_container.open").css({ display:"block"});

})
function reset_service() {
jQuery("div.reminder").css({ display:"none"});
jQuery("div.rebroadcaster").css({ display:"none"});
jQuery('div.amigo').css({ display:"none"});
jQuery("div.pre_info_reminder").css({ display:"none"});
jQuery("div.pre_info_rebroadcaster").css({ display:"none"});
jQuery('div.pre_info_amigo').css({ display:"none"});
jQuery(" img.amigo_trigger").attr({ src: "/i18n/2533506,property=data,v=2.png"});
jQuery(" img.reminder_trigger").attr({ src: "/i18n/2533518,property=data,v=2.png"});
jQuery(" img.rebroadcaster_trigger").attr({ src: "/i18n/2533514,property=data,v=2.png"});
jQuery(".service_container").removeClass('open');
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////amigo

//EPG_Schedule
jQuery("td div.service_container img.amigo_trigger").click(function(){

//The page amigo service might be open and has hidden players, so we have to show them again.

show_video();

// track the request

ajaxWeboTrack();

var elementId = this.parentNode.parentNode.id;

exclude = true;
reset_service();

jQuery("li.social a.amigo").removeClass('amigo_opened');

//object = jQuery("#"+this.parentNode.parentNode.id+" div.amigo")
//object.show(function() {exclude=false;});

var uri = "uri_amigo_"+elementId;

jQuery("#"+elementId+" div#amigo_"+elementId).load(eval(uri),{},function(){

jQuery("#"+elementId+" div.amigo").toggle();

});
jQuery("#"+this.parentNode.parentNode.id+" img.amigo_trigger").attr({ src: "/i18n/2533524,property=data,v=2.png"});
jQuery("#"+this.parentNode.parentNode.id+" .service_container").addClass('open');
});

jQuery("td div.service_container img.amigo_trigger").mouseover(function(){
if(jQuery("#"+this.parentNode.parentNode.id+" div.amigo").css("display")=="none")
jQuery("#"+this.parentNode.parentNode.id+" div.pre_info_amigo").show(function() {exclude=false;
//z-index has to be increased for the clicked element, for others -> decrease
jQuery('div.pre_info_amigo').css({ zIndex:"101"})
jQuery('div.reminder').css({ zIndex:"100"})
jQuery('div.rebroadcaster').css({ zIndex:"100"})

});

jQuery("#"+this.parentNode.parentNode.id+" img.amigo_trigger").attr({ src: "/i18n/2533524,property=data,v=2.png"});
})

jQuery("td div.service_container img.amigo_trigger").mouseout(function(){
jQuery("#"+this.parentNode.parentNode.id+" div.pre_info_amigo").hide(function() {exclude=false;});

if(jQuery("#"+this.parentNode.parentNode.id+" div.amigo").css("display")=="none")
jQuery("#"+this.parentNode.parentNode.id+" img.amigo_trigger").attr({ src: "/i18n/2533506,property=data,v=2.png"});
})

/*********** Amigo Link for the top of Article Page ****/

jQuery("a.amigo.top").click(function(){

// track the request

ajaxWeboTrack();

var elementId = this.parentNode.parentNode.parentNode.id;

//manage link classes

if(jQuery("#"+elementId+' a.amigo.top').hasClass('amigo_opened')){

show_video();

jQuery("#"+elementId+' a.amigo.top').removeClass('amigo_opened');

jQuery("#"+elementId+" div.amigo.top").toggle();

}

else{

jQuery("#"+elementId+' a.amigo.top').addClass("amigo_opened");

//there might be another amigo service open, so we close all

reset_service();

hide_video();

jQuery(".service_container").css({ display:"none"});

var uri = "uri_amigo_"+elementId;

jQuery("#"+elementId+" div#amigo_"+elementId).load(eval(uri),{},function(){

jQuery("#"+elementId+" div.amigo.top").toggle();

});

}

return false;

});

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////reminder
jQuery("td div.service_container img.reminder_trigger").click(function(){

// track the request

ajaxWeboTrack();

var elementId = this.parentNode.parentNode.id;
exclude = true;
reset_service();

jQuery("li.social a.amigo").removeClass('amigo_opened');

//object = jQuery("#"+this.parentNode.parentNode.id+" div.reminder")
//object.show(function() {exclude=false;});

var uri = "uri_reminder_"+elementId;

jQuery("#"+elementId+" div#reminder_"+elementId).load(eval(uri),{},function(){

jQuery("#"+elementId+" div.reminder").toggle();

//close button
jQuery(".container_close").click(function(){
//jQuery(this.parentNode).css({ display:"none"});
reset_service();
})

});
jQuery("#"+this.parentNode.parentNode.id+" img.reminder_trigger").attr({ src: "/i18n/2533516,property=data,v=2.png"});
jQuery("#"+this.parentNode.parentNode.id+" .service_container").addClass('open');
});
jQuery("td div.service_container img.reminder_trigger").mouseover(function(){
if(jQuery("#"+this.parentNode.parentNode.id+" div.reminder").css("display")=="none")
jQuery("#"+this.parentNode.parentNode.id+" div.pre_info_reminder").show(function() {exclude=false;
//z-index has to be increased for the clicked element, for others -> decrease
jQuery('div.pre_info_reminder').css({ zIndex:"101"})
jQuery('div.amigo').css({ zIndex:"100"})
jQuery('div.rebroadcaster').css({ zIndex:"100"})

});

jQuery("#"+this.parentNode.parentNode.id+" img.reminder_trigger").attr({ src: "/i18n/2533516,property=data,v=2.png"});
})

jQuery("td div.service_container img.reminder_trigger").mouseout(function(){
jQuery("#"+this.parentNode.parentNode.id+" div.pre_info_reminder").hide(function() {exclude=false;});

if(jQuery("#"+this.parentNode.parentNode.id+" div.reminder").css("display")=="none")
jQuery("#"+this.parentNode.parentNode.id+" img.reminder_trigger").attr({ src: "/i18n/2533518,property=data,v=2.png"});
})

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////rebroadcaster
jQuery("td div.service_container img.rebroadcaster_trigger").click(function(){

// track the request

ajaxWeboTrack();

var elementId = this.parentNode.parentNode.id;
exclude = true;
reset_service();

jQuery("li.social a.amigo").removeClass('amigo_opened');

//object = jQuery("#"+this.parentNode.parentNode.id+" div.rebroadcaster")
//object.show(function() {exclude=false;});

var uri = "uri_rebroadcaster_"+elementId;

jQuery("#"+elementId+" div#rebroadcaster_"+elementId).load(eval(uri),{},function(){

jQuery("#"+elementId+" div.rebroadcaster").toggle();

//close button
jQuery(".container_close").click(function(){
//jQuery(this.parentNode).css({ display:"none"});
reset_service();
})

});
jQuery("#"+this.parentNode.parentNode.id+" img.rebroadcaster_trigger").attr({ src: "/i18n/2533520,property=data,v=2.png"});
jQuery("#"+this.parentNode.parentNode.id+" .service_container").addClass('open');
});
jQuery("td div.service_container img.rebroadcaster_trigger").mouseover(function(){
if(jQuery("#"+this.parentNode.parentNode.id+" div.rebroadcaster").css("display")=="none")
jQuery("#"+this.parentNode.parentNode.id+" div.pre_info_rebroadcaster").show(function() {exclude=false;
//z-index has to be increased for the clicked element, for others -> decrease
jQuery('div.pre_info_rebroadcaster').css({ zIndex:"101"})
jQuery('div.amigo').css({ zIndex:"100"})
jQuery('div.reminder').css({ zIndex:"100"})

});

jQuery("#"+this.parentNode.parentNode.id+" img.rebroadcaster_trigger").attr({ src: "/i18n/2533520,property=data,v=2.png"});
})

jQuery("td div.service_container img.rebroadcaster_trigger").mouseout(function(){
jQuery("#"+this.parentNode.parentNode.id+" div.pre_info_rebroadcaster").hide(function() {exclude=false;});

if(jQuery("#"+this.parentNode.parentNode.id+" div.rebroadcaster").css("display")=="none")
jQuery("#"+this.parentNode.parentNode.id+" img.rebroadcaster_trigger").attr({ src: "/i18n/2533514,property=data,v=2.png"});
})
/******************************************************************************************************************************************************************************/

/////////////////////////////////////end services links/////////////////////////////////////////

//revoir link
jQuery("td.bind_me .revoir").click(function(){

// track the request
ajaxWeboTrack();

was_open=false;

var elementId = this.parentNode.parentNode.id;

//let's record the inital state
if(jQuery("#"+elementId+' .revoir').hasClass('revoir_opened'))
was_open=true;

//kill all the players
jQuery('div.bloc2 div').html('');
jQuery('.bloc2').hide();
jQuery('.revoir').removeClass('revoir_opened');

//hide minisite
jQuery("#"+elementId+' .bloc1').hide();

//////mini_site remove style
if(jQuery("#"+elementId+' .mini_site').hasClass('mini_site_opened'))
jQuery("#"+elementId+' .mini_site').removeClass('mini_site_opened');

//toggle review aplyer
if(was_open==false)
{
 //z-index has to be increased for the clicked element, for others -> decrease
 jQuery(' .container').css({ zIndex:"100"})
 jQuery("#"+elementId+' .container').css({ zIndex:"101"})
 jQuery("#"+elementId+' .bloc2').show();
 jQuery("#"+elementId+' .revoir').addClass('revoir_opened');
 destroy_all_players('program');
 //launch the video
var uri = elementId+"_trailer_URL";
var click_uri = elementId+"_artePlus7_URL";
loadFile(elementId+'_trailer',{file:eval(uri),javascriptid:'revoir_id_program_trailer_player',click_link:eval(click_uri),autostart:'true',width:'240',height:'180',volume:'80'});
// loadFile(this.parentNode.parentNode.id+'_trailer',{file:'http://download.www.arte.tv/permanent/c0/teaser/'+video_date[id_date]+'_fr.FLV',javascriptid:'revoir_id_program_trailer_player',click_link:'',autostart:'true',width:'240',height:'180',volume:'80'});
}
});

//mini_site link
jQuery("td.bind_me .mini_site").click(function(){

// track the request
ajaxWeboTrack();
  
was_open=false;

//let's record the inital state
if(jQuery("#"+this.parentNode.parentNode.id+' .mini_site').hasClass('mini_site_opened'))
was_open=true;

jQuery('.bloc1').hide();
jQuery('.mini_site').removeClass('mini_site_opened');

//hide revoir
jQuery("#"+this.parentNode.parentNode.id+' .bloc2').hide();

//////revoir remove style
if(jQuery("#"+this.parentNode.parentNode.id+' .revoir').hasClass('revoir_opened'))
jQuery("#"+this.parentNode.parentNode.id+' .revoir').removeClass('revoir_opened');

//toggle minisite now
if(was_open==false)
{
 //z-index has to be increased for the clicked element, for others -> decrease
 jQuery(' .container').css({ zIndex:"100"})
 jQuery("#"+this.parentNode.parentNode.id+' .container').css({ zIndex:"101"})
 jQuery("#"+this.parentNode.parentNode.id+' .bloc1').show();
 jQuery("#"+this.parentNode.parentNode.id+' .mini_site').addClass('mini_site_opened');
}
});

//bind focus on input field
jQuery('input.textfield').bind("focus", function(event,data){
this.value = '';
return false

});

//Script to access a certein video in the VideoReportage, the Index is given bei an anchor with an integer value.

if(typeof(video_link_gallery) != "undefined" && video_link_gallery.length>0){

var pictureIndex = 0;

if(self.document.location.hash.length > 1){

pictureIndex = self.document.location.hash.substring(1);

}

if(parseInt(pictureIndex) < video_link_gallery.length){

for(var videoIndex = 0; videoIndex< parseInt(pictureIndex); videoIndex++){

jQuery("div#video_reportage .next_video_bottom img").click();

}

}

}

// call the print version, if we see the print=true parameter at the end.

url = window.location + '';

suffix='print=true';

if(url.match(suffix+"$")==suffix) window.setTimeout("window.print()", 2000);



jQuery.getScript("http://s7.addthis.com/js/250/addthis_widget.js#username=artegeie", function(){});

});

//end document ready





function initializeAudios() {

   //add the other tracks in the playlist
    var i=0;
    var ul_content='';
    for (i in audio_album_title){
      ul_content = ul_content + '<li><a href="javascript:void(0);" title="'+ audio_album_title[i] +'" id="'+i+'">' + audio_album_title[i] + '</a></li>';
      i++;
    }
    jQuery("#id_article_audio ul.playlist").html(ul_content);

}

// FAQs functionality

function initializeFAQs() {

   $("div.faq-answer").hide();
   $("div.faq-question").click(showFAQAnswer);

}

function showFAQAnswer() {

   // track the request
   ajaxWeboTrack();
   jQuery(this).nextAll("div.faq-answer:first").toggle();
}

/*Services functions */

function callReminder(){

jQuery('#'+divName).load(ajaxuri,{'method':'get','email':document.getElementById('email').value,'time1':document.getElementById('time1').checked,'time2':document.getElementById('time2').checked,'time3':document.getElementById('time3').checked,'artePlus7':document.getElementById('artePlus7').checked,'process':document.getElementById('process').checked});

}

function callRebroadcaster(){

jQuery('#'+divName).load(ajaxuri,{'method':'get','email':document.getElementById('email_rappel').value, 'process':document.getElementById('process').checked});

}

function callAmigo(){

jQuery('#'+divName).load(ajaxuri,{'method':'get','email':document.getElementById('email').value, 'process':document.getElementById('process').checked,'email_dest':document.getElementById('email_dest').value,'email_message':document.getElementById('email_message').value,'name':document.getElementById('name').value });

}

function addToCookie(value) {
if (value.length == 0) return;

var cookieName = 'acc';
var separator = '#';
var currentValue = getCookie(cookieName);
var newValue = value;
//IE has a limit of 4095 characters per cookie, including the cookie name and the equals-char
var maxSize = 4095 - (cookieName.length + 1);
var tmp = '';

//checks if value has the format we expect

var valueSplitted = value.split(':');
if (valueSplitted.length != 2) return;

var names = valueSplitted[0].split('|');
if (names.length != 3) return;

var values = valueSplitted[1].split('|');
if (values.length != 3) return;

//normalize key to lowercase

var key = names[0];
var lowerKey = key.toLowerCase();
newValue = newValue.replace(key, lowerKey);

if (currentValue) {

var currentSplitted = currentValue.split(separator);

for (var i = currentSplitted.length-1; i >= 0; i--) {

//ignore current value for the key in the cookie
if (currentSplitted[i].indexOf(lowerKey) != 0) {

//check if it still fits in the cookie
tmp = escape(currentSplitted[i] + separator + unescape(newValue));
if (tmp.length > maxSize) break;
newValue = tmp;
}
}
}

else {

newValue = escape(newValue);

}
document.cookie = cookieName + '=' + newValue + '; path=/;';
}
