
/* ===== DOM READY ===== */
$(function() {
	
	/* Menu */
	$("#header ul li:first").addClass("first");
	$("#header ul li:last").addClass("last");
	
	/* Table */
	$("#content table").attr("border","0");
	
	/* Tabs */
	// Postavi tab navigaciju 
	$("h3.tabtitle:first").before('<div id="tabnav" class="clear"></div>');

	$("h3.tabtitle").each(function (index) {
		$(this).next("div.tabcontent").attr("id", "tab_"+index).hide(); // dodaj IDjeve divovima i sakrij sve osim prvog
		$(this).wrapInner('<a href="#' + "tab_" + index + '"></a>').remove().clone().appendTo("#tabnav") // Dodaj link u h3, premjesti sve u tab navigaciju
	});
	
	$("h3.tabtitle a:first").parent().addClass("active").parents("div.box").css("margin-top","50px"); // prvi aktivni tab
	
	$("div.tabcontent:first").show(); // prikazi prvi tab
	
	$("h3.tabtitle a").live('click', function() {
		$("h3.tabtitle").removeClass("active");
		$(this).parent().addClass("active");
		href = $(this).attr("href");
		obj = href.substring(href.indexOf('#')+1);
		$('#'+obj).show().siblings("div.tabcontent").hide();
		//temp = $(obj)
		//temp.attr("id",""); // obrisi id privremeno zbog hash behaviora
		//location.hash = obj; // postavi hash u addr var
		//temp.attr("id",obj.replace('#','')); // vrati id
		return false;
	})
	
	
	/* hotel list template */
	$("div.hotel").addClass('list');
	$("div.hotel a").click(function(){
		element = $(this);
		$("div.hotel").find("div.text").remove().end().find('li.active').removeClass('active');
		url = $(this).attr("href");
		$.get(url, function(data){
   			element.after(data).parent('li').addClass('active');
			$("a[rel='gal']").colorbox();
		});
		return false;
	})
	
	
/* ===== Colorbox ===== */ 
	$("a[rel='gal']").colorbox();
	$(".iframe").colorbox({width:"90%", height:"90%", iframe:true});
  $(".video").colorbox({width:"660", height:"430", iframe:true});
	
/* ===== Cycle ===== */
	$('#display').cycle({ 
	fx:      'blindX', 
	speed:    500, 
	timeout:  4000 
	});
	
	$('div.ticker').cycle({ 
	fx:      'scrollUp', 
	speed:    500, 
	timeout:  4000 
	});
	
/* ====== Newslettr ===== */
	$("#nletter").submit(function() {
		frm = $(this);
		$.post(frm.attr("action"), { email: frm.find("input[name=email]").val()},
		function(data){
			$(frm).parent().find("p").html(data);
   	});
	return false;

});
	
});
