$(document).ready(function() {
	$('.newTextBlock').mouseover(function() {		
		$(this).css('background-color', '#f6f1ec');
		
	});

	$('.newTextBlock').mouseout(function() {		
		$(this).css('background-color', '#FBF7F6'); 
	});
	
});

// zoomi - A zoom for images ~ Sean Catchpole - Version 0.9
(function($){

$.fn.zoomi = function() {
  $(this).filter("img").each(function(){
    if(!this.z) {
      $(this).zoom1().mouseover(function(){$(this).zoom2().show();});
      $(this.z).mouseout(function(){$(this).hide();}); }
  });
 return this;
}

$.fn.zoom1 = function() {
  $(this).each(function(){
    var e = this;
    $(e).css({'position':'relative','z-index':'8'}).after('<img class="'+e.className+'">');
    e.z = e.nextSibling;
    $(e.z).removeClass("zoomi").addClass("zoom2").attr("src",e.alt || e.src)
    .css({'position':'absolute','z-index':'10'});
    $(e.z).hide();
  });
  return this;
}

$.fn.zoom2 = function() {
  var s = [];
  this.each(function(){
    var e = this;
    if(!e.z) e = $(e).zoom1()[0]; s.push(e.z);
    if(!e.z.complete) return;
    if(!e.z.width) { $(e.z).show(); e.z.width=e.z.width; $(e.z).hide(); }
    $(e.z).css({left:$(e).offsetLeft()-(e.z.width-e.scrollWidth)/2+'px',
    top:$(e).offsetTop()-(e.z.height-e.scrollHeight)/2+'px'});
  });
  return this.pushStack(s);
}

$.fn.offsetLeft = function() {
  var e = this[0];
  if(!e.offsetParent) return e.offsetLeft;
  return e.offsetLeft + $(e.offsetParent).offsetLeft(); }

$.fn.offsetTop = function() {
  var e = this[0];
  if(!e.offsetParent) return e.offsetTop;
  return e.offsetTop + $(e.offsetParent).offsetTop(); }

$(function(){ $('img.zoomi').zoomi(); });

})(jQuery);


$(document).ready(function () {
	$('.scroll').jScrollPane({showArrows:true});
});

var $overlay_wrapper;
var $overlay_panel;

function show_overlay() {
    if ( !$overlay_wrapper ) append_overlay();
    $overlay_wrapper.fadeIn(700);
}

function hide_overlay() {
    $overlay_wrapper.fadeOut(500);
}

function append_overlay() {
    $overlay_wrapper = $('<div id="overlay"></div>').appendTo( $('BODY') );
    $overlay_panel = $('<div id="overlay-panel"></div>').appendTo( $overlay_wrapper );

    $overlay_panel.html( '<a href="#" class="hide-overlay"><strong>[x] Zamknij okno</strong></a><img src="http://www.dziennikarzpress.pl/images/plakat.jpg" />' );

    attach_overlay_events();
}

function attach_overlay_events() {
    $('A.hide-overlay', $overlay_wrapper).click( function(ev) {
        ev.preventDefault();
        hide_overlay();
    });
}

$(function() {
    $('A.show-overlay').click( function(ev) {
        ev.preventDefault();
        show_overlay();
    });
});


$(document).ready(function() {
    setInterval("updateAbout()", 3000);
    
    
    $('.showHideComments').click(function() {
    	$('.cBlock' + $(this).attr('rel')).find('.comments').toggle();
    });
    
    $('.jScrollPaneContainer').mouseover(function() {
    	 // $(this).find('.jScrollPaneDrag').css('background-color', 'red');
    	// alert($(this).find('.jScrollPaneDrag').html());
    	$(this).find('.scroll').next().find('.jScrollPaneDrag').css('background-color', '#B63C53');
    });

    $('.jScrollPaneContainer').mouseout(function() {
   	 // $(this).find('.jScrollPaneDrag').css('background-color', 'red');
   	// alert($(this).find('.jScrollPaneDrag').html());
    	$(this).find('.scroll').next().find('.jScrollPaneDrag').css('background-color', '#E7DED9');
   });
    
    // no spam
    $('.loginForm').prepend('<input type="hidden" name="comment[no_spam]" value="1" />');
    
  });

  
function addNewsletter() {
        var basedir = 'http://www.dziennikarzpress.pl/';
	
	var newsletter = $('#newsletter_newsletter').val();
	
	$.get(basedir + "newsletter/index/val/" + newsletter, function(data){
		  alert(data);
		});

}

function updateAbout() {  
	elements = 7;
	var attr = { 1 : "<a href=\"http://www.dziennikarzpress.pl/i/reklama\">Reklamuj swoją firmę na dziennikarzpress.pl!</a>",
			     2 : "<a href=\"http://www.dziennikarzpress.pl/i/artykuły-na-zlecenie\">Napiszemy artykuł na zlecenie!</a>",
			     3 : "<a href=\"http://www.forum.dziennikarzpress.pl/\">Publikuj! Komentuj! Dyskutuj!</a>",
			     4 : "<a href=\"http://www.dziennikarzpress.pl/poradniki\">Jak napisać felieton? Poradniki specjalnie dla Ciebie!</a>",
			     5 : "<a href=\"http://www.dziennikarzpress.pl\">Newsletter - najświeższe wiadomości codziennie na Twoim mailu!</a>",
			     6 : "<a href=\"http://www.dziennikarzpress.pl\">Wiadomości ze świata mediów!</a>",
			     7 : "<a href=\"http://www.dziennikarzpress.pl/rejestracja\">Nie czekaj! Zarejestruj się już dziś!</a>"
	           };
	
	var currentElement = attr[$('#about').attr('rel')];
	
	$('#about').html($('<div><strong>' + currentElement + '</strong></div>').fadeIn());
	
	rel = parseInt($('#about').attr('rel')) + 1;
	// alert(attr.length);
	if (rel >= elements) {
		rel = 1;
	}
	$('#about').attr('rel', rel);
	
}

