/**
 * Index helper functions
 */

mainVideoBoxIds=Array();
mainVideoBoxIds[0]="main_sport_div";
mainVideoBoxIds[1]="main_bouldering_div";
mainVideoBoxIds[2]="main_movie_div";
mainVideoBoxIds[3]="main_my_channel_div";

mainSearchDivs=Array()
mainSearchDivs[0]="main_movie_names_div";
mainSearchDivs[1]="main_authors_div";
mainSearchDivs[2]="main_climbers_div";
mainSearchDivs[3]="main_location_div";

function $cs(what){
	return document.getElementById(what);
}

/**
 * Hide/show tabs on the index page
 */
function showMainVideoBox(ind) {

  
   if(mainVideoBoxIds[ind]&&$cs(mainVideoBoxIds[ind])&&$cs(mainVideoBoxIds[ind]).style.display!="block")
   {
      //hide other divs and then show this
      for(i=0;i<mainVideoBoxIds.length;i++)
      {
      	try{
         div=$cs(mainVideoBoxIds[i]);
         div.style.display="none";
        }
        catch(e){};
      }
      
      var show=$cs(mainVideoBoxIds[ind]);
      show.style.display="block";
   }
}

function toggleSliderTab(ind)
{
   if(ind==1)
   {
      var sliderDiv=$cs('ClipWeekDiv');
      var oldDiv=$cs('MostRecentDiv');
      $cs('ClipWeekHeader').className="ClipWeekHeaderON";
      $cs('MostRecent').className="MostRecentOFF";
      
  }
  else {

      var oldDiv=$cs('ClipWeekDiv');
      var sliderDiv=$cs('MostRecentDiv');
      
      $cs('ClipWeekHeader').className="ClipWeekHeaderOFF";
      $cs('MostRecent').className="MostRecentON";
  }
      oldDiv.style.display="none";
      sliderDiv.style.display="block";
 }
 
 moves=0;
 totalTabs=0;
 function moveToPreviousImages()
{
  
  if(moves-1>=0)
  {
  	  new Effect.Move('imageBoxInside', { x: 300, y: 0, transition: Effect.Transitions.sinoidal });
  	  moves--;
  }
}


function moveToNextImages()
{
  if(moves<totalTabs)
  {
  	  new Effect.Move('imageBoxInside', { x: -300, y: 0, transition: Effect.Transitions.sinoidal });
  	  moves++;
  }

}

/**
 * Hide/Show tabs on the search page
 */
 function showMainSearchBox(ind) {

   if(mainSearchDivs[ind]&&$cs(mainSearchDivs[ind])&&$cs(mainSearchDivs[ind]).style.display!="block")
   {
      //hide other divs and then show this
      for(i=0;i<mainSearchDivs.length;i++)
      {
      	try{
         div=$cs(mainSearchDivs[i]);
         div.style.display="none";
        }
        catch(e){};
      }
      
      var show=$cs(mainSearchDivs[ind]);
      show.style.display="block";
   }
}
var cotw_totalTabs=0;
var cotw_moves=0;
function moveToPreviousImages_COTW()
{
  
  if(cotw_moves-1>=0)
  {
  	  new Effect.Move('imageBoxInside_COTW', { x: 300, y: 0, transition: Effect.Transitions.sinoidal });
  	  cotw_moves--;
  }
}


function moveToNextImages_COTW()
{
  if(cotw_moves<cotw_totalTabs)
  {
  	  new Effect.Move('imageBoxInside_COTW', { x: -300, y: 0, transition: Effect.Transitions.sinoidal });
  	  cotw_moves++;
  }

}