jQuery(document).ready(function(){
	var elements = jQuery('a[rel=lightbox[pictures]]');
	
	var li = elements.lightBox({txtImage: '<i><b>'+$("#galleryLightboxDescription").text()+'</b></i><br/> Zdjęcie ', txtOf: 'z'});
	jQuery('a[rel=lightbox]').click(function(){
		li.startBy(this, elements);
		return false;
	});
	/*jQuery('a[rel=lightbox]').lightBox({
		txtImage: 'Zdjęcie',
		txtOf: 'z'
	});*/
	//var elementsMini = jQuery('a[rel=lightboxMini[pictures]]');
	//var liMini = elementsMini.lightBox({txtImage: '<i><b>'+$(".selected:last").text()+'</b> w stylizacji</i><br/> Zdjęcie ', txtOf: 'z'});
	//jQuery('a[rel=lightboxMini]').click(function(){
		//liMini.startBy(this, elements);
	//	return false;
	//});

});

function toogleLightbox(imageToToogle, element) {
	var addr = jQuery(element).attr('href');
	jQuery(element).attr('href','javascript:void(0)');

	//jQuery('.nolightbox').each(function(el) {
	//	jQuery(el).attr('rel', 'lightbox[pictures]');
	//});
	//jQuery(element).attr('rel', '');
	var lightboxLink = jQuery('#lightbox_gallery_toogle').find('a');
	var lightboxImage = jQuery('#lightbox_gallery_toogle').find('img');
	jQuery(lightboxLink).attr('href', addr);
	jQuery(lightboxImage).attr('src', imageToToogle);
	jQuery(element).attr('href',addr);
	return false;
}

function toogleLightboxMini(imageToToogle, element) {
	var addr = jQuery(element).attr('href');
	jQuery(element).attr('href','javascript:void(0)');

	//jQuery('.nolightbox').each(function(el) {
	//	jQuery(el).attr('rel', 'lightbox[pictures]');
	//});
	//jQuery(element).attr('rel', '');
	var lightboxLink = jQuery('#lightbox_gallery_toogle').find('a');
	var lightboxImage = jQuery('#lightbox_gallery_toogle').find('img');
	jQuery(lightboxLink).attr('href', addr);
	jQuery(lightboxImage).attr('src', imageToToogle);
	jQuery(element).attr('href',addr);
	return false;
}


function click(id){
	self.location=$('#'+id).parent().attr('href');
}

function rollIn(in_id, out_id, option){
	$('#'+in_id).width(368);
	$('#'+in_id).css('cursor','pointer'); 
		
	if(option=="1"){
		//$('#'+in_id+'> a').css('float','right');
		$('#'+in_id+'> div').css('float','right');
		$('#'+in_id+'> div').css('margin-left', 10);
		$('#'+in_id+'> div').css('text-decoration', 'none');
		$('#'+in_id+'> div').css('display', 'block').show();
		$('#'+in_id+'> img').css('float','right');
		$('#'+in_id).parent().parent().prev('div').css('display', 'none').hide();
	}else{
		//$('#'+in_id+'> a').css('float','left');
		$('#'+in_id+'> img').css('float','left');
		$('#'+in_id+'> div').css('float','left');
		$('#'+in_id+'> div').css('margin-left', 10)
		$('#'+in_id+'> div').css('display', 'block').show();
		$('#'+in_id).parent().parent().next('div').css('display', 'none').hide();
	}
	
	$('#'+in_id).css('background-color', '#fff');
	$('#'+in_id).css('border', '1px solid #C9C9C9');
}

function rollOut(in_id, out_id){
	$('#'+in_id).width(178);
	$('#'+in_id).parent().parent().prev('div').css('display', 'block').show();
	$('#'+in_id).parent().parent().next('div').css('display', 'block').show();
	
	//$('#'+in_id+'> a').css('float','none');
	$('#'+in_id+'> img').css('float','none');
	$('#'+in_id+'> div').css('float','none').css('margin', 0).css('display', 'none');
	$('#'+in_id).css('border', '1px solid #FFF');
}

function zmianaKryterium(referer,val){
	self.location="do/"+referer+"?sort="+val;
}

