/* <![CDATA[ */

	//jQuery.noConflict(); already set by wp-includes jquery

	

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

		//jQuery("#tabs").tabs();

        $('#globalnav ul').superfish({

        	delay: 200,

        	speed: 'fast',

        	autoArrows: false

        }); 



		$("#sidebar h2 a").click(function () {

			var itemlist = $(this).parents("li:first");

			itemlist.toggleClass("side-switch");

			itemlist.find("ul").slideToggle("fast");

			return false;

			

        });

        //tab-pages

        $(".tabs li").click(function(){

        		if(!$(this).hasClass("active")){

        			$(".tabs li.active").removeClass("active")

        			$(this).toggleClass("active");

        			$(".page-content, .page-switch").toggleClass("hidden");

        		}

        });

        //slide - medarbetare

			var currentPosition = 0;

			var slideWidth = 932;

			var slides = $('.wrapper');

			var numberOfSlides = slides.length;

			// Remove scrollbar

			$('.ngg-galleryoverview').css('overflow', 'hidden');

			// Wrap all .slides with #slideInner div

			slides.wrapAll('<div id="slideInner"></div>')

			// Float left to display horizontally, readjust .slides width

			.css({

      		'float' : 'left',

      		'width' : slideWidth

			});

			

			// Set #slideInner width equal to total width of all slides

  			$('#slideInner').css('width', slideWidth * numberOfSlides);

  			

  			// Insert controls in the DOM

			$('.page-switch')

    			.prepend('<span class="control" id="leftControl">Clicking moves left</span>')

    			.append('<span class="control" id="rightControl">Clicking moves right</span>');



			// Hide left arrow control on first load

			manageControls(currentPosition);

			

			// Create event listeners for .controls clicks

  			$('.control').bind('click', function(){

    			// Determine new position

				currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;

					

				// Hide / show controls

    			manageControls(currentPosition);

    				

    			// Move slideInner using margin-left

    			$('#slideInner').animate({

      			'marginLeft' : slideWidth*(-currentPosition)

    			});

    		});

    		// manageControls: Hides and Shows controls depending on currentPosition

  			function manageControls(position){

    			// Hide left arrow if position is first slide

				if(position==0){

					//$('#leftControl').css('background-position','-43px 155px');
					$('#leftControl').css('display','none');

				} else{

					$('#leftControl').removeAttr('style');

				}

				// Hide right arrow if position is last slide

    			if(position==numberOfSlides-1){

    				$('#rightControl').css('display','none');

    			} else{

    				$('#rightControl').removeAttr('style');

    			}

  			}

  			

  			/* contact-page */

  			$(".city").hide();

  			$(".ddl-heading").click(function(){

  				$(this).next(".hidden").slideToggle(300);

  			});

			$("#office-info ul li").click(function(){

				$(".city").hide();

				$("#office-info ul").slideToggle(100);

				var iCity = parseInt(this.id);

				switch(iCity)

				{

					case 0:

						$("#sth").show();

					break;

					case 1:

						$("#mlo").show();

					break;
					
					case 2:

						$("#arh").show();

					break;

					case 3:

						$("#kob").show();

					break;

					case 4:

						$("#nor").show();

					break;

					default:

						$("#sth").show();

				}

			});

			$("#contact .ddl li").click(function(){

				$(this).parent().hide().prev(".ddl-heading").text($(this).html());

			});

			$("#contact #email").click(function(){

				if($(this).val()=="*E-post"){

					$(this).val('');

				}

			});

			$("#contact #email").blur(function(){

				if($(this).val()==""){

					$(this).val('*E-post');

				}

			});

			$("#contact #contactName").click(function(){

				if($(this).val()=="*Namn"){

					$(this).val('');

				}

			});

			$("#contact #contactName").blur(function(){

				if($(this).val()==""){

					$(this).val('*Namn');

				}

			});

			/* kunder */

			$("#myController").jFlow({

				controller: ".jFlowControl", // must be class, use . sign

				slideWrapper : "#jFlowSlide", // must be id, use # sign

				slides: "#mySlides",  // the div where all your sliding divs are nested in

				selectedWrapper: "jFlowSelected",  // just pure text, no sign

				width: "868px",  // this is the width for the content-slider

				height: "78px",  // this is the height for the content-slider

				duration: 400,  // time in miliseconds to transition one slide

				prev: ".jFlowPrev", // must be class, use . sign

				next: ".jFlowNext", // must be class, use . sign

				auto: false	// true or false

    		});

			/* klick på logotyp */

			$('.jFlowSlideContainer a').click(function(){

				var elmId = $(this).parent('div').attr('id');

				var slideNr = elmId.substring(5);

				$('#textSlider div').hide();

				$('#textSlider').children('div#text'+slideNr).show();

				$($('#myController span')[slideNr-1]).trigger('click');

			});

//			$('.jFlowNext').click(function(){

//				var slideIndex = $('#myController').find('.jFlowSelected').index();

//			});

	});



function printCopyrightYears(startYear) {

	if(!startYear)

		var startYear=2009

	var d=new Date(); 

	yr=d.getFullYear();

	if (yr!=startYear) {

		document.write(startYear+"-"+yr);

	} else {

		document.write(startYear);

	}	

}



clearDefault = function(obj) {

		if(obj.defaultValue == obj.value) obj.value = ''; 

}



restoreDefault = function(obj) {

		if(obj.value == '') obj.value = obj.defaultValue;

}



function optformValidate(form) {

	var error = '';

	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

	var objEmail = form.opt_email;

	

	if(form.opt_name.value == '' || form.opt_name.value == form.opt_name.defaultValue) {

		error += "Please enter your name\n";

		form.opt_name.value = '';

		form.opt_name.focus();

		return false;

	}

	if(objEmail.value == '' || objEmail.value == objEmail.defaultValue) {

		error += "Please enter your email\n";

		objEmail.value= '';

		objEmail.focus();

		return false;

		

	} else if(!filter.test(objEmail.value)) {

		error += "Please enter a valid email\n";

		objEmail.value = '';

		objEmail.focus();

	}

	

	if(error != '') {

		alert(error);

		return false;	

	} else {

		return true;

	}

}

/* ]]> */
