function html5forIE() {
	document.createElement('header');
	document.createElement('nav');
	document.createElement('section');
	document.createElement('article');
	document.createElement('aside');
	document.createElement('footer');
}


$(document).ready(function() {

	$('aside.left *').ready(function(){
		$('article').css('minHeight', $('.bx1020 .bx .bx').innerHeight());
	});

	// block click in menu
	$('#vert-left > ul > li').has('ul').find('> a').attr('href', '#');





	jQuery.fn.exists = function() { return jQuery(this).length>0; }

	//table tr even
	if($('#mainContent table').exists()){
		$('#mainContent table tr:even').addClass('even');
	}

	$('a img').hover(function(){
		$(this).animate({opacity:.8}, 200);
	}, function(){
		$(this).animate({opacity:1}, 200);
	});


	// slider

	if($("#slider").exists()) {

		$.getScript('js/jquery.cycle.all.min.js', function(){
			$('#slider .content').cycle({
				timeout: 4000,
				sync:1,
				speed: 1000,
				pause: true
			});
		});

		$('#slider .tabs li').hover(function(){
			$(this).addClass('on');
			$(this).trigger('click');
		}, function(){
			$(this).removeClass('on');
		});

		$('#slider .tabs .item1').click(function() {
			$('#slider .content').cycle(0);
			return false;
		});
		$('#slider .tabs .item2').click(function() {
			$('#slider .content').cycle(1);
			return false;
		});
		$('#slider .tabs .item3').click(function() {
			$('#slider .content').cycle(2);
			return false;
		});

	}



	// Menu vertical

	$('#vert-left a').click(function() {
		if ($(this).attr('href') == '#') {
			if ($(this).parent().find('ul:first').length > 0) {
				if($(this).next('ul').length == 0) {
					$('.on ul').slideUp();
				}
				$(this).parent().find('ul:first').slideToggle('fast');
				$(this).parent().toggleClass('on');
				return false;
			}
		}
	})

	// Open if 'on' class exist

	$('#vert-left li.on').each(function() {
		$(this).find('ul:first').show();
	});





	// Calendar

	function cal () {
		var el_cal		= $(".cal");
		var el_events	= el_cal.find ("FORM").attr("action");


		// zmiana okresu

		el_cal.find ("select[name=month], select[name=year]").unbind ("change").change (function () {
			$.ajax({
				url: "/event.php?year=" + el_cal.find("select[name=year]").val() + "&pokoj=" + el_cal.find("input[name=pokoj]").val() + "&month=" + el_cal.find("select[name=month]").val() + "/",
				cache:		false,
				success:	function (data){
			        el_cal.html (data);
			        $('select.sel').customStyle();
				cal();
		    	}
			});
		})

		// hover

		$(".cal .days li").hover(function () {
			$(this).addClass("days-hover");
			}, function () {
			$(this).removeClass("days-hover");
			}
		);


		// click

		$(".cal .days li a").click(function(){
			$f = $(this).attr("href");
			$e = $(this).attr("id");

			// set new cookies
			var $cookie_event = "event";
				$.cookie($cookie_event, $e);

			location.href = $f;
			return false;
		});


		// find current date
		var d = new Date();
		var $curr_date = d.getDate();

		$.expr[":"].econtains = function(obj, index, meta, stack){
			return (obj.textContent || obj.innerText || $(obj).text() || "").toLowerCase() == meta[3].toLowerCase();
		}

		$(".days li:econtains"+"('"+$curr_date+"')").addClass('today');

	}

	if ( $(".cal").exists() ) {
		cal();
	};



	// No right aside

	if ($("aside.right").exists()) { } else {
		$("article").addClass("full");
	}



	// Comments

	if($("#comments").exists()) {
		$("#comments .item:odd").addClass("odd");
	}



	// Events
	$('#events h4 a').click(function() {
		$('#events .body').hide();
		$(this).parent().parent().find('.body').fadeIn('fast');
		return false;
	})



	// Focus border remove

	$("a").focus(function() {
		$(this).blur();
	});



	// Fancybox

	if($(".fancy").exists()) {
		$(".fancy").fancybox({
			'titlePosition'	:	'over',
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'onComplete'	:	function() {
				$("#fancybox-wrap").hover(function() {
					$("#fancybox-title").show();
				}, function() {
					$("#fancybox-title").hide();
				});
			}
		});
	}


	// Select replace

	$('select.sel').customStyle();



	// Clear input

	var startValue = '';
	$('.iTxt').focus(function() {
		startValue = this.value;
		if (this.value == startValue) {this.value='';}
	})
	$('.iTxt').blur(function() {
		if (this.value=='') {this.value = startValue;}
	})



	// _blank

	$(function() {
		$('a.blank').click( function() {
			window.open(this.href);
			return false;
		});
	});




	// Form validate

	//$('.error').hide();
	$('form #submit').click(function() {

		var valid = true;
		$('.required').click(function(){
			$(this).removeClass('error');
		});
		$('.required').each(function(){
			if ($(this).val() == ''){
				$(this).addClass('error');
				valid = false;
			} else{
				$(this).removeClass('error');
			}
		});

		if(!valid){
			//$('.error').fadeIn();
			return false;
		}

	});



	// Opacity

	$.fn.opacity = function() {
		$(this).hover(
		  function () {
			$(this).css({ opacity: ".9" });
		  },
		  function () {
			$(this).css({ opacity: "1" });
		  }
		);
	}

	$('.baners li').opacity();




});





/* Select replace */

(function($){
	$.fn.extend({

	 	customStyle : function(options) {
		  if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
		  return this.each(function() {

				var currentSelected = $(this).find(':selected');
				$(this).after('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">'+currentSelected.text()+'</span></span>').css({position:'absolute', opacity:0,fontSize:$(this).next().css('font-size')});
				var selectBoxSpan = $(this).next();
				var selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));
				var selectBoxSpanInner = selectBoxSpan.find(':first-child');
				selectBoxSpan.css({display:'inline-block'});
				selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
				var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
				$(this).height(selectBoxHeight).change(function(){
					// selectBoxSpanInner.text($(this).val()).parent().addClass('changed');   This was not ideal
				selectBoxSpanInner.text($(this).find(':selected').text()).parent().addClass('changed');
					// Thanks to Juarez Filho & PaddyMurphy
				});

		  });
		  }
		}
	});
})(jQuery);
