/**
 * @author ctepeo
 * @copyright 2008
 * @Active Gallery (aGallery) requires jquery
 * @mail me if U have any questions. me@ctepeo.net
 */

//********	по каким ид/классам идентифицировать?
var ident = ".agallery";
//********	
var haveFull = false;
var unfilled = 0;



function aGalleryInit(){
	//	создаем блоки
	$(ident).append('<div class="agalleryBigblock"></div><div style="clear:left;"></div><div class="athumbblock"></div>');
}

function aGalleryAdd(path, path2thumb, main){	
	if (main == 1 && haveFull == false && path != "" && path2thumb != ""){
		$(".agalleryBigblock").append('<img id="agalleryfull" src="'+path+'">');
		$(".athumbblock").append('<img enlarge="'+path+'" class="athumb" src="'+path2thumb+'">');
		haveFull = true;
	} else {	
		if(path != "" && path2thumb != "") {
			$(".athumbblock").append('<img enlarge="'+path+'" class="athumb" src="'+path2thumb+'">');
		} else {
			unfilled++;
			aGalleryPostProcess();
		}
	}
}

$(document).ready(function(){
  $(".athumb").click(function () { 
		var xe = $(this).attr("enlarge");
		$("#agalleryfull").fadeOut("fast", function(){
			$("#agalleryfull").attr("src", xe);
			$("#agalleryfull").fadeIn("slow");
		});
		

      
      $(".athumb").removeClass("athumbselected");
      $(this).addClass("athumbselected");
    });
});

function aGalleryPostProcess(){
	if (unfilled == 2) {
		$(".athumb").remove();
	}
}





