﻿try{
	$(document).ready(function(){	
		$("#page 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;
		      }
		    }
	
	     });
	     
	     
	   /*  $("#dumpar a").click(function(){
	     	$("body").append('<div id="dumpBG" style="background: #333"/><div id="dumpContent" />');
	     	
	     	$("#dumpBG").animate({opacity: "0.8" }, 1000).css(
	        {
		    position: "absolute",top: 0, left: 0,
		    
		    background: "#333",
		    filter: "alpha(opacity=80)",
		    width: $(document).width() + "px",
		    height: $(document).height() + "px"
	       });
	      
	      	      
	      return false;
	      
	      
	     });
	     */
	     
	});
	     
}catch(e){     }	     
	     function emailSetup(){
	
	var oObj = document.getElementsByClassName("email");
	
	if(oObj){
		
		for(var i=0;i<oObj.length;i++)
		{
		   var childNodes = 1;
		 	 
			 try{
						childNodes = oObj[i].childNodes.length;
			 }catch(e){
							childNodes = 1;
			 }
			
			if(oObj[i] && childNodes == 1 && oObj[i].tagName.toLowerCase() == "a"){
				var sEmail = "";
				
				try{
					sEmail = getEmail(oObj[i]);
				}catch(e){
					sEmail = "";
				}
	
				if(sEmail.length != 0 && sEmail.indexOf("@") != -1){
					oObj[i].title = "Skicka epost till " + sEmail;
					oObj[i].innerHTML = sEmail;
					oObj[i].href= "mailto:" + sEmail;
				}
			}				
				
		}
		
	}else{
		//alert("");
	}
}

function getEmail(oObj){

	 var sEmail = oObj.innerHTML.replace("[at]","@").toLowerCase();
		 
	 return sEmail;
}

document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) {
	    var classes = elem[i].className;
	    if (myclass.test(classes)) retnode.push(elem[i]);
	}
	
	return retnode;

};

function addEvent(obj, evType, fn){

	  if (obj.addEventListener){
	
	    obj.addEventListener(evType, fn, true);
	
	    return true;
	
	  }else if(obj.attachEvent){
	
		var r = obj.attachEvent("on"+evType, fn);
	
	    	return r;
	
	  }else{	
		return false;	
	  }
}

addEvent(window,"load",emailSetup);
