﻿$(document).ready(function() {



	//$('a[href="tillbaka"]').attr('href', 'javascript:history.back()').prepend('&laquo; ').addClass('tillbaka');
	


	jQuery.fn.exists = function() { return jQuery(this).length>0; }




	// Focus border remove

			$("a").focus(function() {
				$(this).blur();
			});
		
	
	
	
	
	// Fancybox

			$(".fancy, .lightbox").fancybox({
				'titlePosition'	: 'over'
			});


	// Slider
	
			$('#slides1').bxSlider({
				prev_image: 'images/btn_arrow_left.jpg',
				next_image: 'images/btn_arrow_right.jpg',
				wrapper_class: 'slides1_wrap',
				pause: 6000,
				margin: 70,
				speed: 800,
				auto: true,
				auto_controls: false
			});
	
	
	
	// Menu Drop-Down:
	
			$(".menu_head").click(function() {
				$(".menu_body").slideUp (300);
				$(this).next(".menu_body").slideToggle(300);
			});
			
			$(".hit").next(".menu_body").slideToggle(300).siblings(".menu_body").slideUp("fast");
	
			/* Three Levels
			
			$(".menu_head").click(function() {
				$(this).next(".menu_body").slideToggle(300).siblings(".menu_body").slideUp("fast");	
			});
		
		
			$(".hit").next(".menu_body").slideToggle(300).siblings(".menu_body").slideUp("fast");
			*/





	// Clear input

			clearInput = function (arg) {
				var $nam = $(arg).val();
	
				$(arg).focus(function() {
					if(	$(this).val() == $nam) {
						$(this).val('');
					}
				})
	
				$(arg).blur(function() {
					if(	$(this).val() == '') {
						$(this).val($nam);
					}
				});
			}



	
	// Remove
	
			$("#tools-links a:last").css({ border: "0 none" });
			
			if($("#special").exists()) {
				$("#special .row dl:last-child").css({ float: "right" });
			}





	// Date picker

			if($("#datepicker").exists()) {
				$(function() {
					$("#datepicker").datepicker();
				});
			}
			
			if($("#datepicker").exists()) {
				$(function() {
					$("#datum").datepicker();
				});
			}





	// Form validate
	
	if ($('form').exists()) {
	
		$('.error').hide();

		$('form').bind('submit', function(){
			//var valid = true;
			$('.required').click(function(){
				$(this).removeClass('error-input');
			});
			$('.required').each(function(){
				if($(this).val()==''){
					$(this).addClass('error-input');
					 valid = false;
				} else{
					$(this).removeClass('error-input');
					valid = true;
				}
			});
			if(valid == false){
				$('.error').fadeIn();
				return false;
			}
		});
	
	}






	// Execute scripts

			clearInput("#search");
			scroll("#scroll .ticker");


			

			
	/*******

	***	Anchor Slider by Cedric Dugas   ***
	*** Http://www.position-absolute.com ***
	
	Never have an anchor jumping your content, slide it.

	Don't forget to put an id to your anchor !
	You can use and modify this script for any project you want, but please leave this comment as credit.
	
*****/
});
