/*
	Autor: Grzegorz Jaworek
	E-mail: grzegorz.jaworek@gmail.com
	www: http://gjaworek.pl 
	Tel.: +48 519 133 159
*/

jQuery(document).ready(function(){
	try {
		jQuery('.newsletter form').html(jQuery('.newsletter form').html().replace('{text}','').replace('{newsletter_url}','http://kampanianazywo.pl/'));
		jQuery('.newsletter form').attr('action',window.location);
	} catch(err) {}
	
	try {
		sendTo = window.location.hash.replace('#','');
		jQuery('#your-recipient option').each(function () {
			if (jQuery(this).text() == sendTo) {
				jQuery(this).attr('selected','selected');
				window.location.href.replace( /#.*/, "");
			}
		});
	} catch(err) {}
	
	jQuery('.cytat .fbLikeContainer').hide();
	jQuery('.fbLikeContainer').not('.cytat .fbLikeContainer').show();
	jQuery('.votes .change').each(function () {
		if (jQuery(this).html().indexOf('+') != -1) {
			jQuery(this).addClass('up');
		} 
		if (jQuery(this).html().indexOf('-') != -1) {
			jQuery(this).addClass('down');
		}
	});
	var myWidth = 0, myHeight = 0;
	function getWindowSize() {
	  if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	  }
	  // window.alert( 'Width = ' + myWidth );
	  // window.alert( 'Height = ' + myHeight );
	}
	getWindowSize();
	function ScrollToElement(theElement){
	  theElement = getElementById(theElement);
	  var selectedPosX = 0;
	  var selectedPosY = 0;		  
	  while(theElement != null){
		selectedPosX += theElement.offsetLeft;
		selectedPosY += theElement.offsetTop;
		theElement = theElement.offsetParent;
	  }
	 window.scrollTo(selectedPosX,selectedPosY);
	};

	jQuery('.js-nav').attr('href','javascript:void(0)');	
	jQuery('.post p:first-child').each(function () {
		jQuery(this).fancyletter();
	});
	jQuery('#fan_box').hide();
	jQuery(".ico-facebook").parent().hover( 
		function () {
			jQuery('#fan_box').show();
		}, 
		function () { 
			jQuery('#fan_box').hide();
		}
	); 	 	 	 	 	 	 	 	 	
	jQuery('.date').each(function () {
		jQuery(this).html(jQuery(this).html().replace('January','Stycznia').replace('February','Lutego').replace('March','Marca').replace('April','Kwietnia').replace('May','Maja').replace('June','Czerwca').replace('July','Lipca').replace('August','Sierpnia').replace('September','Września').replace('October','Października').replace('November','Listopada').replace('December','Grudnia'));
	});
	jQuery('.date').each(function () {
		jQuery(this).html(jQuery(this).html().replace('Sunday',' niedziela').replace('Monday','poniedziałek').replace('Tuesday','wtorek').replace('Wednesday','środa').replace('Thursday','czwartek').replace('Friday','piątek').replace('Saturday','sobota'));	 	
	});
	jQuery(window).load(function(){
		jQuery('.komentarze').click( function() {
			var elem = jQuery('#'+jQuery(this).attr('rel'));
			//alert(myHeight+' '+elem.offset().top);
			window.scrollTo(0,elem.offset().top-(myHeight-elem.height())/2);
		}); 	 	
	});
	
	// jQuery('#tweetlist').html(jQuery('#tweetlist .tb_tweetinfo').html().replace(' ago',' temu').replace('hours','godzin').replace('hour','godzinę').replace('minutes','minut').replace('minute','minutę').replace('days','dni').replace('day','dzień').replace('months','miesięcy').replace('month','miesiąc').replace('years','lat').replace('year','rok'));
	
	try {
		jQuery.JuitterTM.starttm({
			searchType:"fromUser", // needed, you can use "searchWord", "fromUser", "toUser"
			searchObjectTM:"tomaszmachala", // needed, you can insert a username here or a word to be searched for, if you wish multiple search, separate the words by comma.
			// The values below will overwrite the ones on the Juitter default configuration. 
			// They are optional here.
			// I'm changing here as a example only
			lang:"pl", // restricts the search by the given language
			liveTM:"live-30", // the number after "live-" indicates the time in seconds to wait before request the Twitter API for updates.
			placeHolderTM:"twitter_tm", // Set a place holder DIV which will receive the list of tweets example <div id="juitterContainer"></div>
			loadMSG: "Wczytywanie wiadomości...", // Loading message, if you want to show an image, fill it with "image/gif" and go to the next variable to set which image you want to use on 
			imgName: "loader.gif", // Loading image, to enable it, go to the loadMSG var above and change it to "image/gif"
			total: 5, // number of tweets to be show - max 100
			readMore: "Więcej", // read more message to be show after the tweet content
			nameUser:"text", // insert "image" to show avatar of "text" to show the name of the user that sent the tweet 
			openExternalLinks:"newWindow", // here you can choose how to open link to external websites, "newWindow" or "sameWindow"
					filter:"sex->*BAD word*,porn->*BAD word*,fuck->*BAD word*,shit->*BAD word*"  // insert the words you want to hide from the tweets followed by what you want to show instead example: "sex->censured" or "porn->BLOCKED WORD" you can define as many as you want, if you don't want to replace the word, simply remove it, just add the words you want separated like this "porn,sex,fuck"... Be aware that the tweets will still be showed, only the bad words will be removed
		});
	} catch(err) {}
	
	try {
		jQuery.Juitter.start({
			searchType:"fromUser", // needed, you can use "searchWord", "fromUser", "toUser"
			searchObject:"pomaska,AdamHofman,kalitaT,mariuszkaminski,Arlukowicz,orzechowski_m_b", // needed, you can insert a username here or a word to be searched for, if you wish multiple search, separate the words by comma.
			// The values below will overwrite the ones on the Juitter default configuration. 
			// They are optional here.
			// I'm changing here as a example only
			lang:"pl", // restricts the search by the given language
			live:"live-30", // the number after "live-" indicates the time in seconds to wait before request the Twitter API for updates.
			placeHolder:"twitter_others", // Set a place holder DIV which will receive the list of tweets example <div id="juitterContainer"></div>
			loadMSG: "Wczytywanie wiadomości...", // Loading message, if you want to show an image, fill it with "image/gif" and go to the next variable to set which image you want to use on 
			imgName: "loader.gif", // Loading image, to enable it, go to the loadMSG var above and change it to "image/gif"
			total: 100, // number of tweets to be show - max 100
			readMore: "Więcej", // read more message to be show after the tweet content
			nameUser:"text", // insert "image" to show avatar of "text" to show the name of the user that sent the tweet 
			openExternalLinks:"newWindow", // here you can choose how to open link to external websites, "newWindow" or "sameWindow"
					filter:"sex->*BAD word*, sex->*BAD word*,porn->*BAD word*,fuck->*BAD word*,shit->*BAD word*"  // insert the words you want to hide from the tweets followed by what you want to show instead example: "sex->censured" or "porn->BLOCKED WORD" you can define as many as you want, if you don't want to replace the word, simply remove it, just add the words you want separated like this "porn,sex,fuck"... Be aware that the tweets will still be showed, only the bad words will be removed
		});
	} catch(err) {}
	
	jQuery('.example').fancybox({'scrolling': 'no', 'titleShow': false, 'overlayOpacity':'.7','overlayColor':'#000'});
	//jQuery('.example').eq(0).click();
	
	jQuery('.calendar_nl iframe').remove();
});

jQuery(window).load(function(){
	jQuery('.calendar_nl iframe').remove();
});

