﻿var g = null;
var current = 0;

$().ready(function(){
    /*
    $("#newslist").accordion({
	    autoheight: false
    });
    
    if(typeof(focus) != "undefined" && focus != null)
        $("#newslist").accordion("activate", "#haber"+focus);
    */
    
    $("#newslist a.captionacc").click(function(){
        $(this).next('div').slideToggle("slow").siblings("div:visible").slideUp("slow");         
    });
    
});

jQuery.gallery = {
    open: function(newsID, caption){
        $("#gcaption").html(caption);
        $.getJSON("/haber/galeri.aspx?news.id="+newsID, function(data){
            g = data;            
            jQuery.gallery.set();
            
            tb_show(null,'#TB_inline?height=540&width=570&inlineId=gallerypopup',false);
        });       
    },
    close: function(){
        tb_remove();
    },
    set: function(){
        $("#galleryimg").attr("src", g[current]);        
    },
    next: function(){
        current++;
        current = current >= g.length ? 0 : current;
        jQuery.gallery.set();
    },
    prev: function(){
        current--;
        current = current < 0 ? g.length -1 : current;
        jQuery.gallery.set();
    }
}
