$(document).ready(function() {


	$('#inline-kupon-link').click(function(){
		$('#inline-kupon').toggle();
	});

	$('#boxKoszykProdukt').hide();
	$('#boxKoszykProdukt').fadeIn(1000);

	setInterval(function() {
		$('.priceInfo:visible').fadeTo(600, 0.1);
		$('.priceInfo:visible').fadeTo(600,1);		
						 },2000);
						 
//$('#boxKoszykProdukt').slideDown();
	//$('#boxKoszykProdukt').fadeTo(500, 0.5);
	//$('#boxKoszykProdukt').fadeTo(500,1);
//tymczasowa podmiana sciezek dla serwisu Kompas
	$('#kompas').find('input:image, img[src="/inc/gfx/btn-zarejestruj.gif"]').each(function() {
		$(this).attr('src', $(this).attr('src').replace('/gfx/', '/gfx_kompas/'));									   
	});
	$('#kompas').find('img').each(function() {
		$(this).attr('src', $(this).attr('src').replace('/images/screeny/', '/images/screeny_kompas/'));									   
	});

	//zakladki
	$('.introBox ul.tabs').tabs({ fx: { opacity: 'toggle', duration: 'fast' } });

	//menu glowne
	$('#mainnav > li.active').addClass('start');
	$('#mainnav > li > a').hover(function() {
		$('#mainnav > li').removeClass('active').find('ul').hide();	
		$(this).parent().addClass('active').addClass('active2').find('ul').show();
	}, function() {
		//
	});
	$('#mainnav > li').mouseout(function() {
		$(this).removeClass('active2');
	});
	$('#mainnav').hover(function() {
		//alert('x');								
	},function() {
		setTimeout(function() {
			if ($('#mainnav > li.active2').size() == 0) {
				$('#mainnav > li').removeClass('active').find('ul').hide();	
				$('#mainnav > li.start').addClass('active').find('ul').show();
			}
		}, 1);						
	});
	
	//prezentacja miejsc
	$('.places .view li').css('cursor', 'pointer').click(function() {
		document.location.href = $(this).find('h4 a').attr('href');
	});
	$('.places .view li').each(function() {
		$(this).append('<div class="overlay"></div>');								
	});
	$('.places ul.tabs').tabs({ fx: { opacity: 'toggle', duration: 400 } }).tabs('rotate', 2000);
	$('.places ul.tabs a').click(function() {
		setTimeout("$('.places ul.tabs').tabs('rotate', 2000);", 400);
	});
	
	//wyszukiwarka
	$('form.search input.text').focus(function() {
		if ($(this).val() == 'Szukaj...') $(this).val('');
	}).blur(function() {
		if ($(this).val() == '') $(this).val('Szukaj...');							  
	});


	//star rating
	//var cv = $('#rate').text();
	//var rateurl= $('#rateURL').val();
	//$('#rate').rating(rateurl, {maxvalue:5, curvalue:cv});
	
	//protezy dla IE
	if ($.browser.msie) {
		$('input:text, textarea').focus(function() {
			$(this).addClass('focus');
		}).blur(function() {
			$(this).removeClass('focus');
		});
		
		var star = '<img src="/inc/gfx/ico-star-8.gif" alt="" /> ';
		$('em.rank1').replaceWith('<img src="/inc/gfx/ico-star-8.gif" alt="" style="margin-right: 42px;" />');
		$('em.rank2').replaceWith(star+'<img src="/inc/gfx/ico-star-8.gif" alt="" style="margin-right: 32px;" />');
		$('em.rank3').replaceWith(star+star+'<img src="/inc/gfx/ico-star-8.gif" alt="" style="margin-right: 22px;" />');
		$('em.rank4').replaceWith(star+star+star+'<img src="/inc/gfx/ico-star-8.gif" alt="" style="margin-right: 12px;" />');
		$('em.rank5').replaceWith(star+star+star+star+'<img src="/inc/gfx/ico-star-8.gif" alt="" style="margin-right: 2px;" />');
	}
	
	$('a.option #map_canvas div div:first').addClass('map_canvas_div_div');
	
});

function toggleBox(target, textCurrentId, textNew, textCurrent) {
	targetObj = document.getElementById(target);
	textCurrentObj = document.getElementById(textCurrentId);
	if (targetObj.style.display == 'none') {
		targetObj.style.display='block';
		textCurrentObj.innerHTML = textNew;
	} else {
		targetObj.style.display='none';
		textCurrentObj.innerHTML = textCurrent;
	}
;}
