﻿// JScript File

var ActionStatus='hide';
var chosenStage; 

var currentRelatedtab;
var relatedTimer;  

/*mp3 vars*/
var so1;
var so2;
var so3;
var so4;
var so5;
var so6;
var so7;
var so8;
var so9;
var so10;
var ap_instances = [1,2,3,4,5,6,7,8,9,10];
var PlayerID;
var PlayerIDOpen;
    
    /*function play chosen mp3 + stopAll others*/
    /*-----------------------------------------*/
    function ap_stopAll(playerID) 
    {
        if(!isPageLoad || PlayerIDOpen==playerID)
        {
            return;
        }
        PlayerID = playerID;
        
	    for(var i = 0;i<ap_instances.length;i++) 
	    {   
	        var embdContainer = null;
	        var embd = null;
	        if (navigator.appName.indexOf("Microsoft Internet")==-1)
            {
                embd = document.embeds["audioplayer" + ap_instances[i].toString()];
                //embdContainer=document.embeds["DVmicro" + ap_instances[i].toString()];
            }
	        else if (navigator.appName.indexOf("Microsoft Internet")!=-1)
            {
                embd = document.getElementById("audioplayer" + ap_instances[i].toString());
                
            }
            
	        embd.SetVariable("closePlayer",ap_instances[i] != playerID ? 1 : 0);    
	        
	        
        }
        
        
         
        setTimeout(function (){ 
        for(i = 0; i < ap_instances.length;i++) 
        {   
            if(ap_instances[i] == PlayerIDOpen){
                var codeToExe = "so" +  ap_instances[i] + ".write('DVmicro" + ap_instances[i] + "')";
                eval(codeToExe);
            }
        }
        PlayerIDOpen = playerID;
        },500);
    
    }

    
/*selected tmenu tab + stages popup display*/
/*------------------------------------------*/
    var div_display=[1,2,3,4,5];
    
    function ap_divDisplay(divId)
    {
        if(!isPageLoad)
        {
           return;
        }
      
        for(var i=0;i<div_display.length;i++)
        {
            if(divId=="stage"+div_display[i])
            {
                selectTab(div_display[i]);
                
                document.getElementById('tab'+ div_display[i]).style.backgroundImage="url('http://icons.aniboom.com/radiohead/firstStage/selectedTabImg.gif')";
                //backgroundColor='#0b0706';
                $("tab" + div_display[i]).IsChecked = true;
                document.getElementById('tab'+ div_display[i]).style.height='62px';
            }
            else
            {
                
                document.getElementById('tab'+ div_display[i]).style.backgroundImage="";
                document.getElementById('tab'+ div_display[i]).style.backgroundColor='#e9e9e9';
                $("tab" + div_display[i]).IsChecked = false;
                document.getElementById('tab'+ div_display[i]).style.height='61px';
            }
        }
    }
    
    /*function menu tabs Mouseover*/
    /*--------------------*/
    function tubMouseover(tabId)
    {
     if(!$(tabId).IsChecked)
        {
        $(tabId).style.backgroundColor='#f5f5f5'; 
        $(tabId).style.cursor="pointer";
        }
    }
    
    /*function menu tabs Mouseout*/
    /*--------------------*/
    function tubMouseout(tabId)
    {
        if(!$(tabId).IsChecked)
        {
           $(tabId).style.backgroundColor='#e9e9e9'; 
           $(tabId).style.cursor="default";
        }
       
    

        
    }
    
    /*set stage info popup div position*/
    /*-----------------------------------*/
    var selectedElem = 'stage1Info';
    function selectTab(elemId)
    {
        if(selectedElem != null)
        {
            if(selectedElem=='stage'+elemId+'Info')
            {
                
            }
            else
            {
                $(selectedElem).style.display='none';
            }
        }
        var offsetParent    = $('tab'+elemId);
        var positions       = Position.cumulativeOffset(offsetParent);
        var infoPanel       = $('stage'+elemId+'Info');
        infoPanel.style.display = 'block';
      switch (elemId)
      {
        case 1:
        case 2:
        case 3:
        {
            infoPanel.style.left    = positions[0] + "px";
            break;
        }
        
        
//        case 4:
//        {
//            infoPanel.style.left    = positions[0] -((infoPanel.offsetWidth - offsetParent.offsetWidth)/2) + "px";
//            break;
//        }
        default:
        {
            infoPanel.style.left    = positions[0] -(infoPanel.offsetWidth - offsetParent.offsetWidth) + "px";
            //alert(positions[0] -(infoPanel.offsetWidth - offsetParent.offsetWidth) + "px");
            
            break;
        }
      }
        
        infoPanel.style.top     = positions[1] + offsetParent.offsetHeight + "px";
        selectedElem = 'stage'+elemId+'Info';
        
      
        
    }
    /**/
    
    
 var isRadioHeadPage=true;
/*function toggleBlocker opacity layer*/    
/*--------------------------------------*/
function toggleBlocker(action, stage){
    if(!isPageLoad)
        {
            return;
        }
     var action = action;
     
     if(isRadioHeadPage)
     {
         if(ActionStatus == 'show' && action == 'show' && stage!=currentStage || stage==currentStage && ActionStatus=='hide')
         {
           return;
         }
         if(stage==currentStage && ActionStatus=='show')
         {
             action='hide';
         }
         else if(action == 'hide' && stage == 'blocker')
         {
            stage = currentStage ;
         }
     }
    
    
    
     try
     {
     document.getElementById('ctl00_ContentPlaceHolder1_PlayerFrame').style.display='none';
     }
     catch(err)
     {
     //Handle errors here
     }

     
     

     containerHeight = (document.all) ? document.documentElement.offsetHeight-4 : document.documentElement.scrollHeight;
     bodyHeight = window.document.body.offsetHeight;
     currentHeight = 0;
     
     if (containerHeight < bodyHeight)
     {
     currentHeight = bodyHeight;
     }
     else 
     {
     currentHeight = containerHeight;
     }
     currentHeight = document.documentElement.scrollHeight;// yosi-update
     document.getElementById("blocker").style.height = currentHeight + "px";
        
     var Iblocker = document.getElementById("blocker");
     Iblocker.style.backgroundColor='#f5f5f5';
     if (action == "show"){
     if (stage!='blocker' && stage!='howToVote')
     {
        pageTracker._trackPageview("radiohead/stagechange/" + "virtual/");
     }

     Iblocker.style.display="block";
     new Effect.Opacity(
     Iblocker,
     {
     duration: 0.2,
     from:0.0,
     to:0.8

     }
     );
     if(isRadioHeadPage)
     {
         Event.observe(Iblocker, 'click',function(){
            toggleBlocker('hide', 'blocker');
            if(isRadioHeadPage){ap_divDisplay(currentStage)};$("CollaborationFrame").style.display="none";$("howToPopUp").style.display="none";
            
         } );
     }
     ActionStatus='show';
     }
     else{
     new Effect.Opacity(
     Iblocker,
     {
     duration: 0.2,
     from:0.8,
     to:0.0,
     afterFinish : function(){
     Iblocker.style.display="none";
     }
     }
     
     );
     ActionStatus='hide';
     
     Event.stopObserving(Iblocker, 'click',function(){
        toggleBlocker('hide', 'blocker');
        if(isRadioHeadPage){ap_divDisplay(currentStage)};$("CollaborationFrame").style.display="none";$("howToPopUp").style.display="none";
        
     } );
     }
}


/* changeImage onMouse Over/Out*/
/*------------------------------*/
function changeImage(elemId,imageName)
{
    $(elemId).src="http://icons.aniboom.com/radiohead/firstStage/"+imageName+'.gif';
}
/* changeImage B onMouse Over/Out*/
/*------------------------------*/
function changeImageB(elemId,imageName)
{
    $(elemId).src="http://icons.aniboom.com/radiohead/firstStage/partB/"+imageName+'.gif';
}
/* changeImage stage 2 onMouse Over/Out*/
/*------------------------------*/
function changeImageStage2(elemId,imageName)
{
    $(elemId).src="http://icons.aniboom.com/radiohead/stage2/"+imageName+'.gif';
}

 
    
/*Collaborate page */
/*-------------------*/
var todoScroll=false;
var scrollTopOldPosition=0;
function changeImageCollaborate(obj,imageName)
{
    $(obj).src="http://icons.aniboom.com/Collaboration/"+imageName;
}
function toggleCollaborateImage(isCollaborating)
{
  if( isRadioHeadPage)
  {
      if(isCollaborating=='True' )
      {
         $("ctl00_ContentPlaceHolder1_CreateCollaboratePanel").style.display="none";
         $("ctl00_ContentPlaceHolder1_EditCollaboratePanel").style.display="block";
      }
      else
      {
         $("ctl00_ContentPlaceHolder1_EditCollaboratePanel").style.display="none";
         $("ctl00_ContentPlaceHolder1_CreateCollaboratePanel").style.display="block";
      }
  }
  
  
}
Position.getWindowSize = function(w) {  
    var width, height;  
    w = w ? w : window;  
    width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);  height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);   
    return { width: width, height: height };
}
Position.center = function(element){
  var options = Object.extend({
      zIndex: 999,
      update: false
  }, arguments[1] || {});

  element = $(element)

  if(!element._centered){
      Element.setStyle(element, {position: 'absolute', zIndex: options.zIndex });
      element._centered = true;
  }
  var dims = Element.getDimensions(element);

  Position.prepare();
  var winSize = Position.getWindowSize();
  var winWidth = winSize.width;
  var winHeight = winSize.height;

  var offLeft = (Position.deltaX + Math.floor((winWidth-dims.width)/2));
  var offTop = (Position.deltaY + Math.floor((winHeight-dims.height)/2));
  element.style.top = ((offTop != null && offTop > 0) ? offTop : '0')+ 'px';
  element.style.left = ((offLeft != null && offLeft > 0) ? offLeft :'0') + 'px';

  if (options.update) {
    Event.observe(window, 'resize', function(evt) { Position.center(element); }, false);
    Event.observe(window, 'scroll', function(evt) { Position.center(element); }, false);
  }
}


function CloseIframe(iframeID)
 {
   if(isRadioHeadPage)
   {
        toggleBlocker('hide', 'blocker');
        if($(iframeID).style.display=="block")
        {
            todoScroll=true;
        }
        
                                                   
        $(iframeID).style.display="none";
        
        if(todoScroll)
        {
            document.documentElement.scrollTop = scrollTopOldPosition;
            todoScroll=false;
        }
   }
   else
      CloseIframeAndRefersh();
    
 }
 function CloseIframeAndRefersh()
 {
   url=window.location.href;
   
   if(window.frames['collaborationFrame'].DORefresh()=='True')
   {
        if(url.indexOf("signed") > -1)
           url=url.replace("signed"," ");  
      window.location.href=url
   }
   else
   {
     toggleBlocker('hide', 'blocker');
     $("CollaborationFrame").style.display="none";
    }
 }
 function OpenIframe(iframeID)
 {
    
    
    if(!isPageLoad)
        {
            return;
        }
    toggleBlocker('show', 'blocker');
    /*set CollaborationFrame position*/
        var offsetParent    = $('tab1');
        if(offsetParent!=null)
        {    
            var positions       = Position.cumulativeOffset(offsetParent);
                   
            $(iframeID).style.top     = positions[1] + offsetParent.offsetHeight + 450 + "px";
            $(iframeID).style.left    = positions[0] +50 + "px";
           
           scrollTopOldPosition = document.documentElement.scrollTop;
            /*set scrollTop position*/
            //window.pageYOffset=650;
            //document.body.scrollTop=650;
            document.documentElement.scrollTop=650;
            $(iframeID).style.display="block";
            if(iframeID=='CollaborationFrame')
            {
                window.frames['collaborationFrame'].ResizeWindow();
            }
        }
        else
        {
               Position.center(iframeID);
               $(iframeID).style.display="block";
//               window.frames['collaborationFrame'].ResizeWindow();
//               width=$("CollaborationFrame").style.width;
//               i=width.indexOf("px",0);
//               width=width.substr(0,i);
//               height=$("CollaborationFrame").style.height;
//               i=height.indexOf("px",0);
//               height=height.substr(0,i);
//               if (navigator.appName.indexOf("Microsoft Internet")>=0)
//               {
//                   alert(document.body.scrollLeft);
//                   alert(document.body.scrollTop);
//                   winX = (document.body.clientWidth-(document.body.scrollLeft + width)) * 0.5;
//                   winY = (document.body.clientHeight-(document.body.scrollTop + height)) * 0.5;
//               }
//               else
//               {
//                   winX = (window.innerWidth  - width) * 0.5;
//                   winY = (window.innerHeight - height) * 0.5;
//               
//               }
//                
//               $("CollaborationFrame").style.left=winX+'px';
//               $("CollaborationFrame").style.top=winY+'px'; 
        }
 
        
    

 }
 function CheckFromSignIn()
 {
   url=window.location.href;
   if(isRadioHeadPage)
   {
    if(url.indexOf("collaborate") > -1)
       OpenIframe('CollaborationFrame');
   }
   else
     if(url.indexOf("signed") > -1)
         OpenIframe('CollaborationFrame');     
   
 }
 function RedirectToSignIn(url)
 {

    if(isRadioHeadPage)
    {
      window.location.href=url;
    }
    else
      url=url.replace("radiohead/1","collaborate/2");
      window.location.href=url;
          
 }
 function Resizeframe(height)
 {
    $("CollaborationFrame").style.height=height;

 } 
 function AnalyticsPageTracker(SampleClick)
 {
     if($("CollaborationFrame").style.display!='none')
     { 
       page="collaboration/"+window.frames['collaborationFrame'].nowShowing;
       pageTracker._trackPageview(page+'/'+ "virtual/");
     }
     
     if(SampleClick!=null)
     {
        pageTracker._trackPageview("radiohead/" + currentStage + '/' + SampleClick+'/' + "virtual/");
        
     }
 } 
 
 
 /*_____________________________________________*/
/* Collaboration Search*/
/*---------------------------------------------*/
function SetMarkedRequest(obj,url)
{
   if(obj.checked)
   {
      $("MarkedRequests").src=url+"/a/obj.value";
      MarkedRequestCount++;
   }
   else
   {
      $("MarkedRequests").src=url+"/r/obj.value";
      MarkedRequestCount--;
   }
}
function ShowMarkedRequest(url)
{
  if(MarkedRequestCount>0)
  {
     winow.open(url);
  }
}








/*_____________________________________________*/
/*RELATED COMPONENT*/
/*---------------------------------------------*/
   var tempItemsCollection;
   var isPopulatedImages=false;
   function ReturnViewParams(viewId)
        {
            switch(viewId)
            {
                case "RadioheadTopRated":
                    if(staticFlag=='stage1')
                    {
                        return "sou=4&typ=35&sor=0&tim=1&adu=0&num=30&trg=1&itr=8&rnd=1";
                    }
                    return "sou=4&typ=36&sor=11&tim=1&adu=0&num=30&trg=1&itr=8&rnd=1";
                case "RadioheadRecent":
                    if(staticFlag=='stage1')
                    { 
                        return "sou=4&typ=35&sor=5&tim=1&adu=0&num=30&trg=1&itr=8&rnd=1";
                    }
                    return "sou=4&typ=36&sor=5&tim=1&adu=0&num=30&trg=1&itr=8&rnd=1";
                case "SemiFinalists":
                    /*the user "In_Rainbows_contest" favorites rss */ 
                    return "sou=3&typ=103432&sor=0&tim=1&adu=0&num=10&trg=1&itr=10&rnd=1";
                case "Finalists":
                    /*the user "in_roey" favorites rss */ 
                    return "sou=3&typ=140254&sor=0&tim=1&adu=0&num=13&trg=1&itr=13&rnd=1";
                case "FinalistBottomFrame":
                    /*the user "in_roey_9" favorites rss */ 
                    return "sou=3&typ=150154&sor=0&tim=1&adu=0&num=9&trg=1&itr=9&rnd=1";
                
                case "5Finalists":
                    /*the user "in_roey_5" favorites rss TO CREATE!!!*/ 
                    return "sou=3&typ=143895&sor=0&tim=1&adu=0&num=5&trg=1&itr=5&rnd=1";
                case "Testimonials":
                    /*the tag "radioheadTestimonials" rss */ 
                    return "sou=1&typ=33368&sor=0&tim=1&adu=0&num=6&trg=1&itr=3&rnd=1";   
            }
            return ReturnViewParams("RadioheadTopRated");
        }
        
       var  FlicksCollection = new FlicksCollectionClass();
            FlicksCollection.TargetPanel = "RelatedPanel";
            FlicksCollection.ContentView = ReturnViewParams("RadioheadTopRated");
        
        
        var AnalyticsOnLoad = false;
        function SwitchView(owner, viewType)
        {
                
             if(!isPageLoad)
              {
                 return;
              }
            
            
            if(currentRelatedtab!=owner && AnalyticsOnLoad==true)
            {
                AnalyticsPageTracker(owner);
            }
            AnalyticsOnLoad = true;
            currentRelatedtab = owner;
            var array=document.getElementsByClassName('dynamicRelatedTab');
           
            switch(currentRelatedtab)
            {
                case "tabBetting":
                case "tabClips":
                case "tabStoryboards":
                case "tabRelated":
                case "tabRelated2":
                {
                    if(staticFlag == 'stage1')
                    {
                        for(var x=0;x<array.length;x++)
                        {
                            array[x].href="http://www.aniboom.com/category/Radiohead%20Storyboards/1/TopRated/All";
                        }
                        break;
                    }
                    else
                    {
                        for(var x=0;x<array.length;x++)
                        {
                            
                            array[x].href="http://www.aniboom.com/category/Radiohead%20Videos/1/TopRated/All";
                        }
                        break;
                    }
                }
                case "tabRecent":
                {
                    if(staticFlag == 'stage1')
                    {
                        for(var x=0;x<array.length;x++)
                        {
                            array[x].href="http://www.aniboom.com/category/Radiohead%20Storyboards/1/MostRecent/All";
                        }
                        break;
                    }
                    else
                    {
                        for(var x=0;x<array.length;x++)
                        {
                            
                            array[x].href="http://www.aniboom.com/category/Radiohead%20Videos/1/MostRecent/All";
                        }
                        break;
                    }
                }
                case "tabSemiFinalists":
                {
                    for(var x=0;x<array.length;x++)
                    {
                        array[x].href="http://www.aniboom.com/category/Radiohead%20Storyboards/1/TopRated/All";
                    }
                    break;
                }
                case "tabTestimonials":
                case "tabFinalists":
                case "tab5Finalists":
                {
                    for(var x=0;x<array.length;x++)
                    {
                        array[x].href="http://www.aniboom.com/category/Radiohead%20Videos/1/TopRated/All";
                    }
                    break;
                }
             }
            
             
           
            if(currentRelatedtab!='FinalistBottomFrame')
            {
                $(owner).style.backgroundColor = "#4a4a4a";
                $(owner).style.height = 29 + "px";
                $(owner).style.color = "#ffffff";
                
                for(i=0;i<allRelatedTabs.length;i++)
                {
                    if(allRelatedTabs[i].id != owner)
                    {
                        allRelatedTabs[i].style.backgroundColor = "#ffffff";
                        allRelatedTabs[i].style.height = 28 + "px";
                        allRelatedTabs[i].style.color = "#4a4a4a";
                    }
                } 
            }
            
            if(currentRelatedtab=='tabBetting')
            {
                return;
            }


            
                FlicksCollection.Reset();
                FlicksCollection.ContentView = ReturnViewParams(viewType);
    
                //var baseUrl = "localhost/aniboom/Pages/Application/Feeds/Rss.aspx?" + FlicksCollection.ContentView;
                var baseUrl = "http://www.aniboom.com/Pages/Application/Feeds/Rss.aspx?" + FlicksCollection.ContentView;
                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 = "";
               if(currentRelatedtab=='tabSemiFinalists' )
               {
                    if( staticFlag=='stage2')
                    {
                        this.Content+=RenderGoldenImage();
                    }
                    else
                    {
                        this.Content+=RenderTheWinnerImage();
                    }
                
               }
               
               if(currentRelatedtab=='tab5Finalists' )
               {
                    this.Content+=Render5FinalistsImgHTML();
               }
               if(currentRelatedtab=='tabTestimonials' )
               {
                    this.Content+=RenderTestimonialsTopHTML();
               }
               this.TargetPanel = $(this.TargetPanel);
               
               switch (currentRelatedtab)
               {
                    case 'tabFinalists':
                    {
                        switch (currentStage)
                        {
                            case 'stage3':
                            {
                                this.Content+=Render13WinnersVoteImage();
                                for(i=0;i<this.Items.length;i++)
                                {   
                                    if(this.Items[i].Url.substr(29,6) == "219148" ||this.Items[i].Url.substr(29,6) == "233397" ||this.Items[i].Url.substr(29,6) == "212568")
                                    this.Content += RenderFlickItem(this.Items[i],i);   
                                    
                                }
                                for(i=0;i<this.Items.length;i++)
                                {   
                                    if(this.Items[i].Url.substr(29,6) != "219148" && this.Items[i].Url.substr(29,6) != "233397" && this.Items[i].Url.substr(29,6) != "212568")
                                    this.Content += RenderFlickItem(this.Items[i],i);   
                                    
                                }
                                break;
                            }
                            case 'stage4':
                            {
                                this.Content+=Render13WinnersImageStage4();
                                for(i=0;i<this.Items.length;i++)
                                {   
                                    this.Content += RenderFlickItem(this.Items[i],i);   
                                }
                                break;
                            }
                            default:
                            {
                                this.Content+=Render13WinnersImage();
                                for(i=0;i<this.Items.length;i++)
                                {   
                                    if(this.Items[i].Url.substr(29,6) == "219148" ||this.Items[i].Url.substr(29,6) == "233397" ||this.Items[i].Url.substr(29,6) == "212568")
                                    this.Content += RenderFlickItem(this.Items[i],i);   
                                    
                                }
                                for(i=0;i<this.Items.length;i++)
                                {   
                                    if(this.Items[i].Url.substr(29,6) != "219148" && this.Items[i].Url.substr(29,6) != "233397" && this.Items[i].Url.substr(29,6) != "212568")
                                    this.Content += RenderFlickItem(this.Items[i],i);   
                                    
                                }
                                break;
                            }
                        }
                        break;
                    }
                    case 'FinalistBottomFrame':
                    {
                        //prompt(tempItemsCollection,tempItemsCollection);
                        this.Content+=FinalistBottomFrameTopHTML();
                        //alert(this.Items.length);
                        var FinalistLoser;
                        if(this.Items[4].Url.substr(29,6)!="237964")
                        {
                           for(i=0;i<this.Items.length;i++)
                            {   
                               
                                if(this.Items[i].Url.substr(29,6) == "237964" )
                                {   
                                    FinalistLoser = i; 
                                    break;                     
                                }
                            }
                            var itemtoReplace=this.Items[4];
                            this.Items[4]=this.Items[FinalistLoser];
                            this.Items[FinalistLoser]=itemtoReplace; 
                        }
                        
                        for(i=0;i<this.Items.length;i++)
                        { 
                            switch(i)
                            {
                                case 4:
                                {
                                    bottomVideoCategory="<div style=\"text-align:left;padding-left:13px;\"><div style=\"text-align:center;height:17px;width:100px;border:2px solid #000000;border-bottom-width:0px;font-size:14px;background-color:#FCB577; \">Finalist</div></div>";
                                    this.Content += RenderFlickItem(this.Items[i],i); 
                                    break;
                                }
                                default:
                                {
                                    bottomVideoCategory="<div style=\"text-align:left;padding-left:13px;\"><div style=\"text-align:center;height:17px;width:100px;border:2px solid #000000;border-bottom-width:0px;font-size:14px;background-color:#ffffff; \">Semi-Finalist</div></div>"
                                    this.Content += RenderFlickItem(this.Items[i],i);
                                    break;
                                }
                            }
                        }    
                        
                        $(currentRelatedtab).style.height = 0 + "px";
                        break;
                    }
                    default :
                    {
                       for(i=0;i<this.Items.length;i++)
                       {
                            this.Content += RenderFlickItem(this.Items[i],i);        
                       }
                       break;
                    }
               }
               this.TargetPanel.innerHTML = this.Content; 
            }
            
            this.PopulateImages=function()
            {
                if(isPopulatedImages)
                {
                    return;
                }
                
                if(currentRelatedtab=='tabFinalists' && currentStage != 'stage4')
                {
                    for(m=0;m<this.Items.length;m++)
                    {
                        switch(this.Items[m].Url.substr(29,6))
                        {
                            case "219148":
                            {                       
                                $("img"+m).src="http://icons.aniboom.com/radiohead/relatedComponent/goldenWinners/vdtp.jpg";
                                break;
                            }
                            case "233397":
                            {
                                $("img"+m).src="http://icons.aniboom.com/radiohead/relatedComponent/goldenWinners/transmutation.jpg";
                                break;
                            }
                            case "212568":
                            {
                                $("img"+m).src="http://icons.aniboom.com/radiohead/relatedComponent/goldenWinners/nude_noodle.jpg";
                                break;
                            }
                            default:
                            {
                                $("img"+m).src=this.Items[m].ThumbUrl;
                                break;
                            }
                            
                            
                        }
                    }
                }
                else if(currentRelatedtab=='tabTestimonials')
                {
                    for(m=0;m<this.Items.length;m++)
                    {
                        switch(this.Items[m].Url.substr(29,6))
                        {
                            case "233107":
                            {                       
                                $("img"+m).src="http://icons.aniboom.com/radiohead/relatedComponent/testimonial/creator_1.jpg";
                                break;
                            }
                            case "233116":
                            {
                                $("img"+m).src="http://icons.aniboom.com/radiohead/relatedComponent/testimonial/creator_2.jpg";
                                break;
                            }
                            case "233106":
                            {
                                $("img"+m).src="http://icons.aniboom.com/radiohead/relatedComponent/testimonial/creator_3.jpg";
                                break;
                            }
                            case "233124":
                            {
                                $("img"+m).src="http://icons.aniboom.com/radiohead/relatedComponent/testimonial/creator_4.jpg";
                                break;
                            }
                            case "233572":
                            {
                                $("img"+m).src="http://icons.aniboom.com/radiohead/relatedComponent/testimonial/Wolfgang.jpg";
                                break;
                            }
                            case "236453":
                            {
                                $("img"+m).src="http://icons.aniboom.com/radiohead/relatedComponent/testimonial/Clement.jpg";
                                break;
                            }
                            default:
                            {
                                $("img"+m).src=this.Items[m].ThumbUrl;
                                break;
                            }
                            
                            
                        }
                    }
                
                }
//                else if(currentRelatedtab=='FinalistBottomFrame')
//                {
//                    var isInTemp;
//                    for(m=0;m<this.Items.length;m++)
//                    {
//                        isInTemp=false;
//                        for(t=0;t< tempItemsCollection.length;t++)
//                        {
//                           if(this.Items[m].Url.substr(29,6)== tempItemsCollection[t])
//                            {
//                                if(this.Items[m].Url.substr(29,6) == "237964")
//                                {
//                                    $("img"+m).src=this.Items[m].ThumbUrl;
//                                }
//                                isInTemp=true;
//                            }
//                        }
//                        if(!isInTemp)
//                        {
//                           $("img"+m).src=this.Items[m].ThumbUrl;
//                        }
//                    }
//                }
                else
                {
                    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>13)
        {
            flick.Title = flickTitleLength(flick.Title);
        }
        
        switch(currentRelatedtab)
        {
            case "tabSemiFinalists":
            {
                return "" 
                    + "<div id=\"container" + pos + "\" style=\"display:inline;text-align:center;margin-top:10px; margin-left:17px;margin-right:17px;float:left;width:80px;height:73px;\">" 
                    + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\"><a href=\""+flick.Url+"\"><img onError=\"SetDefaultImage(this)\" id=\"img" + pos + "\" style=\"width:68px;height:53px;border:2px solid #000000;\" src=\"" + defualtImg.src + "\""
                    + "class=\"RelatedImage\" /></div> "
                    + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\" style=\"margin-top:2px;\"><a class=\"relatedLink\" href=\""+flick.Url+"\"><span id=\"title" + pos + "\">" + flick.Title + "</span></a></div>"
                    + "</div>";
            }
            case "tabFinalists":
            {
                return "" 
                    + "<div id=\"container" + pos + "\" style=\"border:1px soid #ffffff;display:inline;text-align:center;margin-top:14px; margin-left:17px;float:left;width:70px;height:67px;\">" 
                    + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\"><a href=\""+flick.Url+"\"><img onError=\"SetDefaultImage(this)\" id=\"img" + pos + "\" style=\"width:61px;height:47px;border:2px solid #000000;\" src=\"" + defualtImg.src + "\""
                    + "class=\"RelatedImage\" /></div> "
                    + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\" style=\"margin-top:2px;\"><a class=\"relatedLink\" href=\""+flick.Url+"\"><span id=\"title" + pos + "\">" + flick.Title + "</span></a></div>"
                    + "</div>";
            }
            case "tab5Finalists":
            {
                return "" 
                    + "<div id=\"container" + pos + "\" style=\"border:1px soid #ffffff;display:inline;text-align:center;margin-top:10px; margin-left:28px;float:left;width:113px;height:115px;\">" 
                    + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"');relatedTabMouseOver('CreatorName"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"');relatedTabMouseOut('CreatorName"+pos+"')\"><a href=\""+flick.Url+"\"><img onError=\"SetDefaultImage(this)\" id=\"img" + pos + "\" style=\"width:100px;height:77px;border:2px solid #000000;\" src=\"" + defualtImg.src + "\""
                    + "class=\"RelatedImage\" /></div> "
                    + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\" style=\"margin-top:2px;\"><a class=\"relatedLink\" href=\""+flick.Url+"\"><span id=\"title" + pos + "\">" + flick.Title + "</span></a></div>"
                    + "<div onmouseover=\"relatedTabMouseOver('CreatorName"+pos+"')\" onmouseout=\"relatedTabMouseOut('CreatorName"+pos+"')\" style=\"margin-top:2px;\"><a class=\"relatedLink\" href=\""+flick.Url+"\"><span id=\"CreatorName" + pos + "\">by: " + flick.CreatorName + "</span></a></div>"
                    + "</div>";
            }
            case "FinalistBottomFrame":
            {
                return ""
                    + "<div id=\"container" + pos + "\" style=\"border:1px soid #ffffff;display:inline;text-align:center;margin-top:10px; margin-left:17px;float:left;width:130px;height:125px;\">"
                    +  bottomVideoCategory 
                    + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\"><a href=\""+flick.Url+"\"><img onError=\"SetDefaultImage(this)\" id=\"img" + pos + "\" style=\"width:100px;height:77px;border:2px solid #000000;\" src=\"" + defualtImg.src + "\""
                    + "class=\"RelatedImage\" /></div> "
                    + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\" style=\"margin-top:2px;\"><a class=\"relatedLink\" style=\"color:#373737;\" href=\""+flick.Url+"\"><span id=\"title" + pos + "\">" + flick.Title + "</span></a></div>"
                    + "</div>";
            }
            case "tabTestimonials":
            {
                if(pos != "2")
                {
                    return ""
                        + "<div id=\"container" + pos + "\" style=\"border:1px soid #ffffff;display:inline;text-align:center;margin-top:25px; margin-left:37px;float:left;width:105px;height:99px;\">" 
                        + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\"><a href=\""+flick.Url+"\"><img onError=\"SetDefaultImage(this)\" id=\"img" + pos + "\" style=\"width:96px; height:79px;\" src=\"" + defualtImg.src + "\""
                        + "class=\"RelatedImage\" /></div> "
                        + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\" style=\"margin-top:2px;\"><a class=\"relatedLink\" href=\""+flick.Url+"\"><span id=\"title" + pos + "\">Testimonial by:<br />" + flick.Title + "</span></a></div>"
                        + "</div>";
                }
                return ""
                        + "<div id=\"container" + pos + "\" style=\"border:1px soid #ffffff;display:inline;text-align:center;margin-top:25px; margin-left:37px;float:left;width:105px;height:99px;\">" 
                        + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\"><a href=\""+flick.Url+"\"><img onError=\"SetDefaultImage(this)\" id=\"img" + pos + "\" style=\"width:96px; height:79px;\" src=\"" + defualtImg.src + "\""
                        + "class=\"RelatedImage\" /></div> "
                        + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\" style=\"margin-top:2px;\"><a class=\"relatedLink\" href=\""+flick.Url+"\"><span id=\"title" + pos + "\">Testimonial by:<br />" + flick.Title + "</span></a></div>"
                        + "</div>"
                        + "<div style=\"clear:both;\"></div>"
                        + "<div style=\"margin-top:40px; float:right;margin-right:20px;width:135px;\">"
                        + "<a id=\"MoreTestimonials\" href=\"http://www.aniboom.com/search/Animations/radioheadtestimonial/1/0\" onmouseover=\"relatedTabMouseOver(this.id);\" onmouseout=\"relatedTabMouseOut(this.id);\" style=\"color:#ffffff;margin-left:10px;  font-size:13px;\">More testimonials ></a>"
                        + "</div>";
                                
            }
            default:
            {
                return "" 
                    + "<div style=\"display:inline;text-align:center;margin-top:10px; margin-left:18px;margin-right:15px;float:left;width:80px;height:115px;\">" 
                    + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\"><a href=\""+flick.Url+"\"><img onError=\"SetDefaultImage(this)\" id=\"img" + pos + "\" style=\"width:76px;height:59px;border:2px solid #000000;\" src=\"" + defualtImg.src + "\""
                    + "class=\"RelatedImage\" /></a></div> "
                    + "<div onmouseover=\"relatedTabMouseOver('title"+pos+"')\" onmouseout=\"relatedTabMouseOut('title"+pos+"')\" style=\"margin-top:2px;\"><a class=\"relatedLink\" href=\""+flick.Url+"\"><span id=\"title" + pos + "\">" + flick.Title + "</span></a></div>"
                    + "<div style=\"margin-top:2px;\"><img src=\"http://icons.aniboom.com/radiohead/relatedComponent/bombs/" + bombsImg + "\"/></div>"
                    + "<div style=\"color:#ffffff;font-size:11px;margin-top:2px;\" ><span>Views: " + flick.TotalHits + "</span></div>"
                    + "</div>";
            }
        }
        
       
    }
    
    /* functions for rendering content into html - start*/
    function RenderGoldenImage()
    {
        return ""
        +"<div style=\"display:inline;float:left;width:185px;height:57px;margin-left:22px;margin-right:21px;margin-top:10px;\" onmouseover=\"changeImageStage2('goldenImage','goldens_over')\" onmouseout=\"changeImageStage2('goldenImage','goldens_up')\">"
        +"<a href=\"http://www.Aniboom.com/Pages/Application/Competitions/Radiohead/RadioheadAdditionalInfo.aspx\">"
        +"<img id=\"goldenImage\" style=\"width:185px;height:57px;\" src=\"http://icons.aniboom.com/radiohead/stage2/goldens_up.gif\""
                    + "class=\"RelatedGoldenImage\" /></a></div>";
    }
    function RenderTheWinnerImage()
    {
        return ""
        +"<div style=\"display:inline;float:left;width:185px;height:57px;margin-left:22px;margin-right:21px;margin-top:10px;\" >"
        +"<img id=\"goldenImage\" style=\"width:185px;height:57px;\" src=\"http://icons.aniboom.com/radiohead/firstStage/PartB/theWinners.jpg\""
                    + "class=\"RelatedGoldenImage\" /></div>";
    }
    function Render13WinnersImage()
    {
        return ""
        +"<div style=\"display:inline;float:left;width:151px;height:51px;margin-right:4px;margin-left:20px;margin-top:14px;\" >"
        +"<img id=\"goldenImage\" style=\"width:151px;height:51px;\" src=\"http://icons.aniboom.com/radiohead/stage2/13WinnersImage.jpg\""
                    + "class=\"RelatedGoldenImage\" /></div>";
    }
    
    function Render13WinnersImageStage4()
    {
        return ""
        +"<div style=\"display:inline;float:left;width:151px;height:51px;margin-right:4px;margin-left:20px;margin-top:14px;\" >"
        +"<img id=\"goldenImage\" style=\"width:151px;height:51px;\" src=\"http://icons.aniboom.com/radiohead/stage2/13WinnersImageStage4.jpg\""
                    + "class=\"RelatedGoldenImage\" /></div>";
    }
    
    function Render13WinnersVoteImage()
    {
        return ""
        +"<div style=\"display:inline;float:left;width:151px;height:51px;margin-right:4px;margin-left:20px;margin-top:14px;\" >"
        +"<img id=\"goldenImage\" style=\"width:151px;height:51px;\" src=\"http://icons.aniboom.com/radiohead/stage2/13WinnersVoteImage.jpg\""
                    + "class=\"RelatedGoldenImage\" /></div>";
    }
    function Render5FinalistsImgHTML()
    {
         return "" 
            + "<div style=\"display:inline;text-align:center;margin-top:10px; margin-left:28px;float:left;width:113px;height:95px; padding-top:15px;\">" 
            + "<div><img onError=\"SetDefaultImage(this)\"  style=\"\" src=\"http://icons.aniboom.com/radiohead/stage2/5FinalistsImg.jpg\""
            + "/></div> "
            + "</div>";
    }
    function RenderTestimonialsTopHTML()
    {
        return ""

        + "<div style=\"height:40px;\"></div>"                       
        + "<div style=\" margin-left:17px;  height:15px;font-size:14px; font-family:Arial; color:#ffffff; text-align:left;\">"                                
        + "<span>Look at what these semi-Finalists had to say</span>"                            
        + "</div>";                            
    }
    function FinalistBottomFrameTopHTML()
    {
         return ""
        + "<div style=\"height:8px;\"></div>" ;                      
        //+ "<div style=\" margin-left:17px; font-size:22px; font-weight:bold; font-family:Arial; color:#ffffff; text-align:left;\">"                                
        //+ "Semi - finalists:"                            
        //+ "</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)
    {
        return Title.substr(0,10)+"...";
    }
     
    function relatedTabMouseOut(relTabId)
    {
        $(relTabId).style.cursor="default";
        $(relTabId).style.textDecoration="none";
    }
    function relatedTabMouseOver(relTabId)
    {
        $(relTabId).style.cursor="pointer";
        $(relTabId).style.textDecoration="underline";
    }
    
    function switchwhiteBottomDiv(divToShow,divToHide)
    {
        $(divToShow).style.display='block';
        
        $(divToHide).style.display='none';
       
    } 
 


function switchFlag(flagValue)
{
    staticFlag = flagValue;
}

function switchBottomDynamicRelated(elemId)
{
    for(i=0;i < allbottomDynamicRelated.length;i++)
    {
        if(allbottomDynamicRelated[i].id != elemId)
        {
            allbottomDynamicRelated[i].style.display="none";
        }
        else
        {
            allbottomDynamicRelated[i].style.display="block";
        }
    }
}

function SwitchRelatedDiv(ToShow,ToHide)
{
   $(ToHide).style.display="none";
   $(ToShow).style.display="block";
}