$(function() {
//flash
	$("#flaszyk").flash({
		src: 'swf/top.swf',
		id: 'top_flash',
		wmode: 'transparent',
		width: 952,
		height: 189},
        { version: 8 }
    );
	$("#flaszykEn").flash({
		src: 'swf/top-en.swf',
		id: 'top_flash',
		wmode: 'transparent',
		width: 952,
		height: 189},
        { version: 8 }
    );
	
	$("#zaufaliNamFlash").flash({
		src: 'swf/scroll.logotypes.swf',
		id: 'zaufali_flash',
		wmode: 'transparent',
		width: 571,
		height: 83 },
        { version: 8 }
    );
	
//menu	
	$("#menuSzukaj ul li").hover(function() {
		$(this).find("ul").stop().slideDown(400).show(400, function(){
			$(this).height("auto");
		});
		$(this).addClass("hover");
	} , function() {
		$(this).find("ul").slideUp(250);
		$(this).removeClass("hover");
	});
	
//menu left
	$("#left ul li a").hover(function() {
		$(this).stop().animate({ 
			paddingLeft: '18'
		}, 150);
	} , function() {
		$(this).stop().animate({
			paddingLeft: '13'
		}, 150);
	});
	$("#left ul li ul li a").hover(function() {
		$(this).stop().animate({ 
			paddingLeft: '33'
		}, 150);
	} , function() {
		$(this).stop().animate({
			paddingLeft: '28'
		}, 150);
	});
	$("#left ul li ul li ul li a").hover(function() {
		$(this).stop().animate({ 
			paddingLeft: '39'
		}, 150);
	} , function() {
		$(this).stop().animate({
			paddingLeft: '34'
		}, 150);
	});
	
//form validacja
	if ($("#formKontakt").length)
		$('#formKontakt').validate({
			rules: {
				temat: {
					required: true
				},
				imie_nazwisko: {
					required: true,
					minlength: 3
				},
				email: {
					required: true,
					email: true
				},
				zapytanie:{
					required: true
				}
			}
		}); 
	
//kategorie produktow - ostatni element
	if ($("ul#kategorie").length)
		$("ul#kategorie li:odd").addClass("odd");
	
	if ($("ul#produkty").length)
		$("ul#produkty li:odd").addClass("odd");

//faq - zwin rozwin
	$("#faq .showHide").hide();
    $("#faq h2").toggle(function(){
		$(this).next("#faq .showHide").slideDown(700, function() {
			$(this).parent().css("background","#f0f0f0");
		});
	}, function(){
		$(this).next("#faq .showHide").slideUp(700);
		$(this).parent().css("background","none");
	});
// mapa
    if ($("ul#siteMap").length)
		$("ul#siteMap li ul li:last-child").addClass("last");

// flipy
    $(".cooperationFlip").bind("click",function(){
		var elem = $(this);
		
		if(elem.data("flipped"))
		{
			elem.revertFlip();
			elem.data("flipped",false)
		}
		else
		{
			elem.flip({
				direction:"lr",
				speed: 350,
				onBefore: function(){
					elem.html(elem.siblings(".cooperationData").html());
				}
			});
			
			elem.data('flipped',true);
		}
	});
	$(".cooperationFlip").bind("click",function(e,block){

		if(block) return false;
		$(".cooperationFlip").not($(this)).each(function(){
	
			if($(this).data("flipped"))
				$(this).trigger("click",[true]);
		});
	});

});
