


/* ===== jQueryEasing ===== */

jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},

	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	}

});


/* NAV */	
function fnNav1(){
	fnNavOut()
	$('#nav li.n1 a').stop().animate({backgroundPosition:"0px -77px"}, 300);
	$('.subslider').stop().animate({marginTop:'0'}, 400, 'easeOutQuad');
}

function fnNav2(){
	fnNavOut()
	$('#nav li.n2 a').stop().animate({backgroundPosition:"-320px -77px"}, 300)
	$('.subslider').stop().animate({marginTop:'-128px'}, 400, 'easeOutQuad');
}

function fnNav3(){
	fnNavOut()
	$('#nav li.n3 a').stop().animate({backgroundPosition:"-640px -77px"}, 300)
	$('.subslider').stop().animate({marginTop:'-256px'}, 400, 'easeOutQuad');
}

function fnNavOut(){

		$('#nav li.n1 a').stop().animate({backgroundPosition:"0px 0px"}, 300);
	$('#nav li.n2 a').stop().animate({backgroundPosition:"-320px 0px"}, 300);
	$('#nav li.n3 a').stop().animate({backgroundPosition:"-640px 0px"}, 300)

	//
	
}


/* ===== DOM Ready ===== */
$(function() {
		   

$('#nav li.n1 a').mouseover(function(){
		fnNav1();
	})
	
$('#nav li.n2 a').mouseover(function(){
		fnNav2();
	})	
	
$('#nav li.n3 a').mouseover(function(){
		fnNav3();
	})	


$('#nav').mouseout(function(){
		if(typeof naslovna=="undefined"){
			fnNavOut()
		}
	})



	
	/* FLASH  */
	$('#bg').flash({
		src: '../images/bg.swf',
		width: '100%',
		height: 800,
		wmode: 'transparent',
		update: false
	});
	


	$('#mapa2').flash({
		src: '../images/mapa2.swf',
		width: 290,
		height: 180,
		wmode: 'transparent',
		update: false
	});

/* if IE6 */
if(typeof document.body.style.maxHeight === "undefined") {
      
} else {

tooltip();// aktivraj tooltip
}


/*  ==============
	COLORBOX
	============= */

/* ===== Fotogalerija ===== */
$("ul.galerija a").colorbox({slideshow:true}, function(){
	// zamjeni font
	Cufon.replace('#cboxTitle', { fontFamily: 'MyriadPro-BoldCond' });
	Cufon.now();
});

$(".tlocrt").colorbox({}, function(){
	// zamjeni font
	Cufon.replace('#cboxTitle', { fontFamily: 'MyriadPro-BoldCond' });
	Cufon.now();
});


$(".iframe").colorbox({width:"460px"}, function(){
	// zamjeni font
	Cufon.replace('#cboxTitle', { fontFamily: 'MyriadPro-BoldCond' });
	Cufon.now();
});

$(".flv").colorbox({iframe:true, width:510, height:440});


});

/* ===== Fonts ===== */
Cufon.replace('.myriad', { fontFamily: 'MyriadPro-Bold' });
Cufon.replace('.myriadcond', { fontFamily: 'MyriadPro-BoldCond' });






/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 * MODIFIED BY ADI
 */

     

	this.tooltip = function(){	
		/* CONFIG */		
			xOffset = 40;
			yOffset = -20;		
			// these 2 variable determine popup's distance from the cursor
			// you might want to adjust to get the right result		
		/* END CONFIG */	
	
		 
		$("a.tooltip").live("mouseover", function(event){										  
			this.t = this.title;
			this.title = "";									  
			$("#container").append("<div id='tooltip'>"+ this.t +"</div>");
			$("#tooltip")
				.css("top",(event.pageY - xOffset) + "px")
				.css("left",(event.pageX + yOffset) + "px")
				.fadeIn("slow");		
		});
		
		$("a.tooltip").live("mouseout", function(event){		
			this.title = this.t;		
			$("#tooltip").remove();
		});	
		$("a.tooltip").live("mousemove", function(event){		
			$("#tooltip")
				.css("top",(event.pageY - xOffset) + "px")
				.css("left",(event.pageX + yOffset) + "px");
		});			
	};


/**
 * @author Alexander Farkas
 * v. 1.21
 */


(function($) {
	if(!document.defaultView || !document.defaultView.getComputedStyle){ // IE6-IE8
		var oldCurCSS = jQuery.curCSS;
		jQuery.curCSS = function(elem, name, force){
			if(name === 'background-position'){
				name = 'backgroundPosition';
			}
			if(name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[ name ]){
				return oldCurCSS.apply(this, arguments);
			}
			var style = elem.style;
			if ( !force && style && style[ name ] ){
				return style[ name ];
			}
			return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
		};
	}
	
	var oldAnim = $.fn.animate;
	$.fn.animate = function(prop){
		if('background-position' in prop){
			prop.backgroundPosition = prop['background-position'];
			delete prop['background-position'];
		}
		if('backgroundPosition' in prop){
			prop.backgroundPosition = '('+ prop.backgroundPosition;
		}
		return oldAnim.apply(this, arguments);
	};
	
	function toArray(strg){
		strg = strg.replace(/left|top/g,'0px');
		strg = strg.replace(/right|bottom/g,'100%');
		strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
		var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
		return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
	}
	
	$.fx.step. backgroundPosition = function(fx) {
		if (!fx.bgPosReady) {
			var start = $.curCSS(fx.elem,'backgroundPosition');
			
			if(!start){//FF2 no inline-style fallback
				start = '0px 0px';
			}
			
			start = toArray(start);
			
			fx.start = [start[0],start[2]];
			
			var end = toArray(fx.options.curAnim.backgroundPosition);
			fx.end = [end[0],end[2]];
			
			fx.unit = [end[1],end[3]];
			fx.bgPosReady = true;
		}
		//return;
		var nowPosX = [];
		nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
		nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
		fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

	};
})(jQuery);

