jQuery(document).ready(function(){

	//edirect on click submit viea ajax
	jQuery("#edirekt_send_link").click(function(){
			var edirekt_email = jQuery("#edirekt_email").val();
			   var reg = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
			   if(reg.test(edirekt_email) == false) {
					jQuery("#errInvalidEmail").show();
				  return false;
			   }
			jQuery("#subFormEdirekt input#urnih-urnih").val(edirekt_email);
			jQuery("#subFormEdirekt").submit();
			return false;
        });
		
	jQuery("#edirekt_send_link_odj").click(function(){
		var edirekt_email = jQuery("#edirekt_email_odj").val();
		   var reg = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
		   if(reg.test(edirekt_email) == false) {
				jQuery("#errInvalidEmailOdj").show();
			  return false;
		   }
		jQuery("#subFormEdirektOdj input#urnih-urnih").val(edirekt_email);
		jQuery("#subFormEdirektOdj").submit();
		return false;
     });

    //HOME PAGE SLIDESHOW
    jQuery('#slideshowContent').cycle({
        fx:      'scrollHorz',
        timeout:  5000,
        prev:    '#prev',
        next:    '#next',
        pager:   '#nav'
    });
	
	jQuery('.pauseButton').click(function() { 
   		jQuery('#slideshowContent').cycle('pause');
		jQuery(this).hide();
		jQuery('.playButton').show();
		return false;
	});
	jQuery('.playButton').click(function() { 
    	jQuery('#slideshowContent').cycle('resume', true); 
		jQuery(this).hide();
		jQuery('.pauseButton').show();
		return false;
	});

    //MAKES ENTIRE SPECIAL CLICKABLE
    jQuery(".specialsWrap").click(function(){
        window.location=$(this).find("a").attr("href");
        return false;
    });

    jQuery("#aktualno li").click(function(){
        window.location=$(this).find("a").attr("href");
        return false;
    });

    jQuery("#neSpreglejte li").click(function(){
        window.location=$(this).find("a.title").attr("href");
        return false;
    });

    //ADDS .hover CLASS TO SPECIALS FOR IE Z-INDEX FIX
    jQuery(".specials").mouseover(function(){
        jQuery(this).addClass("hover");
    });
    jQuery(".specials").mouseleave(function(){
        jQuery(this).removeClass("hover");
    });

    //ADDS CLASS (last) TO EVERY THIRD LI IN SPECIALS
    jQuery("ul#aktualno li:nth-child(3n)").addClass("last");

    //ADDS CLASS (last) TO THIRD LI IN AKTUALNO
    jQuery("#homePageSpecials ul li:nth-child(3n)").addClass("last");

    //SMOOTH SCROLLING NE SPREGLEJTE
    jQuery(function() {
        var allHeightLiScroller = 0;
        jQuery("#slide li").each( function( intIndex ) {
            allHeightLiScroller = allHeightLiScroller + jQuery(this).height();
        });

        if(allHeightLiScroller > jQuery("#heightWrappar").height()) {
            jQuery("#slide").simplyScroll({
                className: 'vert',
                horizontal: false,
                frameRate: 20,
                speed: 1,
                autoMode: 'loop'
            });
        } else {
            jQuery('.simply-scroll-back, .simply-scroll-forward').hide();
            jQuery('.simply-scroll-back, .simply-scroll-forward').hide();
        }
    });

    //DEFINES HEIGHT OF NE SPREGLEJTE ELEMNTS
    jQuery(function(){
        var defHeight = jQuery("#heightWrappar").height();
        jQuery(".simply-scroll-clip").height(defHeight-10);
    });

    // IE6 SMOOTH SCROLLING FIX
    jQuery("#neSpreglejte li").css("z-index","5");
});
