function reference(){
    $(".referenca").hover(function(){
        //$(this).addClass("referencah").siblings().fadeTo(0, 0.3);
        var imgHeight = $("img", this).height() - 120;
        $("img", this).animate({
            top: -imgHeight
        }, 1000).animate({
            top: "0"
        }, 300);
    }, function(){
        //$(this).removeClass("referencah").siblings().fadeTo(0, 1.0);
    });
}

function podjeli(){
    var myUrl = encodeURIComponent(window.location.href);
    var myTitle = encodeURIComponent(document.title);
    //var myImg = $(this).find('img');
    $("#podjeli a").bind({
        click: function(){
            switch ($(this).attr("id")) {
                case 'facebook':
                    this.href += '?t=' + myTitle + '&u=' + myUrl;
                    break;
                case 'twitter':
                    //this.href += '?status=' + myUrl + '&title=' + myTitle;
                    this.href += '?status=RT+@webstranica:+Liders+internet+usluge+-+Izrada+web+stranica+-+http://liders.hr';
                    break;
                case 'myspace':
                    this.href += '?t=' + myTitle + '&u=' + myUrl;
                    break;
                case 'google':
                    this.href += '?op=edit&title=' + myTitle + '&bkmk=' + myUrl;
                    break;
                case 'bookmark':
                    break;
            }
        },
        mouseenter: function(){
            var myImg = $(this).find('img');
            myImg.animate({
                marginTop: '0'
            }, 500);
        },
        mouseout: function(){
            var myImg = $(this).find('img');
            myImg.animate({
                marginTop: '30'
            }, 500);
        }
    });
}

//tab izrada
function tabSwitch(new_tab, new_content){
    document.getElementById('content_1').style.display = 'none';
    document.getElementById('content_2').style.display = 'none';
    document.getElementById(new_content).style.display = 'block';
    document.getElementById('tab_1').className = '';
    document.getElementById('tab_2').className = '';
    document.getElementById(new_tab).className = 'active';
}

function naslovnica(){
    var api = $("#scroll").scrollable({
        items: '#tools'
    }).navigator().data("scrollable");
    if (api === undefined) {
        return;
    }
    
    $("#tools").hide();
    api.onBeforeSeek(function(e, i){
        if (i) {
            $("#intro").fadeOut("slow"); $("#tools").show();
            if ($.browser.msie && $.browser.version < 8) {
                $("#intro").hide();
            }
        }
        else {
            $("#intro").fadeIn(1000); $("#tools").hide();
        }       
        $("#t0").toggleClass("active", i === 0);
    });
    // a dedicated click event for the intro thumbnail
    $("#t0").click(function(){
        // seek to the beginning (the hidden first item)
        $("#scroll").scrollable().begin();
    });
    //$("#navi" ).scrollable({items: '.tool', circular: true}).autoscroll({ autoplay: true });
}

function formTooltip(){
    var myClass = $("#dnn_ctr398_Default_Form_Primjer_web_stranice");
    myClass.attr('title', "Imate neki primjer stranice koja Vam se sviđa ? Ovdje upišite adresu ...");    
    myClass.tooltip({
        //offset: [50, 0],
        //position: 'top left',
        effect: 'slide',
        tipClass: "tooltip"
    }).dynamic({
        bottom: {
            direction: 'down',
            bounce: true
        }
    });
}

function logoA(){
    var myLogo = $("#logoA");
    var myAkcija = $("#akcijaA");
    var mySredina = $("#najbolji");
    myLogo.css({ "left": "300px", "opacity": "0.0" });
    mySredina.css("opacity", "0.0");
    myAkcija.css("top", "-130px");
    myLogo.animate({ left: 0, opacity: 1.0, filter: "" }, 1000, "swing", 
	function(){ mySredina.animate({ opacity: 1.0, filter: "" }, 1000, 
	function(){ myAkcija.animate({ top: 16 }, 1000, "easeOutBounce");
    });});
}

function logoB(){
    var myLogo = $("#logoB");
    var myAkcija = $("#akcijaB");
    var mySredina = $("#garancija");
    myLogo.css({ "left": "300px", "opacity": "0.0" });
    mySredina.css("opacity", "0.0");
    myAkcija.css("top", "-130px");
    myLogo.animate({ left: 0, opacity: 1.0, filter: "" }, 1000, "swing", 
	function(){ mySredina.animate({ opacity: 1.0, filter: "" }, 1000, 
	function(){ myAkcija.animate({ top: 16 }, 1000, "easeOutBounce");
    });});
}

function vr1( myObj ){
	var params={}; var flashvars={}; attributes={}; params.allowfullscreen ="true"; 
 		swfobject.embedSWF("http://liders.hr/Portals/0/virtual/golubC.swf", "vr", 620, 380, "9.0.0");	

	 $.each(myObj.panorama, function(index, value) {
	 	$("#" + value).click(function() { 
 			swfobject.embedSWF(myObj.path + value + ".swf", "vr", myObj.width, myObj.height, "9.0.0", false, flashvars, params, attributes); 
	 		//$("#vr-tekst").text( $(this).attr("alt")); });
	 	});
	});
}


$(document).ready(function(){
    logoA();
  
    $(".myTooltip a[title]").tooltip({
        effect: 'slide'
    }).dynamic({
        bottom: {
            direction: 'down',
            bounce: true
        }
    });  
    podjeli();
    naslovnica(); 
    // if (!(jQuery.browser.msie)) {
    reference();
    // }

	$('#button-primjeri').delay(15000).fadeIn(1000).click(
	function detalji(){
	    $('#master').animate({ height: 'toggle' }, 1500, 'easeInBack', 
		function(){ $('#detail').animate({  height: 'toggle' }, 1000, 'easeOutBack'
	    );});
	});
    

     vr({
       path: "/Portals/0/virtual/",
       width: "620",
       height: "380",
       panorama: ["vr-adastraB", "golubC", "vz-starigradA", "vr-ribnjak"]
     });

});

$(window).load(function(){

});

