
jQuery(document).ready(function() {
	//setTimeout("LoadReklamaImg();", 600);
	setTimeout("LoadReklamaFlash();", 600);
});


// IMG
function LoadReklamaImg() {
	var date = new Date();
	window.onresize = arguments.callee;
  var MyWindowHeight	= jQuery(window).height();
  var MyWindowWidth		= jQuery(window).width();

	if ( jQuery.cookie('ReklamaCookie') == null ) {
		var RandomImages = new Array();
		RandomImages[0]	= Array('baner-ish2.jpg', '600', '323');

		var RndNum	= Math.floor(Math.random() * RandomImages.length);
		var MyImage	= RandomImages[RndNum];

		BoxReklama = '<div class="MessageKontener">';
			BoxReklama += '<div class="MessageZamknij"><img src="banery/ico_close.png" alt="" border="0" /></div>';
			BoxReklama += '<div class="MessageTresc"><img src="banery/'+MyImage[0]+'" alt="" border="0" style="width: '+MyImage[1]+'px; height: '+MyImage[2]+'px;" /></div>';
		BoxReklama += '</div">';

		if ( jQuery('.MaskaKontener').length == 0 ) {
			jQuery('body').prepend('<div class="MaskaKontener"></div>');
			jQuery('.MaskaKontener').height(MyWindowHeight).width(MyWindowWidth).append(BoxReklama); // Mozna zrezygnowac z ustawiania 'height' i 'width' gdy maska nie bedzie miala background-color.
		} else {
			jQuery('.MaskaKontener').height(MyWindowHeight).width(MyWindowWidth); //
		}

	  var CenterMessage = (MyWindowWidth - jQuery('.MessageKontener').width()) / 2;

		if ( MyWindowHeight <= 800 ) {
			var MiddleMessage = (MyWindowHeight - jQuery('.MessageKontener').height()) / 2;
		} else {
			var MiddleMessage = '150';
		}

		jQuery('.MessageKontener').css({marginLeft: CenterMessage+'px', marginTop: MiddleMessage+'px'});


	  jQuery('.MessageZamknij').click(function() {
	    jQuery('.MaskaKontener').remove();
				date.setTime(date.getTime() + (1 * 900 * 1000)); // 'date' jesli chcemy ustawic minuty lub godziny...
				jQuery.cookie('ReklamaCookie', '1', { expires: date }); // cyfra zamiast 'date' toznacza ilosc dni...
	  });

		jQuery(window).scroll( function() {
		  jQuery('.MessageKontener').animate( {top: jQuery(window).scrollTop()+'px' }, {queue: false, duration: 350} );
		});
	}
}



// SWF
function LoadReklamaFlash() {
	var date = new Date();
	window.onresize = arguments.callee;
  var MyWindowHeight	= jQuery(window).height();
  var MyWindowWidth		= jQuery(window).width();

	if ( jQuery.cookie('ReklamaCookie') == null ) {
		var file = 'banery/cennik15_609x484.swf';
		var width = '609';
		var height = '484';
		var wmode = 'transparent';
		var bgcolor = '#FFFFFF';

	  IncSwf = '<object type="\application/x-shockwave-flash\" data=\"'+file+'\" width=\"'+width+'\" height=\"'+height+'\">';
	    IncSwf += '<param name=\"movie\" value=\"'+file+'\" />';
	    IncSwf += '<param name=\"menu\" value=\"false\" />';
	    IncSwf += '<param name=\"quality\" value=\"high\" />';
	    IncSwf += '<param name=\"scale\" value=\"noscale\" />';
	    IncSwf += '<param name=\"wmode\" value=\"'+wmode+'\" />';
	    IncSwf += '<param name=\"bgcolor\" value=\"'+bgcolor+'\" />';
	  IncSwf += '<\/object>';

		BoxReklama = '<div class="MessageKontenerNoBorder">';
			BoxReklama += '<div class="MessageZamknijSwf"></div>';
			BoxReklama += '<div class="MessageLinkSwf"></div>';
			BoxReklama += '<div class="">'+IncSwf+'</div>';
		BoxReklama += '</div">';


		if ( jQuery('.MaskaKontener').length == 0 ) {
			jQuery('body').prepend('<div class="MaskaKontener"></div>');
			jQuery('.MaskaKontener').height(MyWindowHeight).width(MyWindowWidth).append(BoxReklama); // Mozna zrezygnowac z ustawiania 'height' i 'width' gdy maska nie bedzie miala background-color.
		} else {
			jQuery('.MaskaKontener').height(MyWindowHeight).width(MyWindowWidth); //
		}

	  var CenterMessage = (MyWindowWidth - jQuery('.MessageKontenerNoBorder').width()) / 2;

		if ( MyWindowHeight <= 800 ) {
			var MiddleMessage = (MyWindowHeight - jQuery('.MessageKontenerNoBorder').height()) / 2;
		} else {
			var MiddleMessage = '150';
		}

		jQuery('.MessageKontenerNoBorder').css({marginLeft: CenterMessage+'px', marginTop: MiddleMessage+'px'});

		jQuery('.MessageLinkSwf').css({ opacity: 0 }); //.MessageZamknijSwf,

		jQuery('.MessageZamknijSwf').click(function() {
	    jQuery('.MaskaKontener').remove();
				date.setTime(date.getTime() + (1 * 900 * 1000)); // 'date' jesli chcemy ustawic minuty lub godziny...
				jQuery.cookie('ReklamaCookie', '1', { expires: date }); // cyfra zamiast 'date' toznacza ilosc dni...
	  });

	  jQuery('.MessageLinkSwf').click(function() {
	    jQuery('.MaskaKontener').remove();
			date.setTime(date.getTime() + (1 * 900 * 1000)); // 'date' jesli chcemy ustawic minuty lub godziny...
			jQuery.cookie('ReklamaCookie', '1', { expires: 1 }); // cyfra zamiast 'date' toznacza ilosc dni...
	  	location.href = "?pID=21";
	  	//window.open('files/promocja_glowicever_wrzesien-grudzien_2010.PDF');
		});

		jQuery(window).scroll( function() {
		  jQuery('.MessageKontenerNoBorder').animate( {top: jQuery(window).scrollTop()+'px' }, {queue: false, duration: 350} );
		});
	}
}
