

jQuery(function($) {
	$('html').removeClass('no-js').addClass('js');
	
	$.maxZIndex = $.fn.maxZIndex = function(opt) {   
		var def = { inc: 10, group: "*" };
		$.extend(def, opt);
		var zmax = 0;
		$(def.group).each(function() {
			var cur = parseInt($(this).css('z-index'));
			zmax = cur > zmax ? cur : zmax;
		});
		if (!this.jquery)
			return zmax;

		return this.each(function() {
			zmax += def.inc;
			$(this).css("z-index", zmax);
		});
	}

	/* datepicker */
	
	var dates = $( "#termin_od, #termin_do" ).datepicker({
		defaultDate: "+1w",
		changeMonth: false,
		numberOfMonths: 1,
		showOn: "both",
		buttonImage: "images/cal_icon.gif",
		minDate:0,
		autoSize: false,
		prevText: 'Poprzedni',
		nextText: 'Nast&#281;pny',
		monthNames: ['Stycze&#324;','Luty','Marzec','Kwiecie&#324;','Maj','Czerwiec','Lipiec','Sierpie&#324;','Wrzesie&#324;','Pa&#378;dziernik','Listopad','Grudzie&#324;'],
		dayNamesMin: ['Nd','Pn','Wt','&#346;r','Czw','Pt','So'],
		dateFormat: 'dd.mm.yy',
		beforeShow: function(input) {			
			setTimeout(function(){
				$('#ui-datepicker-div').css({'z-index':'9999'});      
			},1); 
		},		

		onSelect: function( selectedDate ) {
			var option = this.id == "termin_od" ? "minDate" : "maxDate",
				instance = $( this ).data( "datepicker" );
				date = $.datepicker.parseDate(
					instance.settings.dateFormat ||
					$.datepicker._defaults.dateFormat,
					selectedDate, instance.settings );
			dates.not( this ).datepicker( "option", option, date );
		}
		
	});
	
	/* topmenu */
	$("#topMenu ul ul").css({display: "none"});
	$("#topMenu li").hover(function(){

		if($.browser.msie && $.browser.version == 7.0) {
			$(this).children("ul").css({display: "block"});
		};
		$(this).children('ul')
		.css({visibility:"visible"})
		.stop(true,true)
		.slideDown(200, "easeOutCirc");
	},
	function(){
		$(this).children('ul')
		.stop(true,true)
		.delay(0)
		.fadeOut(100);
	});
	
	/* colorbox */
	$("a[rel='lightbox']").colorbox({slideshow:true,transition:"fade"});
	$("a.gal-box").colorbox({slideshow:true,transition:"fade"});
	$("a#negocjuj_btn").colorbox({transition:"fade",iframe:true, innerWidth:510, innerHeight:550, scalePhotos:true, scrolling:false});
	
	/* slideshow */
	if(slideshow_on == true){
		demo3Effect1 = {name: 'myEffect31',  fade: true, duration: 1700};
		var demoSlider = Sliderman.slider({container: 'show', width: 610, height: 220, effects: demo3Effect1, display: {autoplay: 3000}});
	}
});

