(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');
			
			$('.project').attr({href: $("#home_banner_"+next_index).attr('href')});
			
            $("#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);
                });
            });
			
			$(".loop_prev").click(function(){
				$("#home_banner_choosers").stopTime(); 
				var kuris = $("#home_banner_choosers li.active").attr('id');
				var activ = $("#home_banner_choosers li.active");
				
				if (kuris == 'home_banner_holder_0'){
					activ=$("#home_banner_choosers  li:last");
				}else{
					kuris = kuris.replace('home_banner_holder_', '');
					kuris=kuris*1-1;
					activ = $("#home_banner_choosers #home_banner_holder_"+kuris);
				}			
				
				home_show_banner(activ);

			});
			
			$(".loop_next").click(function(){
				$("#home_banner_choosers").stopTime(); 
				var kuris = $("#home_banner_choosers li.active").attr('id');
				var activ = $("#home_banner_choosers li.active");
				
				
				if (kuris == $("#home_banner_choosers  li:last").attr('id')){
					activ=$("#home_banner_choosers  li:first");
					
				}else{
				
					kuris = kuris.replace('home_banner_holder_', '');
					kuris=kuris*1+1;
					
					activ = $("#home_banner_choosers #home_banner_holder_"+kuris);
				}			
				
				home_show_banner(activ);

			});			
			
        }
        

    });
})(jQuery);

jQuery(document).ready(function(){

	resizeWindow();	
	$(window).bind("resize", resizeWindow);
	
	$('.atgal').bind('click', function(){
		history.back(-1);
	});

	

	jQuery('.thumb > a').click(function(){
		 jQuery(".thumb a").removeClass("active");
		 jQuery(this).addClass("active");

		  var kuris = jQuery(this).attr('alt');   
		  var kuris2 = jQuery(this).attr('href'); 

			jQuery('#item_image').fadeOut(function(){
				jQuery('#item_image').fadeIn();
			jQuery('#item_image').attr('src', kuris);
			jQuery('.itemfo').attr('href', kuris2);
			
		  });
	});
	
});








function resizeWindow(){
	var langoplotis = screen.width;
	var narsyklesplotis = $(window).width();
	
	if (langoplotis == "1024"){
		scroll(0,0)
		if (((narsyklesplotis>1000) && (narsyklesplotis<1024))){		
			$("html").css({overflowX: "hidden"});			
		}else{
			$("html").css({overflowX: "auto"});
		}
	}
}



