$(document).ready( function(){

	// Equal hights
	var min_height = null;
	$('.start div').each(function() {
		if ( ! min_height || min_height > $(this).height() )
			min_height = $(this).height();
	});
	$('.start div').each(function() {
		if ( min_height < $(this).height() ) {
			var padding = 39 - ( $(this).height() - min_height )
			$(this).css('padding-bottom', padding+'px');
		}
	});
	
	/*DROPDOWN*/
	var dropdown_children = $("#dropdown li");
	var dropdown = $("#dropdown_parent");
	var dropdown_a = $("#dropdown_parent a");
	var dropdown_active = $("#dropdown_parent_active a");
	
	/* Initial hide/show */
	dropdown_children.hide();
	dropdown.show();
	
	/* Bolded */
	$(dropdown).next().addClass('important');
	/* Hover */
	$(dropdown_a).mouseover(function(){
		$(this).parent().addClass('hover');
	});
	$(dropdown_a).mouseout(function(){
		$(this).parent().removeClass('hover');
	});
	
	/* Not active */
	dropdown_a.live('click', function(){
		$(this).parent().attr("id", "dropdown_parent_active");
		$(this).parent().parent().addClass('active');
		dropdown_children.show();
		return false;
	});
	
	/* Active */
	dropdown_active.live('click', function() {
		$(this).parent().attr("id", "dropdown_parent");
		$(this).parent().parent().removeClass('active');
		dropdown_children.hide();
		dropdown.show();
		return false;
	});
	
	/* NAVIGATION */
	$(".nav li a").mouseover( function(){
		$(this).parent('li').addClass('active_');
	});
	$(".nav li a").mouseout( function(){
		$(this).parent('li').removeClass('active_');
	});
	
	/*STARTPAGE ADS*/
	$('.start a img').mouseover( function(){
		$(this).parent().parent().prev().addClass('hover');
	//	$(this).parent().parent().siblings('a').addClass('hover');
	});
	$('.start a img').mouseout( function(){
		$(this).parent().parent().prev().removeClass('hover');
	//	$(this).parent().parent().siblings('a').removeClass('hover');
	});
	$('.start h3 a').mouseover( function(){
	//	$(this).parent().siblings('a').addClass('hover');
	});
	$('.start h3 a').mouseout( function(){
	//	$(this).parent().siblings('a').removeClass('hover');
	});
	$('.start a.button').mouseover( function(){
		$(this).siblings('h3').addClass('hover');
	});
	$('.start a.button').mouseout( function(){
		$(this).siblings('h3').removeClass('hover');
	});
	
	/*NEWS FORM BUTTON HOVER*/
	$('div.button').mouseover( function(){
		$(this).addClass('hover');
	});
	$('div.button').mouseout( function(){
		$(this).removeClass('hover');
	});
	
	// Cheat with "external" links
	var uri = decodeURIComponent(window.location.pathname);
	if ( uri == '/huvudmeny/vi-hjalper-dig-salja-mer/full-force/full-force' )
		$('a[href="'+uri+'"]').parent('li').addClass('active');
	
	/*CLEAR INPUT*/
	(function($) {$.fn.ClearInput = function() {
		$(this).each(function() {
			var DefaultValue = this.defaultValue;
			$(this).focus(function(){
				var CurrValue = $(this).val();
				if(CurrValue == DefaultValue) {
					$(this).val("");
				}
			});
			$(this).blur(function(){
				var CurrValue = $(this).val();
				if(CurrValue.length == 0) {
					$(this).val(DefaultValue);
				}
			});
		});
	}})(jQuery);
	
	try {
		if ( $('form input.cleardefault').length ) $('form input.cleardefault').ClearInput();
	} catch(err) {}
});
