//Cufon erstatter disse taggene
Cufon.replace ('.cufonfont')('h4')('.box_index a.button');

//Tooltips
$(document).ready(function() {
	//$(".tips").tooltip({effect: 'slide',offset: [-170, 0]}).dynamic({ bottom: { direction: 'down', offset: [100, 0], bounce: true }});
	$(".trigger").tooltip({ effect: 'slide'});
	});

//Scrollable og Tabs
$(document).ready(function() {
	$(".scrollable").scrollable({circular: true});
	$("ul.tabs").tabs("div.panes > div");
	});
	
//Active class på li tags i sidemeny når siden er aktiv
    window.onload = function() {
		var menuID = 'subnav'; // The ID of your menu
        var activeClass = 'active'; // The class to add
		var menu = document.getElementById(menuID);
        var items = menu.getElementsByTagName('a');
        for( var i = 0; i < items.length; i++ ) {
            if( items[i].href.replace(/https?:\/\/.*?\//i , '/') == 
                location.href.replace(/https?:\/\/.*?\//i , '/') ) {
                items[i].parentNode.className = activeClass;
                break;}}
				};

//--------Logg inn CMS sidepanel-----------
//Vis logg inn skjema
$(document).ready(function() {
$('.toggle-loginform').click(function() {
  $('.toggle-loginform').hide('fast', function() {
  });
  $('.loginform').slideDown('fast', function() {
  });  
});
//Skjul logg inn skjema
$('.toggle-loginform_close').click(function() {
  $('.toggle-loginform').show('fast',function() {
  });
  $('.loginform').slideUp('fast', function() {
  });
});
});

//Roundabout
$(document).ready(function() {
$('ul#myRoundabout').roundabout({
	  	minOpacity: 0.6, // The lowest opacity value that a moveable item can be assigned. (Will be the opacity of the item farthest from the focus bearing.)
		maxOpacity: 1.0, // The greatest opacity value that a moveable item can be assigned. (Will be the opacity of the item in focus.)
		minScale: 0.5, // The lowest percentage of font-size that a moveable item can be assigned. (Will be the scale of the item farthest from the focus bearing.)
		maxScale: 1, // The greatest percentage of font-size that a moveable item can be assigned. (Will be the scale of the item in focus.)
		duration: 800, // The length of time (in milliseconds) that all animations take to complete by default.
		btnNext: '#next',
        btnPrev: '#previous',
		shape: 'square',
		easing: 'easeOutBack' // The easing method to be used for animations by default. jQuery comes with "linear" and "swing," although any of the jQuery Easing plugin's values can be used if the easing plugin is included.
	  	});	
});

//Nivoslider
$(window).load(function() {
    $('#slider').nivoSlider({
		effect:'fade', // Type transition (http://nivo.dev7studios.com/support/jquery-plugin-usage/)
		animSpeed: 500, // Slide transition speed
        pauseTime: 5000, // How long each slide will show
		});	
});

//Fancybox
$(document).ready(function() {

		/* Legg fancybox til flere elementer */
		$("a.fancybox").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'fade',
		'speedIn'		:	500, 
		'speedOut'		:	100, 
		'overlayShow'	:	true,
		'overlayColor'  :   '#000',
		'overlayOpacity':   0.5
		});

		/* Fancybox Loginskjema*/
		$("a.cmsformtrigger").fancybox({
		'scrolling'		: 'no',
		'titleShow'		: false,
		'onClosed'		: function() {
	    $("#login_error").hide();
		}
		});
		
		/*Title on Hover Fancybox*/
		$("a.fancybox_title").fancybox({
		'titlePosition'	:	'over',
		'onComplete'	:	function() {
		$("#fancybox-wrap").hover(function() {
		$("#fancybox-title").show();
		}, function() {
		$("#fancybox-title").hide();
		});
		}
		});
		
		/* Fancybox link in roundabout */
		$('ul#myRoundabout .roundabout-in-focus a').live('click',function(event){
		event.preventDefault();
		$.fancybox({'href':$(this).attr('href')});
		})
		
		/* Legg fancybox til Youtube videoer. */
		$("a.youtube-button, a.video").click(function() {
		$.fancybox({
		'padding'		: 0,
		'autoScale'		: false,
		'transitionIn'	: 'fade',
		'transitionOut'	: 'fade',
		'title'			: this.title,
		'width'			: 800,
		'height'		: 500,
		'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
		'type'			: 'swf',
		'swf'			: {'wmode': 'transparent','allowfullscreen'	: 'true'}
		});
		return false;
		});
});

