﻿// JScript File
function changeImageSrc(elemId,imageName)
{
    $(elemId).src="http://icons.aniboom.com/Awards2008/"+imageName;
}
function changeCursorMouseOut(elemId)
{

    $(elemId).style.cursor="default";
    //$(relTabId).style.textDecoration="none";
}
function changeCursorMouseOver(elemId)
{
    $(elemId).style.cursor="pointer";
   // $(relTabId).style.textDecoration="underline";
}
function changeDecorationMouseOut(elemId)
{
    //$(elemId).style.cursor="default";
    $(elemId).style.textDecoration="none";
}
function changeDecorationMouseOver(elemId)
{
    //$(elemId).style.cursor="pointer";
    $(elemId).style.textDecoration="underline";
}



function switchDisplayDivs(divToShow,divToHide)
{
    
    $(divToHide).style.display='none';
    $(divToShow).style.display='block';
}
/*_____________________________________________*/
/*RELATED COMPONENT (new videos)*/
/*---------------------------------------------*/
       
       
       var relatedTimer;  
        
       var  FlicksCollection = new FlicksCollectionClass();
            
            
        
        var RhBgImage;
        var AnalyticsOnLoad = false;
        function getNewVideos(conteinerId)
        {
        /*
            FlicksCollection.TargetPanel = conteinerId;
        
            FlicksCollection.Reset();               
            

            
            var baseUrl = "http://www.aniboom.com/Pages/Application/Feeds/Rss.aspx?sou=4&typ=42&sor=5&tim=1&adu=0&num=30&trg=1&itr=10&rnd=1";
            new Ajax.Request(baseUrl,
            {   parameters: '',
                method: 'post', 
                onSuccess: function(transport)
                {
                    clearTimeout(relatedTimer);
                    FlicksCollection.Reset();
                    eval(transport.responseText);
                    FlicksCollection.RenderResult(); 
                    FlicksCollection.PopulateImages();
                },
                
                onFailure: function(){
                    alert("problem with ajax");
                    //window.status = "problem with ajax";
                }
                
            });
             */   
        }

       
       function FlicksCollectionClass()
       {
            var me = this ;
            this.Items = new Array();
            this.Count=this.Items.length;
            this.TargetPanel = "";
            this.Content = "";
            this.ContentView = "";
            
            
            this.Reset = function(){
                this.Items = new Array();    
            }
            
            this.AddElement = function(elem){
            
                this.Items[this.Items.length] = elem;
                this.Count++;
            }
        
            this.GetElementByName = function(elemName){
                for(i=0;i<this.Items.length;i++){
                    if(this.Items[i].Id==elemName)
                    return this.Items[i];
                }
            }

            
            this.RenderResult = function()
            {
               this.Content = "";
               
               this.TargetPanel = $(this.TargetPanel);
               
               
                //prompt(tempItemsCollection,tempItemsCollection);
                this.Content+=NewVideosFrameTopHTML();
                for(i=0;i<this.Items.length;i++)
                { 
                    this.Content += RenderFlickItem(this.Items[i],i);
                }
                
                this.Content+=NewVideosFrameBottomHTML();
                this.TargetPanel.innerHTML = this.Content; 
            }
            
            this.PopulateImages=function()
            {
                for(m=0;m<this.Items.length;m++)
                {
                    $("img"+m).src=this.Items[m].ThumbUrl;
                }
            
            }
       }
    
    var defualtImg = new Image();
            defualtImg.src="http://icons.aniboom.com/animations/default.jpg";
    var bottomVideoCategory;
    function RenderFlickItem(flick,pos)
    {
        var bombsImg = switchToImg(flick.Rating);
        
        
        if(flick.Title.length>25)
        {   
            if(flick.Title.length>50)
            {
                flick.Title = flickTitleLength(flick.Title,47);
            }
            flick.Title = flickTitleBreakRow(flick.Title,50);
        }
        if(flick.CreatorName.length>21)
        {
            flick.CreatorName = flickTitleLength(flick.CreatorName,18);
        }
        
        
                return ""                       
                    + "<div id=\"container" + pos + "\" class=\"singleScoreContainer\" style=\"\">"
                        +"<div style=\"\">"
                            + "<div style=\"\" class=\"singleScoreImgDiv\" onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\">"
                                + "<a style=\"color:#000000;\" href=\""+flick.Url+"\">"
                                    + "<img onError=\"SetDefaultImage(this)\" id=\"img" + pos + "\" \" src=\"" + defualtImg.src + "\" class=\"singleScoreImgId\" />"
                                + "</a>"
                            + "</div>"
                            + "<div style=\"float:left;\">"
                                + "<a style=\"color:#000000;\" href=\""+flick.Url+"\">"
                                    + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\" style=\"margin-top:13px;width:175px; font-weight:bold;\"><span id=\"title" + pos + "\">" + flick.Title + "</span>"
                                    + "</div>"
                                + "</a>"
                                + "<a style=\"color:#000000;\" href=\""+flick.CreatorBoomZone+"\">"
                                    + "<div onmouseover=\"relatedTabMouseOver('creator"+pos+"')\" onmouseout=\"relatedTabMouseOut('creator"+pos+"')\" style=\"margin-top:2px;width:175px; \"><span id=\"creator" + pos + "\">by: " + flick.CreatorName + "</span>"
                                    + "</div>"
                                + "</a>"
                            + "</div>"
                        +"</div>"
                    + "</div>";
            
        
       
    }
    
    /* functions for rendering content into html - end*/
    
    

    function SetDefaultImage( obj ) {
        obj.onError!=SetDefaultImage;
       
       obj.src = "http://icons.aniboom.com/animations/default.jpg"

    }
    
    function switchToImg(fullRank)
    {
        fullRank=(fullRank % 0.5) > 0.25 ?
            (fullRank - (fullRank % 0.5) + 0.5) : fullRank - (fullRank % 0.5);
            
            var str =new String(fullRank);
            
            return ("bomb" + str.replace(".5","half") + ".gif");
    }
    
    function flickTitleLength(Title,tLength)
    {
        return Title.substr(0,tLength)+"...";
    }
    function flickTitleBreakRow(Title,tLength)
    {
        return Title.substr(0,25)+"<br />"+Title.substr(25,tLength);
    }
    function NewVideosFrameTopHTML()
    {
         return ""
         + "<div id=\"divScoreBoardSeeAllSubmissionsTop\" class=\"divScoreBoardSeeAllSubmissions divScoreBoardSeeAllSubmissionsTop\" >"
         + "<a style=\"color:#ffffff; font-family:Arial; font-size:11px;\" id=\"NewVideosSeeAllSubmissionsHrefTop\" class=\"ScoreBoardSeeAllSubmissionsHref ScoreBoardSeeAllSubmissionsHrefTop\" href=\""+seeAllSubmissionHref+"/1/MostRecent/All\" onmouseover=\"changeDecorationMouseOver('NewVideosSeeAllSubmissionsHrefTop');\" onmouseout=\"changeDecorationMouseOut('NewVideosSeeAllSubmissionsHrefTop');\">>See all <span class=\"ScoreBoardSeeAllSubmissionsNumber\">"+flickscount+"</span> submissions</a>"
         + "</div>"
         + "<div id=\"seconderyNewVideosTitleDiv\" class=\"seconderyTitleDiv\" onclick=\"javascript:window.location='"+jsAppath+"/awards2008/promotevideo/';\" onmouseover=\"changeCursorMouseOver('seconderyNewVideosTitleDiv');\" onmouseout=\"changeCursorMouseOut('seconderyNewVideosTitleDiv');\" style=\"margin-top:10px;\" runat = \"server\">"
         + "</div>";
    } 
    function NewVideosFrameBottomHTML()
    {
         return ""
         + "<div style=\"margin-bottom:10px;\" id=\"divScoreBoardSeeAllSubmissionsTop\" class=\"divScoreBoardSeeAllSubmissions divScoreBoardSeeAllSubmissionsBottom\" >"
         + "<a style=\"color:#ffffff; font-family:Arial; font-size:11px;\" id=\"NewVideosSeeAllSubmissionsHrefBottom\" class=\"ScoreBoardSeeAllSubmissionsHref ScoreBoardSeeAllSubmissionsHrefBottom\" href=\""+seeAllSubmissionHref+"/1/MostRecent/All\" onmouseover=\"changeDecorationMouseOver('NewVideosSeeAllSubmissionsHrefBottom');\" onmouseout=\"changeDecorationMouseOut('NewVideosSeeAllSubmissionsHrefBottom');\">>See all <span class=\"ScoreBoardSeeAllSubmissionsNumber\">"+flickscount+"</span> submissions</a>"
         + "</div>";
         
    } 
  //SwitchView( 'FinalistBottomFrame','FinalistBottomFrame');  
 






