/**********************************************************| Austausch Headerbild nav1 |***/

function change(tausch_nav_nr,position)
{
document.getElementById(tausch_nav_nr).style.background = "url(images/"+tausch_nav_nr+".jpg)";
document.getElementById(tausch_nav_nr).style.backgroundPosition  = position;
document.getElementById(tausch_nav_nr).style.backgroundRepeat = "no-repeat";
}




/**********************************************************| Verschlüsselte eMail Adresse |***/

    function CryptMailto()
    {
        var n = 0;
        var r = "";
        var s = "mailto:"+document.forms[0].emailField.value;
        var e = document.forms[0].emailField.value;

        e = e.replace( /@/, " [at] ");
        e = e.replace( /\./g, " [dot] ");

        for( var i=0; i < s.length; i++ )
        {
            n = s.charCodeAt( i );
            if( n >= 8364 )
            {
                n = 128;
            }
            r += String.fromCharCode(n+1);
        }
        document.forms[0].cyptedEmailField.value = r;
        document.forms[0].HTMLCyptedEmailField.value = "javascript:Security_gfbCode('"+ r +"');";
    }

    function gfbCode( s )
    {
        var n = 0;
        var r = "";
        for( var i = 0; i < s.length; i++)
        {
            n = s.charCodeAt( i );
            if( n >= 8364 )
            {
                n = 128;
            }
            r += String.fromCharCode( n - 1 );
        }
        return r;
    }

    function Security_gfbCode( s )
    {
        location.href=gfbCode( s );
    }    




/**********************************************************| Team Gallery |***/
// -------------------------------------------------------------------
// Photo Album Script v2.0- By Dynamic Drive, available at: http://www.dynamicdrive.com
// Mar 11th, 07': Script updated to v2.0
// -------------------------------------------------------------------

function photogallery(garray, cols, rows, twidth, theight, paginatetext){
	gcount=(typeof gcount=="undefined")? 1 : gcount+1 //global var to keep count of current instance of photo gallery
	this.gcount=gcount
	this.galleryarray=garray
	this.cols=cols
	this.rows=rows
	var twidth=twidth || "100px" //default table width is 700px
	var theight=theight || "500px"
	var ptext=(typeof paginatetext=="object")? paginatetext : ["", ""] //Store 2 compontents of paginate DIV text inside array
	this.pagecount=Math.ceil(this.galleryarray.length/(cols*rows)) //calculate number of "pages" needed to show the images
	document.write('<table class="photogallery" id="photogallery-'+gcount+'">') //Generate table for Photo Gallery
	for (var r=0; r<rows; r++){
		document.write('<tr>')
		for (var c=0; c<cols; c++)
			document.write('<td valign="top"></td>')
		document.write('</tr>')
	}
	document.write('</table>')
	document.write('<div class="photonavlinks" id="photogallerypaginate-'+gcount+'"></div>') //Generate Paginate Div

	var gdiv=document.getElementById("photogallery-"+this.gcount)
	var pdiv=document.getElementById("photogallerypaginate-"+this.gcount)
	gdiv.onselectphoto=function(imgobj, linkobj){return true} //custom event handler "onselectphoto", invoked when user clicks on an image within gallery
	this.showpage(gdiv, 0)
	this.createNav(gdiv, pdiv, ptext)
	gdiv.onclick=function(e){return photogallery.defaultselectaction(e, this)} //attach default custom event handler action to "onclick" event
	return gdiv
}


photogallery.prototype.createImage=function(imgparts){
	var imageHTML='<img src="'+imgparts[0]+'" title="'+imgparts[1]+'"/>'
	if (typeof imgparts[2]!="undefined" && imgparts[2]!=""){ //Create URL?
		var linktarget=imgparts[3] || ""
		imageHTML='<a href="'+imgparts[2]+'" target="'+linktarget+'">'+imageHTML+'</a>'
	}
	if (typeof imgparts[1]!="undefined" && imgparts[1]!="") //Display description?
		imageHTML+='<br />'+imgparts[1]
	return imageHTML
}


photogallery.prototype.showpage=function(gdiv, pagenumber){
	var totalitems=this.galleryarray.length //total number of images
	var showstartindex=pagenumber*(this.rows*this.cols) //array index of div to start showing per pagenumber setting
	var showendindex=showstartindex+(this.rows*this.cols) //array index of div to stop showing after per pagenumber setting
	var tablecells=gdiv.getElementsByTagName("td")
	for (var i=showstartindex, currentcell=0; i<showendindex && i<totalitems; i++, currentcell++) //Loop thru this page's images and populate cells with them
		tablecells[currentcell].innerHTML=this.createImage(this.galleryarray[i])
	while (currentcell<tablecells.length){ //For unused cells, if any, clear out its contents
		tablecells[currentcell].innerHTML=""
		currentcell++
	}
}

photogallery.prototype.createNav=function(gdiv, pdiv , ptext){
	var instanceOfGallery=this
	var navHTML=""
	for (var i=0; i<this.pagecount; i++)
		navHTML+='<a href="#navigate" rel="'+i+'">'+ptext[1]+(i+1)+'</a> ' //build sequential nav links
	pdiv.innerHTML=ptext[0]+' '+navHTML
	var navlinks=pdiv.getElementsByTagName("a")
	navlinks[0].className="current" //Select first link by default
	this.previouspage=navlinks[0] //Set previous clicked on link to current link for future ref
	for (var i=0; i<navlinks.length; i++){
		navlinks[i].onclick=function(){
			instanceOfGallery.previouspage.className="" //"Unhighlight" last link clicked on...
			this.className="current" //while "highlighting" currently clicked on flatview link (setting its class name to "selected"
			instanceOfGallery.showpage(gdiv, this.getAttribute("rel"))
			instanceOfGallery.previouspage=this //Set previous clicked on link to current link for future ref
			return false
		}
	}
}

photogallery.defaultselectaction=function(e, gdiv){ //function that runs user defined "onselectphoto()" event handler
	var evtobj=e || window.event
	var clickedobj=evtobj.target || evtobj.srcElement
	if (clickedobj.tagName=="IMG"){
		var linkobj=(clickedobj.parentNode.tagName=="A")? clickedobj.parentNode : null
		return gdiv.onselectphoto(clickedobj, linkobj)
	}
}


























//** Tab Content script- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)

var enabletabpersistence=1 //enable tab persistence via session only cookies, so selected tab is remembered?

////NO NEED TO EDIT BELOW////////////////////////
var tabcontentIDs=new Object()

function expandcontent(linkobj){
var ulid=linkobj.parentNode.parentNode.id //id of UL element
var ullist=document.getElementById(ulid).getElementsByTagName("li") //get list of LIs corresponding to the tab contents
for (var i=0; i<ullist.length; i++){
ullist[i].className=""  //deselect all tabs
if (typeof tabcontentIDs[ulid][i]!="undefined") //if tab content within this array index exists (exception: More tabs than there are tab contents)
document.getElementById(tabcontentIDs[ulid][i]).style.display="none" //hide all tab contents
}
linkobj.parentNode.className="selected"  //highlight currently clicked on tab
document.getElementById(linkobj.getAttribute("rel")).style.display="block" //expand corresponding tab content
saveselectedtabcontentid(ulid, linkobj.getAttribute("rel"))
}

function expandtab(tabcontentid, tabnumber){ //interface for selecting a tab (plus expand corresponding content)
var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber]
if (thetab.getAttribute("rel"))
expandcontent(thetab)
}

function savetabcontentids(ulid, relattribute){// save ids of tab content divs
if (typeof tabcontentIDs[ulid]=="undefined") //if this array doesn't exist yet
tabcontentIDs[ulid]=new Array()
tabcontentIDs[ulid][tabcontentIDs[ulid].length]=relattribute
}

function saveselectedtabcontentid(ulid, selectedtabid){ //set id of clicked on tab as selected tab id & enter into cookie
if (enabletabpersistence==1) //if persistence feature turned on
setCookie(ulid, selectedtabid)
}

function getullistlinkbyId(ulid, tabcontentid){ //returns a tab link based on the ID of the associated tab content
var ullist=document.getElementById(ulid).getElementsByTagName("li")
for (var i=0; i<ullist.length; i++){
if (ullist[i].getElementsByTagName("a")[0].getAttribute("rel")==tabcontentid){
return ullist[i].getElementsByTagName("a")[0]
break
}
}
}

function initializetabcontent(){
for (var i=0; i<arguments.length; i++){ //loop through passed UL ids
if (enabletabpersistence==0 && getCookie(arguments[i])!="") //clean up cookie if persist=off
setCookie(arguments[i], "")
var clickedontab=getCookie(arguments[i]) //retrieve ID of last clicked on tab from cookie, if any
var ulobj=document.getElementById(arguments[i])
var ulist=ulobj.getElementsByTagName("li") //array containing the LI elements within UL
for (var x=0; x<ulist.length; x++){ //loop through each LI element
var ulistlink=ulist[x].getElementsByTagName("a")[0]
if (ulistlink.getAttribute("rel")){
savetabcontentids(arguments[i], ulistlink.getAttribute("rel")) //save id of each tab content as loop runs
ulistlink.onclick=function(){
expandcontent(this)
return false
}
if (ulist[x].className=="selected" && clickedontab=="") //if a tab is set to be selected by default
expandcontent(ulistlink) //auto load currenly selected tab content
}
} //end inner for loop
if (clickedontab!=""){ //if a tab has been previously clicked on per the cookie value
var culistlink=getullistlinkbyId(arguments[i], clickedontab)
if (typeof culistlink!="undefined") //if match found between tabcontent id and rel attribute value
expandcontent(culistlink) //auto load currenly selected tab content
else //else if no match found between tabcontent id and rel attribute value (cookie mis-association)
expandcontent(ulist[0].getElementsByTagName("a")[0]) //just auto load first tab instead
}
} //end outer for loop
}


function getCookie(Name){ 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}

function setCookie(name, value){
document.cookie = name+"="+value //cookie value is domain wide (path=/)
}
