/*
Copyright Globaldizajn 2010
*/

var ss = 1;
var total_links_to_images = 0;

window.addEvent("domready",function(){
	if ($("email")) $("email").innerHTML = " info@globaldizajn.hr";
	
	$$("li.hoverer").each(function(el){
	   if (el.className!= "hoverer selected") {
            el.addEvents({
                "mouseenter" : function(){
                    el.setStyle("background", "Transparent url(css/li3.png) top left no-repeat");
                    el.getFirst('a').setStyle("background", "Transparent url(css/li4.png) top right no-repeat");
                    el.getFirst('a').setStyle("color", "#ffffff");
                },
                "mouseleave" : function(){
                    el.setStyle("background", "Transparent url(css/li1.png) top left no-repeat");
                    el.getFirst('a').setStyle("background", "Transparent url(css/li2.png) top right no-repeat");
                    el.getFirst('a').setStyle("color", "#262626");
                }
            })
        }
	})
	
	$$("a").each(function(el){
        if (el.getAttribute("href") != null) {
            if ((el.getAttribute("href").indexOf(".png") > 0 || (el.getAttribute("href").indexOf(".jpg")) > 0)) {
                el.setAttribute("rel", "lightbox[0]");
            }
        }
    })
	
	
	
	$$("input.txt1").each(function(el){
	   el.addEvents({
                "focus" : function(){
                    el.setStyle("background-color", "#f6f6b2");
                    el.setStyle("border", "solid 2px #6a92e8");
                },
                "blur" : function(){
                    el.setStyle("background-color", "#ffffff");
                    el.setStyle("border", "solid 2px #294e76");
                }
       })
    })
    
    
    
    if (Browser.Engine.gecko || Browser.Engine.webkit) {
        $$("select#langSel").each(function(el){
           el.addEvents({
                    "focus" : function(){
                        el.setStyle("color", "#719dce");
                    }
           })
        })
    }
    
    
    if ($("radioStation")) {
        $("radioStation").focus();
    }
	
	
	if ($('download')) {
        $('download').addEvents({
            "mouseenter" : function(){
                $('download').setProperty("src", "img/download_o.gif");
            },
            "mouseleave" : function(){
                $('download').setProperty("src", "img/download.gif");
            }
        })
    }
    
	if ($('add')) {
        $('add').addEvents({
            "mouseenter" : function(){
                $('add').setProperty("src", "img/dodaj_o.gif");
            },
            "mouseleave" : function(){
                $('add').setProperty("src", "img/dodaj.gif");
            }
        })
    }

    
    
    
	if ($('addE')) {
        $('addE').addEvents({
            "mouseenter" : function(){
                $('addE').setProperty("src", "img/dodajE_o.gif");
            },
            "mouseleave" : function(){
                $('addE').setProperty("src", "img/dodajE.gif");
            }
        })
    }
    
    
    
    
	if ($('face')) {
        $('face').addEvents({
            "mouseenter" : function(){
                $('face').setProperty("src", "img/icon_fb_hover.png");
            },
            "mouseleave" : function(){
                $('face').setProperty("src", "img/icon_fb.png");
            }
        })
    }
    
	if ($('twitter')) {
        $('twitter').addEvents({
            "mouseenter" : function(){
                $('twitter').setProperty("src", "img/icon_twitter_hover.png");
            },
            "mouseleave" : function(){
                $('twitter').setProperty("src", "img/icon_twitter.png");
            }
        })
    }
    
    
	if ($('myspace')) {
        $('myspace').addEvents({
            "mouseenter" : function(){
                $('myspace').setProperty("src", "img/icon_myspace_hover.png");
            },
            "mouseleave" : function(){
                $('myspace').setProperty("src", "img/icon_myspace.png");
            }
        })
    }
	
	
    if ($('Rotator')) {
		var nS1 = new noobSlide({
		    mode: 'horizontal',
			box: $('Rotator'),
			items: [0,1,2,4,5],
			interval: 4000,
			fxOptions: {
				duration: 1500,
				transition: Fx.Transitions.Elastic.easeOut,
				wait: false
			},
			size: 192,
			autoPlay: true
		});
	}
	
	if ($("listaStanica")){
        $("listaStanica").addEvent("click", function(){
			if ($("listaStanica").getStyle("display")=="block"){
                $("listaStanica").setStyles({
					"display":"none"
				})
			}
			else{
                $("listaStanica").setStyles({
					"display":"block"
				})
			}
		})
	}
	
	if ($("brojStanica")){
		$("brojStanica").setStyle("cursor","pointer");
		$("brojStanica").addEvent("click", function(){
			$("listaStanica").setStyles({
				"display":"block",
				"position":"absolute",
				"top":$("brojStanica").offsetTop+20
			})

		})
	}


    if ($("ras")){ 
    
		$("ras").setStyle("cursor","pointer");
		
		$("ras").addEvent("click", function(){
            showHideLista();
		})
		
		$("iphone-push").addEvent("click", function(){
            showHideLista();
		})
    
        //Fx.Tween has already implemented the Chain class because of inheritance of the Fx class.
        var myFx = new Fx.Tween('ras', {property: 'color'});
        myFx.start("#ffffff","#000000").chain(
            //Notice that "this" refers to the calling object (in this case, the myFx object).
            function(){ this.start("#000000","#ffffff"); },
            function(){ this.start("#ffffff","#000000"); },
            function(){ this.start("#000000","#ffffff"); },
            function(){ this.start("#ffffff","#000000"); },
            function(){ this.start("#000000","#3f7ae0"); }
        ); //Will fade the Element out and in twice.
    }

})


function showHideLista() {
    if ($("listaStanica2").getStyle("display")=="block"){
		$("listaStanica2").setStyles({
			"display":"none",
			"position":"absolute"
		})
    } else {
		$("listaStanica2").setStyles({
			"display":"block",
			"position":"absolute"
		})
    }
    initSlider();
    
	/*
    $("listaStanica2").addEvent("click", function(){
		$("listaStanica2").setStyles({
			"display":"none",
			"position":"absolute"
		})

		
    })
	*/
}

function initSlider(){
    
    $("inner").setStyle("height", $("knob").getStyle("height").replace("px","")*2+282 + "px");
    $("inner").setStyle("top", -1*$("inner").getStyle("height").replace("px","")/2 + "px");
    $("inner").setStyle("position", "absolute");
    
    $('knob').setStyle("top", $("inner").getStyle("height").replace("px","")/2 + "px");
    
    knobHeight = parseInt($("knob").getStyle("height").replace("px",""));
    var yStart = 0;
    var yEnd = 0;
    var iner = 0;
    
    $('knob').makeDraggable({
        onStart: function() {
		  yStart = this.mouse.start.y;
		},
	    onComplete: function() {
		  yEnd = this.mouse.now.y;
		  iner = yEnd - yStart;
		  if (!isNaN(iner)) inercija(iner);
		  
	    },
        modifiers:{x:false},
        container: 'inner'
    });
}

var knobHeight = 0;

function inercija(val){
    
    
    var newTop =  parseInt($("knob").getStyle("top").replace("px","")) + parseInt(val);

    if (newTop < 420){
        newTop = 420;
    }
    else if(newTop > knobHeight+140){
        newTop = knobHeight+140;
    }
    
    
    new Fx.Tween('knob', {
    	property: 'top', //this bit
    	transition: Fx.Transitions.Quart.easeOut

    }).start( newTop );      
}



/*
Copyright Globaldizajn 2010
*/


