/**
 * jQuery isHovered (http://mktgdept.com/jquery-ishovered)
 * A jQuery plugin to test if an element is currently hovered
 *
 * v0.0.1 - 11 June 2010
 *
 * Copyright (c) 2010 Chad Smith (http://twitter.com/chadsmith)
 * Dual licensed under the MIT and GPL licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/gpl-license.php
 *
 * Test if an element is hovered using: $(selector).isHovered() or $.isHovered(selector)
 *
 **/

//_____________________________________





jQuery(document).ready(function(){
    var x=0;
    var y=0;

     (function(b,c){b('*').hover(function(){b(this).data(c,1)},function(){b(this).data(c,0)}).data(c,0);b[c]=function(a){return b(a)[c]()};b.fn[c]=function(a){a=0;b(this).each(function(){a+=b(this).data(c)});return a>0}})(jQuery,'isHovered');


	jQuery.fn.delay = function(time, callback){
		jQuery.fx.step.delay = function(){};
		return this.animate({delay:1}, time, callback);
		}

	//Prvo skrijemo meni za jezik (langdd) in meni za filter(filterdd)
	jQuery('#langdd ul').hide();
	jQuery('#filterdd ul').hide();
	// Skrijemo glavni meni
	//$('.menu ul li ul').hide();

	//Potem definiramo funkcije za animacijo
	jQuery('#langmenu').click(function () {
		jQuery('#langdd ul').slideToggle(400);
    });
	jQuery('#filter ').click(function () {
		jQuery('#filterdd ul').slideToggle(400);
    });


	// MENU - start

	// Skrijemo glavni meni
	jQuery('.menu > ul > li > ul').hide();
	// skrijemo podmenije
	jQuery('li.submenu').children('ul').attr('style', 'visibility: hidden; display: none;');


    jQuery('div.menu > ul > li > a').hover(
			function () {

				// odpiramo samo ce se ni odprto   // in če je miška nad linkom
				if ( jQuery(this).parent().height() != '60' && jQuery(this).isHovered() ) {

					jQuery(this).parent().animate({
						height: '60px'
					}, 150, function() {

						// odpira samo ce je span ze odprt // in če je miška nad spanom
						if ( jQuery(this).height() == '60' && jQuery(this).isHovered() ) {
							jQuery(this).children('ul').animate({height: 'show'}, 150);
						}else{							jQuery(this).animate({
								height: '40px'
							}, 150);
						}

					} );

				}
			}
	);

	jQuery('div.menu > ul > li').mouseleave(
			function  () {

				// zapiramo samo ce je odprto
				if ( jQuery(this).height() == '60' ) {

					jQuery(this).children('ul').animate({
						height: 'hide'
					}, 150, function () {

						if ( jQuery(this).css('display') == 'none' ) {


							jQuery(this).parent().animate({
								height: '40px'
							}, 150);

						}

					});

					if ( jQuery(this).children('ul').size() == 0) {
						jQuery(this).animate({
							height: '40px'
						}, 150);
					}
				}
			}
	);


	jQuery('div.menu li.submenu').mouseenter(
			function () {

				jQuery(this).children('ul').attr('style', 'visibility: visible; display: block;');

				// v ie se nocejo pokazati li elementi, ko gremo drugic na meni tretje stopnje ... fix:
				jQuery(this).children('ul').children('li').attr('style', 'visibility: visible; display: block;');

			}
	);

	jQuery('div.menu li.submenu').mouseleave(
			function () {

				jQuery(this).children('ul').attr('style', 'visibility: hidden; display: none;');

			}
	);


	// MENU - end

});

jQuery.noConflict();
