﻿/*
* ############################################################################################################################################################
* BEGIN GALLERY Project X10
* Description:	This functions enable the close events and handle different Buttons
* Action:		Handles any registrated Button Action on Window-ChangeEvent		
* ############################################################################################################################################################
*/
	/*global array contains all Gallery-Controls 
	*	[x][0] -> Ident e.g Gallery4711
	* 	[x][1] -> Controls
	*	[x][y][-1]-> Gallery Div Fullscreen (optional defined) - can contain null
	*	[x][y][0] -> Gallery Div
	*	[x][y][1] -> Gallery Description
	*	[x][y][2] -> Gallery Control Div Left
	*	[x][y][3] -> Gallery Control Img Left 
	*	[x][y][4] -> Gallery Control Div Right
	*	[x][y][5] -> Gallery Control Img Right
	*	[x][y][6] -> Gallery PictureNumbers (1/10)
	*	[x][y][7] -> Gallery Process
	*	[x][y][8] -> Gallery Process Current (depending on PictureNumbers)	
	*	[x][y][9] -> Gallery Image Object - Display Object of the Requested Image
	*	[x][y][10]-> Gallery Preloader Object
	*   [x][2] -> Gallery PictureCurrent
	*   [x][3] -> Gallery PictureTotal
	*   [x][4] -> Show Description
	* 	[x][5] -> Gallery Image Descriptions
	*	[x][y][0] -> Description  of Picture [0]<-CurPicture, Value Contains the Description
	* 	[x][6] -> Gallery Reference
	* 	[x][7] -> Gallery Image Dimensions
	* 	[x][y][1] -> Gallery Image MaxWidth
	* 	[x][y][2] -> Gallery Image MaxHeight
	*/
 	//var aGalleryObjects = new Array(); 
	var aGalleryObjects = null;
	
	//flag is to store the state of updates to disturb wrong control changing on fired change-events from normale div-controls when active control is hovered
	var fGalControlUpdCommon = true; //one is enough because the flag must be global handeled
	var sGalControlImgPathLeft_disabled = ProjectURL + '/grafiken/galleryX10/ui/links_disabled.png';
	var sGalControlImgPathLeft_enabled = ProjectURL + '/grafiken/galleryX10/ui/links.png';
	var sGalControlImgPathLeft_hover = ProjectURL + '/grafiken/galleryX10/ui/links_hover.png';
	
	var sGalControlImgPathRight_disabled = ProjectURL + '/grafiken/galleryX10/ui/rechts_disabled.png';
	var sGalControlImgPathRight_enabled = ProjectURL + '/grafiken/galleryX10/ui/rechts.png';
	var sGalControlImgPathRight_hover = ProjectURL + '/grafiken/galleryX10/ui/rechts_hover.png';
	
	var sGalImgLoader = ProjectURL + '/grafiken/galleryX10/ui/loader.gif';
	var fFirstInitOfCurrentGal = false; //check if the current gallery got an Init-Call -> neccessary on popup-mode for preview image
	/****************************************************************************************
	* Function 		GalleryRegisterControls 			
	* Description	Register all Controls and Elements for a new Gallery
	* Action		Handles any registrated Button Action on Window-ChangeEvent		
	*****************************************************************************************/
	function GalleryRegisterControls(sGalIdent, 
									 sGalObjDivFullScreen,
									 sGalObjDiv, 
									 sGalObjDescr, 
									 sGalObjControlLeft, 
									 sGalObjControlLeftImg, 
									 sGalObjControlRight, 
									 sGalObjControlRightImg, 
									 sGalObjPictureNumbers, 
									 sGalObjProcess, 
									 sGalObjProcessCurrent,
									 sGalObjImage,
									 sGalObjImageLoader,
									 iGalPictureTotal,
									 iGalShowDescription, 
									 aGalImageDescriptions,
									 iGalRef){
		//disturb doubled initialisazion
		if(GalleryGetCurrentConfig(sGalIdent) != null){
			return;
		}
		//init new array
		if(aGalleryObjects == null){
	 		aGalleryObjects = new Array();
		}
		aGalleryObjects[aGalleryObjects.length] = new Array();
		aGalleryObjects[aGalleryObjects.length-1][0] = sGalIdent;
		
		aGalleryObjects[aGalleryObjects.length-1][1] = new Array();
		aGalleryObjects[aGalleryObjects.length-1][1][-1]= (sGalObjDivFullScreen.replace(/^\s+|\s+$/g, '') != '')?document.getElementById(sGalObjDivFullScreen):null; //optional can be null
		aGalleryObjects[aGalleryObjects.length-1][1][0] = document.getElementById(sGalObjDiv);
		aGalleryObjects[aGalleryObjects.length-1][1][1] = document.getElementById(sGalObjDescr);
		aGalleryObjects[aGalleryObjects.length-1][1][2] = document.getElementById(sGalObjControlLeft);
		aGalleryObjects[aGalleryObjects.length-1][1][3] = document.getElementById(sGalObjControlLeftImg);
		aGalleryObjects[aGalleryObjects.length-1][1][4] = document.getElementById(sGalObjControlRight);
		aGalleryObjects[aGalleryObjects.length-1][1][5] = document.getElementById(sGalObjControlRightImg);
		aGalleryObjects[aGalleryObjects.length-1][1][6] = document.getElementById(sGalObjPictureNumbers);
		aGalleryObjects[aGalleryObjects.length-1][1][7] = document.getElementById(sGalObjProcess);
		aGalleryObjects[aGalleryObjects.length-1][1][8] = document.getElementById(sGalObjProcessCurrent);
		aGalleryObjects[aGalleryObjects.length-1][1][9] = document.getElementById(sGalObjImage);
		aGalleryObjects[aGalleryObjects.length-1][1][10]= document.getElementById(sGalObjImageLoader);
		
		
		aGalleryObjects[aGalleryObjects.length-1][2] = 1; //rep-picture is one 
		aGalleryObjects[aGalleryObjects.length-1][3] = iGalPictureTotal
		aGalleryObjects[aGalleryObjects.length-1][4] = iGalShowDescription;
		aGalleryObjects[aGalleryObjects.length-1][5] = aGalImageDescriptions;	
		aGalleryObjects[aGalleryObjects.length-1][6] = iGalRef;	
		aGalleryObjects[aGalleryObjects.length-1][7] = new Array(); 
		aGalleryObjects[aGalleryObjects.length-1][7][0] = 0;	
		aGalleryObjects[aGalleryObjects.length-1][7][1] = 0;//init will be done later	

		fGalleryFirstInit = false;
		GalleryInit(sGalIdent);
		fGalleryFirstInit = true;
	}
	
	/****************************************************************************************
	* Function 		GalleryInit
	* Description	Initialisze the Gallery to display RepPic onload
	* Action		Init the Gallery, Set PreviewPic, InitControls
	*****************************************************************************************/
	function GalleryInit(sGalIdent){
		var aGalleryObject = GalleryGetCurrentConfig(sGalIdent);
		if(aGalleryObject != null){			
			//set PictureNumbers - Display
			var oPictureNumbers = aGalleryObject[1][6];
			var iGalPicCurrent = aGalleryObject[2];
			var iGalPicTotal = aGalleryObject[3];
			
			//refresh
			oPictureNumbers.innerHTML = iGalPicCurrent + ' / ' + iGalPicTotal;
			oPictureNumbers.style.visibility = 'hidden';

			//display default image
			GalleryCalculateDimensions(sGalIdent); 
			GalleryDisplayImg(sGalIdent, iGalPicCurrent);
			GalleryControlUpdate(sGalIdent, 0, 0);
			
		}//check if Gallery Exists / found
	}
	

	
	/****************************************************************************************
	* Function 		GalleryCalculateDimensions 			
	* Description	Calculates the actual Image-Dimension depending on the Window-size of the Containers
	* Action		Writes the actual image-sizes to the GalleryObjects array
	*****************************************************************************************/
	function GalleryCalculateDimensions(sGalIdent){
		var aGalleryObject = GalleryGetCurrentConfig(sGalIdent);
		if(aGalleryObject != null){			
			//set PictureNumbers - Display
			//calculate maximal picture-sizes, on fullscreen mode change the dependencies of the maxwidht
			var oTmpDivContainterFullScreen = aGalleryObject[1][-1];
			var oTmpDivContainer = aGalleryObject[1][0];
			var oGalObjProcess = aGalleryObject[1][7];;
			var iOffsetWidth = 0, iOffsetHeight = 0;
			
			//calculate FullScreen Div if string is passed
			if(oTmpDivContainterFullScreen != null){
				iOffsetWidth = (oTmpDivContainterFullScreen!=null)?oTmpDivContainterFullScreen.offsetWidth:0;  //subtract progressbar on fullscreen mode
				iOffsetHeight = (oTmpDivContainterFullScreen!=null)?oTmpDivContainterFullScreen.offsetHeight-(oGalObjProcess!=null?oGalObjProcess.offsetHeight:0):0;
			}
			
			//calculate Embedded-Div
			if(!(iOffsetWidth > 0 && iOffsetWidth > 0)){
				iOffsetWidth = oTmpDivContainer.offsetWidth>0?oTmpDivContainer.offsetWidth:500;
				iOffsetHeight = oTmpDivContainer.offsetHeight>0?oTmpDivContainer.offsetHeight:276;
			}
			
			
			//search for ident in current configurations
			for($iIndex = 0; $iIndex < aGalleryObjects.length; $iIndex++){
				if(aGalleryObjects[iIndex][0] == sGalIdent){
					//update calculated values
					aGalleryObjects[iIndex][7][0] = iOffsetWidth;	
					aGalleryObjects[iIndex][7][1] = iOffsetHeight;			
					var sTmpStyleHeight = ((oTmpDivContainterFullScreen!=null)?iOffsetHeight:aGalleryObjects[iIndex][1][0].offsetHeight) + 'px';
					aGalleryObjects[iIndex][1][0].style.height = sTmpStyleHeight;	
					
					break;
				}			
			}			
		}//check if Gallery Exists / found
	}
	
	/****************************************************************************************
	* Function 		GalleryGetCurrentConfig 			
	* Description	Search for an actual element in the global array for interact with gallery
	* Action		Returns the current searched config as an array / default null
	*****************************************************************************************/
	function GalleryGetCurrentConfig(sGalIdent){
		var aGalleryObject = null;
		
		//search for ident in current configurations
		if(aGalleryObjects != null){
			for(iIndex = 0; iIndex < aGalleryObjects.length; iIndex++){
				if(aGalleryObjects[iIndex][0] == sGalIdent){
					aGalleryObject = aGalleryObjects[iIndex];
					break;
				}			
			}
		}
		
		return 	aGalleryObject;
	}
	
	/****************************************************************************************
	* Function 		GalleryControlUpdate	
	* Description	Update the GalleryControls for handle States on Central Point
	*				iOverOut -> 1 = mouseover (common - side null)
	*							2 = mouseout (common - side null)
	*							3 = mouseover (gallery control - side specified)
	*							4 = mouseout (gallery control - side specified)
	*				iSideLR	-> 0 = null 
	*						   1 = left (gallery control)
	*						   2 = right (gallery control)
	* Action		Handles the Redraw of the Left/Right arrow-Controls	
	*****************************************************************************************/
	function GalleryControlUpdate(sGalIdent, iOverOut, iSideLR){
		var aGalleryObject = GalleryGetCurrentConfig(sGalIdent);
		if(aGalleryObject != null){			
			//get Current Gal-State
			var iGalPicCurrent = aGalleryObject[2];
			var iGalPicTotal = aGalleryObject[3];
			
			//arrows left and right
			var oGalObjControlDivLeft   = aGalleryObject[1][2];
			var oGalObjControlImgLeft 	= aGalleryObject[1][3];
			var oGalObjControlDivRight  = aGalleryObject[1][4];
			var oGalObjControlImgRight 	= aGalleryObject[1][5];
			
			//Graphic and style to set - rember old config on wrong call
			var sGalDisplayImgArrowLeft =  oGalObjControlImgLeft.src;
			var sGalDisplayImgArrowRight =  oGalObjControlImgRight.src;
			var sGalDisplayCursorStyleLeft = oGalObjControlDivLeft.style.cursor; 
			var sGalDisplayCursorStyleRight = oGalObjControlDivRight.style.cursor;
		
		
			//switch action for left-right controls
			switch (iOverOut) {
				//every element
				case 1: //hier fehlt noch check wenn  4 noch nicht da ist aber 3 gesetzt
						//gallery picture count muss beachtet werden
						if(fGalControlUpdCommon){
							sGalDisplayImgArrowLeft = (iGalPicCurrent>1)?sGalControlImgPathLeft_enabled:sGalControlImgPathLeft_disabled;
							sGalDisplayImgArrowRight = (iGalPicCurrent<iGalPicTotal)?sGalControlImgPathRight_enabled:sGalControlImgPathRight_disabled;

							//set default pointer
							sGalDisplayCursorStyleLeft = "default"; 
							sGalDisplayCursorStyleRight = "default";
						}
						
						break;
			 
				case 2: if(fGalControlUpdCommon){
							sGalDisplayImgArrowLeft = sGalControlImgPathLeft_disabled
							sGalDisplayImgArrowRight = sGalControlImgPathRight_disabled
							
							//set default pointer
							sGalDisplayCursorStyleLeft = "default"; 
							sGalDisplayCursorStyleRight = "default";
						}
						
						break;
						
				//control elements
				case 3: if(iSideLR == 1){
							sGalDisplayImgArrowLeft = (iGalPicCurrent>1)?sGalControlImgPathLeft_hover:sGalControlImgPathLeft_disabled;
							sGalDisplayImgArrowRight = (iGalPicCurrent<iGalPicTotal)?sGalControlImgPathRight_enabled:sGalControlImgPathRight_disabled;
							
							//enable pointer when pic count matches
							sGalDisplayCursorStyleLeft = (iGalPicCurrent>1)?"pointer":"default";
							sGalDisplayCursorStyleRight = "default"; 
						}else if(iSideLR == 2){
							sGalDisplayImgArrowLeft = (iGalPicCurrent>1)?sGalControlImgPathLeft_enabled:sGalControlImgPathLeft_disabled;
							sGalDisplayImgArrowRight = (iGalPicCurrent<iGalPicTotal)?sGalControlImgPathRight_hover:sGalControlImgPathRight_disabled;
							
							//enable pointer when pic count matches
							sGalDisplayCursorStyleLeft = "default"; 
							sGalDisplayCursorStyleRight = (iGalPicCurrent<iGalPicTotal)?"pointer":"default";
						}
						fGalControlUpdCommon = false;
						break;			 
								 
				case 4: sGalDisplayImgArrowLeft = sGalControlImgPathLeft_disabled
						sGalDisplayImgArrowRight = sGalControlImgPathRight_disabled
						
						//set default pointer
						sGalDisplayCursorStyleLeft = "default"; 
						sGalDisplayCursorStyleRight = "default"; 
						fGalControlUpdCommon = true;
						break;
			}
			
			
			//set matching path to the arrows
			oGalObjControlImgLeft.src = sGalDisplayImgArrowLeft;
			oGalObjControlImgRight.src = sGalDisplayImgArrowRight;
			oGalObjControlDivLeft.style.cursor = sGalDisplayCursorStyleLeft;
			oGalObjControlDivRight.style.cursor = sGalDisplayCursorStyleRight;
			
		}//check if Gallery Exists / found
	}
	
	/****************************************************************************************
	* Function 		GalleryDivMouseOverOut			
	* Description	Control the MouseOver and MouseOut event of the complete Gallery
	*				iOverOut -> 1 = mouseover
	*						    2 = mouseout
	* Action		Display Image-Counter, 
	*				Switch ControlLeft/ControlRight Arrows inactive / normal
	*****************************************************************************************/
	function GalleryDivMouseOverOut(sGalIdent, iOverOut){
		var aGalleryObject = GalleryGetCurrentConfig(sGalIdent);
		if(aGalleryObject != null){			
			//set PictureNumbers - Display
			var oPictureNumbers = aGalleryObject[1][6];
			var iGalPicCurrent = aGalleryObject[2];
			var iGalPicTotal = aGalleryObject[3];
			
			//check for display 
			oPictureNumbers.style.visibility = iOverOut==1?'visible':'hidden';

			//check for control-update				  //no side is specified
			GalleryControlUpdate(sGalIdent, iOverOut, 0);
		}//check if Gallery Exists / found
	}

	
	/****************************************************************************************
	* Function 		GalleryControlMouseOverOut		
	* Description	Controls the handling of the left and right buttons in the script
	*				iOverOut -> 1 = mouseover
	*						    2 = mouseout
	*				SideLR -> 1 = left
	*						  2 = right
	* Action		En-/Disable Arrows if last or first image is reached
	*****************************************************************************************/
	function GalleryControlMouseOverOut(sGalIdent, iOverOut, iSideLR){
		var aGalleryObject = GalleryGetCurrentConfig(sGalIdent);
		if(aGalleryObject != null){			
			//check for control-update		//convert values to the right step (GalleryControl got 3 and 4)
			GalleryControlUpdate(sGalIdent, (iOverOut==1?3:4), iSideLR);
		}//check if Gallery Exists / found
	}
	
	
	/****************************************************************************************
	* Function 		GalleryControlOnClick		
	* Description	Controls the Click-Event on the Left-or Right
	*				iInDecrease -> Value for in-decrease counter of pictures
	* Action		Calculates the new image and request the display
	*****************************************************************************************/
	function GalleryControlOnClick(sGalIdent, iInDecrease){
		var aGalleryObject = GalleryGetCurrentConfig(sGalIdent);
		if(aGalleryObject != null){			
			//set next picture
			var iGalPicCurrent = aGalleryObject[2];
			var iGalPicTotal = aGalleryObject[3];	
			var iGalPicCurrentNew = iGalPicCurrent + iInDecrease;
			
			GalleryDisplayImg(sGalIdent, iGalPicCurrentNew)
			
			//check for control-update when pic limit is reached 
												//when counter is positive, the right side is clicked / negative normally left side
			GalleryControlUpdate(sGalIdent, 3, (iInDecrease>0?2:1));
		}//check if Gallery Exists / found
	}
	
	/****************************************************************************************
	* Function 		GalleryDisplayImg		
	* Description	Display the Requested image by number
	* Action		Updates the new Current picture / change the displayed gallery image
	*****************************************************************************************/
	function GalleryDisplayImg(sGalIdent, iGalPicCurrentNew){
		var aGalleryObject = GalleryGetCurrentConfig(sGalIdent);
		if(aGalleryObject != null){	
			//check if set value is correct / image exists
			var iGalPicCurrent = aGalleryObject[2];
			var iGalPicTotal = aGalleryObject[3];	
			var iGalShowDescription = aGalleryObject[4];
			var aGalImageDescriptions = aGalleryObject[5];	
			var oGalObjDescr = aGalleryObject[1][1];
			var oGalImage = aGalleryObject[1][9];
			var oGalImageLoader = aGalleryObject[1][10];
			var iGalRef = aGalleryObject[6];	
			var iGalPicMaxWidth = aGalleryObject[7][0];	
			var iGalPicMaxHeight = aGalleryObject[7][1];

			
			if(iGalPicCurrentNew >= 1 && iGalPicCurrentNew <= iGalPicTotal){
				//update value
				fGalValueUpdate = false;
				//search for ident in current configurations
				for(iIndex = 0; iIndex < aGalleryObjects.length; iIndex++){
					if(aGalleryObjects[iIndex][0] == sGalIdent){
						aGalleryObjects[iIndex][2] = iGalPicCurrentNew;
						fGalValueUpdate = true;
						break;
					}			
				}			
				
				//set new picture 
				if(fGalValueUpdate){
					//define inline-function for preload images
					var oGalImgPreload = new Image();
					//enable preloader
					if(fGalleryFirstInit){
						oGalImageLoader.style.visibility = 'visible';
						oGalImageLoader.style.zIndex = 110;
						oGalImageLoader.src = sGalImgLoader;
					}
					
					oGalImgPreload.onload=function(){
						//set background loaded pic to display output
						oGalImage.src=this.src;
						
						//set loader invisible
						oGalImageLoader.style.visibility = 'hidden';  
						oGalImageLoader.style.zIndex = -110;
					}
					//triggers the onload-function after fully load
					oGalImgPreload.src = ProjectURL + '/admin/gallery/' + 'admin_galleryX10ShowImg.php?iGalRef=' + iGalRef + '&iGalReqPic=' + iGalPicCurrentNew + '&iGalPicMaxWidth=' + iGalPicMaxWidth + '&iGalPicMaxHeight=' + iGalPicMaxHeight;	
					
					//set states after load
					oGalImage.alt = aGalImageDescriptions[iGalPicCurrentNew];
					oGalObjDescr.innerHTML = iGalShowDescription==1?aGalImageDescriptions[iGalPicCurrentNew]:' ';
				}

			}
			
			//update progress bar by a change
			GallerySetProgressBar(sGalIdent);
		}
	}
	
	
	/****************************************************************************************
	* Function 		GallerySetProgressBar		
	* Description	Updates the state of the Progressbar depending on the displayed picture
	* Action		Refresh the Progress-Bar Control-Style Width
	*****************************************************************************************/
	function GallerySetProgressBar(sGalIdent){
		var aGalleryObject = GalleryGetCurrentConfig(sGalIdent);
		if(aGalleryObject != null){			
			//set next picture
			var iGalPicCurrent = aGalleryObject[2];
			var iGalPicTotal = aGalleryObject[3];
			var oPictureNumbers = aGalleryObject[1][6];
			var oGalObjProcessCurrent = aGalleryObject[1][8];		
			
			//refresh
			oPictureNumbers.innerHTML = iGalPicCurrent + ' / ' + iGalPicTotal;
			
			//calculate percentage of display
			var iGalProgress = 100 / iGalPicTotal * iGalPicCurrent;
			oGalObjProcessCurrent.style.width = iGalProgress + '%';
		}//check if Gallery Exists / found
	}





/*
* ############################################################################################################################################################
* END GALLERY Project X10
* ############################################################################################################################################################
*/













/*
* ############################################################################################################################################################
* Description:	This functions enable the close events and handle different Buttons
* Action:		Handles any registrated Button Action on Window-ChangeEvent		
* ############################################################################################################################################################
*/
var eButtons = { ButtonBackClose:0, ButtonSave:1, ButtonDelete:2, ButtonRefresh:3, ButtonGo:4, ButtonNew:5, ButtonCancel:6};
var m_iButton = eButtons.ButtonBackClose;

//funktion die bei jedem Button aufgerufen wird, damit das Verlassen der Seite abgebrochen werden kann
function setButton(iButton){
	m_iButton = iButton;
	window.onbeforeunload = changeWindow;
}

function changeWindow(e){
	var sMessage = "";
	if(!e)e=window.event; 
	
	if(m_iButton == eButtons.ButtonDelete){
		sMessage = "Wollen Sie die Seite wirklich unwiderruflich l\u00F6schen?";
	}else if(m_iButton == eButtons.ButtonCancel){
		sMessage = "Beim Verlassen der Seite gehen alle nicht gespeicherten Eingaben verloren!";
	}

	m_iButton = eButtons.ButtonBackClose; //variable defaultmäßig auf close setzen, da Browserfenster buttons so abgefangen werden können
	
	if(sMessage != "" && e != null){
		e.returnValue = sMessage;	
	}
}



/*
* ############################################################################################################################################################
* Description:	Crossbrowser Fade Script
* Example: 	http://brainerror.net/scripts/javascript/blendtrans/
* ############################################################################################################################################################
*/



function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}



/*
* ############################################################################################################################################################
* Description:	This functions resizes the cms if it is inside an iframe
* Action:		Handles any registrated Button Action on Window-ChangeEvent		
* ############################################################################################################################################################
*/
function resizeIframe(){
	if (parent.document.getElementById('IframeAdminpanel') != null){
		oParentIframe = parent.document.getElementById('IframeAdminpanel');
		oCurrentContentDiv = document.getElementById('ReadContentHeight');
		
		if((oParentIframe != null) && (oCurrentContentDiv != null)){		
			iContentDivHeight = oCurrentContentDiv.offsetHeight;	
			
			if(iContentDivHeight > 0){
				oParentIframe.style.height= oCurrentContentDiv.offsetHeight +'px';
			}//check for resize
		}//check if object is in iframe and resize is need
	}
}












