<!--

function SymError()
{
  return true;
}

window.onerror = SymError;

//-->

function emailscramble(){
	
	var a,b,c,d,e,f,g,h,i;
	a='<a href=\"mai';
	b='pkarlstroem';
	c='\" class=\"bottom\">';
	a+='lto:';
	b+='@';
	e='</a>';
	b+='gmail.com';
	f='Contact';
	document.write(a+b+c+f+e);

}



function fadeElement(seconds,element_id,start,end){
	
	if(start > end) document.getElementById(element_id).style.visibility='visible';
	else if (end == 0.01) setTimeout(document.getElementById(element_id).disabled=true,seconds*1000);
	new Effect.Opacity(element_id, { duration: (seconds), transition: Effect.Transitions.linear,  from: start, to: end } );

}

function fadeTransition(page,direction){
	
	currentImage = findCurrentImage();
	
	if((direction == 1 && currentImage < imageCount) || (direction == -1 && currentImage > 1)){
		
		Effect.Fade("content", {duration:0.5})
		
		if(direction == -1) currentImage--;
		else if(direction == 1) currentImage++;
	
		window.location.hash = "#image:"+currentImage;
	
		setTimeout('setImageSource("'+page+'")', 500);
		//alert('http://www.cityant.net/images/'+page+'_'+urlImage+'.jpg');
		setTimeout('Effect.Appear("content")', 500);
		
		if(slideShow == 1) setTimeout('nextSlideshowImage("'+page+'","'+direction+'")', slideShowSpeed); // imagecount gjøres i system-filen fra arrayen over load images

	}
	else if(slideShow == 1) toggleSlideShow();
	
}

function nextSlideshowImage(page,direction){
	
	if(slideShow == 1) fadeTransition(page,direction);
	
}

function nextImage(page){
	
	slideShow = 0;
	fadeTransition(page,1);
	
}

function previousImage(page){
	
	slideShow = 0;
	fadeTransition(page,-1);
	
}

function setImageSource(page){
	
	currentImage = findCurrentImage();
	changeImageSrc("contentImage", "http://www.cityant.net/images/"+page+"_"+currentImage+".jpg");
	
	//control fixes
	if(currentImage == imageCount){
		changeImageSrc("next", "http://www.cityant.net/images/controls/test/next_off.png");
		changeImageSrc("next", "http://www.cityant.net/images/controls/test/next_off.png");
		changeImageSrc("playpause", "http://www.cityant.net/images/controls/test/play_off.png");
	}
	else{
		changeImageSrc("next", "http://www.cityant.net/images/controls/test/next.png");
		if(slideShow != 1) changeImageSrc("playpause", "http://www.cityant.net/images/controls/test/play.png");
	}
	if(currentImage == 1){
		changeImageSrc("previous", "http://www.cityant.net/images/controls/test/previous_off.png");
	}
	else{
		changeImageSrc("previous", "http://www.cityant.net/images/controls/test/previous.png");
	}


}

function toggleSlideShow(page){
	
		if(currentImage != imageCount){
			if(slideShow == 0){
				changeImageSrc("playpause", "http://www.cityant.net/images/controls/test/pause.png");
				slideShow = 1;
				fadeTransition(page,1);
			}
			else{
				changeImageSrc("playpause", "http://www.cityant.net/images/controls/test/play.png");
				slideShow = 0;
			}
		}
		else slideShow = 0;

}

function revealControls(){
	
	//if(controls == 0){
		Element.show('controls');
		new Effect.Opacity('controls', {duration:0.0, from:0.0, to:0.0});
		setTimeout("document.getElementById('controls').style.visibility='visible';",100);
		setTimeout("new Effect.Opacity('controls', {duration:1, from:0.0, to:0.6});",200);
		controls=1;
	//}
	
}

function activateControls(){
	
	controlsActive=1;
	setTimeout('fadeInControls()',100);
	
}

function deactivateControls(){
	
	controlsActive=0;
	setTimeout('fadeOutControls()',100);
	
}

function fadeOutControls(){
	
	if(controlsActive == 0 && controls == 1){
		new Effect.Opacity('controls', {duration:0.4, from:0.6, to:0.0});
		controls=0;
	}
	else if(controls == 1){
		//setTimeout('fadeOutControls()',1000);
	}

}

function fadeInControls(){
	
	if(controls == 0){
		new Effect.Opacity('controls', {duration:0.2, from:0.0, to:0.6});
		controls=1;
	}
	
}



function findCurrentImage(){
	
	currentUrl = window.location+":bug";
	if(currentUrl.indexOf("#") > 0){
		var urlSplit = currentUrl.split(":");
		urlImage = urlSplit[2];
		currentImage = urlImage;
	}
	else currentImage = 1; // case: første bilde
	
	return currentImage;

}

function changeImageSrc(imgName, imgSrc){
   document[imgName].src = imgSrc;
}

function blindTransition(url){
	
	Effect.BlindUp("centeredFrame", {duration:1})
	Effect.BlindUp("centeredContent", {duration:1})
	Effect.BlindUp("activeAboveContent", {duration:1})
	Effect.BlindUp("controlsHolder", {duration:1})
	//Effect.Fade("bottom", {duration:1})
	setTimeout('window.location = "http://www.cityant.net/' + url + '"', 1200);
	setTimeout('Effect.Appear("centeredFrame")', 1500);
	setTimeout('Effect.Appear("centeredContent")', 1500);
	setTimeout('Effect.Appear("activeAboveContent")', 1500);
	setTimeout('Effect.Appear("controlsHolder")', 1500);

	//fix for back/forward in browse
	//setTimeout('Effect.Appear("centeredFrame", {duration:2})', 1200);
	//setTimeout('Effect.Appear("centeredContent", {duration:2})', 1200);
	
}


function contentAppear(){

	setTimeout("fadeElement(1,'layerName',1.0,0.01);", 1000);

}


