
var slideShowImage = 0;
var slideShowImagesUrl = new Array("/wp-content/themes/default/images/carmen.jpg","/wp-content/themes/default/images/cerberus.jpg","/wp-content/themes/default/images/zoria.jpg","/wp-content/themes/default/images/hilp.jpg");
var slideShowText = new Array("<h3>Teori och Metod</h3><p>Projekt Tassavtryck hj&auml;lper till att g&ouml;ra tillvaron hanterbar, begriplig och meningsfull. <a href=\"http://projekt-tassavtryck.geodesis.se/teori-och-metod/\">L&auml;s Mer &raquo;</a></p>",
"<h3>Projekt Tassavtryck p&aring; Terapihundsl&auml;ger!</h3><p>Missa inte Projekt Tassavtrycks f&ouml;rel&auml;sning i Stockholm i april. <a href=\"http://www.projekt-tassavtryck.se/nyheter/terapihundlager-94-2011/\">L&auml;s Mer &raquo;</a></p>",
"<h3>F&ouml;rel&auml;sningar</h3><p>Missa inte v&aring;ra intressanta f&ouml;rel&auml;sningar. <a href=\"http://projekt-tassavtryck.geodesis.se/arbetsomraden/forelasningar/\">L&auml;s Mer &raquo;</a></p>",
"<h3>Projekt Tassavtryck p&aring; Kanal 5!</h3><p>Projekt Tassavtryck har medverkat vid inspelningarna av en ny serie om hundar. <a href=\"http://www.projekt-tassavtryck.se/nyheter/projekt-tassavtryck-i-kanal-5/\">L&auml;s Mer &raquo;</a></p>");
var slideShowImages = new Array();
var slideShowButtons = new Array("slideShowBtn0","slideShowBtn1","slideShowBtn2","slideShowBtn3");
var	init = 0;
var imageClicked = 0;

function ini(){

	for(var i in slideShowImagesUrl){
		slideShowImages[i] = new Image();
		slideShowImages[i].src = slideShowImagesUrl[i];
		if(i != 0){ 
			elem = document.getElementById(slideShowButtons[i]);
			setOpacity(elem,'50');
		}
	}	
	autoReload(0);
}


function isIE(){
	return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}
function autoReload(start){
	if(start && !imageClicked){
		slideShow('move',+1);
	}
    window.setTimeout("autoReload(1)", 4500);
}
function slideClick(action,move){
	imageClicked = 1;
	slideShow(action,move);
}
function slideShow(action,move){
	init = 0;
	if(action == "move"){
		slideShowImage += move;
		if(slideShowImage < 0){
			slideShowImage = slideShowImages.length-1;
		}
		if(slideShowImage > slideShowImages.length-1){
			slideShowImage = 0;
		}
		fadeOut('slideShowImage',100);
	} else if (action == "direct" && slideShowImage != move)
	{
		slideShowImage = move;	
		fadeOut('slideShowImage',100);	
	}
	
}



function fadeIn(target,opacity) {
    elem = document.getElementById(target);
    if (opacity <= 100) {
      setOpacity(elem, opacity);
	  opacity += 10;
      window.setTimeout("fadeIn('"+target+"',"+opacity+")", 20);     

    }
	
}

function fadeOut(target,opacity) {
    elem = document.getElementById(target);
    if (opacity >= 0) {		
      setOpacity(elem, opacity);
	  opacity -= 10;
      window.setTimeout("fadeOut('"+target+"',"+opacity+")", 20);
    }

	if(opacity <= 0 && !init){
		init = 1;
		switchImage();
		fadeIn('slideShowImage',0);
	}

}

function switchImage(){
	document.getElementById('slideShowImage').src = slideShowImages[slideShowImage].src;
	document.getElementById('imageSlideShowText').innerHTML = slideShowText[slideShowImage];
	for(var i in slideShowButtons){
		if(slideShowImage != i){
			elem = document.getElementById(slideShowButtons[i]);
			setOpacity(elem,50);
		} else {
			elem = document.getElementById(slideShowButtons[i]);
			setOpacity(elem,100);
		}
	}

}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
    // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

