/*
	Autor: Grzegorz Jaworek
	E-mail: grzegorz.jaworek@gmail.com
	www: http://gjaworek.pl 
	Tel.: +48 696 818 300
*/

jQuery(document).ready(function(){
	try {
		Cufon.replace('h2 a, h3 a, #menu > #menu_center > ul > li > a, .fb', { fontFamily: 'lithos', hover: true });
		Cufon.replace('h2, h3', { fontFamily: 'lithos' });
	} catch(err) {}
	
	jQuery('.totop').click(function () {
		scroll(0,0);
		return false;
	});
	
	//adjustWindow();
	
	jQuery('.submit').mouseover(function () { jQuery(this).addClass('submit_hover') });
	jQuery('.submit').mouseout(function () { jQuery(this).removeClass('submit_hover') });
	jQuery('#menu li').mouseover(function () { jQuery(this).addClass('hover') });
	jQuery('#menu li').mouseout(function () { jQuery(this).removeClass('hover') });
	
	jQuery('#menu ul ul').hide();
	jQuery('#menu > #menu_center > ul > li').hoverIntent(hoverIn,hoverOut);
	
	jQuery('#bottom .links ul').easyListSplitter({ 
		colNumber: 3
	});
	
	jQuery('.ngg-gallery-thumbnail a').fancybox();
	jQuery('#date_from, #date_to').datepicker();
	jQuery('.entry').jScrollPane({scrollbarWidth:21, scrollbarMargin:10, dragMaxHeight: 51, dragMinHeight: 51, showArrows: true });		jQuery('a').click(function () {				jQuery('.entry').jScrollPane({scrollbarWidth:21, scrollbarMargin:10, dragMaxHeight: 51, dragMinHeight: 51, showArrows: true });	});
	jQuery('.newsletter .submit').click(function () {
		validate = validateForm(jQuery(this).parents('form'));
		return validate;
	});
});

jQuery(window).resize(function(){
	//adjustWindow();
});

function adjustWindow() {
	myWidth = jQuery('body').width(); 
	myHeight = jQuery('body').height();
	myHeight = myHeight-162/*top*/-134/*bottom*/-42/*footer*/;
	jQuery('#content').height(myHeight);
	myHeight = myHeight-75/*content*/-158;
	jQuery('.entry, .sidebar').height(myHeight);
	//jQuery('.entry').jScrollPane({scrollbarWidth:21, scrollbarMargin:10, dragMaxHeight: 51, dragMinHeight: 51});
}
function hoverIn(){ jQuery(this).children('ul').animate({height: 'toggle'}, 400);}
function hoverOut(){ jQuery(this).children('ul').animate({height: 'toggle'}, 400);}

function validateForm(form)
{	
	validate = true;
	email = form.children().find('.text');
	if ((email.attr('name') == 'ne') && !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email.val())) ) {
		email.parent('p').append('<span class="wpcf7-not-valid-tip">Proszę podać poprawny adres email</span>').mouseover(function () { jQuery(this).children('.wpcf7-not-valid-tip').hide(200) });
		validate = false;
	}
    return validate;
}
