// JavaScript Document Kvinnoagenda
// krypterad epostadress till klarskrift
function eposttext(myarray, uttext){var encryptedemail=''; //variable to contain encrypted email 
	for (var i=0; i<myarray.length; i++)
		encryptedemail+=String.fromCharCode(myarray[i]);
	encryptedemail='<a href="mailto:'+encryptedemail+'">'+uttext+'</a>';
	return encryptedemail;
}
function epost(myarray) {var encryptedemail=''; //variable to contain encrypted email 
	for (var i=0; i<myarray.length; i++)
		encryptedemail+=String.fromCharCode(myarray[i]);
		encryptedemail='<a href="mailto:'+encryptedemail+'">'+encryptedemail+'</a>';
	 return encryptedemail; 
}
var ac=[99,99,101,100,101,114,103,114,101,110,64,103,109,97,105,108,46,99,111,109];
var ipr=[105,110,102,111,64,105,112,114,106,117,114,105,115,116,98,121,114,97,46,115,101];
var iva=[105,118,97,46,112,97,114,105,122,107,111,118,97,46,114,121,103,103,101,115,116,97,104,108,64,98,114,101,100,98,97,110,100,46,110,101,116];
/**
* hoverIntent is similar to jQuery's built-in "hover" function except that
* instead of firing the onMouseOver event immediately, hoverIntent checks
* to see if the user's mouse has slowed down (beneath the sensitivity
* threshold) before firing the onMouseOver event.
* 
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* hoverIntent is currently available for use in all personal or commercial 
* projects under both MIT and GPL licenses. This means that you can choose 
* the license that best suits your project, and use it accordingly.
* 
* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
* $("ul li").hoverIntent( showNav , hideNav );
* 
* // advanced usage receives configuration object only
* $("ul li").hoverIntent({
*	sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
*	interval: 100,   // number = milliseconds of polling interval
*	over: showNav,  // function = onMouseOver callback (required)
*	timeout: 0,   // number = milliseconds delay before onMouseOut function call
*	out: hideNav    // function = onMouseOut callback (required)
* });
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($) {
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
			if ( p == this ) { return false; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};
})(jQuery);
//jQuery
$(function() {
	$('#menu li ul').css({
    display: "none",
    left: "auto"
  });
  $('#menu li').hoverIntent(function() {
    $(this)
      .find('ul')
      .stop(true, true)
      .slideDown('fast');
  }, function() {
    $(this)
      .find('ul')
      .stop(true,true)
      .fadeOut('fast');
  });
// lägg till uppdateringsdatum					 
	var datum = new Date(document.lastModified)
	datum= $.formatDate(datum,"d MMMM yyyy");
	$("li#datum span").html(datum);							 
// gör epostlänkar				
	$("p#epost_ac span").html(epost(ac));
	$("p#epost_ipr span").html(epost(ipr));
	$("p#epost_iva span").html(epost(iva));
	// ta bort test om javascript äv aktiverad
	$(".utanJs").hide();	
	//bildvisare 
	var mySida= $('body').hasClass('bildsida');
	if (mySida) { 
		$("a[rel='example1']").colorbox({opacity:0.6, transition:"elastic"});	}
		$(".inline").colorbox({inline:true, width:"50%"});
});		// $ slut
/*
$.formatDate(date,pattern) Formats the passed date according to the supplied pattern. The tokens that are substituted in the pattern are as follows:
yyyy: the 4-digit year, yy: the 2-digit year, MMMM: the full name of the month, MMM: the abbreviated name of the month, MM: the month number as a 0-filled, 2-character field, M: the month number, dd: the day in the month as a 0-filled, 2-character field, d: the day in the month
EEEE: the full name of the day of the week, EEE: the abbreviated name of the day of the week, a: the meridium (AM or PM), HH: the 24-hour clock hour in the day as a 2-character, 0-filled field, 
H: the 24-hour clock hour in the day, hh: the 12-hour clock hour in the day as a 2-character, 0-filled field, h: the 12-hour clock hour in the day, mm: the minutes in the hour as a 2-character, 0-filled field, m: the minutes in the hour, ss: the seconds in the minute as a 2-character, 0-filled field, s: the seconds in the minute, S: the milliseconds in the second as a 3-character, 0-filled field, Parameters, date (Date) The date to be formatted., pattern (String) The pattern to format the date into. Any characters not matching pattern, tokens are copied as-is to the result. ReturnsThe formatted date.
*/
(function($){$.toFixedWidth = function(value,length,fill) {var result = value.toString();if (!fill) fill = '0';var padding = length - result.length;if (padding < 0) {result = result.substr(-padding);}else {for (var n = 0; n < padding; n++)result = fill + result;}return result;};})(jQuery);(function($){$.formatDate = function(date,pattern) {var result = [];while (pattern.length > 0) {$.formatDate.patternParts.lastIndex = 0;var matched = $.formatDate.patternParts.exec(pattern);if (matched) {result.push($.formatDate.patternValue[matched[0]].call(this,date));pattern = pattern.slice(matched[0].length);} else {result.push(pattern.charAt(0));pattern = pattern.slice(1);}}return result.join('');};$.formatDate.patternParts =/^(yy(yy)?|M(M(M(M)?)?)?|d(d)?|EEE(E)?|a|H(H)?|h(h)?|m(m)?|s(s)?|S)/;$.formatDate.monthNames = [
'januari','februari','mars','april','maj','juni','juli','augusti','september','oktober','november','december'];$.formatDate.dayNames = ['Söndag','Måndag','Tisdag','Onsdag','Torsdag','Fredag','Lördag'];$.formatDate.patternValue = {yy: function(date) {return $.toFixedWidth(date.getFullYear(),2);},yyyy: function(date) {return date.getFullYear().toString();},MMMM: function(date) {return $.formatDate.monthNames[date.getMonth()];},MMM: function(date) {return $.formatDate.monthNames[date.getMonth()].substr(0,3);},MM: function(date) {return $.toFixedWidth(date.getMonth() + 1,2);},M: function(date) {return date.getMonth()+1;},dd: function(date) {return $.toFixedWidth(date.getDate(),2);},d: function(date) {return date.getDate();},EEEE: function(date) {return $.formatDate.dayNames[date.getDay()];},EEE: function(date) {return $.formatDate.dayNames[date.getDay()].substr(0,3);},HH: function(date) {return $.toFixedWidth(date.getHours(),2);},H: function(date) {return date.getHours();},hh: function(date) {var hours = date.getHours();return $.toFixedWidth(hours > 12 ? hours - 12 : hours,2);},h: function(date) {return date.getHours() % 12;},mm: function(date) {return $.toFixedWidth(date.getMinutes(),2);},m: function(date) {return date.getMinutes();},ss: function(date) {return $.toFixedWidth(date.getSeconds(),2);},s: function(date) {return date.getSeconds();},S: function(date) {return $.toFixedWidth(date.getMilliseconds(),3);},a: function(date) {return date.getHours() < 12 ? 'AM' : 'PM';}};})(jQuery);	

