//------PicView---------------------------
picView = function(name,pics,descs,start){
	this.width=100;
	this.height=50;
	this.name=name;
	this.pics=pics;
	this.picArray=pics.split("</pic><pic>");
	for(i in this.picArray) {
		this.picArray[i]=this.picArray[i].replace("<pic>","");
		this.picArray[i]=this.picArray[i].replace("</pic>","");
	}
	this.descArray=descs.split("</desc><desc>");
	for(i in this.descArray) {
		this.descArray[i]=this.descArray[i].replace("<desc>","");
		this.descArray[i]=this.descArray[i].replace("</desc>","");
	}
	this.alpha;
	this.aktPicNr=start;
	this.aktPic=new Image();
	this.aktDesc='';
	var self=this;
	if (document.addEventListener) { this.aktPic.addEventListener("load", function(e) { self.aktPic.height=e.target.naturalHeight*1.5; self.aktPic.width=e.target.naturalWidth*1.5; self.resizeDiv(); }, true); }
//	else { this.aktPic.onload = function(event) { alert(event.srcElement);self.aktPic.height=event.srcElement.height; self.aktPic.width=event.srcElement.width;  }; }
	else { this.aktPic.onload = function(event) { self.aktPic.height=self.aktPic.height*1.5; self.aktPic.width=self.aktPic.width*1.5; self.resizeDiv(); }; }

	this.hide=function(){
		if (document.getElementById(this.name+'_picView')) { document.getElementsByTagName('body')[0].removeChild(document.getElementById(this.name+'_picView')); }
		if (document.getElementById(this.name+'_picViewBG')) { document.getElementsByTagName('body')[0].removeChild(document.getElementById(this.name+'_picViewBG')); }
		var objects = document.getElementsByTagName('object');
		for(var i in objects) if (objects[i].style) objects[i].style.display='';
		picViewItem[this.name]=null;
	}

	this.show=function(){
		var objects = document.getElementsByTagName('object');
		for(var i in objects) if (objects[i].style) objects[i].style.display='none';
		bgDiv=document.createElement("div");
		bgDiv.id=this.name+'_picViewBG';
		bgDiv.name=this.name+'_picViewBG';
		bgDiv.style.zIndex='104';
		bgDiv.style.position='absolute';
		bgDiv.style.background='#000000';
		bgDiv.style.display='block';
		bgDiv.style.filter = "alpha(opacity:80)"; // IE/Win
		bgDiv.style.KHTMLOpacity = 0.8; // Safari<1.2, Konqueror
		bgDiv.style.MozOpacity = 0.8; // Older Mozilla and Firefox
		bgDiv.style.opacity = 0.8; // Safari 1.2, newer Firefox and Mozilla, CSS3
		bgDiv.style.width=document.documentElement.clientWidth+'px';
		bgDiv.style.height=document.documentElement.clientHeight+'px';
		bgDiv.style.top=document.documentElement.scrollTop+'px';
		bgDiv.style.left='0px';
		document.getElementsByTagName('body')[0].appendChild(bgDiv);
		self=this;
		if (document.addEventListener) { document.getElementById(this.name+'_picViewBG').addEventListener("click", function(e) { self.hide(); }, true); }
		else { document.getElementById(this.name+'_picViewBG').onclick = function(e) { self.hide(); }; }

		if (document.addEventListener) { window.addEventListener("scroll", function(e) { self.hide(); }, true); }
		else { window.onscroll = function(e) { self.hide(); }; }

		newDiv=document.createElement("div");
		newDiv.id=this.name+'_picView';
		newDiv.name=this.name+'_picView';
		newDiv.style.zIndex='105';
		newDiv.style.position='absolute';
		newDiv.style.background='#ffffff';
		newDiv.style.border='1px solid #000000';
		newDiv.style.display='none';
		newDiv.style.textAlign='center';
		document.getElementsByTagName('body')[0].appendChild(newDiv);
		this.loadPic();
	}

	this.loadPic=function(){
		document.getElementById(this.name+'_picView').innerHTML='<img src="script/loading.gif" />';
		document.getElementById(this.name+'_picView').style.top=(document.documentElement.clientHeight-50)/2+document.documentElement.scrollTop+'px';
		document.getElementById(this.name+'_picView').style.left=( (document.documentElement.clientWidth-100)/2 )+'0px';
		document.getElementById(this.name+'_picView').style.height='65px';
		document.getElementById(this.name+'_picView').style.width='100px';
		document.getElementById(this.name+'_picView').style.display='block';
		this.aktDesc=this.descArray[this.aktPicNr];
		this.aktPic.src=this.picArray[this.aktPicNr];
	}

	this.resizeDiv=function(){
		if(document.getElementById(this.name+'_picView').innerHTML!='') document.getElementById(this.name+'_picView').innerHTML='';
		if(this.aktPic.height!=(document.documentElement.clientHeight-100)) {
			var targetHeight=Math.min(document.documentElement.clientHeight-100,(this.aktPic.height));
			var targetWidth=(targetHeight/this.aktPic.height)*this.aktPic.width;
			this.aktPic.height=targetHeight;
			this.aktPic.width=targetWidth;
		}
		if(this.width<this.aktPic.width+20) this.width=Math.min(this.width+10,this.aktPic.width+20);
		if(this.height<this.aktPic.height+70) this.height=Math.min(this.height+10,this.aktPic.height+70);
		if(this.width>this.aktPic.width+20) this.width=Math.max(this.width-10,this.aktPic.width+20);
		if(this.height>this.aktPic.height+70) this.height=Math.max(this.height-10,this.aktPic.height+70);
		document.getElementById(this.name+'_picView').style.top=(document.documentElement.clientHeight-this.height)/2+document.documentElement.scrollTop+'px';
		document.getElementById(this.name+'_picView').style.left=( (document.documentElement.clientWidth-this.width)/2 )+'px';
		document.getElementById(this.name+'_picView').style.height=(this.height)+'px';
		document.getElementById(this.name+'_picView').style.width=this.width+'px';
		self=this;
		if(this.width!=this.aktPic.width+20 || this.height!=this.aktPic.height+70)
			setTimeout("picViewItem['"+this.name+"'].resizeDiv();",10);
		else if(this.picArray.length>1){
			if(this.aktDesc!='') var hint=' <div style="KHTMLOpacity:0.7;MozOpacity:0.7;opacity:0.7;filter:alpha(opacity:70);background:#000000; color:#ffffff;font-weight:bold;padding:10px;position:absolute; top:20px; left:20px;">'+this.aktDesc+'</div> ';
			else var hint='';
			document.getElementById(this.name+'_picView').innerHTML='<div><div><img id="'+this.name+'_picViewI" style="KHTMLOpacity:0;MozOpacity:0;opacity:0;filter:alpha(opacity:0);margin:10px;height:'+this.aktPic.height+'px;width:'+this.aktPic.width+'px" src="'+this.aktPic.src+'" />'+hint+'</div>'+
				' <div style="background:#eeeeee; border:1px solid #aaaaaa; font-size:22px;cursor:pointer; font-weight:bold; float:left; margin:0px 0px 0px 20px; padding:0px 10px 5px 10px;" onClick="picViewItem[\''+this.name+'\'].prevPic();">«</div>'+
				' <div style="background:#eeeeee;border:1px solid #aaaaaa; font-size:22px;cursor:pointer; font-weight:bold; float:right; margin:0px 20px 0px 0px; padding:0px 10px 5px 10px;" onClick="picViewItem[\''+this.name+'\'].nextPic();">»</div>'+
				' <div style="padding:10px 0px 0px 0px; cursor:pointer; font-weight:bold;" onClick="picViewItem[\''+this.name+'\'].hide();">schließen</div></div>';
			this.alpha=0;
			this.fadeIn();
		}else{
			if(this.aktDesc!='') var hint=' onMouseOver="addCpHint(event,\'hint_'+this.name+'\',\'<div style=&quot;background:#ffffff;padding:10px;&quot;>'+this.aktDesc+'</div>\');" onMouseOut="removeCpHint(event,\'hint_'+this.name+'\');" onMouseMove="moveCpHint(event,\'hint_'+this.name+'\');" ';
			else var hint='';
			document.getElementById(this.name+'_picView').innerHTML='<div><img id="'+this.name+'_picViewI" '+hint+' style="KHTMLOpacity:0;MozOpacity:0;opacity:0;filter:alpha(opacity:0);margin:10px;height:'+this.aktPic.height+'px;width:'+this.aktPic.width+'px" src="'+this.aktPic.src+'" />'+
				' <div style="padding:10px 0px 0px 0px; cursor:pointer; font-weight:bold;" onClick="picViewItem[\''+this.name+'\'].hide();">schließen</div></div>';
			this.alpha=0;
			this.fadeIn();
		}
	}

	this.fadeIn=function(){
		this.alpha=this.alpha+10;
		var tmpdiv=document.getElementById(this.name+'_picViewI');
		if(this.alpha==100) tmpdiv.style.filter = "";
		else tmpdiv.style.filter = "alpha(opacity:"+this.alpha+")";
		tmpdiv.style.KHTMLOpacity = tmpdiv.style.MozOpacity = tmpdiv.style.opacity = this.alpha/100;
		if(this.alpha<100) setTimeout("picViewItem['"+this.name+"'].fadeIn();",10);
	}

	this.nextPic=function(){
		document.getElementById(this.name+'_picView').innerHTML='<img src="script/loading.gif" style="margin-top:'+(this.aktPic.height/2)+'px;"/>';
		this.aktPicNr++;
		if(this.aktPicNr>(this.picArray.length-1)) this.aktPicNr=0;
		this.aktDesc=this.descArray[this.aktPicNr];
		this.aktPic.src=this.picArray[this.aktPicNr];
	}

	this.prevPic=function(){
		document.getElementById(this.name+'_picView').innerHTML='<img src="script/loading.gif" style="margin-top:'+(this.aktPic.height/2)+'px;" />';
		this.aktPicNr--;
		if(this.aktPicNr<0) this.aktPicNr=this.picArray.length-1;
		this.aktDesc=this.descArray[this.aktPicNr];
		this.aktPic.src=this.picArray[this.aktPicNr];
	}
}


var picViewItem=Array();

function addPicView(id,pics,descs,start){
	if(picViewItem[id]==null) {
		picViewItem[id]=new picView(id,pics,descs,start);
		picViewItem[id].show();
	}
}
