/*		Analytics		*/

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-21048775-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  
  

/*		Add displaytext attribute in share logos		*/
	
	$(".st_twitter_large").attr('displaytext','Tweet');
	$(".st_facebook_large").attr('displaytext','Facebook');
	$(".st_ybuzz_large").attr('displaytext','Yahoo! Buzz');
	$(".st_email_large").attr('displaytext','Email');
	$(".st_sharethis_large").attr('displaytext','ShareThis');
	
	$.preloadCssImages();

var images = 1;
var imagesCount = 4;

function bytBilder(){
  
	if ( images == imagesCount)
		{
			images = 1;
		}
	else
		{
			images++;
		}		
			
  			$("#header-images").removeClass("images-" + ( imNo = images == 1 ? imagesCount : (images-1)));
			$("#header-images").addClass("images-" + images);
			$("#header-images").fadeIn('slow');
			
	}
	
	
$(document).ready(function(){
      
	setInterval('fadeImage()', 7000);
      
	});
	
function fadeImage() {

	$("#header-images").fadeOut('slow',function (){
	
	bytBilder();
	
	});
	
	
}

/*		Gallery		*/
$(function() {
	$('.images-container a').lightBox();
});

/*		Nästa funktion är tagen från css-tricks.com		*/

$(function() {

    $("a.polaroid").each(function() {
        $(this)
            .css({
                "-webkit-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg)',
                "-moz-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg)'
            })
            .hover(function() {
                $(this).css({
                    "-webkit-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg) scale(1.05)',
                    "-moz-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg) scale(1.05)'
                })
            }, function() {
                $(this).css({
                    "-webkit-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg) scale(1)',
                    "-moz-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg) scale(1)'
                })
            });
    });   	
});

