$(function(){
    //$("#debug")[0].innerHTML="Ready.";
    
    
    $('a.lightbox').lightBox(); // Select all links with lightbox class
    //#gt_prev, #gt_next, #g_prev, #g_next {
    
    $('#t_prev').click(thumbPrev);
    $('#t_next').click(thumbNext);
    
    $('#g_prev').click(galPrev);
    $('#g_next').click(galNext);
    
    $.getJSON("services/image_service.php", gotJSON);
});

oJSON = null;



function gotJSON(json){
    oJSON = json;
    
    oAG.cats = oJSON.categories;
    oAG.pics = oJSON.pictures;
    
    // should know the id of the first category, don't assume 1 or 0
	var defaultCats = null;
	$.each(oAG.cats, function(k,v) {
		if (v["category"]) {
			defaultCats = v["category"];
		}
	});
	
	if (defaultCats) {
		oAG.createGallery(defaultCats);
	}
    //oAG.preloadThumbs();
    //oAG.preloadImg();	
    
    $("#pic_cats_left").animate({
        opacity: "1",
        left: "0px"
    }, 1);
    $("#pic_cats_right").animate({
        opacity: "1",
        left: "0px"
    }, 1);
    
}




