/* JS Document Karlskrona Lakareforbund*/
// 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 acj=[97,110,110,45,99,104,97,114,108,111,116,116,101,45,106,101,110,110,121,46,106,111,104,97,110,115,115,111,110,64,108,116,98,108,101,107,105,110,103,101,46,115,101]; //Ann-Charlotte J
var ad=[97,110,100,101,114,115,100,105,109,98,101,114,103,64,104,111,116,109,97,105,108,46,99,111,109]; //Anders D
var ah=[97,110,100,101,114,115,46,104,97,108,108,105,110,103,64,103,109,97,105,108,46,99,111,109]; //Anders H
var anm=[107,97,114,108,115,107,114,111,110,97,46,108,97,107,97,114,101,102,111,114,101,110,105,110,103,64,103,109,97,105,108,46,99,111,109]; // Anmälan
var ba=[98,101,110,103,116,46,97,98,101,114,103,64,108,116,98,108,101,107,105,110,103,101,46,115,101]; //Bengt Å
var bl=[98,97,114,98,114,111,46,108,97,103,101,114,99,114,97,110,116,122,64,103,109,97,105,108,46,99,111,109]; //BarbroL
var gb=[103,111,114,97,110,46,98,106,111,114,107,64,108,116,98,108,101,107,105,110,103,101,46,115,101]; // Göran B
var gh=[105,110,102,111,64,103,104,110,101,116,46,115,101]; //Göran H
var hk=[104,97,107,97,110,46,107,108,101,109,101,110,116,115,115,111,110,64,108,116,98,108,101,107,105,110,103,101,46,115,101]; //Håkan K
var ho=[104,97,107,97,110,64,111,100,101,98,101,114,103,46,99,111,109]; //Håkan O
var jj=[106,111,104,110,46,106,111,104,110,115,101,110,64,108,116,98,108,101,107,105,110,103,101,46,115,101]; //John J
/*var ks=[107,101,114,115,116,105,110,46,115,116,114,111,109,64,108,116,98,108,101,107,105,110,103,101,46,115,101];*/
/*var kt=[107,114,105,115,116,105,110,101,46,116,104,111,114,101,108,108,64,108,116,98,108,101,107,105,110,103,101,46,115,101];*/
var lgl=[108,97,114,115,45,103,111,114,97,110,46,108,117,110,100,103,114,101,110,64,108,116,98,108,101,107,105,110,103,101,46,115,101]; //Lars-Göran L 
var lj=[108,105,115,97,46,106,111,104,97,110,115,115,111,110,64,108,116,98,108,101,107,105,110,103,101,46,115,101]; //Lisa J
var lm=[108,101,105,102,46,109,97,114,107,117,115,115,111,110,64,116,101,108,105,97,46,99,111,109]; //Leif M
var lt=[108,105,110,100,97,46,116,104,111,114,110,64,108,116,98,108,101,107,105,110,103,101,46,115,101]; //Linda T
/*var mb=[109,97,114,103,97,114,101,116,97,46,98,114,111,115,116,114,111,109,64,108,116,98,108,101,107,105,110,103,101,46,115,101];*/
var re=[114,105,99,107,97,114,100,46,101,105,116,114,101,109,64,108,116,98,108,101,107,105,110,103,101,46,115,101]; //Richard E
var to=[116,104,111,109,97,115,95,111,108,115,111,110,64,116,101,108,105,97,46,99,111,109]; //Thomas 0
//jQuery
$(function() {
// 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	
	$("span#epost_acj").html(epost(acj));
	$("span#epost_ad").html(epost(ad));
	$("span#epost_ah").html(epost(ah));	
	$("span#epost_anm").html(epost(anm));
	$("span#epost_ba").html(epost(ba));	
	$("span#epost_bl").html(epost(bl));
	$("span#epost_gb").html(epost(gb));
	$("span#epost_gh").html(epost(gh));
	$("span#epost_hk").html(epost(hk));
	$("span#epost_ho").html(epost(ho));
	$("span#epost_jj").html(epost(jj));
	//$("span#epost_ks").html(epost(ks));
	//$("span#epost_kt").html(epost(kt));
	$("span#epost_lgl").html(epost(lgl));
	$("span#epost_lj").html(epost(lj));
	$("span#epost_lm").html(epost(lm));
	$("span#epost_lt").html(epost(lt));
	//$("span#epost_mb").html(epost(mb));
	$("span#epost_re").html(epost(re));	
	$("span.epost_to").html(epost(to));		
	
	//bildvisare					 	
	$("a[rel='example1']").colorbox({opacity:0.6});				 	
	$("a[rel='example2']").colorbox({opacity:0.6});					 	
	$("a[rel='example3']").colorbox({opacity:0.6});	
});		// $ 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);	

// Example:
// simplePreload( '01.gif', '02.gif' ); 
function simplePreload() { 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++) {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}
// global variable for subwindow reference 
var newWindow; 
// generate and fill the new window 
function openCenteredWindow(url) { 
	var width = 430; 
    var height = 500; 
    var left = parseInt((screen.availWidth/2) - (width/2)); 
    var top = parseInt((screen.availHeight/2) - (height/2)); 
    var windowFeatures = "width=" + width + ",height=" + height + 
        ",status,resizable,left=" + left + ",top=" + top + 
        ",screenX=" + left + ",screenY=" + top; 
    // make sure it isn't already opened 
    if (!newWindow || newWindow.closed) { 
        newWindow = window.open(url,"subWind", windowFeatures); 
        // delay writing until window exists in IE/Windows 
        setTimeout("writeToWindow()", 50); 
    } else if (newWindow.focus) { 
        // window is already open and focusable, so bring it to the front 
        newWindow.focus(); 
    } 
} 

/* 
*  Copyright 2006-2007 Dynamic Site Solutions.
*  Free use of this script is permitted for non-commercial applications,
*  subject to the requirement that this comment block be kept and not be
*  altered.  The data and executable parts of the script may be changed
*  as needed.  Dynamic Site Solutions makes no warranty regarding fitness
*  of use or correct function of the script.  Terms for use of this script
*  in commercial applications may be negotiated; for this, or for other
*  questions, contact "license-info@dynamicsitesolutions.com".
*
*  Script by: Dynamic Site Solutions -- http://www.dynamicsitesolutions.com/
*  Last Updated: 2007-06-17
*/

//IE5+/Win, Firefox, Netscape 6+, Opera 7+, Safari, Konqueror 3, IE5/Mac, iCab 3

var addBookmarkObj = {
  linkText:'Lägg in www.k-lf.se i Favoriter/Bokmärken!',
  addTextLink:function(parId){
    var a=addBookmarkObj.makeLink(parId);
    if(!a) return;
    a.appendChild(document.createTextNode(addBookmarkObj.linkText));
  },
  addImageLink:function(parId,imgPath){
    if(!imgPath || isEmpty(imgPath)) return;
    var a=addBookmarkObj.makeLink(parId);
    if(!a) return;
    var img = document.createElement('img');
    img.title = img.alt = addBookmarkObj.linkText;
    img.src = imgPath;
    a.appendChild(img);
  },
  makeLink:function(parId) {
    if(!document.getElementById || !document.createTextNode) return null;
    parId=((typeof(parId)=='string')&&!isEmpty(parId))
      ?parId:'addBookmarkContainer';
    var cont=document.getElementById(parId);
    if(!cont) return null;
    var a=document.createElement('a');
    a.href=location.href;
    if(window.opera) {
      a.rel='sidebar'; // this makes it work in Opera 7+
    } else {
      // this doesn't work in Opera 7+ if the link has an onclick handler,
      // so we only add it if the browser isn't Opera.
      a.onclick=function() {
        addBookmarkObj.exec(this.href,this.title);
        return false;
      }
    }
    a.title=document.title;
    return cont.appendChild(a);
  },
  exec:function(url, title) {
    // user agent sniffing is bad in general, but this is one of the times 
    // when it's really necessary
    var ua=navigator.userAgent.toLowerCase();
    var isKonq=(ua.indexOf('konqueror')!=-1);
    var isSafari=(ua.indexOf('webkit')!=-1);
    var isMac=(ua.indexOf('mac')!=-1);
    var buttonStr=isMac?'Command/Cmd':'CTRL';

    if(window.external && (!document.createTextNode ||
      (typeof(window.external.AddFavorite)=='unknown'))) {
        // IE4/Win generates an error when you
        // execute "typeof(window.external.AddFavorite)"
        // In IE7 the page must be from a web server, not directly from a local 
        // file system, otherwise, you will get a permission denied error.
        window.external.AddFavorite(url, title); // IE/Win
    } else if(isKonq) {
      alert('Du måste trycka på  CTRL + B för att lägga in vår sida i Favoriter/Bokmärken.');
    } else if(window.opera) {
      void(0); // do nothing here (Opera 7+)
    } else if(window.home || isSafari) { // Firefox, Netscape, Safari, iCab
      alert('Du måste trycka på '+buttonStr+' + D för att lägga in vår sida i Favoriter/Bokmärken.');
    } else if(!window.print || isMac) { // IE5/Mac and Safari 1.0
      alert('Du måste trycka på Command/Cmd + D för att lägga vår in sida i Favoriter/Bokmärken.');    
    } else {
      alert('Du måste manuellt lägga in vår sida i Favoriter/Bokmärken med webbläsaren');
    }
  }
}

function isEmpty(s){return ((s=='')||/^\s*$/.test(s));}

function dss_addEvent(el,etype,fn) {
  if(el.addEventListener && (!window.opera || opera.version) &&
  (etype!='load')) {
    el.addEventListener(etype,fn,false);
  } else if(el.attachEvent) {
    el.attachEvent('on'+etype,fn);
  } else {
    if(typeof(fn) != "function") return;
    if(typeof(window.earlyNS4)=='undefined') {
      // to prevent this function from crashing Netscape versions before 4.02
      window.earlyNS4=((navigator.appName.toLowerCase()=='netscape')&&
      (parseFloat(navigator.appVersion)<4.02)&&document.layers);
    }
    if((typeof(el['on'+etype])=="function")&&!window.earlyNS4) {
      var tempFunc = el['on'+etype];
      el['on'+etype]=function(e){
        var a=tempFunc(e),b=fn(e);
        a=(typeof(a)=='undefined')?true:a;
        b=(typeof(b)=='undefined')?true:b;
        return (a&&b);
      }
    } else {
      el['on'+etype]=fn;
    }
  }
}

dss_addEvent(window,'load',addBookmarkObj.addTextLink);


