$(document).ready(function(){			
		// tooltip - dodawanie i usuwanie ze schowka
	   var conf = {   			
					
				showCloseLink: 	true,								
				ajaxUse: 		true,	
				

				ajaxSuccess: function(data){					
					var href = this.elem.attr('href');		
					var tekst = '';		

					if(href.match('e=ajaxAdd')){	
											
						href = href.replace('e=ajaxAdd', 'e=ajaxDelete');		
						this.elem.removeClass('clipboard');
						this.elem.addClass('clipboardOut');
						tekst = 'Usuń ze schowka';
						updateClipCount(1);
						
					}else{					
						href = href.replace('e=ajaxDelete', 'e=ajaxAdd');
						this.elem.removeClass('clipboardOut');
						this.elem.addClass('clipboard');	
						tekst = 'Dodaj do schowka';								
						updateClipCount(-1);								
					}				

					// zmiana atrybutu href
					this.elem.attr('href', href);				

					// zmiana tekstu w linku
					this.elem.empty();
					this.elem.append(tekst);					
									
	   			},

							
				triggerEvent: 	'click',			
				position: 		'top-left'
		}	


		function updateClipCount(increment){

		   var countClip 		= $('#countClip');		   

		   try{
		   		var count = parseInt(countClip.get(0).firstChild.nodeValue); 
		   }catch(exception){
				// nie rob nic
		   }		 
		   
		   if(typeof count != 'number') count = 0;	   		
		   
		    if(increment < 0){
				count = count - 1;
			}else{
				count = count + 1;
			}

			if(count < 0) return;

			countClip.empty();
			
			var verb = ' oferta';
			if(count>1 && count<5){
				verb = ' oferty';
			}
			if(count>4){
				verb = ' ofert';
			}

			var fullString = ''+count + verb;
			countClip.append(fullString);
	   }		
				
	   $('.clipboard').mytooltip(conf, 'clipboardTooltip');
	   
	   $('.clipboardOut').mytooltip(conf, 'clipboardTooltip');  
		
});
