
window.addEvent("domready",function() {
	
    menuShowHide();
    playShowHide();
    if ($('content-inner')) {
        if ($('content-inner').getSize().y > 290) { 
            makeScrollbar( $('content'), $('scrollbar1'), $('handle1') );
        } else {
            $('scrollbar1').setStyle("display", "none");
        }
    }
    
    if ($("search")) {
        searchShowHide();
    }
    
    
    if ($("maslina-inner")) {    
        $("maslina-inner").setOpacity(0);  
        (function(){
            $("maslina-inner").fade("in");
        }).delay(2500);
    }

    if ($("f1")) {  
        var mover1= new Fx.Tween($("f1"),{
            property:'margin-top',
            link:'chain',
            duration: 300,
            transition: Fx.Transitions.easeOut
        });
        
        var mover2= new Fx.Tween($("f2"),{
            property:'margin-top',
            link:'chain',
            duration: 300,
            transition: Fx.Transitions.easeOut
        });
        
        var mover3= new Fx.Tween($("f3"),{
            property:'margin-top',
            link:'chain',
            duration: 300,
            transition: Fx.Transitions.easeOut
        });
        
        var mover4= new Fx.Tween($("f4"),{
            property:'margin-top',
            link:'chain',
            duration: 300,
            transition: Fx.Transitions.easeOut
        });
        
        var mover5= new Fx.Tween($("f5"),{
            property:'margin-top',
            link:'chain',
            duration: 300,
            transition: Fx.Transitions.easeOut
        });
        
    	$('f1').addEvents({
    		'mouseenter': function(){
                //mover1.start(0);
                $("f2").fade(.1);
                $("f3").fade(.1);
                $("f4").fade(.1);
                $("f5").fade(.1);
                //$("shadow").fade(.4);
    		},
    		'mouseleave': function(){
                //mover1.start(140);
                $("f2").fade(1);
                $("f3").fade(1);
                $("f4").fade(1);
                $("f5").fade(1);
                //$("shadow").fade(1);
    		}
    	});
    	
    	$('f2').addEvents({
    		'mouseenter': function(){
                //mover2.start(135);
                $("f1").fade(.1);
                $("f3").fade(.1);
                $("f4").fade(.1);
                $("f5").fade(.1);
                //$("shadow").fade(.4);
    		},
    		'mouseleave': function(){
                //mover2.start(145);
                $("f1").fade(1);
                $("f3").fade(1);
                $("f4").fade(1);
                $("f5").fade(1);
                //$("shadow").fade(1);
    		}
    	});
    	
    	
    	$('f3').addEvents({
    		'mouseenter': function(){
                //mover3.start(60);
                $("f1").fade(.1);
                $("f2").fade(.1);
                $("f4").fade(.1);
                $("f5").fade(.1);
                //$("shadow").fade(.4);
    		},
    		'mouseleave': function(){
                //mover3.start(70);
                $("f1").fade(1);
                $("f2").fade(1);
                $("f4").fade(1);
                $("f5").fade(1);
                //$("shadow").fade(1);
    		}
    	});
    	
    	$('f4').addEvents({
    		'mouseenter': function(){
                //mover4.start(140);
                $("f1").fade(.1);
                $("f2").fade(.1);
                $("f3").fade(.1);
                $("f5").fade(.1);
                //$("shadow").fade(.4);
    		},
    		'mouseleave': function(){
                //mover4.start(150);
                $("f1").fade(1);
                $("f2").fade(1);
                $("f3").fade(1);
                $("f5").fade(1);
                //$("shadow").fade(1);
    		}
    	});
    	
    	$('f5').addEvents({
    		'mouseenter': function(){
                //mover5.start(135);
                $("f1").fade(.1);
                $("f2").fade(.1);
                $("f3").fade(.1);
                $("f4").fade(.1);
                //$("shadow").fade(.4);
    		},
    		'mouseleave': function(){
                //mover5.start(145);
                $("f1").fade(1);
                $("f2").fade(1);
                $("f3").fade(1);
                $("f4").fade(1);
                //$("shadow").fade(1);
    		}
    	});
    }	

})


function playShowHide() {
    if ($("play-btn")) {
        $("play-btn").addEvents({
            "mouseenter" : function() {
                $("p-maslina").fade(0);
                $("p-film").fade(1);                
            },
            "mouseleave" : function() {
                $("p-maslina").fade(1);
                $("p-film").fade(0);               
            }
            ,
            "click" : function() {
                
                if ($("p-film").src.indexOf("prikazi_") > -1) {
                    $("p-film").src = "img/sakrij_film_hr.gif";
                    $("video").fade(1);
                    $("maslina").fade(0);
                } else {
                    $("p-film").src = "img/prikazi_film_hr.gif";
                    $("video").fade(0);
                    $("maslina").fade(1);
                }
                
                
                
            }
        })
    }
}


function searchShowHide() {
    $("search").setOpacity(0);
    if ($("a-search")){
	    $("a-search").addEvents({
	        "click" : function() {
	            if ($("search").getStyle("opacity") == 0) {
	                $("search").fade(1); 
	            } else {
	                $("search").fade(0);    
	            }
	        }
	    })  
    }  
}

function menuShowHide() {
    $$("div.expander").each(function(el){
        $("a-"+el.get("id")).setOpacity(0);
        el.addEvents({
            "mouseenter" : function(){
                $("a-"+el.get("id")).fade("in");
            },
            "mouseleave" : function(){
            	$("a-"+el.get("id")).fade("out");
            }
        })
     })
     
     
    $$("div.expander2").each(function(el){
        $("b-"+el.get("id")).setOpacity(0);
        el.addEvents({
            "mouseenter" : function(){
                $("b-"+el.get("id")).fade("in");
            },
            "mouseleave" : function(){
            	$("b-"+el.get("id")).fade("out");
            }
        })
     })
     
}


function makeScrollbar(content,scrollbar,handle,horizontal,ignoreMouse){
	var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y))
	var slider = new Slider(scrollbar, handle, {	
		steps: steps,
		mode: (horizontal?'horizontal':'vertical'),
		onChange: function(step){
			// Scrolls the content element in x or y direction.
			var x = (horizontal?step:0);
			var y = (horizontal?0:step);
			content.scrollTo(x,y);
		}
	}).set(0);
	if( !(ignoreMouse) ){
		// Scroll the content element when the mousewheel is used within the 
		// content or the scrollbar element.
		$$(content, scrollbar).addEvent('mousewheel', function(e){	
			e = new Event(e).stop();
			var step = slider.step - e.wheel * 30;	
			slider.set(step);					
		});
	}
	// Stops the handle dragging process when the mouse leaves the document body.
	$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
}

