jQuery(document).ready(function(){
    
    function advance_slideshow(){
        var ids = new Array();
        var itr = 1;
        var selected = 1;
        
        var ele = jQuery('.tag-clk').each(function(){
            ids[itr] = this.id;
            if(jQuery('#'+this.id).hasClass('selected')){
                var s = this.id.split('-');
                selected = s[2];
              
                jQuery('.sliderblk').customFadeOut(700,function(){
                    jQuery('.sliderblk').removeClass('active');
                    jQuery(this).css('filter','');
                });
                jQuery('#'+this.id).removeClass('selected'); 
            }
            itr++;
        });
        var next = (parseInt(selected) + 1);
        
        if(next == ids.length){
            var data = ids[1].split('-');
            jQuery('#slider-'+data[1]).customFadeIn(800,function(){
                jQuery('#'+ids[1]).addClass('selected');
                jQuery('#slider-'+data[1]).addClass('active');
                jQuery(this).css('filter','');
            });
        }else{
        
            var data = ids[next].split('-');
            jQuery('#slider-'+data[1]).customFadeIn(800,function(){
                jQuery('#'+ids[next]).addClass('selected');
                jQuery('#slider-'+data[1]).addClass('active');
                 jQuery(this).css('filter','');
            });
        }
    }
     
    rotateSwitch = function(){
        play = setInterval(function(){ //Set timer - this will repeat itself every 8 seconds
            var sid = jQuery('a.link-next').attr('id');
            advance_slideshow();
        }, 8000); //Timer speed in milliseconds (8 seconds)
    };
    //if(!jQuery.browser.msie)
    rotateSwitch(); 
    
    (function($) {
        //alert($.browser.version);
	    $.fn.customFadeIn = function(speed, callback) {
		    $(this).fadeIn(speed, function() {
			    if(jQuery.browser.msie)
				    $(this).get(0).style.removeAttribute('filter');
			    if(callback != undefined)
				    callback();
		    });
	    };
	    $.fn.customFadeOut = function(speed, callback) {
		    $(this).fadeOut(speed, function() {
			    if(jQuery.browser.msie)
				    $(this).get(0).style.removeAttribute('filter');
			    if(callback != undefined)
				    callback();
		    });
	    };
    })(jQuery);  
              
});

