

$(document).ready(function() {

	$("#header-links a:first").css("border-left", "0");
	$("#columns-frontpage .video-line-frontpage:first").css("border-top", "0");
	
	/************** Change text size *****************/
	
	$(".changeTextSize").click(function() {
		
		var currentTextSize = $("body").css("font-size");
		var unit = currentTextSize.slice(-2);
		currentTextSize = parseFloat(currentTextSize);
		var newSize;
		
		if (this.id == 'smallerTextSize') {
			// newSize = currentTextSize * 0.9;
			var original = $("#original-text-size").css("font-size"); 
			newSize = parseFloat(original);
		} 
		else if (this.id == 'resetTextSize') {
			newSize = 15;			
		} 
		else if (this.id == 'largerTextSize') {
			// newSize = currentTextSize * 1.1;
			newSize = 17;
		}
		
		$("body").css("font-size", newSize + unit);
	})
	
	/************** End change text size **************/
	
		/** Sharethis buttons */
		var switchTo5x=true;
		stLight.options({
			publisher: 'ee755793-e1e9-40c6-b067-336b4d0d1dba',
			onhover: 'false'
		});
		/** End sharethis buttons */
		
		/***** Showing / hiding contact info and newsletters divs *****/
		$("#visKontaktinformasjon").click(function(){
			$("#nyhetsbrev").hide("slow");		
			$("#kontaktinformasjon").toggle("slow");
		});
			
		$("#kontaktinformasjonLukk").click(function(){
			$("#kontaktinformasjon").hide("slow");
		});
		
		$("#visNyhetsbrev").click(function(){
			$("#kontaktinformasjon").hide("slow");		
			$("#nyhetsbrev").toggle("slow");
		});
			
		$("#nyhetsbrevLukk").click(function(){
			$("#nyhetsbrev").hide("slow");
		});

		/******************* Høykontrast *************************/

		$('#hoykontrast a').click( function() {

			if ($('body').attr('id')) {
				$('body').removeAttr('id');
				$('html').css('background-color', '#fff');
				$('#hoykontrast a').html('H&oslash;ykontrast');
				/*$.cookie('css_style', 'normal');*/
	
			} else {
				$('body').attr('id', 'contrast');
				$('html').css('background-color', '#000');
				$('#hoykontrast a').html('Normal');
				/*$.cookie('css_style', 'contrast', { expires: 7, path: '/' });*/
				
			}
		});

		
		/******************* Slider frontpage ********************/
		var $container = $('#slider').cycle({
			fx: 'fade',
			next: '#slider-next',
			prev: '#slider-prev',
			after: onAfter,
			timeout: 8000
		});
		
		$('#slider-pause').click(function() { 
		    $('#slider').cycle('pause'); 
		});
		
		$('#slider-play').click(function() {
		    $('#slider').cycle('resume'); 
		});
		
 			var bc = $('#slider-nav'); 
 		 $container.children().each(function(i) { 
    		
    			if (i == 0) {
      				$('<input type="button" id="'+i+'" class="active_nav_button" />').appendTo(bc); 
    			}
     			else {
      			$('<input type="button" id="'+i+'" />').appendTo(bc); 
     			}
  			});

		

 

		/***** Rounding corners on divs *****/
		$("div.infobox").css("border-style", "solid");
		$("div.infobox").corner();

	

		$("div#HON-logo").css("border-style", "solid");
		$("div#HON-logo").corner();
		
		$("div.article-frontpage").css("border-style", "solid");
		$("div.article-frontpage").corner();
		
		$("#columns-frontpage .column").css("border-style", "solid"); 
		$("#columns-frontpage .column").corner();
		
		$("div#main-article-area").corner();
		

		/************** Video sizes *****************/
	
$('#sb-body-inner').html('test');
		/************** Cookie *****************/

/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie = function (key, value, options) {

    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        value = String(value);

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
	

/*if ( $.cookie('css_style') == 'contrast') {
$('body').attr('id', 'contrast');
$('#hoykontrast a').html('Normal');
} else {
$('body').removeAttr('id');
$('#hoykontrast a').html('H&oslash;ykontrast');
}*/

	
});

function onAfter(curr, next, opts) {
	var $id = $('.active_nav_button').attr('id');


	$id++;
	if ($('#'+$id).length == 0 ) {
	$id = 0;
	}
	$('.active_nav_button').removeAttr('class');  
	
	$('#'+$id).attr('class', 'active_nav_button');

};

	
