Cufon.replace('.menu a,h2, h3,h4,h5', { fontFamily: "Existence Light"});
Cufon.replace('.scrollable .cufon,.cufon', { fontFamily: "Existence Light"});
Cufon.replace('.cart p,.price', { fontFamily: "Existence Light"});
Cufon.replace('.logo');
Cufon.replace('.under_promotion span', { TextDecoration: "line-through"})




$(document).ready(function(){
	
	$('.promocja_inf .add_to_cart').click(function(){
		$(this).parent().submit();
	});
	
	var h = $('.cat').height();
	$('.item_border').css('min-height', h);
	
	$(".scrollable").scrollable({circular: true}).autoscroll({ autoplay: true });
	
	$('.miniaturki a').hover(function(){
		$(this).find('span').fadeOut();
	}, function(){
		$(this).find('span').fadeIn();
	});
	$('.miniaturki a').click(function(event){
		event.preventDefault();
		$('.miniaturki a.current').removeClass('current');
		$('.fotka span.current').removeClass('current');
		var rel =$(this).attr('class');
		//alert(rel);
		$('.fotka .foto_big[rel="'+ rel +'"]').addClass('current');
		$(this).addClass('current');
	});
	
	$('.close').click(function(event){
		event.preventDefault();
		$('.login_slide').animate({
			top: '-150'
		}, 500, function() {
			// Animation complete.
		});

	});
	$('.open').click(function(event){
		event.preventDefault();
		$('.login_slide').animate({
			top: '0'
		}, 500, function() {
			// Animation complete.
		});

	});
	
	
	var h_top = $('#top').height();
	var h_midd= $('#middle').height();
	var red_line = h_top+h_midd;

$(window).scroll(function (e) { 
		var top = $(window).scrollTop();
		var offset= red_line -285;

		if(top>=offset){
			if($(".track").css('position')=='fixed'){
				$(".track").css('position','absolute');
				$(".track").css('top', ''+offset+'px');
			}
		}else{
			$(".track").css('position','fixed');
			$(".track").css('top', '0px');
		}
	});

////////////////////////////////////////////////////////////////////////////////////////////
// Dodatkowe  dla logowania na s.g.
////////////////////////////////////////////////////////////////////////////////////////////
	$("#login_panel input, #login_panel textarea, .serch input").not('.submit').each(function(){
			$(this).attr('orgValue', $(this).attr('value'));
		});
	$("#login_panel input, #login_panel textarea, .serch input").not('.submit').focus(function(){
			if($(this).attr('value') == $(this).attr('orgValue')){
				$(this).attr('value', "");
			}
	});
	$("#login_panel input, #login_panel textarea, .serch input").not('.submit').focusout(function(){
		if($(this).attr('value') == ""){
			$(this).attr('value', $(this).attr('orgValue'));
		}
	});


	$('#alert_login button').click(function(){
		$('#alert_tlo').css('display','none');
	});
	
	
	
	
	
//  Obsługa newslettera
	
	$('.newsletter_add').submit(	function()	{
			$("#newsletterError").html('');
			//$("#newsletterInfo").html('<img class="loading" src="img/loading.gif">');
			var mail=$('.newsletter_add .mail').val();
			//alert(mail);
			xajax_add_mail(mail);
			return false;
	});
	
		var h = $('body').height();
		$('#fog').css('height', h+150);
	$('.add_to_newsletter').click(function(event){
		event.preventDefault();
		$('#fog').css('display','block');
		
	});
	$('#fog .close').click(function(){
		$('#fog').css('display','none');
	});
	
	
	
	
	
///        Dodawanie rozwijanego
	$('.zawartosc').slideUp();
	
	$('.rozwin').click(function(){
		$(this).parent().find('.zawartosc').toggle('fast');
	});
	
	
	
	
/////////////////////////////////////////////////////////////////////////////////
// Usuwanie przykładowego tekstu w formularzach  -- j.s. 9.04
/////////////////////////////////////////////////////////////////////////////////

	// zapamiętaj oryginalne wartości
	$('.formText').each(function(){
		$(this).attr('orgValue', $(this).attr('value'));
	});
	$('.formTextArea').each(function(){
		$(this).attr('orgValue', $(this).attr('value'));
	});

	// klik
	$('.formText').focus(function(){
		if($(this).attr('value')==$(this).attr('orgValue'))
		   $(this).attr('value', '');
	});
	// wyjście
	$('.formText').blur(function(){
		if($(this).attr('value')=='')
		   $(this).attr('value', $(this).attr('orgValue'));
	});

	// klik
	$('.formTextArea').focus(function(){
		if($(this).attr('value')==$(this).attr('orgValue'))
		   $(this).attr('value', '');
	});
	// wyjście
	$('.formTextArea').blur(function(){
		if($(this).attr('value')=='')
		   $(this).attr('value', $(this).attr('orgValue'));
	});
	
});


