// JavaScript Document
var gallerybild;
var galleryLeft ="";
var galleryRight = "";
galleryLeftInactive="../../static/imgs/galerie_links_passiv.gif";
galleryRightInactive="../../static/imgs/galerie_rechts_passiv.gif";
var thumbs;
var pg_timer;
var thumbswidth=527;
var gallerybildDims=new Array();

function setGalleryBild(){
gallerybild=document.getElementById('gallery_bild');
setGalleryBorders(gallerybild);
}

function setGalleryLeft(src){
galleryLeft= src;
}
function setGalleryRight(src){
galleryRight= src;
}

function countThumbsWidth(length){
thumbswidth-=length;
//thumbswidth=(thumbs.parentNode.scrollWidth-thumbs.parentNode.offsetWidth)*-1;
}

function pg_stopscroll(){
	thumbs= document.getElementById('thumbs');
	if(thumbs.offsetLeft==0)
		document.getElementById('gallery_left').src=galleryLeftInactive;
	else if((thumbs.offsetLeft)==thumbswidth)
		document.getElementById('gallery_right').src=galleryRightInactive;
	
	window.clearInterval(pg_timer);
}

function pg_scroll(direction){	

	thumbs=document.getElementById('thumbs');
	pg_stopscroll();
	
	pg_timer=window.setInterval('pg_scrollz('+direction+')',40);
	
	
}
function pg_scrollz(direction){
	//thumbs= document.getElementById('thumbs');
	
	var offy=thumbs.offsetLeft+direction;

	var stoppen=false;
	if(offy>0){ offy=0;stoppen=true;}
		else if( offy<(thumbswidth)){ offy=thumbswidth;stoppen=true;}
	thumbs.style.left=offy+'px';
	if(stoppen){
		pg_stopscroll();	
	}
	else{
		document.getElementById('gallery_left').src=galleryLeft;
		document.getElementById('gallery_right').src=galleryRight;	
	}
}

function hover(obj){
	switchStyleClass(obj,"hover");
}

function out(obj){
	switchStyleClass(obj,"");
}

function changeGalleryImage(srce){
	var tmpimg=new Image();
//	tmpimg.onload=loadTmpImg;
	AddRefHandler("onload",loadTmpImg,tmpimg,tmpimg);
	tmpimg.src=srce;
	tmpimg.id="gallery_bild";
	
}

function loadTmpImg(obj,ev){
	
//	AddRefHandler("onload",loadImg,obj,document.getElementById('gallery_bild'));
	var ImageKnoten= document.createElement("img");
	ImageKnoten.src=obj.src;
	ImageKnoten.id=obj.id;
	document.getElementById('gallery_bild_parent').innerHTML="";
document.getElementById('gallery_bild_parent').appendChild(ImageKnoten);
	
setGalleryBorders(obj);
}


function loadImg(obj,ev){
	setGalleryBorders(obj);
}

function setGalleryBorders(obj){
	if(obj.width>0){
		document.getElementById('divGalery').style.width=(obj.width+8)+'px';
		document.getElementById('galleryBorderTop').width=(obj.width);
		document.getElementById('galleryBorderBottom').width=(obj.width);
	}
	
}

//mail-obfuscator by sandro wolf
function mailOb_decode(z,k){

	return z+'@'+k;
}


function mailOb_encode(d,k){

}

function mailOb_getLink(el,al, label, clss, target){
	var s="<"+"a hr"+'ef="ma'+"ilto:"+(mailOb_decode(el,al))+'"';
	if(clss && clss!="") s+=' class="'+clss+'"';
	if(target && target!="") s+=' target="'+target+'"';
	s+=">";
	if(label && label!="") s+=label;else s+=mailOb_decode(el,al); 
	s+="</a>";
	return s;
}

