
if (!dk) {
  var dk = {} ;
  dk.danskinternetselskab = {} ;
} else if (!dk.danskinternetselskab) {
  dk.danskinternetselskab = {};
}

var dkis = dk.danskinternetselskab;
	    
//constructor
dkis.Slideshow = function(sidframe, sclassitem) { 
        var _Self = this;
		this.timeOut = null;
		this.nextIndex = 1;
		this.position = 0;
		this.idFrame = sidframe;
		this.classItem = sclassitem;
		this.classShow = "slideShow";
		this.classHide = "slideHide";
		this.classNavi = "slideshownavigation";
		this.imgSelected = "/files/design/images/slide_selected.jpg";
		this.imgNotSelected = "/files/design/images/slide_notselected.jpg";
		this.imgTitle = "Show slide ";
		this.time = 3000;
		this.slideHeight = 0;
		
        var elFrame = document.getElementById(this.idFrame);
        if (!elFrame) return;
        this.slideArray = dkis.getElementsWithClassName(elFrame, this.classItem);
        this.slideArrayLength = this.slideArray.length;
        this.i = 0;
        this.j = 0;
        if(this.slideArrayLength == 1)
            return;
        var d = null;    
        for (i = 0; i< this.slideArrayLength;i++) {
            d=Element.getDimensions(this.slideArray[i]);
            if(d.height > this.slideHeight)
              this.slideHeight = d.height;
              
            this.slideArray[i].id = this.idFrame + "-" + i;
            var aNavi = dkis.getElementsWithClassName(this.slideArray[i], this.classNavi);
            if (!aNavi) return;
            var elNavi = aNavi[0];
            for (j = 0; j < this.slideArrayLength; j++) {
                var img = document.createElement("img");
                if(i == j){
                    img.src = this.imgSelected;
                }
                else {
                    img.src = this.imgNotSelected;
                }
                img.alt = (j+1);
                img.title = this.imgTitle + (j+1);
                img.showIndex = j;
                img.hideIndex = i;
                var func = function(e) {
                    var targ;
	                if (!e) var e = window.event;
	                if (e.target) targ = e.target;
	                else if (e.srcElement) targ = e.srcElement;
	                if (targ.nodeType == 3) // defeat Safari bug
		                targ = targ.parentNode;	
                    _Self.slide(true, targ.showIndex ,targ.hideIndex);
                }
                dkis.addEvent(img, "click", func ,false);
                elNavi.appendChild(img);
            }
            if (this.position == i) {
                dkis.addClass(this.slideArray[i], this.classShow);
            } 
            else {
                dkis.addClass(this.slideArray[i], this.classHide);
            }
            
        }
        
        elFrame.style.height = this.slideHeight+'px';
        var autoslide = function () {
            _Self.slide(false, _Self.nextIndex,_Self.position);  
        }
        this.timeOut = setTimeout(autoslide, this.time); 
};


dkis.Slideshow.isSupported = (document.getElementById && document.getElementsByTagName && document.createElement && document.appendChild);	    

dkis.fadeSlide = function(elFrom, elTo, value, classShow, classHide){
	elTo.style.opacity = value/10;
	elTo.style.filter = 'alpha(opacity=' + value*10 + ')';
	elFrom.style.opacity = (9-value)/10;
	elFrom.style.filter = 'alpha(opacity=' + (9-value)*10 + ')';
	if(value==9)
	{
	    dkis.removeClass(elFrom, classShow);
        dkis.addClass(elFrom, classHide);
	}
	if(value==0)
	{
	    dkis.removeClass(elTo, classHide);
        dkis.addClass(elTo, classShow);
	}
}
   
dkis.Slideshow.prototype.slide = function(clicked, showIndex, hideIndex) {
    clearTimeout(this.timeOut);
    
    var _Self = this;
    var iShow = parseInt(showIndex);
    var iHide = parseInt(hideIndex);
    
    var idFadeto = this.slideArray[iShow].id;
    var idFadefrom = this.slideArray[iHide].id;
    for (var i=0;i<10;i++){	
    
        setTimeout('dkis.fadeSlide(document.getElementById("'+idFadefrom+'"),document.getElementById("'+idFadeto+'"),'+i+',"'+this.classShow + '","'+ this.classHide+'")',100*i);
    }
        
    this.position = iShow;
    this.nextIndex = this.position+1;
    if(this.nextIndex >= this.slideArray.length)
        this.nextIndex = 0;
    
    var autoslide = function () {
        _Self.slide(false, _Self.nextIndex ,_Self.position);  
    }
     var t = this.time;
    if(clicked)
    {   
        t = t+t;
    }
    this.timeOut = setTimeout(autoslide, t);
};
	    
dkis.activateStylesheet = function(sheetref) {
    var ss;
	if(document.getElementsByTagName) {
		ss=document.getElementsByTagName('link');
	} else if (document.styleSheets) {
		ss = document.styleSheets;
	}
	for(var i=0;ss[i];i++ ) {
		if(ss[i].href.indexOf(sheetref) != -1) {
			ss[i].disabled = true;
			ss[i].disabled = false;			
		}
	}
};
	    
	    
dkis.addEvent = function (oEl, sEvent, sFunction, useCapture) {	
	if (oEl) {
		if (oEl.addEventListener) { // MOZ
			oEl.addEventListener(sEvent,sFunction,useCapture);
			return true;
		} else if (oEl.attachEvent) { // IE5
			var r = oEl.attachEvent("on"+sEvent,sFunction);
			return r;
		}
	}
}	    
dkis.getElementsWithClassName = function (el,className) {
	var nodeList;
	var searchObj = new Array();
	nodeList = el.all || el.getElementsByTagName("*");
		for (var i = 0, c = null, cn; (document.all ? c = nodeList(i) : c = nodeList.item(i)); i++) {
		if (c.nodeType == 1) {
				cn = c.className.split(" ");
				for (j = 0; j < cn.length; j++) {
					if (cn[j]==className) {
						searchObj[searchObj.length] = c;
					}
				}
		}
		}
  return searchObj;
}
dkis.hasClass = function (el, className) {
	var cs, j
	cs = el.className.split(" ");
	for (j = 0; j < cs.length; j++) {
		if (cs[j] == className) {
			return true;
		}
	}
	return false;
} 
dkis.addClass = function (el, className) {
	if (el.className==null) 
		el.className='';
	el.className+=(el.className.length>0?' ':'')+className;
}
dkis.removeClass = function (el, className) {
  var cs, j, remainClass
  remainClass = new Array();
  cs = el.className.split(" ");
  for (j = 0; j < cs.length; j++) {
    if (cs[j] != className) {
      remainClass.push(cs[j]);
	 }
  }
  el.className = remainClass.join(" ");
}
// Array.push() - Add an element to the end of an array - Only IE5.0
if (typeof(Array.prototype.push) == 'undefined') {
  Array.prototype.push = function() {
  	var currentLength = this.length;
  	for (var i = 0; i < arguments.length; i++) {
  		this[currentLength + i] = arguments[i];
  	}
  	return this.length;
  };
}
	    
dkis.Slideshowinit = function(){
    if (!dkis.Slideshow.isSupported) return;

    var aClassFrame = dkis.getElementsWithClassName(document, "slideshowFrame");



    for (var i=0;i < aClassFrame.length;i++) {
        aClassFrame[i].id = "slideshow"+i;
        var mySlideshow = new dkis.Slideshow(aClassFrame[i].id, "slideshowItem");
    }
}
if (dkis.Slideshow.isSupported) dkis.activateStylesheet('javascript.css');
dkis.addEvent(window, "load", dkis.Slideshowinit, false);	    
	    
	    