
/* ===== jQueryEasing ===== */

jQuery.extend( jQuery.easing,{
		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;
	}
});



/*  =============
	Get querystring from URL
	============= */
function  getQuerystring(key, url, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  if(url==null){
	  url = window.location.href;
  }
  var qs = regex.exec(url);

  if(qs == null)
    return default_;
  else
    return qs[1];
}

/* ===== Slideshow ===== */

$(function() {
	$('.slideshow').cycle({		 
	fx: 'custom',
	sync: 1, 
	fit:1,
	cssBefore: {  
			left:800,
			zIndex: 1,
			display: 'block'
		}, 
	animIn: { 
			left:0,
			opacity: 1  
		}, 
	animOut: {  
			left:700,
			opacity: 0 
		}, 
	cssAfter: {  
			zIndex: 0,
			display: 'none', left:0
		},
	cssFirst: {
			left:0
		},
	delay: -3000 ,
	easeIn: 'easeInOutQuad',
	easeOut: 'easeInOutQuad',
	startingSlide: 0,
	prev:'#prev',
	next:'#next',
	pager:  '#thumb',
	  pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        return '#thumb li:eq(' + idx + ') a'; 
    } 
	});
	
	$('#pause').click(function() { 
    	
	});
	
/* Pause/Play Slideshow */

	 $("#pause").toggle(
      function () {
		$(this).text('o');  
		$('.slideshow').cycle('pause'); 
      },
      function () {
		$(this).text('||');  
		$('.slideshow').cycle('resume', true); 
      });



/* ===== Highlight active liks ===== */

/*	var page = location.pathname.substring(4);
	getid = queryString('','id');*/
	
	$("li a").each(function(){
		currUrl = getQuerystring('id', $(this).attr("href"));
		if(currUrl==getQuerystring('id')){
			$(this).attr('class', 'active');
		}
	})
	
	//$('li a[href*="' + ".php?id="+ getid + '"]').attr('class', 'active');
	
/* ===== Virtual tour ===== */
$("a.virtual").each(function(){
		url = this.href;
		
			$(this).before("<iframe src='"+url+"' width='100%' height='450px' marginheight='0' frameborder='0'  scrolling='no'></iframe>");
		 
		$(this).remove();
	});


/* ===== FOTOGALERIJA ===== */
	$('#content a[href^="' +'fotogalerija.php?id="]').each(function(){
		url = this.href;
		$(this).wrap("<div class='fotogalerija'></div>").parent().load(url, function(){
			// aktiviraj carousel
			$('.fotogalerija div').jCarouselLite({
			btnNext: '.naprijed',
			btnPrev: '.nazad',
			scroll: 1,
			visible: 6,
			speed: 500,
			circular: false
			});
			// aktiviraj colorbox
			$("a[rel='example1']").colorbox();
			})
		$(this).remove();
	});
	
	

	
   
});





