$(document).ready(function() {

	//wyszukiwarka
	$('form.search input.text').focus(function() {
		if ($(this).val() == 'Szukaj...') $(this).val('');
	}).blur(function() {
		if ($(this).val() == '') $(this).val('Szukaj...');							  
	});
	
	$('form.productSend input.text').focus(function() {
		if ($(this).val() == 'e-mail znajomego') $(this).val('');
	}).blur(function() {
		if ($(this).val() == '') $(this).val('e-mail znajomego');							  
	});
	
	$('.sideBoxPolec input.text').focus(function() {
		if ($(this).val() == 'wpisz adres e-mail') $(this).val('');
	}).blur(function() {
		if ($(this).val() == '') $(this).val('wpisz adres e-mail');							  
	});
	
		
	$('.slideshow .part').each(function() {
		$(this).find('.content').before('<div class="shadow"></div>');
	});
	
	$('.slideshow .parts').after('<div class="nav"></div>').cycle({
		fx:     'fade',
		timeout: 6000,
		delay:  -2000,
		pager: '.slideshow .nav'
	});
	
	$('#mainnav > ul > li > h2 > a.active').addClass('active2');
	
	$('#mainnav > ul > li.mega').hover(function() {
		$('#mainnav > ul > li').not($(this)).find('.subnav').hide();
		$(this).find('h2 > a').addClass('active');
		$(this)
		.addClass('activeMega')
		.find('h2 a').addClass('hover').end()
		.find('div.subnav').show();
	}, function() {
		$(this).removeClass('activeMega')
		.find('h2 a').removeClass('hover').end()
		.find('div.subnav').hide();
		$(this).find('h2 > a').not('active2').removeClass('active');
	});
	
	$('#packSizeSliderIn').after('<div id="packSizeSliderInHelper" class="opt opt_5"></div>')
	.slider({
		value: $("#initPackSizeValue").attr('value'),
		min: 1,
		max: 5,
		step: 1,		
		slide: function(event, ui) {							
			$('#packSizeLabel li').removeClass('active');
			//$('#packSizeValue').val(ui.value);
			//alert(ui.value);								
			switch (ui.value) {
				case 1: $('#packSizeLabel .opt_1').addClass('active'); break;
				case 2: $('#packSizeLabel .opt_2').addClass('active'); break;
				case 3: $('#packSizeLabel .opt_3').addClass('active'); break;
				case 4: $('#packSizeLabel .opt_4').addClass('active'); break;
				case 5: $('#packSizeLabel .opt_5').addClass('active'); break;
			}			
		},
		change: function(event, ui) {			
			//$('#packSizeValue').val(ui.value);
			id = $('li.opt_'+ui.value).attr('id');			
			$('#packSizeValue').val(id.substr( 4 ));	
			//alert($(".sposobMielenia:checked").attr('value'));						
			ajaxPrice();		
		}			
	});
	
	if (!$.browser.msie) {
		$('#packSize li.opt, #packSizeSliderInHelper').click(function() {
			var idw = $(this).attr('class').substr(-1);
			$('#packSizeSliderIn').slider("option", "value", idw);
			$('#packSizeLabel li').removeClass('active');
			$('#packSize li.opt_'+idw).addClass('active');
			id = $('li.opt_'+idw).attr('id');			
			$('#packSizeValue').val(id.substr( 4 ));
			ajaxPrice();
		});
	}
	
	$('#sposobMielenia li').each(function() {
		$(this).find('input').addClass('bye').after('<span class="radioBtn"></span>');
		if ($(this).find('input').is(':checked')) $(this).find('.radioBtn').addClass('radioBtnChecked');
	});
	$('#sposobMielenia li input').click(function() {
		$('#sposobMielenia .radioBtn').removeClass('radioBtnChecked');
		$(this).parent().find('.radioBtn').addClass('radioBtnChecked');
	});
	
	$('.box > h3 > a, .sideBox > .inside > h3 > a').each(function() {
		$(this).parent().parent().css('cursor', 'pointer').click(function() {
			document.location.href = $(this).find('h3 > a').attr('href');
		});
	});
	
	var cur_url = encodeURIComponent(document.location.href);
	var cur_title = encodeURIComponent(document.title);
	$('.dodajDo ul')
		.find('li.wykop a').attr('href', 'http://www.wykop.pl/dodaj?url='+cur_url+'&title='+cur_title).end()
		.find('li.gwar a').attr('href', 'http://www.gwar.pl/DodajGwar.html?u='+cur_url).end()
		.find('li.delicious a').attr('href', 'http://del.icio.us/post?url='+cur_url+'&title='+cur_title).end()
		.find('li.google a').attr('href', 'http://www.google.com/bookmarks/mark?op=add&bkmk='+cur_url+'&title='+cur_title).end()
		.find('li.facebook a').attr('href', 'http://www.facebook.com/share.php?src=bm&u='+cur_url+'&t='+cur_title).end()
		.find('li.elefanta a').attr('href', 'http://elefanta.pl/member/bookmarkNewPage.action?url='+cur_url+'&title='+cur_title).end()
		.find('li.flaker a').attr('href', 'http://flaker.pl/add2flaker.php?url='+cur_url+'&title='+cur_title).end()
		.find('li.blip a').attr('href', 'http://blip.pl/dashboard?body='+cur_url+'%20-%20'+cur_title);

});

