﻿var ie6 = false;
 var opera = false;
 
 $(document).ready(function() {

    	jQuery.each(jQuery.browser, function(i, val) {
  		if(i=="msie" && jQuery.browser.version.substr(0,3)=="6.0")
     		ie6 = true;
     		if(i=="opera" && val == true)
     		opera = true;
	});
	
  
     $(".CS_email").each(function(){
    	try{

		var sEmail = $(this).text();
		sEmail = sEmail.replace("[at]","@").toLowerCase();
		$(this).hide();
		$(this).after('<a class="' + $(this).attr('class') + '" href="mailto:' + sEmail + '" title="Skicka e-post till ' + sEmail + '">' + sEmail + '</a>');
		$(this).remove();
	}
	catch(e)
	{
	
	}

    });
    
    $('#wrapper a[href^=#]').click(function() {
	  
	 
		  if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		    && location.hostname == this.hostname) {
		      var $target = $(this.hash);
		      $target = $target.length && $target 
		      || $('[name=' + this.hash.slice(1) +']');
		      if ($target.length) {
		        var targetOffset = $target.offset().top - 94;
		        $('html,body')
		        .animate({scrollTop: targetOffset},{duration: 1000, easing:'easeInSine'});
		       return false;
		      }
		    }
	
	     });

});

$(document).ready(function () {
    $(".CS_question").after("<span class=\"CS_showHideQuestion\">Visa svar</span>");    
    
    $(".CS_faqList").each(function (i){
          
          if($(this).find("li").length > 1)
          {
            $(this).find("h2").after("<span class=\"CS_showHideQuestions\">Visa alla svar</span>");
          
                $(this).find(".CS_showHideQuestions").click(function(){       
        
                    if($(this).hasClass("CS_active"))
                    {
                            $(this).parent().find("li div").slideUp({ duration: 500, easing: "easeOutSine" });
                            $(this).parent().find("li .CS_showHideQuestion").removeClass("CS_active").text("Visa svar");
                    }
                    else
                    {
                            $(this).parent().find("li div").slideDown({ duration: 500, easing: "easeOutSine" });
                            $(this).parent().find("li .CS_showHideQuestion").addClass("CS_active").text("Dölj svar");
                    }
                
                    $(this).toggleText("Visa alla svar","Dölj alla svar").toggleClass("CS_active");       
                
                });
          }  
    });
        
    
    $(".CS_showHideQuestion").click(function(){
        $(this).toggleText("Visa svar","Dölj svar").toggleClass("CS_active").parent().find("div").slideToggle({ duration: 500, easing: "easeOutSine" });
    });
    
 
       
    
     $(".CS_documentList .CS_info").click(function(){
		$(this).toggleClass("CS_active");
		$(this).parent().parent().next().find("p").slideToggle({ duration: 200, easing:'easeOutQuad'});
     }); 
     
         
});

jQuery.fn.toggleText = function(a, b) {
      return this.each(function() {
        jQuery(this).text(jQuery(this).text() == a ? b : a);
      });
};
