try {
//document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

var awf = {
	start : function(){
		$('#index #news li').wrapInner('<div class="proper"></div>')
		$('#index #news li').prepend('<div class="top"></div><div class="bottom"></div>');
		$('#index #news li').prepend('<div class="fade-top"></div><div class="fade-bottom"></div>');
		$('#index #older-news').wrapInner('<div class="proper"></div>')
		$('#index #older-news').prepend('<div class="top"></div><div class="bottom"></div>');
		$('#index #shortcuts li:not(.no-corners)').wrapInner('<div class="proper"></div>')
		$('#index #shortcuts li:not(.no-corners)').prepend('<div class="bottom"></div>');

		$('#head .proper > li >  ul > li,#head .proper > li >  ul > li > ul > li  ').each(function(){ //poprawić, żeby dodawało div przy trzecim poziomie menu
			if ($(this).children('ul').length>0)
				$(this).append('<div></div>');
		});

		$('#head .proper > li:first-child.active span:first').css('background','url("/images/menu-first-position.png") left bottom no-repeat');
		$('#head .proper li:first').hover(function(){
				if ($(this).attr('class')!='active'){
					$('span:first',this).css('background','url("/images/menu-first-position.png") left bottom no-repeat')
				}
			}, function(){
				if ($(this).attr('class').indexOf('active')=='-1'){
					$('span:first',this).css('background','url("/images/menu-first-position.png") 1000px 10000px no-repeat');
				}
			});
		$('#content #left-col>li > ul > li:last-child > a').css('background','url("/images/left-first-level-bottom.png") left bottom no-repeat');

		$('#content #left-col > li > span').append('<span></span>');
		$('.employer.wysiwyg').wrapInner('<div class="added"></div>');
		$('.employer.wysiwyg:last .added ').css('background','none');
		$('.employer.wysiwyg:last').css('border',' 0 none');
	},
	header_animation : function(){
		$('.head h1').cycle('scrollHorz');
		//$('.head').append('<div id="above" />');
		$('#head-images').cycle({fx:'fade',speed:500, timeout:10000});
	},

	articles_menu : function(){
		$('#content #left-col > li').hover(function(){
				if (!$(this).hasClass('active')){
					$('span span',this).css('backgroundImage','url(/images/left-first-level-bottom.png)');
					$('span span',this).css('backgroundPosition','left bottom');
					$('span span',this).width(225);
					$('span span',this).height(10);
				}
			},
			function(){
				if (!$(this).hasClass('active')){
					$('span span',this).css('backgroundPosition','1000px 1000px');
				}
			});

		$('#content #left-col > li:not(.active) ul').hide();
		$('#content #left-col > li span, #content #left-col > li li span').bind('click',function(){
			$('#content #left-col > li span span').css('backgroundPosition','1000px 1000px');
			if ($(this).parent().attr('class')!='active'){
				$('span span',$(this).parent()).css('background','url(/images/left-span-added.png) no-repeat scroll 1000px 1000px');
				$('span span',$(this).parent()).width(224);
				$('span span',$(this).parent()).height(15);
				if (($(this).parent().parent()).attr('id')=='left-col'){
					$('#content #left-col li.active ul').slideUp();
					$('#content #left-col li.active').toggleClass('active');
				}
				$(' > ul',$(this).parent()).slideDown().parent().toggleClass('active');
				$('#content #left-col > li.active span span').css('backgroundPosition','left bottom');
			}
		});
	},
	printer : function(){
		$('p.links').append('&nbsp;|&nbsp;<a class="print" href="#" onclick="window.print(); return false;">'+i18n.print+'</a>');
	}
}

$(document).ready(function(){
	awf.start();
	awf.articles_menu();
	awf.header_animation();
	awf.printer();
});