/*
make_video.js
stream video
*/


function embedMovie(str_m_id, str_type, str_w, str_h)
{    
     
    var str_url;
    if (str_type == "y"){
         str_url = "http://www.youtube.com/v/" + str_m_id + "&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=1&amp;show_portrait=0&amp;color=#000&amp;fullscreen=1";  
    }
    else{
         str_url =  "http://vimeo.com/moogaloop.swf?clip_id=" + str_m_id + "&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=1&amp;show_portrait=0&amp;color=#000&amp;fullscreen=1";
    }
    
    if (swfobject.hasFlashPlayerVersion("8")) {
        var att = { data:str_url, width:str_w, height:str_h };
        var par = { menu:"false", bgcolor:"#000000"};
        var id = "embedPlayer";
        var myFlashContent = swfobject.createSWF(att, par, id);
    }

}      


// <a href="javascript:{loadMovie('zEpeZm_f1Zk',61, 'Cocteau Twins ', 'y');}">
function loadMovie(str_m_id, int_rate_id, str_rate_t, str_type_video)
{
    // appler par le thumb on click
    //    
    $("#yt_type").attr("value", str_type_video);  
    $("#yt_r").attr("value", int_rate_id);  
    $("#yt_m").attr("value", str_m_id);
    $("#yt_t").attr("value", str_rate_t);
    $("#mainForm").submit();
}


function loadMoviePopUp(str_m_id, str_type_video, str_w, str_h)
{
    // appler par le thumb on click
    //  
    jQuery.facebox( "<div id='myEmbedPlayer'></div>" );
    embedMovie( str_m_id, str_type_video, str_w, str_h);    
    
 
}

function setMovie(str_w, str_h)
{
    // on load charge movie selon 
    // val dans form
    //    
    str_t = $("#yt_type").attr("value");    
    int_m = $("#yt_m").attr("value");    
    embedMovie( int_m, str_t, str_w, str_h);    
    
}
function updateForm(str_m_id, int_rate_id, str_rate_t, str_type_video)
{
    $("#yt_type").attr("value", str_type_video);  
    $("#yt_r").attr("value", int_rate_id);  
    $("#yt_m").attr("value", str_m_id);
    $("#yt_t").attr("value", str_rate_t);
}

function embedRating(str_prefix, boo_accueil)
{
    var str_rate_id = $("#yt_r").attr("value"); 
    var str_rate_text = $("#yt_t").attr("value");
    var str_id = "embedRating";
    var str_code = "<div class=\"js-kit-rating\" ";
    if (boo_accueil==true){
        str_code += "view=\"split\" ";
        str_code += "title=\""+str_rate_text+"\" path=\"/" +str_prefix+"_"+str_rate_id;
        str_code += "\" starColor=\"Ruby\"></div>";
        +$("#embedRating").append(str_code);
    }
    else{
        str_code += "view=\"combo\" ";
        str_code += "title=\""+str_rate_text+"\" path=\"/" +str_prefix+"_"+str_rate_id;
        str_code += "\" starColor=\"Ruby\"></div>";
        +$("#embedRating").append(str_code);    
    }
    
    
        
}

function embedTitre()
{
    var str = $("#yt_t").attr("value"); 
    //console.log(str);
    $("#embedTitre").append("<div class=\"mTitle\">"+str+"</div>");
}
function setCurrentThumb()
{
    var str_code = $("#yt_m").attr("value");    
    $("div[rel='"+ str_code+"']").addClass("current");  
}

// accueil
function hover_info(obj, booShow){
    var str_id = obj.attr("rel");
    str_id = jQuery.trim(str_id);
    if ( (str_id != "") && (str_id !=  $("#yt_m").attr("value") ) ){
                
        str_id = "#info_"+str_id;
        
        if (booShow){            
            obj.addClass("hover");
            var obj_offset = $("#playerBox").offset();
            $(str_id).css("top", obj_offset.top+360);            
            $(str_id).css("left", obj_offset.left+2);
              
            $(str_id).show();
            $("#embedRating").hide();            
        }
        else{
            obj.removeClass("hover");
            $(str_id).fadeOut("slow");
            $("#embedRating").show();
        }
    }
    
 
}

