/**
 * @author arek
 */

	
(function($){

$.fn.realizacje={
	current: 0,
	counter:0,
	loaded:[],
	complete: true,
/*	
openRealizacje: function (id){
	if (id != this.current) {
	if (this.complete) {
		this.complete = false;
		this.closeRealizacje();
		
		this.current = id;
		var data = "id=" + id;
		var compareNot = true;
		$('#gallery' + this.current).slideDown('slow');
		
		for (var i = 0; i < this.loaded.length; i++) {
			if (this.loaded[i] == id) {
				compareNot = false;
			}
		}
		
		if (compareNot) {
		
			this.loaded[this.counter] = id;
			this.counter += 1;
			$.fn.ajax.sendRequest("/pl/realizacjea/getimages", data);
			$('#g' + id).html($.fn.ajax.result);
		}
		//	setTimeout(function(){
			
				$.fn.ga.startGallery($.fn.realizacje.current);
		//	}, 1000);
			
		//};
		
		$('#g' + id).ready( function($) {
			$.fn.realizacje.complete=true;
		});
	  }
	}
	
},*/

openRealizacje: function (id){
	if (id != this.current) {
		this.closeRealizacje();	
		this.current = id;
		$('#gallery' + this.current).slideDown('slow');
		$('#g' + this.current+" a").lightBox();
		$('#g' + this.current).children('li').each(function(i){
				$.fn.realizacje.addEfect($(this).children('a').children('img'), 0.7);
				//$(this).children('a').lightBox('li');
				//$('#test'+id).prepend(" c: "+i);
			});
	}
	
},

addEfect: function(thumb, fadeDeg){
		if (jQuery.browser.msie) {
				thumb.css({
					display: 'none',
					opacity: 1
				}).show();
			}
			else {
				thumb.css({
					display: 'none',
					opacity: fadeDeg
				}).fadeIn(1500);
			}
		
		thumb.hover(function(){
				if (jQuery.browser.msie) {
				
				}
				else {
					thumb.fadeTo('fast', 1);
				}
			}, function(){
				if (jQuery.browser.msie) {
				
				}
				else {
					thumb.fadeTo('fast', 0.7);
				}
			} // don't fade out if the parent is active	
			)
			
},

closeRealizacje: function(){
	$('#gallery'+this.current).slideUp('fast');
	
}

}
})(jQuery);

