(function($)
{
    
    $(function()
    {
       
        /*
         * Homepage
         */
        var banners_change_interval = 5000;
        function home_show_banner(holder)
        {
            $("#home_banner_choosers .active").each(function()
            {
                var current_index   = $(this).attr('id')
                    .replace('home_banner_holder_', '');
                $("#home_banner_holder_"+current_index).removeClass('active');
                $("#home_banner_"+current_index).fadeOut(500);
                
            });
            
            var next_index      = $(holder).attr('id').replace('home_banner_holder_', '');
            $("#home_banner_holder_"+next_index).addClass('active');
            $("#home_banner_"+next_index).fadeIn(500);
            
			var prev_index  = next_index-1;
          
            if ($("#s"+next_index)){
             $("#s"+next_index).css({visibility: 'hidden'});
            }
            if ($("#s"+prev_index)){
             $("#s"+prev_index).css({visibility: 'hidden'});
            }
        }
        if ($("#home_banner_choosers .holder").length > 0) {
            $("#home_banner_choosers").everyTime(banners_change_interval, function() {
                if ($(".active", this).nextAll(".holder:not('.active')").length) {
                    home_show_banner($(".active", this).nextAll(".holder:not('.active')"));
                } else {
                    home_show_banner($(".holder:eq(0)", this));
                }
            });
            
            $("#home_banner_choosers .holder").each(function()
            {
                var holder = this;
                $("a", this).click(function()
                {
                    $("#home_banner_choosers").stopTime(); 
                    home_show_banner(holder);
                });
            });
        }
        

    });
})(jQuery);



jQuery(document).ready(function(){

	resizeWindow();	
	$(window).bind("resize", resizeWindow);
	
	$('.subm').mouseover(function(){
		var parent = $(this).parent().width()+42;
		var subm = $(this).parent().find('.submenu').show().css({width: parent});
		$(this).parent().find('.submenu li').show().css({width: parent-42});
		
		
	});
	
	$('.subm').mouseout(function(){
		$(this).parent().find('.submenu').hide();
	});

	$('.submenu').mouseover(function(){	

		$(this).show();
		//$(this).parent().find('a').css({textDecoration: 'underline'});
	});
	
	$('.submenu').mouseout(function(){	
		$(this).hide();
		//$(this).parent().find('a').css({textDecoration: 'none'});
	});	

});


function resizeWindow(){
	var langoplotis = screen.width;
	var narsyklesplotis = $(window).width();
	var erelis = $('.inner_l').height();
	if (erelis){
	 if (erelis <= 700)
		$('.inner_l').css({height: '625px'})
	}else{
	
		erelis = $('.inner_lw').height();
		
		if (erelis <= 400)
			$('.inner_lw').css({height: '450px'})		
	}
	
	if (langoplotis == "1024"){
		scroll(0,0)
		if (((narsyklesplotis>1000) && (narsyklesplotis<1024))){		
			$("html").css({overflowX: "hidden"});			
		}else{
			$("html").css({overflowX: "auto"});
		}
	}
}


