(function($){$.setCookie=function(name,value,options){if(typeof name==='undefined'||typeof value==='undefined')
return false;var str=name+'='+encodeURIComponent(value);if(options.domain)str+='; domain='+options.domain;if(options.path)str+='; path='+options.path;if(options.duration){var date=new Date();date.setTime(date.getTime()+options.duration*24*60*60*1000);str+='; expires='+date.toGMTString();}
if(options.secure)str+='; secure';return document.cookie=str;};$.delCookie=function(name){return $.setCookie(name,'',{duration:-1});};$.readCookie=function(name){var value=document.cookie.match('(?:^|;)\\s*'+name.replace(/([-.*+?^${}()|[\]\/\\])/g,'\\$1')+'=([^;]*)');return(value)?decodeURIComponent(value[1]):null;};$.CooQueryVersion='v 2.0';})(jQuery);


var popupCloseClick = function(e){
	e.preventDefault();
	$('#popup_container').hide();
};

var ShowPopup = function(){
	var intHeight = Math.max( $('body').height(), $(window).height() );
	$('#popup_container').height(intHeight).show();
	$('#popup_tlo').css({'backgroundColor':'black', 'opacity':0.6, 'zIndex': 100});
};

var ShowLightbox = function() {
	/*
	$.colorbox({
		inline: true,
		href: '#lightbox-info-content',
        open: true,
		innerWidth: 550,
		innerHeight: 400,
		initialWidth: 550,
		initialHeight: 400
	});
	*/
}

var externalLink = function(e){
	if( $(this).attr('rel') === '_external' ){
		e.preventDefault();
		window.open( $(this).attr('href'), 'NewWindow' );
		$('#zewnetrznyLink').hide();
	} else if( $(this).attr('rel') === '_externalPopup' ) {
		e.preventDefault();
		externalLinkPopup( $(this).attr('href') );
	} else if ( $(this).attr("rel") === '_blank' ) {
		e.preventDefault();
		window.open( $(this).attr("href"), 'NewWindow'+Math.round(Math.random*100) );
	}
};

var externalLinkPopup = function(strAddress){
	$('#zewnetrznyLink').show();
	$('#zwLink').attr('href', strAddress);
};

$(document).ready( function() {

	$('a').click(externalLink);
	
	$('#zwClose, .close.closeZ').click(function(e){
		e.preventDefault();
		$('#zewnetrznyLink').hide();
	});

	$('#popup4_close, #popup_container').click(popupCloseClick);

	var ciacho3 = $.readCookie('adc_popup5');
	if(!ciacho3){
		if( false==$('#popup_container').is(':visible') ){
			$.setCookie('adc_popup5', 'seen1', {'path':'/', 'duration':1000});
			ShowPopup();
		}
	}else if('seen1'==ciacho3){
		if( false==$('#popup_container').is(':visible') ){
			$.setCookie('adc_popup5', 'seen2', {'path':'/', 'duration':1000});
			ShowPopup();
		}
	}
	
	$("#easytouch_popup_close").hover( function() {
		$(this).css("cursor","pointer");
	}, function() {
		$(this).css("cursor","auto");
	}
	);
	
	$("#easytouch_popup_close").click( function() {
		$("#easytouch_popup").fadeOut(200);
	});
	
	var easytouch_popup = $("#easytouch_popup");
	if (easytouch_popup.length > 0) {
		$("#easytouch_popup").fadeIn(500);
	}
	/*
	$(".externlink").click( function(event) {
		event.preventDefault();
		var ahref = $(this).attr("href");
		if (confirm("Wybrane hiperłącze prowadzi do strony umieszczonej poza granicami Polski.\nCzy na pewno chcesz opuścić stronę?")) {
			location.href = ahref;
		} else return false;
	});*/
	
});
