$(document).ready(function(){
	Cufon.replace('#header a', { fontFamily: 'AlternateGothicNo2EU', hover:true});
	Cufon.replace('#main-menu a', { fontFamily: 'AlternateGothicNo2EU', hover:true});
	Cufon.replace('h1', { fontFamily: 'zurich'});
	Cufon.replace('h2', { fontFamily: 'zurich'});
	Cufon.replace('h3', { fontFamily: 'zurich'});
	Cufon.replace('h4', { fontFamily: 'zurich'});
	Cufon.replace('#box1-header li', { fontFamily: 'zurich'});
	Cufon.replace('#menu li', { fontFamily: 'zurich', hover:true});
	Cufon.replace('#submenu .in li a', { fontFamily: 'zurich', hover:true});
	
	//$(document).pngFix(); 
	$('#main-menu a').hover(
		function(){$(this).parent().parent().addClass("active");},
		function(){$(this).parent().parent().removeClass("active");}
		);
	/*$('#menu a').hover(
		function(){$(this).parent().addClass("selected");},
		function(){$(this).parent().removeClass("selected");}
		);
	*/
	$('#box1-header li').click(function(){
		$('.box-hidden').animate({'opacity':'0'}, 300).hide();
		$('#box1-header li').children().attr('class', '');
		temp =  $(this).attr('class');
		$('#' + temp).animate({'opacity':'1'}, 300).show();
		$(this).children().attr('class', 'selected');
		Cufon.replace('#box1-header li', { fontFamily: 'zurich'});
		
	});
	
	$('hr').wrap('<div class="hr"></div>');
	
	if ($(".archive-year")) {
		$(".archive-year:first").next().show();
		$(".archive-year").click(function(){
			//$("#toggle1 li h2").not(this).children("span").show();
			//$(this).children("span").hide();
			$(this).next($(".archive-year")).show();
			$(".archive-year").not(this).next($(".archive-year")).hide();
		});
	}
	
	education_no = $('#LongApplicationEducationNo').val();
	if(!education_no)
		$('#LongApplicationEducationNo').val(1);
	for(i=1; i<education_no; i++)
		$('#edu'+i).show();
	$('#button-add-1').click(function(){
		$('.h-edu:visible').next().slideDown();
		$('#LongApplicationEducationNo').val(parseInt($('#LongApplicationEducationNo').val())+1);
		if($('#LongApplicationEducationNo').val()=='5')
			$('#button-add-1').hide();
	});
	
	experience_no = $('#LongApplicationExperienceNo').val();
	if(!experience_no)
		$('#LongApplicationExperienceNo').val(0);
	for(i=0; i<experience_no; i++)
		$('#ex'+i).show();
	$('#button-add-2').click(function(){
		$('.h-ex:visible').next().slideDown();
		$('#LongApplicationExperienceNo').val(parseInt($('#LongApplicationExperienceNo').val())+1);
		if($('#LongApplicationExperienceNo').val()=='5')
			$('#button-add-2').hide();
	});
	
	qualification_no = $('#LongApplicationQualificationNo').val();
	if(!qualification_no)
		$('#LongApplicationQualificationNo').val(0);
	for(i=0; i<qualification_no; i++)
		$('#qual'+i).show();
	$('#button-add-3').click(function(){
		$('.h-qual:visible').next().slideDown();
		$('#LongApplicationQualificationNo').val(parseInt($('#LongApplicationQualificationNo').val())+1);
		if($('#LongApplicationQualificationNo').val()=='5')
			$('#button-add-3').hide();
	});
	
});


function changeEx(){
	answ = $('input[name="data[LongApplication][have_experience]"]:checked').val();
	//alert(answ);
	if(answ && answ==1)
	{
		$('#button-add-2').show();
		$('#LongApplicationExperienceNo').val(1);
		
		$('#ex0').slideDown();
	}
	if(answ && answ==0)
	{
		$('#button-add-2').hide();
		$('#LongApplicationExperienceNo').val(0);
		
		$('.h-ex').slideUp();
	}
}
function changeQual(){
	//console.log($(this));
	answ2 = $('input[name="data[LongApplication][have_qualifications]"]:checked').val();
	//alert(answ2);
	if(answ2 && answ2==1)
	{
		$('#button-add-3').show();
		$('#LongApplicationQualificationNo').val(1);
		
		$('#qual0').slideDown();
	}
	if(answ2 && answ2==0)
	{
		$('#button-add-3').hide();
		$('#LongApplicationQualificationNo').val(0);
		
		$('.h-qual').slideUp();
	}
}

function changeFont(size)
{
	switch(size)
	{
		case 12:
			$('#content .text').css({
				'font-size': '12px',
				'line-height': '17px'
			});
			$('#home .text').css({
				'font-size': '11px'
			});
			$('#content .group-box .list li').css({
				'font-size': '12px',
				'line-height': '17px',
				'height': '30px'
			});
			$('#content .more').css({
				'font-size': '11px',
				'line-height': '17px'
			});
			$('#home .box2 .more a').css({
				'font-size': '11px',
				'line-height': '17px'
			});
			$('.form-choose-text').css({
				'font-size': '11px',
				'line-height': '17px'
			});
			$('.form-small-text').css({
				'font-size': '11px',
				'line-height': '17px'
			});
            $('#content.list.herb-intro .list li').css({
				'height': '45px'
			});
			$('#content.list .list2 li').css({
				'height': '45px'
			});
			$('#content .products-list-item .text .name').css({
				'font-size': '14px',
				'line-height': '19px'
			});
			$('#home .products-list-item .text .name').css({
				'font-size': '14px',
				'line-height': '19px'
			});
			$('#home .box2 .left-side').css({
				'height':'180px',
				'height':'auto !important',
				'min-height':'180px'
			});
			$('#home .box2 .right-side').css({
				'height':'180px',
				'height':'auto !important',
				'min-height':'180px'
			});
			
			$.cookie('CakeCookie[Font][size]', null, { path: '/' });
            return false;

			break;
		case 14:
			$('#content .text').css({
				'font-size': '14px',
				'line-height': '19px'
			});
			$('#home .text').css({
				'font-size': '13px'
			});
			$('#content .group-box .list li').css({
				'font-size': '14px',
				'line-height': '19px',
				'height': '45px'
			});
			$('#content .more').css({
				'font-size': '13px',
				'line-height': '18px'
			});
			$('#home .box2 .more a').css({
				'font-size': '13px',
				'line-height': '18px'
			});
			$('.form-choose-text').css({
				'font-size': '13px',
				'line-height': '18px'
			});
			$('.form-small-text').css({
				'font-size': '13px',
				'line-height': '18px'
			});
			$('#content.list.herb-intro .list li').css({
				'height': '70px'
			});
			$('#content.list .list2 li').css({
				'height': '70px'
			});
			$('#content .products-list-item .text .name').css({
				'font-size': '16px',
				'line-height': '21px'
			});
			$('#home .products-list-item .text .name').css({
				'font-size': '16px',
				'line-height': '21px'
			});
			$('#home .box2 .left-side').css({
				'height':'210px',
				'height':'auto !important',
				'min-height':'210px'
			});
			$('#home .box2 .right-side').css({
				'height':'210px',
				'height':'auto !important',
				'min-height':'210px'
			});
            
			var date = new Date();
            date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));
            $.cookie('CakeCookie[Font][size]', size, { path: '/', expires: date });
            return false;

			break;
		case 16:
			$('#content .text').css({
				'font-size': '16px',
				'line-height': '21px'
			});
			$('#home .text').css({
				'font-size': '15px'
			});
			$('#content .group-box .list li').css({
				'font-size': '16px',
				'line-height': '21px',
				'height': '55px'
			});
			$('#content .more').css({
				'font-size': '15px',
				'line-height': '19px'
			});
			$('#home .box2 .more a').css({
				'font-size': '15px',
				'line-height': '19px'
			});
			$('.form-choose-text').css({
				'font-size': '15px',
				'line-height': '19px'
			});
			$('.form-small-text').css({
				'font-size': '15px',
				'line-height': '19px'
			});
			$('#content.list.herb-intro .list li').css({
				'height': '78px'
			});
			$('#content.list .list2 li').css({
				'height': '78px'
			});
			$('#content .products-list-item .text .name').css({
				'font-size': '18px',
				'line-height': '23px'
			});
			$('#home .products-list-item .text .name').css({
				'font-size': '18px',
				'line-height': '23px'
			});
			$('#home .box2 .left-side').css({
				'height':'230px',
				'height':'auto !important',
				'min-height':'230px'
			});
			$('#home .box2 .right-side').css({
				'height':'230px',
				'height':'auto !important',
				'min-height':'230px'
			});
            
			var date = new Date();
            date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));
            $.cookie('CakeCookie[Font][size]', size, { path: '/', expires: date });
            return false;

			break;
	}
}

function archive(date)
{
	location.href = base + 'centrum-prasowe/informacje-prasowe/date:' + date;
}

var param1 = '1';
var param2 = '1';
var param3 = '1';
function sort_out(nr, param, selected)
{
	if(param==1)
	{
		temp = 'param' + nr;
		temp = '1';
	}
	el = $('#sort-list'+nr);
	if(nr==1)
	{
		if(param1=='1')
		{
			param1 = '2';
			el.animate({'opacity':'1'}, 300).show();
			$('#arrow'+nr).attr('src', 'img/arrow_up.jpg');
		}
		else
		{
			param1 = '1';
			el.animate({'opacity':'0'}, 300).hide();
			$('#arrow'+nr).attr('src', 'img/arrow_down.jpg');
		}
	}
	
	if(nr==2)
	{
		if(param2=='1')
		{
			param3 = '1';
			$('#sort-list3').animate({'opacity':'0'}, 300).hide();
			$('#arrow3').attr('src', 'img/arrow_down.jpg');
			param2 = '2';
			el.animate({'opacity':'1'}, 300).show();
			$('#arrow'+nr).attr('src', 'img/arrow_up.jpg');
		}
		else
		{
			param2 = '1';
			el.animate({'opacity':'0'}, 300).hide();
			$('#arrow'+nr).attr('src', 'img/arrow_down.jpg');
			if(selected)
			{
				temp = $('.submenu-select2-'+selected).text();
				$('#submenu-i-search span').html(temp);
			}
		}
	}
	
	if(nr==3)
	{
		if(param3=='1')
		{
			param2 = '1';
			$('#sort-list2').animate({'opacity':'0'}, 300).hide();
			$('#arrow2').attr('src', 'img/arrow_down.jpg');
			param3 = '2';
			el.animate({'opacity':'1'}, 300).show();
			$('#arrow'+nr).attr('src', 'img/arrow_up.jpg');
			if($('#slider'))
			{		
				$('#slider').slider({
						orientation: 'vertical',
						min: 0,
						max: $('#select-scroll-3').height(),
						change: function(event, ui){
							$('#select-scroll-3').scrollTo($('#slider').slider('option', 'max') - ui.value);
						}
					});
			}
		}
		else
		{
			param3 = '1';
			el.animate({'opacity':'0'}, 300).hide();
			$('#arrow'+nr).attr('src', 'img/arrow_down.jpg');
			if(selected)
			{
				temp = $('.submenu-select3-'+selected).text();
				$('#submenu-t-search span').html(temp);
			}
		}
	}
}



function scroll_up(nr)
{
	it = setInterval(function(){$('#select-scroll-'+nr).scrollTo('-=5px');},50);
}

function scroll_down(nr)
{
	it = setInterval(function(){$('#select-scroll-'+nr).scrollTo('+=5px');},50);
}
function scroll_stop()
{
	clearInterval(it);
}

function scroll_engine(nr)
{
	it = setInterval(function(){$('#select-scroll-'+nr).scrollTo('+=5px');},50);
}
