﻿var movieCount;
var currentCount=3;
var cur_movie;
addLoadEvent(function() {
    setActiveLink();
    if (document.getElementById('shimmer')) {
        document.getElementById('shimmer').style.display = 'none';
    }
    document.getElementById('movieNav').onmouseout = function() {
        document.getElementById('movie_label').innerHTML=cur_movie;
    }
    var a = document.getElementById('movieNav').getElementsByTagName('img');
    showMovie(a[0]);
    for (var i = 0; i < a.length; i++) {
        if (a[i].className.indexOf('reflect') != -1) {

            a[i].onclick = function() {
                showMovie(this);
                return false;
            }
            a[i].onmouseover = function() {
                document.getElementById('movie_label').innerHTML="";
                var obj = this;
                if (document.getElementById('shimmer').style.display == 'none') {
                    document.getElementById('movie_label').innerHTML=this.getAttribute("title").split(" - ")[0];
                    $('#shimmer').animate({
                        height: 'toggle',
                        opacity: "jswing"
                    }, 50, function() {
                    })
                } else {
                    $('#shimmer').animate({
                        height: 'toggle',
                        easing: "jswing"
                    }, 50, function() {
                        $('#shimmer').animate({
                            height: 'toggle',
                            easing: "jswing"
                        }, 50, function() {
                            document.getElementById('movie_label').innerHTML=obj.getAttribute("title").split(" - ")[0];
                        })
                    })
                }
                return false;
            }
        }
    }
    //ARCTick=new ARCticker("caucus/ticker_rss.aspx");
});
$().ready(function(){
    document.getElementById('back_mov').onclick=function(){
        moveNavRight();
        return false;
    }
    document.getElementById('next_mov').onclick=function(){
        moveNavLeft();
        return false;
    }
    movieCount=document.getElementById('movieNav').getElementsByTagName('td').length;
    
});
function moveNavLeft(){
    if((currentCount*1)+1<movieCount){
        $('#slide_mov').animate({
            left: '+=-308',
            easing: "jswing"
          }, 500, function() {
          });
      currentCount+=3;
    }
}
function moveNavRight(){
    
    if(currentCount!=3){
        $('#slide_mov').animate({
            left: '+=308',
            easing: "jswing"
          }, 500, function() {
          });
      currentCount+=-3;
    }
}
function setActiveLink(){
    var a=document.getElementById('NAVrootbox').getElementsByTagName('a');
    var len=a.length;
    if(window.location.href.indexOf("p=")==-1){
        a[0].className='nav_on';
        return;
    }
    for(var i=1;i<len;i++){
        if(window.location.href.indexOf(a[i].href)!=-1){
            a[i].className='nav_on';
        }else{
            a[i].className='';
        }
    }
}
