	//ovde se definisu svi klipovi koji postoje na sajtu kako bi mogli posle da se zatvaraju
    var ubuntuVideo;
    var yeleVideo;
    var erinMongoliaVideo;
    var cherPanamaVideo;
    var bjornMoroccoVideo;
    var chelsiNorwayVideo;
    var sierraVanuatuVideo;
    var avaThailandVideo;
    var marissaIndiaVideo;
    var amandaKenyaVideo;
    var melenyPeruVideo;
    
    var brojOtovrenihPopupova = 0;
    var otvoreniPopupovi=new Array(5);
    otvoreniPopupovi[0] = "";
    otvoreniPopupovi[1] = "";
    otvoreniPopupovi[2] = "";
    otvoreniPopupovi[3] = "";
    otvoreniPopupovi[4] = "";
	function otvoriPopup(id){

		otvoreniPopupovi[brojOtovrenihPopupova] = id;
		brojOtovrenihPopupova = brojOtovrenihPopupova + 1;
        document.getElementById("otvorenPopup").value = id;
        id = '#' + id;
        if(document.getElementById("otvorenPopup").value == 'ubuntuPopup'){
    		if ( ubuntuVideo ) {
    			ubuntuVideo.appendTo("#ubuntuPopupVideoDiv");
    	      }
        }else if(document.getElementById("otvorenPopup").value == 'yelePopup'){
    		if ( yeleVideo ) {
    			yeleVideo.appendTo("#yelePopupVideoDiv");
    			yeleVideo = null;
    	      }
        }else if(document.getElementById("otvorenPopup").value == 'ubuntuVideoAdvisePopup'){
    		if ( ubuntuVideo ) {
    			ubuntuVideo.appendTo("#ubuntuAdvisePopupVideoDiv");
    	      }
        }else if(document.getElementById("otvorenPopup").value == 'erinMongoliaPopup'){
    		if ( erinMongoliaVideo ) {
    			erinMongoliaVideo.appendTo("#erinMongoliaPopupVideoDiv");
    			erinMongoliaVideo = null;
    	      }
        }else if(document.getElementById("otvorenPopup").value == 'cherPanamaPopup'){
    		if ( cherPanamaVideo ) {
    			cherPanamaVideo.appendTo("#cherPanamaPopupVideoDiv");
    			cherPanamaVideo = null;
    	      }
        }else if(document.getElementById("otvorenPopup").value == 'bjornMoroccoPopup'){
    		if ( bjornMoroccoVideo ) {
    			bjornMoroccoVideo.appendTo("#bjornMoroccoPopupVideoDiv");
    			bjornMoroccoVideo = null;
    	      }
        }else if(document.getElementById("otvorenPopup").value == 'chelsiNorwayPopup'){
    		if ( chelsiNorwayVideo ) {
    			chelsiNorwayVideo.appendTo("#chelsiNorwayPopupVideoDiv");
    			chelsiNorwayVideo = null;
    	      }
        }else if(document.getElementById("otvorenPopup").value == 'sierraVanuatuPopup'){
    		if ( sierraVanuatuVideo ) {
    			sierraVanuatuVideo.appendTo("#sierraVanuatuPopupVideoDiv");
    			sierraVanuatuVideo = null;
    	      }
        }else if(document.getElementById("otvorenPopup").value == 'avaThailandPopup'){
    		if ( avaThailandVideo ) {
    			avaThailandVideo.appendTo("#avaThailandPopupVideoDiv");
    			avaThailandVideo = null;
    	      }
        }else if(document.getElementById("otvorenPopup").value == 'marissaIndiaPopup'){
    		if ( marissaIndiaVideo ) {
    			marissaIndiaVideo.appendTo("#marissaIndiaPopupVideoDiv");
    			marissaIndiaVideo = null;
    	      }
        }else if(document.getElementById("otvorenPopup").value == 'amandaKenyaPopup'){
    		if ( amandaKenyaVideo ) {
    			amandaKenyaVideo.appendTo("#amandaKenyaPopupVideoDiv");
    			amandaKenyaVideo = null;
    	      }
        }else if(document.getElementById("otvorenPopup").value == 'melenyPeruPopup'){
    		if ( melenyPeruVideo ) {
    			melenyPeruVideo.appendTo("#melenyPeruPopupVideoDiv");
    			melenyPeruVideo = null;
    	      }
        }
        
        $(id + ' .imaMouseOver').bind('mouseover', function(){
				mouseOverBubble($(this).attr('id'));
        });
		$(id + ' .imaMouseOver').bind('mouseout', function(){
				mouseOutBubble($(this).attr('id'));
		});
		$(id).fadeIn(500); 
        $('#mask').fadeIn(500);    
        $('#mask').fadeTo("slow",0.8);  
	}

	function otvoriPopupPopupa(id){
		zatvoriPopup(otvoreniPopupovi[brojOtovrenihPopupova], false);
        otvoriPopup(id);
	}
	
	function zatvoriPopup(id, skroz){
		if(skroz){
			brojOtovrenihPopupova = brojOtovrenihPopupova - 1;
			otvoreniPopupovi[brojOtovrenihPopupova] = "";
		}
    	if(document.getElementById("otvorenPopup").value == 'ubuntuPopup' || 
    			document.getElementById("otvorenPopup").value == 'ubuntuVideoAdvisePopup'){
    		ubuntuVideo = $("#iframeUbuntu").detach();
    	}else if(document.getElementById("otvorenPopup").value == 'yelePopup'){
    		yeleVideo = $("#iframeYele").detach();
    	}else if(document.getElementById("otvorenPopup").value == 'erinMongoliaPopup'){
    		erinMongoliaVideo = $("#embedErinMongolia").detach();
    	}else if(document.getElementById("otvorenPopup").value == 'cherPanamaPopup'){
    		cherPanamaVideo = $("#embedCherPanama").detach();
    	}else if(document.getElementById("otvorenPopup").value == 'bjornMoroccoPopup'){
    		bjornMoroccoVideo = $("#embedBjornMorocco").detach();
    	}else if(document.getElementById("otvorenPopup").value == 'chelsiNorwayPopup'){
    		chelsiNorwayVideo = $("#embedChelsiNorway").detach();
    	}else if(document.getElementById("otvorenPopup").value == 'sierraVanuatuPopup'){
    		sierraVanuatuVideo = $("#embedSierraVanuatu").detach();
    	}else if(document.getElementById("otvorenPopup").value == 'avaThailandPopup'){
    		avaThailandVideo = $("#embedAvaThailand").detach();
    	}else if(document.getElementById("otvorenPopup").value == 'marissaIndiaPopup'){
    		marissaIndiaVideo = $("#embedMarissaIndia").detach();
    	}else if(document.getElementById("otvorenPopup").value == 'amandaKenyaPopup'){
    		amandaKenyaVideo = $("#embedAmandaKenyad").detach();
    	}else if(document.getElementById("otvorenPopup").value == 'melenyPeruPopup'){
    		melenyPeruVideo = $("#embedMelenyPeru").detach();
    	}
    	$(document.getElementById("mask")).hide();
        document.getElementById(document.getElementById("otvorenPopup").value).style.display = 'none'; 
        if(skroz){
        	if(brojOtovrenihPopupova != 0){
    			brojOtovrenihPopupova = brojOtovrenihPopupova - 1;
        		otvoriPopup(otvoreniPopupovi[brojOtovrenihPopupova]);
        	}
        }
	}
	

	
jQuery(document).ready(function ($) {

			$('.jScrollbar2').jScrollbar();
			$("#contactSubjectText").Watermark("Subject*");
			$("#contactFromText").Watermark("Email*");
			$("#contactTwitterText").Watermark("Twitter Handle");
			$("#contactMessageText").Watermark("Message*");
			
			$("#exiledPress").prettyPhoto();
			
			$("#exiledPress").prettyPhoto({animation_speed:'normal',theme:'light_rounded',slideshow:false, hideflash: true, social_tools:false, opacity:0.2});
	

			podesavanjeVelicineContentDiva();

			//vertikalno pozicioniranje divova sa baloncicima
			if(browserWidth / browserHeight > 1.551){
				document.getElementById("slikaPozadina").style.width = '100%';
				document.getElementById("slikaPozadina").style.height = 'auto';
			} else {
				document.getElementById("slikaPozadina").style.width = 'auto';
				document.getElementById("slikaPozadina").style.height = '100%';
			}
			
			//kad refreshujemo stranicu da vrati home
			$('#content').scrollLeft(0).scrollTop(0);


		    $('#mask').click(function () {
		    	zatvoriPopup(otvoreniPopupovi[brojOtovrenihPopupova], true); 
		    }); 

		    $('.popup').click(function () {
			    if(document.getElementById("zatvoriPopup").value == "true"){
			    	zatvoriPopup(otvoreniPopupovi[brojOtovrenihPopupova], true); 
			    }else{
			    	document.getElementById("zatvoriPopup").value = "true";
			    }
		    }); 
				
		
			$('#logo').click(function () {
		        pozicioniraj(0, 0, '7px', '13px', 'home');
		    });
			
			$('.imaMouseOver').mouseout(function(){
				mouseOutBubble($(this).attr('id'));
			});
			$('.imaMouseOver').mouseover(function(){
				mouseOverBubble($(this).attr('id'));
			});
			$('.imaMouseOverSlozen').mouseout(function(){
				mouseOutBubbleSlozen($(this).attr('id'));
			});
			$('.imaMouseOverSlozen').mouseover(function(){
				mouseOverBubbleSlozen($(this).attr('id'));
			});
			$('.imaMouseOverVideo').mouseout(function(){
				mouseOutBubbleVideo($(this).attr('id'));
			});
			$('.imaMouseOverVideo').mouseover(function(){
				mouseOverBubbleVideo($(this).attr('id'));
			});
		});

		$(window).resize(function() {

			podesavanjeVelicineContentDiva();

			//vrsi se pozicioniranje na trenutnu aktivnu stranicu
			pozicioniraj(document.getElementById("pozicijaGore").value, document.getElementById("pozicijaLevo").value,
					document.getElementById("crtaLeftValue").value, document.getElementById("crtaWidthValue").value,
				 	document.getElementById("aktivnaStrana").value, 0);

		});
