//// -------------------------------------------------------------------------------
		$(document).ready(function(){
			
// linki w nowym oknie			
			$('a[rel="external"]').click( function() {
        		window.open( $(this).attr('href') );
        		return false;});
		
// --------------------------- no spam mail

			$('a[rel="mail"]').each( function() {
			   this.href = this.href.replace('(at)',"@");
       		   return true;});
			
			$('a.mail').each( function() {
			   this.href = this.href.replace('(at)',"@");
       		   return true;});			
			
//----------------------------------------------------------------------------------------------------------------------------------

// link blur		
			$("a").focus(function() {
  			$(this).blur();
			});
//----------------------------------------------------------------------------------------------------------------------------------

// logotypy scroll

		$('#logotypy_scroll').slide({autoplay: true, duration: 2000, showSlideIndex: false});

// ----------------------------------------------------------------

// go to top

		$.fn.scrollToTop=function(){
//			$(this).hide().removeAttr("href");
			var scrollDiv=$(this);
					$(this).click(function(){
							$("html, body").animate({scrollTop:0},"slow")
					})
		}

		$("#right_bottom a").scrollToTop();

// sitemap - przycisk

/*//accordion
			$('ul.accordion').accordion();
//----------------------------------------------------------------------------------------------------------------------------------*/

//fancybox

			$("div.podstrony_galeria a").fancybox();	
			
			$(".news_galeria a").fancybox();
			$("a.podstrony_foto").fancybox();			
			$("a.kartka_fancy").fancybox();						
			
			
			$("a.zoom2").fancybox();						

//			$("a.kamera_fancy").fancybox({'padding':0,'frameWidth':400,'frameHeight':400});		
			
			$('a.kamera_fancy').fancybox({
				  'width'            : 530,
				  'height'         : 340,
					'autoScale'        : true,
					'transitionIn'      : 'fade',
				  'transitionOut'      : 'fade',
				  'type'            : 'iframe',
				  'scrolling' : 'no',
				  'centerOnScroll' : true
			   });			
			
			
		
			$("a.mapa_witryny").fancybox({'padding':0,'frameWidth':800,'frameHeight':500});		
		
		
//			$("a.list_referencyjny").fancybox();					
			
			

/*

			$("a.zoom1").fancybox({
				'overlayOpacity'	:	0.7,
				'overlayColor'		:	'#FFF'
			});

			$("a.zoom2").fancybox({
				'zoomSpeedIn'		:	500,
				'zoomSpeedOut'		:	500,
				'centerOnScroll' : true
			});
	*/		
//----------------------------------------------------------------------------------------------------------------------------------

// TOOLTIP Kalendarz

$("#kalendarz a[title]").tooltip({
	tipClass : "tooltip_kalendarz",
	delay: 1,
	offset: [10, 2],
	effect: 'slide'
}).dynamic({ bottom: { direction: 'up', bounce: true } });		

//----------------------------------------------------------------------------------------------------------------------------------

// formularz kontaktowy

			$("#form-kontakt").submit(function(){

			var str = $(this).serialize();

  				 $.ajax({
  				 type: "POST",
 				 url: "/form_ajax_contact.php?lang="+lang,
 				 data: str,
  				success: function(msg){
    
			$("#note").ajaxComplete(function(event, request, settings){

			if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
			{
	if(lang=='pl') {
result = '<div class="notification_ok">Dziękujemy za wypełnienie formularza. <br />Wiadomość została wysłana. <br /><br /><strong>Nasz przedstawiciel skontaktuje się z Państwem najszybciej, jak to będzie możliwe!</strong></div>';
	} else {
result = '<div class="notification_ok">Thank you for completing the form. <br /> This message was sent. <br /> <br /> <strong> Our representative will contact you as soon as possible!</strong></div>';		
	}

			$("#fields").hide();
			}
			else
			{
			result = msg;
			}

			$(this).html(result);

			});

			}

			 });

			return false;

			});
//----------------------------------------------------------------------------------------------------------------------------------

// hover dla elemnetow logoscrolla
			$("div.items div.scroll_item").hover(function() { //On hover...

				var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'

		//Set a background image(thumbOver) on the <a> tag - Set position to bottom
			$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});

		//Animate the image to 0 opacity (fade it out)
			$(this).find("span").stop().fadeTo('normal', 0 , function() {
				$(this).hide() //Hide the image after fade
				});
			} , function() { //on hover out...
		//Fade the image to full opacity 
				$(this).find("span").stop().fadeTo('normal', 1).show();
			});
//----------------------------------------------------------------------------------------------------------------------------------


// dodawanie ikon dla zalącznikow

	// pdf 
	$("a[href$='.pdf']").addClass("pdf");
	 
	// txt (doc, rtf, txt)
	$("a[href$='.doc'], a[href$='.txt'], a[href$='.rft']").addClass("txt");

	// zip (zip, rar)
	$("a[href$='.zip'], a[href$='.rar']").addClass("zip"); 
	
	// Add email icons to email links
	//$("a[href^='mailto:']").addClass("email");

	// external link 
	//$('a').filter(function() {
		///Compare the anchor tag's host name with location's host name
	  //  return this.hostname && this.hostname !== location.hostname;
	 // }).addClass("external");

//----------------------------------------------------------------------------------------------------------------------------------
		});
//// ------------------------------------------------------------------------------	







// -------------------------------------------------------------------------------	
// -------------------------------------------------------------------------------			
/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 

 
this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};
// -------------------------------------------------------------------------------	
// -------------------------------------------------------------------------------	


//// ------------------------------------------------------------------------------	PLUG INS END


// starting the script on page load
/*
$(document).ready(function(){						 

	// Set the transparent pixel
	jQuery.ifixpng('/blank.gif');
	jQuery('#pasek_banery_start').ifixpng();
});		
		
*/

/* CUFON - wywołania */

	Cufon('h1.tytul');
	Cufon('h1.cufon');	
	
	Cufon('h2.news');	
	Cufon('h2.nazwa_galerii');	
		
	Cufon('h3.tytul');
	Cufon('#left_news_top');	
	Cufon('#left_menu_top');	
	
	Cufon('.left_naglowek_tytul');
	
	Cufon('.podstrony_galeria .tytul');
	Cufon('.podstrony_zalaczniki .tytul');
	
	Cufon('.news_galeria .tytul');
	Cufon('.news_zalaczniki .tytul');	
	
	Cufon('#home_center .tytul_panoramy');
	
	
	Cufon('fieldset.tbl_cennik div strong');
	
	
	
	
	
		
	
	

	

 // tooltip galeria podstrony
//		$('a.tooltip').tooltip();

/* banery start */

$(document).ready(
                function(){
                    	$('ul#animacja_rand').innerfade({
                        speed: 2000,
                        timeout: 10000,
                        type: 'sequence',
                        containerheight: 	'1000px',
                        slide_timer_on: 	'yes',
                        slide_ui_parent: 	'animacja_rand',
                        slide_ui_text:		'animacja_rand_core'
                    	});
                    	$.setOptionsButtonEvent();					
			});

/* animacja - pokaz/ukryj */

		$("#animacja_content").hide();
$(document).ready(function(){
	
	if( $.cookie('oc')=='close') {
//		$("#banery_start").css('display', 'none');			
//		$("#banery_start").hide();
		$("#animacja_content").hide();
		$("#animacja_header a").html('pokaż');
	} else {
//		$("#banery_start").css('display', 'block');					
//		$("#banery_start *").show();
		$("#animacja_content").show();
		$("#animacja_header a").html('ukryj');		
	}

	$("#animacja_header").click (function() { 

        var date = new Date();
		date.setTime(date.getTime() + (3 * 24 * 60 * 60 * 1000));

		if( $.cookie('oc')=='close' ) {
			$("#banery_start_nav").show();			
			$(this).parent().find("#animacja_content").slideDown('fast').fadeIn(5).show();
			$("#animacja_header a").html('ukryj');
		    $.cookie('oc', 'open', { path: '/', expires: date });
		} else {
			$("#banery_start_nav").hide();			
			$(this).parent().find("#animacja_content").slideUp('fast').fadeOut(5).hide();
			$("#animacja_header a").html('pokaż');
		    $.cookie('oc', 'close', { path: '/', expires: date });
		}
		return false;

	});

});
