/* zabrana selektovanja texta na divovima */
jQuery.fn.extend({ 
        disableSelection : function() { 
                this.each(function() { 
                        this.onselectstart = function() { return false; }; 
                        this.unselectable = "on"; 
                        jQuery(this).css('-moz-user-select', 'none'); 
                }); 
        } 
}); 

/* ucitaj css slike pozadina 
$(document).ready(function(){
  $.preloadCssImages();
}); 
*/

/* Pozadina fullscreen */
	(function($){
 					$.fn.supersize = function() {	
					$(document).ready(function() {
						$("#pozadina").hide(); 
					});
					$(window).bind("resize", function(){
			    		$("#pozadina").hide(); 
					});
				};
			})(jQuery);	


/* centriranje funkcija */
(function($){
     $.fn.extend({
          center: function () {
                return this.each(function() {
                        var top = ($(window).height() - $(this).outerHeight()) / 2;
                        var left = ($(window).width() - $(this).outerWidth()) / 2;
                        $(this).css({position:'absolute', margin:0, top: (top > 0 ? top : 0)+'px', left: (left > 0 ? left : 0)+'px'});
                });
        }
     });
})(jQuery);

/* Funkcija blinkanje */
var prolaz = 1;
function blinkaj1()
{
   $('#blink1').fadeOut(300, blinkaj2);
}

function blinkaj2()
{
    $("#blink2").fadeOut(300).fadeIn(300, blinkaj3);
}

function blinkaj3()
{
    if (prolaz == 9) { $("#blink1").fadeIn(300); }
	else { prolaz++; $("#blink1").fadeIn(300, blinkaj1); }	
}



//////////////////////////////////////////////////////
jQuery(document).ready(function() {
$("#box").fancybox({
	    'padding'           : 0,
        'autoScale'     	: false
	});
});
//////////////////////////////////////////////////////
jQuery(document).ready(function() {
$("#box_p").fancybox({
	    'padding'           : 0,
        'autoScale'     	: false
	});
});

// video link
jQuery(document).ready(function() {
$("#box").click(function() {
$("#pozadina").fadeOut("slow", function() {
		$("#pozadina").load("pozadine/video.html", function() {
			$("#pozadina").fadeIn("slow");
			});
		});
	});
});

//////////////////////////////////////////////////////


/* funkcija startovanje*/
$(document).ready(function() {	 
	$(document).pngFix();						   
	//$("#tekst").load("video/index.html");					   
	//$("#pozadina").delay(900).fadeIn("slow");
	$("#sadrzaj").animate({"opacity":0.81}, "slow");
	$(".linkovi").animate({"opacity":0.81}, "slow");
	$(".linkovi1").animate({"opacity":0.81}, "slow");
	$("#natpis").delay(1500).fadeIn(3000).center().delay(3000).fadeOut(3000, 
	function(){
    	$("#drzac_natpisa").slideDown("slow", 
					function() {
						blinkaj1();
					});

$("#player").load("music/player.html", function(){
						$("#player").fadeIn(900);
						$("#player").animate({"opacity":0.93}, "slow");
												});
						});
	
	  $.preloadCssImages();
	
	//$('#drzac_linkova').hide('slow');
	//$("#drzac_natpisa").slideDown("slow");
	//$("#drzac_natpisa").load( function(){ $("#drzac_natpisa").slideDown("slow"); } );

	//$("#zgrada").delay(10500).fadeIn(3000).center();
	$("#pozadina").delay(10500).fadeIn(3000);
	$("#drzac_linkova").disableSelection();
	$("#tekst").disableSelection();

$("#u_close").click(
	function()
		{
    	$("#u_sadrzaj").fadeOut(900);
    	return false;
		});


$("#bozzzi").click(
	function()
		{
    	window.open("http://www.bozzzi.com");
    	return false;
		});

/*
$("#atlas").click(
	function()
		{
    	//window.open("http://www.atlas-g.com");
    	//return false;
		alert ("To kralju!");
		});
*/
});



/* player opacity */
$("#player").hover(function() {
					$("#player").animate({"opacity":0.93}, "slow");
				}, function() {
					$("#player").animate({"opacity":0.81}, "slow");
				});

/* funkcija meni*/
$(document).ready(			
			function() {				
				$("#drzac_natpisa").click(function() {
				if( $("#drzac_linkova").is(":visible")){
  						$("#drzac_linkova").slideUp("slow");
						$("#sadrzaj").slideUp("slow");
						}
				else{
   				$("#drzac_linkova").slideDown("slow");
				$("#sadrzaj").slideDown("slow");
			}	
					
				});
			}														
		);

/* sadrzaj opacity */
$(document).ready(			
			function() {				
				$("#sadrzaj").hover(function() {
					$("#sadrzaj").animate({"opacity":0.93}, "slow");
				}, function() {
					$("#sadrzaj").animate({"opacity":0.81}, "slow");
				});
			}														
		);

/* bozzi multimedia link */
$(document).ready(			
			function() {				
				$("#bozzzi").hover(function() {
					$("#bozzzi").css("color","#6d4424");
				}, function() {
					$("#bozzzi").css("color","#c2b4a9");
				});
			}														
		);

/* dugmad opacity
$(document).ready(			
			function() {				
				$(".linkovi").hover(function() {
					$(".linkovi").animate({"opacity":0.93}, "slow");
				}, function() {
					$(".linkovi").animate({"opacity":0.63}, "slow");
				});
			}														
		);
 */

// link montenegro
$(document).ready(function(){
		$("#montenegro").hover(function() {
		$("#montenegro").animate({"opacity":0.93}, 150);}, function() {
		$("#montenegro").animate({"opacity":0.81}, "fast");
	});
  });
// link hotel
$(document).ready(function(){
		$("#hotel").hover(function() {
		$("#hotel").animate({"opacity":0.93}, 150);}, function() {
		$("#hotel").animate({"opacity":0.81}, "fast");
	});
  });
// link about
$(document).ready(function(){
		$("#about").hover(function() {
		$("#about").animate({"opacity":0.93}, 150);}, function() {
		$("#about").animate({"opacity":0.81}, "fast");
	});
  });
// link parking
$(document).ready(function(){
		$("#parking").hover(function() {
		$("#parking").animate({"opacity":0.93}, 150);}, function() {
		$("#parking").animate({"opacity":0.81}, "fast");
	});
  });
// link residential
$(document).ready(function(){
		$("#residential").hover(function() {
		$("#residential").animate({"opacity":0.93}, 150);}, function() {
		$("#residential").animate({"opacity":0.81}, "fast");
	});
  });
// link amenities
$(document).ready(function(){
		$("#amenities").hover(function() {
		$("#amenities").animate({"opacity":0.93}, 150);}, function() {
		$("#amenities").animate({"opacity":0.81}, "fast");
	});
  });
// link retail
$(document).ready(function(){
		$("#retail").hover(function() {
		$("#retail").animate({"opacity":0.93}, 150);}, function() {
		$("#retail").animate({"opacity":0.81}, "fast");
	});
  });
// link contact
$(document).ready(function(){
		$("#contact").hover(function() {
		$("#contact").animate({"opacity":0.93}, 150);}, function() {
		$("#contact").animate({"opacity":0.81}, "fast");
	});
  });
// link business
$(document).ready(function(){
		$("#business").hover(function() {
		$("#business").animate({"opacity":0.93}, 150);}, function() {
		$("#business").animate({"opacity":0.81}, "fast");
	});
  });
// link gallery
$(document).ready(function(){
		$("#gallery").hover(function() {
		$("#gallery").animate({"opacity":0.93}, 150);}, function() {
		$("#gallery").animate({"opacity":0.81}, "fast");
	});
  });
// link video
$(document).ready(function(){
		$("#video").hover(function() {
		$("#video").animate({"opacity":0.93}, 150);}, function() {
		$("#video").animate({"opacity":0.81}, "fast");
	});
  });
// link floor plans
$(document).ready(function(){
		$("#plans").hover(function() {
		$("#plans").animate({"opacity":0.93}, 150);}, function() {
		$("#plans").animate({"opacity":0.81}, "fast");
	});
  });


// dugmad generalna funkcija 
$(document).ready(function(){	
	$(".meni").click(function() {
	
	var dugme = $(this).attr("href");
	dugme =  dugme.replace("#","");
	/*
	$(".linkovi").animate({"opacity":0.81}, "fast");
	$(dugme).animate({"opacity":0.93}, "fast");
	$(this).unbind('onmouseover').unbind('onmouseout');
	*/
	
	$("#ucitavanje").fadeIn("slow", function(){
		$('#tekst').load("tekst/"+dugme+".html", function(){
		$('#ucitavanje').fadeOut('slow');
		});
	});						  

	$("#pozadina").fadeOut("slow", function() {
		$("#pozadina").load("pozadine/"+dugme+".html", function() {
			$("#pozadina").fadeIn("slow");
			});												  
		});
	});
});




/////////////////////////   funkcija za slideshow    /////////////////////////
/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/
function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});
/////////////////////////   funkcija za slideshow    /////////////////////////
