/*

	D�bica - JavaScripts

	rka@emarketingexperts.pl / www.emarketingexperts.pl

*/



function initBack() {

	$("#back").click(function() {

		history.back();

		return false;

	});

}



function initPrint() {

	$("#print").click(function() {

		window.print();

		return false;

	});

}



function initInputLabelFromLabel(input_id,label_id) {

	var text = $(label_id).text(); 

	$(input_id).val(text);

	$(input_id).focus( function() {

		if ($(this).val() == text) {

			$(this).val("");

		}

	} );

	  $(input_id).blur( function() {

		if ($(this).val() == '') {

			$(this).val(text);

		}

	} );

}



function initInputLabelFromInput(input_id) {

	var text = $(input_id).val(); 

	$(input_id).val(text);

	$(input_id).focus( function() {

		if ($(this).val() == text) {

			$(this).val("");

		}

	} );

	  $(input_id).blur( function() {

		if ($(this).val() == '') {

			$(this).val(text);

		}

	} );

}



function initFakeSelect(id) {

	$(id).mouseover(function() {

		$(this).find("dd").show();

		$(this).find("dt").addClass("hover");

	});

	$(id).mouseout(function() {

		$(this).find("dd").hide();

		$(this).find("dt").removeClass("hover");

	});

	

}

$(document).ready(function(){

    $(".opony1").css('display','none');

    $(".oferta-maszyny-rolnicze").click(function (event) {

      event.preventDefault();

      $(".opony1").toggle("slow");		

			$(".oferta-maszyny-rolnicze").toggleClass('opony-active');

    });    



  });

var timeout = 200;

		$(document).ready(function(){
		
				 $('#search_but-opony').hover(
		 function(){$(this).addClass('active');},function(){$(this).removeClass('active');}
		 );
 $('#nav-global li ul li.last').hover(function(){$(this).children('ul').stop(true,true).fadeIn('slow');},function(){$(this).children('ul').fadeOut('slow');});
		$('input.hidden').css('display','none');

			t = $(document).height(); 

		$("#overlay").css({'height': t , 'opacity':'0.55', 'background':'#fff','z-index':'90','display':'none'});

		$('ul#nav-global > li').hover(

		 function(){

		 $(this).children('ul').stop(true,true).fadeIn(timeout);

		$(this).children('a').addClass('hover');

			$('#overlay').stop(true,true).fadeIn(timeout);

		 },

		 function(){$(this).children('ul').fadeOut(timeout); $(this).children('a').removeClass('hover');$(this).children('li').removeClass('hover');$('#overlay').fadeOut(timeout);$(this).children('a').removeClass('hover');}

		 );

		 $('ul#nav-global li').hover(function(){$(this).addClass('active');},function(){$(this).removeClass('active');});

		 $('ul#nav-global li li').hover(function(){$(this).addClass('active');},function(){$(this).removeClass('active');});

		 });

 



function initialize() {

	//initInputLabelFromLabel("#search","#search_l");

	initInputLabelFromLabel("#search","#search_l");

	initInputLabelFromLabel("#newslet","#newslet_l");

	initInputLabelFromLabel("#password","#password_l");

	initInputLabelFromLabel("#kont_imie","#kont_imie_l");

	initInputLabelFromLabel("#kont_nazwisko","#kont_nazwisko_l");

	initInputLabelFromLabel("#kont_firma","#kont_firma_l");

	initInputLabelFromLabel("#kont_email","#kont_email_l");

	initInputLabelFromLabel("#kont_kom","#kont_kom_l");

	initInputLabelFromLabel("#kont_txt","#kont_txt_l");

	initInputLabelFromLabel("#wyszk_fraza","#wyszk_fraza_l");

	initInputLabelFromLabel("#wyszk-wyd-_fraza","#wyszk-wyd-fraza__l2");

	initInputLabelFromLabel("#event-form_email","#event-form_email_l2");

	initInputLabelFromLabel("#event-form_skad_wiesz","#event-form_skad_wiesz_l2");

	initInputLabelFromLabel("#kont1_email","#kont1_email_l2");

	initFakeSelect("#fs1");

	initFakeSelect("#fs2");

	initFakeSelect("#wo1");

	initFakeSelect("#wo2");

	initFakeSelect("#wo3");

	initFakeSelect("#wo4");

	initFakeSelect("#wo5");

	initBack();

	initPrint();

	//initFileUploads();
	
	/*
	$('#form_woj').each(function() {
		var _this = $(this);
		var current = this;
		var x = 0;
		var y = 0;
		while(current) {
			x += current.offsetLeft;
			y += current.offsetTop;
			current = current.offsetParent;
		}
	//	$('body').append(this);
	//	_this.css({position: 'absolute', left: x + 'px', top: y + 'px'});
	});*/

	$("select.selectbox").selectbox({animationSpeed: 'fast', listboxMaxSize: 8, elemHeightRatio: 1.55});

}



$(document).ready(initialize);