﻿var hvcl=null;
var slideint = null;
function slideSwitch(img) {   
   var $active = $('#slshw IMG.active');
   if ( $active.length == 0 ) $active = $('#slshw IMG:last');
   var $next =  $active.next().length ? $active.next(): $('#slshw IMG:first');
   if (img)
   {
        $next = $('#'+ img.replace('thumb_','img_'))
   }

    $active.addClass('last-active');
    $('#thumb_'+ $active.attr('id').replace('img_','')).removeClass('active');
    $('#thumb_'+ $next.attr('id').replace('img_','')).addClass('active');  
    $('#slimg_title').text($next.attr('title'));
    $('#slimg_title').attr('href','http://anhso.net/UserRedirect.aspx?action=image&imgID='+$next.attr('id').replace('img_',''))
     $('#sl_link').attr('href',$('#slimg_title').attr('href'));
    $('#slimg_owner').text($next.attr('user'));
     $('#slimg_owner').attr('href','http://'+$next.attr('user')+'.anhso.net');
          
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            clearInterval(slideint);
            slideint= setInterval( "slideSwitch()", 5000 );
            $active.removeClass('active last-active');
        });
}


$(function() {
$("#taglist").tagcloud({ type: "list", sizemin: 12, colormin: '0093B3', colormax: '004C69' });

    var firstimg = $('#slshw IMG:first');
    $('#slimg_title').text(firstimg.attr('title'));
    $('#slimg_title').attr('href', 'http://anhso.net/UserRedirect.aspx?action=image&imgID=' + firstimg.attr('id').replace('img_', ''))
    $('#sl_link').attr('href', $('#slimg_title').attr('href'));

    $('#slimg_owner').text(firstimg.attr('user'));
    $('#slimg_owner').attr('href', 'http://' + firstimg.attr('user') + '.anhso.net');

    $('#imglist IMG').click(function() {

        clearInterval(slideint);
        slideSwitch(this.id);
    });

    slideint = setInterval("slideSwitch()", 5000);

    $('.imgbox').hover(function() {
        clearTimeout(hvcl);
        var elem = this;
        hvcl = setTimeout(function() { $('.img_title:not(:animated)', elem).animate({ opacity: '100', height: '50px' }, 500); }, 200)

    }, function() {
        $('.img_title', this).animate({ height: '1px', opacity: '0' }, 200);

    });
      

    $('#nav_left').click(function() {
        if (this.className != 'left_in') {
            $('#cmh_1').animate({ marginLeft: '0px' }, 600);
            $(this).removeClass('left');
            $(this).addClass('left_in');
            $('#nav_right').removeClass('right_in');
            $('#nav_right').addClass('right');
        }

    });

    $('#nav_right').click(function() {
        if (this.className != 'right_in') {
            $('#cmh_1').animate({ marginLeft: '-647px' }, 600);
            $(this).removeClass('right');
            $(this).addClass('right_in');
            $('#nav_left').removeClass('left_in');
            $('#nav_left').addClass('left');
        }

    })

    $('.tipsyselect').tipsy({ gravity: 's' });

});



