jQuery(document).ready(function($) {
 
	$(".scroll").click(function(event){		
		event.preventDefault();
		$('html,body').animate({scrollTop:$(this.hash).offset().top}, 500);
	});
	$().UItoTop({ easingType: 'easeOutQuart' });
	
	// set all input.text default value according to alt attribute
        $("input.contactinput, input.contactinputemail, textarea.contacttextarea").each(function(){
          $(this).val($(this).attr("alt"));
        });
 
        // clear input.text on focus, if still in default
        $("input.contactinput, input.contactinputemail, textarea.contacttextarea").focus(function() {
 
          if($(this).val()==$(this).attr("alt")) {
            $(this).val("");
          }
        });
 
        // if field is empty afterward, add text again
        $("input.contactinput, input.contactinputemail, textarea.contacttextarea").blur(function() {
          if($(this).val()=="") {
            $(this).val($(this).attr("alt"));
          }
        });
	
});

/*
|--------------------------------------------------------------------------
| UItoTop jQuery Plugin 1.1
| http://www.mattvarone.com/web-design/uitotop-jquery-plugin/
|--------------------------------------------------------------------------
*/

(function($){
	$.fn.UItoTop = function(options) {

 		var defaults = {
			text: 'To Top',
			min: 100,
			inDelay:600,
			outDelay:400,
  			containerID: 'toTop',
			containerHoverID: 'toTopHover',
			scrollSpeed: 1200,
			easingType: 'linear'
 		};

 		var settings = $.extend(defaults, options);
		var containerIDhash = '#' + settings.containerID;
		var containerHoverIDHash = '#'+settings.containerHoverID;
		
		$('body').append('<a href="#" id="'+settings.containerID+'">'+settings.text+'</a>');
		$(containerIDhash).hide().click(function(){
			$('html, body').animate({scrollTop:0}, settings.scrollSpeed, settings.easingType);
			$('#'+settings.containerHoverID, this).stop().animate({'opacity': 0 }, settings.inDelay, settings.easingType);
			return false;
		})
		.prepend('<span id="'+settings.containerHoverID+'"></span>')
		.hover(function() {
				$(containerHoverIDHash, this).stop().animate({
					'opacity': 1
				}, 200, 'linear');
			}, function() { 
				$(containerHoverIDHash, this).stop().animate({
					'opacity': 0
				}, 200, 'linear');
			});
					
		$(window).scroll(function() {
			var sd = $(window).scrollTop();
			if(typeof document.body.style.maxHeight === "undefined") {
				$(containerIDhash).css({
					'position': 'absolute',
					'top': $(window).scrollTop() + $(window).height() - 50
				});
			}
			if ( sd > settings.min ) 
				$(containerIDhash).fadeIn(settings.inDelay);
			else 
				$(containerIDhash).fadeOut(settings.Outdelay);
		});

};
})(jQuery);
function setHeight(which) {
    var div = $(which);
    div.css({height: div.height() });
}
 $(document).ready(function() {
        $('img.buttonNOTINUSE').each(function() {
            $(this).hover(function() {
                $(this).stop().animate({ opacity: 0.8 }, 200);
            },
           function() {
               $(this).stop().animate({ opacity: 1.0 }, 200);
           });
        });
              $('img.closeNOTINUSE').each(function() {
            $(this).hover(function() {
                $(this).stop().animate({ opacity: 0.8 }, 200);
            },
           function() {
               $(this).stop().animate({ opacity: 0.3 }, 200);
           });
        });
        
	 $('a.ekologiska-link').click(function(){

	  $("#workdetailwrapper > div").slideUp('slow'); //hide previous
	  $('#workdetailwrapper > div').promise().done(function(){
      $('#ekologiska').slideDown('slow'); //show what's clicked on
});
	  return false;
	});
	 $('a.likevent-link').click(function(){
	  $("#workdetailwrapper > div").slideUp('slow'); //hide previous
	  	  $('#workdetailwrapper > div').promise().done(function(){
      $('#likevent').slideDown('slow'); //show what's clicked on
});
	  return false;
	});
	 $('a.uniquedive-link').click(function(){
	  $("#workdetailwrapper > div").slideUp('slow'); //hide previous
	  $('#workdetailwrapper > div').promise().done(function(){
	  $('#uniquedive').slideDown('slow'); //show what's clicked on
});
	  return false;
	});
	 $('a.seeimdb-link').click(function(){
	  $("#workdetailwrapper > div").slideUp('slow'); //hide previous
	  $('#workdetailwrapper > div').promise().done(function(){
	  $('#seeimdb').slideDown('slow'); //show what's clicked on
});
	  return false;
	});
	 $('a.traningsmaskiner-link').click(function(){
	  $("#workdetailwrapper > div").slideUp('slow'); //hide previous
	  $('#workdetailwrapper > div').promise().done(function(){
	  $('#traningsmaskiner').slideDown('slow'); //show what's clicked on
});
	  return false;
	});
	 $('a.krustang-link').click(function(){
	  $("#workdetailwrapper > div").slideUp('slow'); //hide previous
	  $('#workdetailwrapper > div').promise().done(function(){
	  $('#krustang').slideDown('slow'); //show what's clicked on
});
	  return false;
	});
	$('a.close-link').click(function(){
	  $("#workdetailwrapper > div").slideUp('slow'); //hide previous
	  return false;
	});
	//$('#menu').stickyfloat({ duration: 00 });
});
/*
$.fn.stickyfloat = function(options, lockBottom) {
 var $obj                 = this;
 var parentPaddingTop     = parseInt($obj.parent().css('padding-top'));
 var startOffset         = $obj.parent().offset().top;
 var opts                 = $.extend({ startOffset: startOffset, offsetY: parentPaddingTop, duration: 200, lockBottom:true }, options);
 
 $obj.css({ position: 'absolute' });
 
 if(opts.lockBottom){
 var bottomPos = $obj.parent().height() - $obj.height() + parentPaddingTop; //get the maximum scrollTop value
 if( bottomPos < 0 )
 bottomPos = 0;
 }
 
 $(window).scroll(function () {
 $obj.stop(); // stop all calculations on scroll event
 
 var pastStartOffset            = $(document).scrollTop() > opts.startOffset;    // check if the window was scrolled down more than the start offset declared.
 var objFartherThanTopPos    = $obj.offset().top > startOffset;    // check if the object is at it's top position (starting point)
 var objBiggerThanWindow     = $obj.outerHeight() < $(window).height();    // if the window size is smaller than the Obj size, then do not animate.
 
 // if window scrolled down more than startOffset OR obj position is greater than
 // the top position possible (+ offsetY) AND window size must be bigger than Obj size
 if( (pastStartOffset || objFartherThanTopPos) && objBiggerThanWindow ){
 var newpos = ($(document).scrollTop() -startOffset + opts.offsetY );
 if ( newpos > bottomPos )
 newpos = bottomPos;
 if ( $(document).scrollTop() < opts.startOffset ) // if window scrolled < starting offset, then reset Obj position (opts.offsetY);
 newpos = parentPaddingTop;
 
 $obj.animate({ top: newpos }, opts.duration );
 }
 });
 };
 
 */
$(function() {
    $('img[data-hover]').hover(function() {
        $(this).attr('tmp', $(this).attr('src')).attr('src', $(this).attr('data-hover')).attr('data-hover', $(this).attr('tmp')).removeAttr('tmp');
    }).each(function() {
        $('<img />').attr('src', $(this).attr('data-hover'));
    });;
});

