var d = document;

var agent=navigator.userAgent.toLowerCase();
var mac = (agent.indexOf("mac")>-1)
var ie5 = (agent.indexOf("msie 5")>-1);

if(ie5 && mac==true)
{
	d.write('<link rel="stylesheet" type="text/css" href="../css/screen_macie5.css" media="screen" />');
}

if(ie5 == false && mac == true){
	d.write('<link rel="stylesheet" type="text/css" href="../css/screen_mac.css" media="screen" />');
}


var d = document;
var agent=navigator.userAgent.toLowerCase();
var mac = (agent.indexOf("mac")>-1)
var opera = ( agent.indexOf("opera")>-1 );

var ie5 = (agent.indexOf("msie 5")>-1);
var ie55 = (agent.indexOf("msie 5.5")>-1);
var ie6 = 	(agent.indexOf("msie 6")>-1);

var ie = ( (ie6 || ie5 || ie55 )&& !opera);

var ns6 = (!ie &&  !opera && (agent.indexOf("6.1")>-1 || agent.indexOf("6")>-1));
var ns62 = (!ie && !opera && ((agent.indexOf("6.2")>-1) || (agent.indexOf("7.0")>-1)) );

function ImageToggler()
{

	this.images = new Array();
	this.loadEvents = new Array();
	this.controls = new Array();
	this.descriptions = new Array();
	for( var i=0; i< arguments.length-1; i++)
	{
		a = arguments[i].split('|');
		this.loadEvents[i] = false;
		this.images[i] = new Image();
		this.images[i].klug = i;
		this.images[i].src = "uploads/pics/" + a[0];
		this.images[i].onload = function() {SetLoadEvents( this.klug ) };
		this.controls[i] = d.getElementById( "t"+ i );
		this.controls[i].className = "togglerLoading";
		this.descriptions[i] = a[1];
	}
			
	this.index = 0;
	this.targetImage = d.images[arguments[arguments.length-1]];
	this.label = d.getElementById("toggler-text");
	this.controls[0].className = "togglerActive";
	if (ie55 || ie6 )
	{
		this.imgObj = this.targetImage.parentNode;
		this.imgObj.style.filter = "progid:DXImageTransform.Microsoft.Fade(Overlap=1.00)";
		//this.imgObj.style.filter = "FILTER: progid:DXImageTransform.Microsoft.Slide(slidestyle=SWAP,Bands=2)";
	}
			
}

function SetLoadEvents( i ){
	it.loadEvents[i] = true;
	if ( i == 0 )return;
	it.controls[i].className = "togglerInactive";
}


ImageToggler.prototype.GetNext = function()
{
	this.controls[ this.index ].className = "togglerInactive";
	this.index = ( this.index+1 == this.images.length ) ? 0 : this.index+1;
	this.doTrans( this.index )
	this.label.innerHTML = this.descriptions[ this.index ];
	this.controls[ this.index ].className = "togglerActive";
}

ImageToggler.prototype.GetPrevious = function()
{
	this.controls[ this.index ].className = "togglerInactive";
	this.index = ( this.index==0 ) ? this.images.length-1 : this.index-1;
	this.doTrans( this.index );
	this.label.innerHTML = this.descriptions[ this.index ];
	this.controls[ this.index ].className = "togglerActive";
}

ImageToggler.prototype.GetById = function( id )
{
	this.controls[ this.index ].className = "togglerInactive";
	this.doTrans( id );
	this.index = id;
	this.label.innerHTML = this.descriptions[ id ];
	this.controls[ this.index ].className = "togglerActive";
}


ImageToggler.prototype.doTrans = function( id )
{
	if( !this.loadEvents[id]  )
	{
		alert( "Bild noch nicht geladen.." )
	}
	if( ie55 || ie6 )
	{
		this.imgObj.filters[0].apply();
		this.targetImage.src = this.images[ id ].src;
		this.imgObj.filters[0].play();
	}
	else
	{
		this.targetImage.src = this.images[ id ].src;
	}
}

function makepopup (url) {
 fenster = window.open(url, "_blank", "width= 600,height= 650,status=yes,scrollbars=yes,resizable=yes");
 fenster.focus();
 return false;
}