$(document).ready(function() {
	/*ANKIETA*/
	/*
	var napis;
  $.ajax({
   url: 'ankieta.htm',
   type: 'GET',
   async: false,
   success: function(html){
napis=html;
   }
   });
$('body').prepend('<div id="cover" style="position:fixed;_position:absolute;top:0;left:0;height:'+screen.height+'px;width:'+screen.width+'px;background-color:#000;filter:alpha(opacity=75);opacity:0.75;z-index:10"></div>');
$('body').prepend('<div id="getk" style="position:absolute;top:50%;left:50%;background-color:#fff;z-index:11;border:5px solid #125BAC;padding:50px">'+napis+'</div>');
$('#getk').css({'margin-top':-($('#getk').height()/2+40),'margin-left':-($('#getk').width()/2+40),'width':$('#getk').width()});
$('#getk #close').click(function(){
$('#getk form span').remove();
if((($('input:checked').val()!='K')&&($('input:checked').val()!='M'))||($('input[name=age]').val()=='')){
$('#getk input[type=submit]').before('<span style="color:red">Nie wszystkie pola wypełnione</span>');
return false;
}
else {
  $.ajax({
   url: 'zapisz_ankiete.php',
   data: $('#getk form').serialize(),
   type:"POST"
   });
$('#getk,#cover').remove();
}
});
*/
/*ANKIETA*/
/*Button like*/
//if(navigator.appName=='Microsoft Internet Explorer')
$('h1').before('<div id="like"><a name="fb_share" type="icon_link" href="http://www.facebook.com/sharer.php">Udostępnij</a></div><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>');
/*KONIEC LIKE*/
/*TAGI*/
if($('meta[name=keywords]').attr('content')){
tags=$('meta[name=keywords]').attr('content');
if(tags.length>0){
tags=tags.replace(/ł/g,'l');
tags=tags.replace(//g,'s');
tags=tags.replace(/ż/g,'z');
tags=tags.replace(/ę/g,'e');
tags=tags.replace(/ć/g,'c');
  $.ajax({
   url: 'tags.php',
   data: 'tags='+tags,
   type:"POST",
   contentType: "application/x-www-form-urlencoded; charset=iso-8859-2",
   success:function(html){
   if(html.length>45)$('h1').after(html);
   }
   });
}
}
/*KONIEC TAGÓW*/
str=document.location.href;
num=document.location.href.search('news');
today=new Date();
str=str.substring(num,str.length)+', Czas: '+today;
if(num>0){
  $.ajax({
   url: 'zapisz_newsletter.php',
   data: '&news='+str,
   type:"POST"
   });
}
	if($('#r').height()<160){
	$('#r').css({'padding-top':'50px','height':'80px','margin-bottom':'-50px','padding-top':'45px','position':'relative','top':'-18px'});	
	$('#r object').hide();
	}
	$('#tg li:last a').css('background','none');
	$('#Scroll_Relative').css('margin-left','10px');
	$('#Scroll_Relative object embed').css('width','735px');
	$('#fiveDays h2, #fourDays h2, #threeDays h2, #fiveDays span, #fourDays span, #threeDays span').toggle(function(){
		$(this).parent().addClass("vis");
	}, function() {
		$(this).parent().removeClass("vis");
	});
	$('#tright form').submit(function(){
		emailReg = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
		if(!emailReg.test($('#tright form input[name=mail]').val())){
			gg('Nieprawidłowy adres e-mail');
			return false;
		}
		else{
			 $.ajax({
				url: $(this).attr('action'),
				type: $(this).attr('method'),
				data: '&mail='+$('input[name=mail]').val(),
				success:function(data){
					gg('Twój mail został dopisany do naszej bazy.<br/>Będziesz otrzymywał nasz newsletter raz na 2 tygodnie');
					return false;
				}
			}); 
			return false;
		}
	});
$('#img_c').click(function(){
if($(this).next().attr('id')!='addComment')
$(this).after('<form id="addComment" method="post" action="?"><p>Nick: <input type="text" maxlength="30" name="nick" class="area" style="margin-left: 17px;"></p><p>Tytuł: <input type="text" maxlength="30" name="title" class="area" style="margin-left: 13px;"></p><p>Treść komentarza:</p><p><textarea rows="10" cols="60" name="content" class="area"></textarea></p><p><input type="submit" class="send" value="Wyślij"></p><input type="hidden" value="" name="link"></form>');
$('#addComment').slideDown('slow');
});
$('#addComment').live('submit',function(){
	$('.err').remove();
  $.ajax({
   url: 'add-comment.php',
   data: 'nick='+$('input[name=nick]').val()+'&title='+$('input[name=title]').val()+'&content='+$('textarea[name=content]').val()+'&link='+window.location.href,
   type:"POST",
   success:function(html){
   if(html==1) window.location.reload();
   else $('#addComment').append('<p class="err">Nie wszystkie pola zostały wypełnione</p>')
   }
   });
return false;
});
setTimeout('viral();',500);
$('#menu a:last').click(function(){
_gaq.push(['_trackEvent','event','klik-megapower',document.location.pathname]);
window.open(this.href); 
return false;
});
});
function gg(napis){
$('body').prepend('<div id="cover" style="position:fixed;top:0;left:0;height:100%;width:100%;background-color:#000;filter:alpha(opacity=75);opacity:0.75;z-index:10"></div>');
$('body').prepend('<div id="getka" style="position:fixed;top:50%;left:50%;background-color:#fff;z-index:11;border:5px solid #ddd;padding:50px"><strong id="close" style="position:absolute;right:5px;top:3px;cursor:pointer">X</strong>'+napis+'</div>');
$('#getka').css({'margin-top':-($('#getka').height()/2+40),'margin-left':-($('#getka').width()/2+40),'width':$('#getka').width()});
$('#getka #close').click(function(){
$('#getka,#cover').remove();
});
}
function viral(){
	if(window.location.href.substring(11,12)=='u'&&$('#tcent img:first').css('float')=='right'&&
	window.location.href.indexOf('bialko.html')<0&&
	window.location.href.indexOf('weglowodany.html')<0&&
	window.location.href.indexOf('tribulus.html')<0
	){
		$('#tcent img:first').after('<div id="viral"><span>Daj linka do artykułu znajomemu</span><label>Link do tego artykułu:</label><input type="text" value="'+window.location.href+'"/></div>');
		$('#viral').css({'margin-top':jQuery('#viral').prev('img').height()+10,'width':jQuery('#viral').prev('img').width()-12});
		$('#tcent img:first').css({'margin-bottom':$('#viral').height()+40,'margin-left':10});
	}
	$('#viral input').hover(function(){
		$(this).select();
	});
}
$('#viral input').live("click",function(){
	_gaq.push(['_trackEvent','event','polec',document.location.pathname]);
});
$('#like').live("click",function(){
	_gaq.push(['_trackEvent','event','fb_share',document.location.pathname]);
});