function cookieResize(selector, defaultSize) {
    
    var lastSize = defaultSize;
    
    function write(name, value, days) {
        var expires = "";
    	if (days) {
      		var date = new Date();
      		date.setTime(date.getTime() + (days * 86400000));
      		var expires = "; expires=" + date.toGMTString();
     	}
     	document.cookie = name + "=" + value + expires + "; path=/";
    }

    function read(name) {
     	name += "=";
     	var ca = document.cookie.split(';');
     	for(var i = 0; i < ca.length; i++) {
      		var c = ca[i];
      		while (c.charAt(0) == ' ') c = c.substring(1, c.length);
      		if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
     	}
     	return null;
    }

    function updateSizeFromCookie() {
        $('#MiddleCol p').removeClass(lastSize);
        $('#RightListingArticles div ul li p').removeClass(lastSize);
        $('#ColumnRightKontakt p').removeClass(lastSize);     
        $('.KlientTPL p').removeClass(lastSize);
        $('#InformationLeftCol p').removeClass(lastSize);
        lastSize = read('size') || defaultSize;     
        $('#MiddleCol p').addClass(lastSize);
        $('#RightListingArticles div ul li p').addClass(lastSize);
        $('#ColumnRightKontakt p').addClass(lastSize);
        $('.KlientTPL p').addClass(lastSize);
        $('#InformationLeftCol p').addClass(lastSize);
    }
    
    jQuery(selector).click(function() {
        write('size', this.className);
        updateSizeFromCookie();
        return false;
    });

    updateSizeFromCookie();
    
}


      $(function() {
        cookieResize('#SizerFont a', 'medium');
      });
      


 $(function() {
        $('a.ZoomPhoto').lightBox();
    });
    
    
    
 	function SendClick() {
 	text = $('textarea#textArea').val();
  email = $('input#EmailArea').attr('value');
  phone = $('input#PhoneArea').attr('value');
  $('span#Success').html('<img src="gfx/loader.gif" alt="Ładuję..." style="margin: 0 0 0 10px;" /> Trwa ładowanie...');
    $.ajax({
	type: "POST",
	url: "../library/send_form.php",
	data: "text="+text+"&email="+email+"&phone="+phone+"",
	success: function (html) {
	$("span#Success").fadeIn();
	$('span#Success').html(html);
	      setTimeout(function()
{
  $("span#Success").fadeOut(500);

}, 1200); 
	  }
	});
  }	
  
  
function externalLinks(){
if(!document.getElementsByTagName) return;
var anchors=document.getElementsByTagName("a");
for(var i=0;i<anchors.length;i++){
var anchor=anchors[i];
if(anchor.getAttribute("href")&&(anchor.getAttribute("rel")=="external"||anchor.getAttribute("rel")=="external nofollow"||anchor.getAttribute("rel")=="nofollow external"))
anchor.target="_blank";}}

window.onload=function(){externalLinks();} 


function slideShow() {
    var $active = $('#slideshow ul.active');

    if ( $active.length == 0 ) $active = $('#slideshow ul:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow ul:first');

    $active.animate({opacity: 0.0}, 800, function() {
        
        $active.addClass('last-active');
         
        });   
         

    setTimeout(function() {
    

    
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        }); 
    
    }, 1000); 
}


$(function() {
    setInterval("slideShow()", 3000);
});

