


/*  ==============
	DOM READY
	============= */
$(function() {
			
			
			
/* GOOLE TRANSLATE */	
	
	// set cookie
	$('#translator').change( function(){
		$.cookie("lng", $('#translator :selected').val());
		//googletranslate();	
		window.location.reload();
	})
	
	
		
function googletranslate(){
	// get cookie and translate
	if($.cookie("lng") ){
		ln =  $.cookie("lng");
		
		// translate
		$('body').translate('hr', ln, {
			complete: function(){
				//  console.log( this.translation );
/*			Cufon.replace('#header li a', {
			textShadow: '2px 1px rgba(51, 51, 51, 0.6)'
			});
			Cufon.replace('#menu a', {
				hover: true
			});
			Cufon.refresh()*/
		}
		});
		
		// set selected
		$("#translator").val(ln);
	} else {
	 Cufon.replace('#header li a', {
				textShadow: '2px 1px rgba(51, 51, 51, 0.6)',
				fontSize: '16px',
				letterSpacing: 'normal'
				
			});
	Cufon.replace('#menu a', {
				hover: true,
				fontSize: '19px',
				letterSpacing: 'normal'
			});
	}
	
}
googletranslate();


/* CUFON FONTS */
/*	Cufon.replace('#header li a', {
				textShadow: '2px 1px rgba(51, 51, 51, 0.6)'
			});
	Cufon.replace('#menu a', {
				hover: true
			});*/
			
	
/* ROUNDED THUMBNAILS */		
	$(".thumb").load(function() {
	$(this).wrap(function(){
	return '<span class="' + $(this).attr('class') + '" style="background:url(' + $(this).attr('src') + ') no-repeat center center; width: ' + $(this).width() + 'px; height: ' + $(this).height() + 'px;" />';
	});
	$(this).css("opacity","0");
	});
	
	
/* SUBMENU */

    var pathArray = window.location.pathname.split( '/' );	
	
	// Convert url path to array, return first x elements and remove last slash	 
    function getPath(end){
	var newPathname = "";
	  for ( i = 0; i <= end; i++) {
      newPathname += pathArray[i]+'/';
    }
	return newPathname.replace(/\/$/g, '');
   }    		
	
    $("#header ul a[href$='"+getPath(2)+"']").addClass('active')
	$("#menu ul a[href$='"+getPath(2)+"']").addClass('active');
	$("#submenu ul ul").css('display','none');
		
	// Find link in submenu that starts with first 4 elements	
	$("#submenu ul a[href$='"+getPath(3)+"']").addClass('active').next('ul').css('display', 'block');
	$("#submenu ul ul a[href^='"+getPath(4)+"']").addClass('active').end().parents('ul').css('display', 'block');
	
    
/* EQUAL COL */	
	$("div.vertikalno li").equalHeights();
	
	
/* COLORBOX */ 
	$("a[rel='gal']").colorbox();
	$(".iframe").colorbox({width:"90%", height:"90%", iframe:true});	
	$("a.colorbox").colorbox();
	
	// in-text images
	$("#content .text p img").colorbox({href: function(){ return $(this).attr('src') } });
	

/* FOTOGALERIJA */
	$('#content a.fotogalerija').each(function(){
		url = "/ajax/fotogalerija.php?url="+$(this).attr('href');
		$(this).wrap("<div class='fotogalerija'></div>").parent().load(url, function(){

			// aktiviraj colorbox
			$("a[rel='gal']").colorbox();
			})
		$(this).remove();
	});
	





/* ===== Clear on focus ===== */

var clearMePrevious = "";
// clear input on focus
$('.clearfocus').focus(function(){
	if($(this).val()==$(this).attr('title')){
		clearMePrevious = $(this).val();
		$(this).val("");
	}
});
// if field is empty afterward, add text again
$('.clearfocus').blur(function(){
	if($(this).val()==""){
		$(this).val(clearMePrevious);
	}
});	
	
	
	
});




$(document).ready( function() {
	/**
	 * Maximize the real estate available to the portal contents
	 */
	stretch_portal_content();
	$(window).resize( stretch_portal_content );
});


function stretch_portal_content() {
	if($( '#content' ).height() < $('#navigation').height() ) {
		$( '#content' ).height(
			( $('#navigation').height()+80 )
		);
	}
}





