/**
 * Productions Vic Pelletier tous droits réservées
 * Tommy Brière
 * Avril 2009
 */(function(){
function setImgP(){
$j("#fond-video").hide();
$j("#fond-photo").show();}
function setImgV(){
$j("#fond-video").show();
$j("#fond-photo").hide();}

var PV= window.PhotoVideo= new function(){
function setUpOnglet(index, init){
var nav= OngletNavigateurs.getCurItem();
if(index==nav.getIndex()){
init();}
nav.get(index).onCreate= init;}
this.init= function(){
setUpOnglet(0, PV.Photo.init);
setUpOnglet(1, PV.Video.init);
var nav= OngletNavigateurs.getCurItem();
nav.get(0).onShow= setImgP;
nav.get(1).onShow= setImgV;}};

function PNAV(){
this.dz= new DynamicZone(this.RZ_ID, DynamicZoneJavascriptEval);
var me= this;
this.page= 0;
this.rech="";
this.set= function(r){
this.rech= r;
this.page= 0;
Tracking.event("Recherche",(this==P) ?"Photo" :"Vidéo" , r);
this.update();}
function dataRCV(data){
me.dz.setContenu(data);
me.afterDataRCV();}
this.afterDataRCV= function(){}
this.update= function(){
me.dz.setContenu("<p>Chargement en cours...</p>");
var url= this.action+"&action=recherche&rech="+ this.rech+"&nopage="+ this.page;
$j.get(url,{}, dataRCV);}
this.setPage= function(no){
me.page= no;
me.update();}
function apresRate(id, cote, data){
$j(".star-rating").show();
if(data=="OK" ){
$j(".rag_"+id).parent().find(".votre-vote").remove();
$j(".rag_"+id).after("<p class=\"votre-vote\">"+_TR("photovideo.votre_votre","Votre vote : {0}" , cote)+"</p>");} else{
alert(data);}}
this.rate= function(id, cote){
$j(".star-rating").hide();
var url= this.action+"&action=noter&note="+cote+"&id="+id;
$j.get(url,{}, function(data){ apresRate(id, cote, data)});}
this.incNbVue= function(id){
$j.get("/plugin.php",{
plugin:"photo" ,
action:"incNbVue" ,
id:id});}}

var P= PV.Photo= new function(){
var POPUP_PARAMS={callbackOnShow: affPhoto};
this.RZ_ID="liste-resultats-photo";
this.action="/plugin.php?plugin=photo";
PNAV.call(this);
this.recherche= function(){
this.set($j("#form-rechercher-photo input").val());}
function affPhoto(){
var h= this.itemArray[ this.itemCurrent].href;
h= h.substr(h.lastIndexOf("/")+1);
h= h.replace(".jpg","" );
P.incNbVue(h);}
this.init= function(){
P.update();
$j('.photo-de-lheure .image').fancybox(POPUP_PARAMS);
setImgP();}
this.afterDataRCV= function(){
$j('#liste-resultats-photo .image').fancybox(POPUP_PARAMS);}}

var V= PV.Video= new function(){
var POPUP_PARAMS={frameWidth: 750, frameHeight: 510};
this.RZ_ID="liste-resultats-video";
this.action="/plugin.php?plugin=video";
PNAV.call(this);
this.recherche= function(){
this.set($j("#form-rechercher-video input").val());}
this.play= function(lien,id){
var h='<div style="text-align: center">';
var uri='http://www.youtube-nocookie.com/v/'+lien;
uri+='&hl=fr&fs=1&rel=0&color1=0x006699&color2=0x54abd6&showinfo=0';
uri+='&autoplay=1';
h+= generateFlashHtml(uri, 640, 505, true,["allowscriptaccess","always" ,"allowfullscreen" ,"true"]);
h+="</div>";
this.incNbVue(id);
return h;}
this.init= function(){
V.update();
$j('.videos-regardees .thumb').fancybox(POPUP_PARAMS);
setImgV();}
this.afterDataRCV= function(){
$j('#liste-resultats-video .thumb').fancybox(POPUP_PARAMS);}}
$j(document).ready(function(){
PV.init();
$j('#fond-menu img, #fond-vert, #zone-contenu, #zone-contenu .bottom, #navigation').ifixpng();
$j('#main-body').animate({
backgroundPosition:"("+bgYPos+")"}, 800,"easeOutBack" , function(){
if($j.support.opacity){
$j('#container').css({opacity: 0, display:'block'});
var cssPos=-25;
$j('#liste-onglets li').each(function(i){
$j(this).css({'left': cssPos+"px"});
cssPos+= $j(this).width();});
$j('head').append('<style type="text/css">#menu-onglet .selected a {padding: 0 19px 12px 18px;} #menu-onglet .selected a .box {padding: 16px 29px 12px 28px;}</style>');
$j('#container').animate({opacity: 1}, 400);} else{
$j('#container').css({display:'block'});
var cssPos=-25;
$j('#liste-onglets li').each(function(i){
$j(this).css({'left': cssPos+"px"});
cssPos+= $j(this).width();});
$j('head').append('<style type="text/css">#menu-onglet .selected a {padding: 0 19px 12px 18px;} #menu-onglet .selected a .box {padding: 16px 31px 12px 30px;}</style>');}}
);});})();
