

/*******************************************
 *
 * JS VideoGallery Class
 *
 * Created by Cary Buchmann May 26, 2010
 *
 * videoContainer - the div container that
 * the video object will be embedded in
 *
 * galleryContainer - the div container
 * that the galleryImages will be contained
 * in
 *
 ******************************************/

$(function(){
    var vG = new VideoGallery();
    vG.loadData();
    
    $(vG.imageSet).live('mouseover', function(){
        $(this).css('cursor', 'pointer');
    });
    $(vG.imageSet).live('mousedown', function(){
        var id = vG.extractUID( $(this).attr("id") );
        $("#video_embed").html($("#videolink_"+id).html());
    });
    $(".photogallery_image").live("mouseover", function(){
        $(this).css("border", "solid 2px black");
    }).live("mouseout", function(){
        $(this).css("border", "solid 2px #6e6e6e");
    });
    
    if($.browser.msie){
        $("#video_frame").css("height", 443);
        $("#video_slider").css("margin-top", 20);
    }
})

var VideoGallery = function()
{
    //change the urlLink to the proper location
    this.urlLink = "http://cp.inkrefuge.com/platinumstagesreciever/ajax_client.php";
    
    var gC = "video_thumbs";
    this.imageSet = "#"+gC+" img";
    this.videoPrefix = "#videolink_";
    this.imagePrefix = "#image_";
    this.videoData = "hey there";
    this.ajaxLink = this.urlLink+"?request=videos&callback=?";
    gC = "#"+gC;
    var vC =  "#video_embed";
    
    this.setup = function()
    {
        alert("ready");
    }
    
    this.loadData = function()
    {
        $.getJSON(this.ajaxLink, function(data) {
            $(vC).html(data.videolink[0]);
            
            var size = data.thumbimage.length*110;
            var html = "<div class = 'innerThumbFrame' style = 'width:"+size+"px; height:85px;'>";
            
            if(data.thumbimage.length <= 3)
                size = 500;
            
            var style = "height:75px; width:95px; margin-left:5px; margin-right:5px;";
            if($.browser.msie)
                style = "height:105px; width:95px; margin-left:5px; margin-right:5px;";
            
            $.each(data.thumbimage, function(i, thumb){
                html+="<img src = '"+thumb+"' id = 'image_"+i+"' style = '"+style+"' />";
            });
            $.each(data.videolink, function(i, video){
                html+="<div id = 'videolink_"+i+"' style = 'display:none;'>"+video+"</div>";
            });
            html+= "</div>"
            $(gC).append(html);
        });
    }
    
    this.extractUID = function(id)
    {
        var arr = id.split("_");
        return arr[1];
    }
}