Cufon.replace('#header h2, #brd-title, #header .logout, .qfileassetDbox h1, .profil #content h2, .elements-space h3, .article-item h3, .download .type', { fontFamily: 'Myriad Pro Light' });
Cufon.replace('#footer-container h4', { fontFamily: 'Myriad Pro Cond' });
Cufon.replace('.second-level a, .admin #main-menu a', { fontFamily: 'Myriad Pro Normal' });

var externalLink = function(event){
	if ( $(this).attr('rel') === '_blank' ) {
		event.preventDefault();
		window.open( $(this).attr('href'), 'NewWindow'+new Date().getTime() );
	}
};

var Resize = {
	intWidth: 0,
	objContent: '#container',
	Init: function(){
		Resize.Set();
		setInterval(Resize.Set, 1000);
		$(window).resize(Resize.Set);
	},
	Set: function(){
		Resize.intWidth = $(window).width();
		if(Resize.intWidth<990){ Resize.intWidth = 990;}
		$(Resize.objContent).width(Resize.intWidth);
	}
};

var WrapTextarea = {
	Init: function(){
		$('.profil #content textarea, .admin #content textarea').wrap('<div class="bg_textarea" />');
	}
};

var wrapthat = function(target, divname) {
	$(target).wrap('<div class="'+divname+'" />');
};

var hoverLink = function(target) {
	$(target).mouseover(function() {
		$(this).addClass('hover');
	}).mouseout(function(){
		$(this).removeClass('hover');
	});
};
var Paginacja = {
	intCurrentPage: -1,
	intNewpage: -1,
	Init: function(){
		$('.content-bg').bind("goto", function(e,p){
			if(Paginacja.intCurrentPage == -1){
				Paginacja.intNewpage = p;
				Paginacja.intCurrentPage = Paginacja.intNewpage;
			}else{
				Paginacja.intNewpage = p;
				if(Paginacja.intCurrentPage != Paginacja.intNewpage){
					Paginacja.intCurrentPage = Paginacja.intNewpage;
					$('html, body').animate({scrollTop:150}, 'fast');
				}
			}
		}).pajinate({
			items_per_page : 1,
			item_container_id : '.pages',
			nav_panel_id : '.pages-navigation',
			show_first_last: false
		});
	}
};


$(document).ready(function() {
	$('a').click(externalLink);
	Resize.Init();

	WrapTextarea.Init();

	$("#ProfilONasForm .avatar-upload input").prettyfile();
	$(".profil .inputFile input").prettyfile();
	$(".admin .inputFile input").prettyfile();
	
	$('.profil input:checkbox').checkbox({cls:'jquery-safari-checkbox'});
	
	hoverLink('.cities_list a');
	hoverLink('.btn_miasto');
	hoverLink('.item-aktu a');
	hoverLink('#main-menu a');
	
	Paginacja.Init();
	
	$(".colorbox").colorbox();
	$(".colorbox-frame").colorbox({innerWidth:"700px", innerHeight:"580px", iframe:true});
	$(".colorbox-frame-main").colorbox({innerWidth:"640px", innerHeight:"380px", iframe:true});
	
	$('#carousel-list').cycle({ 
		fx: 'fade',
		timeout: 5000,
		pager:	'#carousel-nav'
	});
});
