		
	
		
	
	/***************************************************************
	*  Copyright notice
	*
	*  (c) 2007 Reto Kernen <2kk@gmx.ch>
	*  All rights reserved
	*
	*  This script is part of the SSIP project. The SSIP project is
	*  free software; you can redistribute it and/or modify
	*  it under the terms of the GNU General Public License as published by
	*  the Free Software Foundation; either version 2 of the License, or
	*  (at your option) any later version.
	*
	*  The GNU General Public License can be found at
	*  http://www.gnu.org/copyleft/gpl.html.
    *    
	*  !!!!  Important GNU License Exeptions  !!!!!
    *  SSIP musten't be used under the following cases :  
    *  1. If your  Organisation got any Military propose.  
    *  2. If your Organisation violate the human rights.  What is included you
    *  can  read here:
    *  en.wikipedia.org/wiki/European_Convention_on_Human_Rights
	*
	*  This script is distributed in the hope that it will be useful,
	*  but WITHOUT ANY WARRANTY; without even the implied warranty of
	*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	*  GNU General Public License for more details.
	*
	*  This copyright notice MUST APPEAR in all copies of the script!
	***************************************************************/
	
	/* Globals */
	
	
	
	function SSIPFl(){
		
		this.cookiedomain = "www.swiix.ch";
		this.cookiepath   = "/";
		this.ssipFLE      = new Array();	// SSIP Funlib Element Array
		
		document.cookie = "domain="+this.cookiedomain+";";
		document.cookie = "path="+this.cookiepath+";";

		/*********************    SNAPNAVIGATOR     ****************************/
		
	
		
		this.snapNavigator = function(scaleRange,snapnavigator,snapnavbutton,widthmessure,heigthmesure,atWindow){
			
			FLEid = this.getFLElement(scaleRange);
			
			this.ssipFLE[FLEid]["snapNavigator"] = snapnavigator;
			this.ssipFLE[FLEid]["snapnavButton"] = snapnavbutton;
			this.ssipFLE[FLEid]["widthmessure"]  = widthmessure;
			this.ssipFLE[FLEid]["heigthmesure"]  = heigthmesure;
			this.ssipFLE[FLEid]["snapMoveLayer"] = "ml"+scaleRange;
			if(atWindow != "div"){
				this.ssipFLE[FLEid]["appendToWindow"]  = true;
			}else{
				this.ssipFLE[FLEid]["appendToWindow"]  = false;
			}
	
			if(!this.ssipFLE[FLEid]["appendToWindow"]){
				this.$(scaleRange).style.position = "absolute";
				this.$(scaleRange).style.top = "0";
				this.$(scaleRange).style.left = "0";
			}
			
			this.addListener(this.ssipFLE[FLEid]["snapnavButton"],'onclick',"mySSIPFl.initSnapnavigator('"+this.ssipFLE[FLEid]["name"]+"');");
		}
		
	
		this.initSnapnavigator  = function(scaleRange){
			
			FLEid = this.getFLElement(scaleRange);
			
			snapNavigator       = this.$(this.ssipFLE[FLEid]["snapNavigator"]);
			widthMesureElement  = this.$(this.ssipFLE[FLEid]["widthmessure"]);
			heigthMesureElement = this.$(this.ssipFLE[FLEid]["heigthmesure"]); 
			
			
			if(this.ssipFLE[FLEid]["appendToWindow"]){
				viewport = this.getViewport();
				offsetWidth = viewport[0]/widthMesureElement.offsetWidth ;
				offsetHeight = (viewport[1]-150)/heigthMesureElement.offsetHeight ;
		
	
			}else{
				offsetWidth = widthMesureElement.parentNode.offsetWidth/widthMesureElement.offsetWidth ;
				offsetHeight = heigthMesureElement.parentNode.offsetHeight/heigthMesureElement.offsetHeight ;
			}
			
			if(offsetWidth<1){
				offsetWidth = offsetWidth*100;
			}else{
				offsetWidth = 98;
			}
			
			if(offsetHeight<1){
				offsetHeight = offsetHeight*100;
			}else{
				offsetHeight = 98;
			}
			
			if(snapNavigator.innerHTML != ""){
				snapNavigator.innerHTML = "";
				snapNavigator.style.display = "none";
			}else{
				
				baseWidth = widthMesureElement.offsetWidth;
				if(this.$(scaleRange+"_wm")){
					this.$(scaleRange+"_wm").style.display = "block";
				}else{
					backgroundDiv = '<div id="'+scaleRange+'_wm" style="height:10em;width:10em;overflow:hidden;position:absolute;left:0;top:0;"></div>';
				}
				this.$(scaleRange).innerHTML = this.$(scaleRange).innerHTML+backgroundDiv;
				
				fontFactor = this.$(scaleRange+"_wm").offsetWidth/160;
				
				verhaltniss = (parseFloat(snapNavigator.style.width)/baseWidth)*fontFactor;
				this.$(scaleRange+"_wm").style.display = "none";
				
				snapNavigator.style.fontSize = verhaltniss+"em";
				
				
				snapNavigator.innerHTML  = this.$(scaleRange).innerHTML;
				
				if(this.ssipFLE[FLEid]["appendToWindow"]){
					if(window.pageYOffset){
						y = window.pageYOffset;
						x = window.pageXOffset;
						
					}else if (document.documentElement && document.documentElement.scrollTop)
						// Explorer 6 Strict
					{
						x = document.documentElement.scrollLeft;
						y = document.documentElement.scrollTop;
					}
					else if (document.body) // all other Explorers
					{
						x = document.body.scrollLeft;
						y = document.body.scrollTop;
					}
				}else{
						x = (parseFloat(widthMesureElement.style.left))*-1;
						y = (parseFloat(heigthMesureElement.style.top))*-1;
				}
				
				initTopPos = (100/heigthMesureElement.offsetHeight) * y;
				initLeftPos = (100/widthMesureElement.offsetWidth) * x;
	
				snapNavigator.innerHTML  += "<div id=\"ml"+this.ssipFLE[FLEid]["name"]+"\" onMouseDown=\"mySSIPFl.initCaptureMove('"+this.ssipFLE[FLEid]["name"]+"');\"  style=\"position:absolute;width:"+offsetWidth+"%;height:"+offsetHeight+"%;border:2px solid #FF0000;top:"+initTopPos+"%;left:"+initLeftPos+"%;cursor:move;\"></div>";
												 
				snapNavigator.style.display = "block";
			}
	
		}
	
	
		this.initCaptureMove = function(scaleRange){
			
			FLEid = this.getFLElement(scaleRange);	
			this.addListener('body','onmousemove', "mySSIPFl.captureMouseMove('"+this.ssipFLE[FLEid]["snapMoveLayer"]+"',event.clientX,event.clientY,'"+this.ssipFLE[FLEid]["name"]+"');");
			this.addListener('body','onmouseup',"mySSIPFl.stopCaptureMove('"+this.ssipFLE[FLEid]["name"]+"');");
			this.ssipFLE[FLEid]["capturemove"] = true;
		}
		
		
		this.stopCaptureMove = function(scaleRange){
			
			FLEid = this.getFLElement(scaleRange);
			this.ssipFLE[FLEid]["capturemove"] = false;
		}
		
		
		this.captureMouseMove = function(fadenkreuz,moveX,moveY,scaleRange){
			FLEid = this.getFLElement(scaleRange);
			if(this.ssipFLE[FLEid]["capturemove"]){
				window.setTimeout("mySSIPFl.mesureMove('"+fadenkreuz+"',"+moveX+","+moveY+",'"+this.ssipFLE[FLEid]["name"]+"')",1);
			}else{
				return;
			}
		}
		
		
		this.mesureMove = function(fadenkreuzid,moveX,moveY,scaleRange) {
			
			FLEid = this.getFLElement(scaleRange);
	
			fadenkreuz    = this.$(fadenkreuzid);
			snapNavigator = this.$(fadenkreuz.parentNode.id);
			
			snapNavigatorWidth  = snapNavigator.offsetWidth;
			snapNavigatorHeight = snapNavigator.offsetHeight;
			
			fadenkreuzWidth     = fadenkreuz.offsetWidth;
			fadenkreuzHeight    = fadenkreuz.offsetHeight;
			
			quaderDiffW = snapNavigatorWidth  - fadenkreuzWidth;
			quaderDiffH = snapNavigatorHeight - fadenkreuzHeight;
			
			scrollFaktor = this.$(this.ssipFLE[FLEid]["widthmessure"]).offsetHeight/snapNavigatorHeight;
			
			objektX = moveX - this.ssipFLE[FLEid]["mouseAltX"];
			objektY = moveY - this.ssipFLE[FLEid]["mouseAltY"];
			
			this.ssipFLE[FLEid]["mouseAltX"] = moveX;
			this.ssipFLE[FLEid]["mouseAltY"] = moveY;
			
			if(!isNaN(moveX)){
				newPosX = parseFloat(fadenkreuz.style.left) + objektX;
				newPosY = parseFloat(fadenkreuz.style.top) + objektY;
				
				if(newPosX > -0.1 && newPosX < quaderDiffW ){
					
				}
				
				if(this.ssipFLE[FLEid]["appendToWindow"]){
					if(newPosX > -0.1 && newPosX < quaderDiffW ){
						fadenkreuz.style.left = newPosX + "px";
						window.scrollBy(objektX*scrollFaktor,0);
					}
					if(newPosY > -0.1 && newPosY < quaderDiffH){
						fadenkreuz.style.top  = newPosY + "px";
						window.scrollBy(0,objektY*scrollFaktor);
					}
				}else{
					if(newPosX > -0.1){
						if(newPosX < quaderDiffW ){
							fadenkreuz.style.left = newPosX + "px";
							newsnapperposx = -1*objektX*scrollFaktor+parseFloat(this.$(scaleRange).style.left)
							if(newsnapperposx < 0 ){
								this.$(scaleRange).style.left = newsnapperposx+"px";
							}
						}
					}else{
						fadenkreuz.style.left = 0 + "px";
						this.$(scaleRange).style.left = 0+"px";
					}
					if(newPosY > -0.1){
						if(newPosY < quaderDiffH){
							fadenkreuz.style.top  = newPosY + "px";
							newsnapperposy  = -1*objektY*scrollFaktor+parseFloat(this.$(scaleRange).style.top)
							if(newsnapperposy < 0){
								this.$(scaleRange).style.top = newsnapperposy+"px";
							}
						}
					}else{
						fadenkreuz.style.top = 0 + "px";
						this.$(scaleRange).style.top= 0+"px";
					}
				}
			}
		}
		
	
		
		
		/**************          SCALEBAR          *****************/
		
	
		this.scaleBar = function(elementName, bar, zoomOutput, bardirection, initPercent, scaleMin, scaleMax, scaleRange){
			
			FLEid = this.getFLElement(scaleRange);
			
			this.ssipFLE[FLEid]["barHandler"]   = elementName;
			this.ssipFLE[FLEid]["barName"]      = bar;
			this.ssipFLE[FLEid]["zoomOutput"]   = zoomOutput;
			this.ssipFLE[FLEid]["barDirection"] = bardirection;
			this.ssipFLE[FLEid]["initPercent"]  = initPercent;
			this.ssipFLE[FLEid]["barScaleMin"]  = scaleMin;
			this.ssipFLE[FLEid]["barScaleMax"]  = scaleMax;
			this.ssipFLE[FLEid]["barRange"]     = scaleMax-scaleMin;
			this.ssipFLE[FLEid]["doCapture"]    = false;
			
			ssipCrumbs = this.getSsipCrumbs();
			
			if(ssipCrumbs){
				for(c=0;c<ssipCrumbs.length;c++){
					if(ssipCrumbs[c]["name"]==scaleRange){
						this.ssipFLE[FLEid]["initPercent"] = parseInt(ssipCrumbs[c]["value"]);
						this.$(this.ssipFLE[FLEid]["zoomOutput"]).innerHTML = parseInt(ssipCrumbs[c]["value"]) +"%";
					}
				}
			}
		
			barHandler = this.$(this.ssipFLE[FLEid]["barHandler"]);
			bar = this.$(this.ssipFLE[FLEid]["barName"]);
			
			if(this.ssipFLE[FLEid]["barDirection"] == "v"){	
				barHandler.style.top  = parseInt((bar.offsetHeigth/this.ssipFLE[FLEid]["barRange"])*(this.ssipFLE[FLEid]["initPercent"]-this.ssipFLE[FLEid]["barScaleMin"])) + "px";
			}else{
				barHandler.style.left = parseInt((bar.offsetWidth/this.ssipFLE[FLEid]["barRange"])*(this.ssipFLE[FLEid]["initPercent"]-this.ssipFLE[FLEid]["barScaleMin"])) + "px";
			}
			
			initCaptureParam = "mySSIPFl.initCapture('"+this.ssipFLE[FLEid]["name"]+"');";
			this.addListener(this.ssipFLE[FLEid]["barHandler"],'onmousedown',initCaptureParam);
		}
		
		
		this.initCapture = function(scaleRange){	
		
			FLEid = this.getFLElement(scaleRange);
	
			this.ssipFLE[FLEid]["doCapture"]=true;
			captureMoveParam = "mySSIPFl.captureMove('"+this.ssipFLE[FLEid]["name"]+"',event.clientX,event.clientY);";
			this.addListener('body','onmousemove', captureMoveParam);
			this.addListener('body','onmouseup'," mySSIPFl.stopCapture('"+this.ssipFLE[FLEid]["name"]+"');");
		}
		
			
	
		this.captureMove = function(scaleRange,mouseX,mouseY){
	
			FLEid = this.getFLElement(scaleRange);
			
			if(this.ssipFLE[FLEid]["doCapture"]){
				if(this.ssipFLE[FLEid]["barDirection"] = "h"){
					mousePos = mouseX;
				}else{
					mousePos = mouseY;
				}
				setTimeout("mySSIPFl.divMouseMove('"+this.ssipFLE[FLEid]["name"]+"',"+mousePos+")",1);
			}
		}
		
	
		this.divMouseMove = function(scaleRange,mousePos){
			
			FLEid   = this.getFLElement(scaleRange);
			
			element = this.$(this.ssipFLE[FLEid]["barHandler"]);
			bar     = this.$(this.ssipFLE[FLEid]["barName"]);
			
			if(this.ssipFLE[FLEid]["barDirection"] == "v"){
				posMax = parseInt(bar.style.height);
			}else{
				posMax = parseInt(bar.style.width);
			}
			moveHandle = mousePos - this.ssipFLE[FLEid]["oldMousePos"];
			if(!isNaN(moveHandle)){	   
			   if(direction = 'h'){
					newpos = parseInt(element.style.left) + moveHandle;
					if(newpos <= posMax && newpos >= 0){
						element.style.left = newpos  + "px";
					}
				}else{
					newpos = parseInt(element.style.top) + moveHandle;
					if(newpos <= posMax && newpos >= 0){
						element.style.top = + "px";
					}
			   }
			}	
			this.ssipFLE[FLEid]["oldMousePos"] = mousePos;
		}
		
		
		this.stopCapture = function(scaleRange){
			
			FLEid   = this.getFLElement(scaleRange);
			
			this.ssipFLE[FLEid]["doCapture"]=false;
			this.removeListener('body','onmousemove');
			this.removeListener('body','onmouseup');
			
			barRange   = parseInt(this.ssipFLE[FLEid]["barRange"]);
			scaleMin   = parseInt(this.ssipFLE[FLEid]["barScaleMin"]);
	
			bar        = this.$(this.ssipFLE[FLEid]["barName"]);
			barHandler = this.$(this.ssipFLE[FLEid]["barHandler"]);
			
			if(this.ssipFLE[FLEid]["barDirection"] == "h"){
				output = 0;
				output = (barRange/bar.offsetWidth)*parseInt(barHandler.style.left);
				output += scaleMin;
			}else{
				output = 0;
				output = (barRange/bar.offsetHeight)*parseInt(barHandler.style.top);
				output += scaleMin;
			}
	
			output = parseInt(output);
		
			if(output > this.ssipFLE[FLEid]["barScaleMax"]){
				output =  this.ssipFLE[FLEid]["barScaleMax"];
			}
			
			
			
			if(output < this.ssipFLE[FLEid]["barScaleMin"]){
				output = this.ssipFLE[FLEid]["barScaleMin"];
			}
			
			this.updatePageSize(scaleRange,output);
			
			this.$(this.ssipFLE[FLEid]["zoomOutput"]).innerHTML = output+"%";
		}
		
	
		
		/* Lock to Page */
		
		this.lockToWindow = function(scaleRange,lockbutton,designedFor,origimg,setimg,beginFloatSize,defaultLTW){
			
	
			FLEid = this.getFLElement(scaleRange);
			
			this.ssipFLE[FLEid]["lockButton"]     = lockbutton;
			this.ssipFLE[FLEid]["designedFor"]    = designedFor;
			this.ssipFLE[FLEid]["origImg"]        = origimg;
			this.ssipFLE[FLEid]["setimg"]         = setimg;
			this.ssipFLE[FLEid]["beginFloatSize"] = beginFloatSize;
			if(defaultLTW){
				this.ssipFLE[FLEid]["lockToWindow"]   = defaultLTW;
				
			}else{
				this.ssipFLE[FLEid]["lockToWindow"]   = false;
			}
			
			if(!beginFloatSize){
				beginFloatSize = 0;
			}
			this.addListener('body','onresize','');
			this.addListener(this.ssipFLE[FLEid]["lockButton"],"onclick","mySSIPFl.lockToWindowInit('"+this.ssipFLE[FLEid]["name"]+"');");
	
		}
		
		
		this.lockToWindowInit = function(scaleRange){
			
			this.getFLElement(scaleRange);
			if(this.ssipFLE[FLEid]["lockToWindow"]==false){
				this.addListener	("body","onresize","mySSIPFl.fixWindow('"+this.ssipFLE[FLEid]["name"]+"')");
				this.ssipFLE[FLEid]["lockToWindow"] = true;
			}else{
				this.removeListener('body','onresize');	
				this.ssipFLE[FLEid]["lockToWindow"] = false;
			}
			
			if(this.$(this.ssipFLE[FLEid]["lockButton"]).src == this.ssipFLE[FLEid]["origImg"]){
				
				this.$(this.ssipFLE[FLEid]["lockButton"]).src = this.ssipFLE[FLEid]["setimg"];
			}else{
				this.$(this.ssipFLE[FLEid]["lockButton"]).src = this.ssipFLE[FLEid]["origImg"];
			}	
		}
		
		
		this.fixWindow = function(scaleRange){
			
			this.getFLElement(scaleRange);
			
			viewport = this.getViewport();
			zoomDegree = (viewport[0]/this.ssipFLE[FLEid]["designedFor"])*100;
			
			if(viewport[0]>this.ssipFLE[FLEid]["beginFloatSize"]){
				this.updatePageSize(scaleRange,zoomDegree);
			}
		}
		
		
		/* Font size Bar*/
		
		this.fontSizeBar = function(scaleRange,fontsmalerbtn,fontnormalbtn,fontbigerbtn,zoomSteps){
			FLEid = this.getFLElement(scaleRange);
			
			this.ssipFLE[FLEid]["fontSmalerBtn"]  = fontsmalerbtn;
			this.ssipFLE[FLEid]["fontNormalBtn"]  = fontnormalbtn;
			this.ssipFLE[FLEid]["fontBigerBtn"]   = fontbigerbtn;
			this.ssipFLE[FLEid]["zoomSteps"]      = zoomSteps;
			
			this.addListener(fontsmalerbtn,'onclick',"mySSIPFl.fontResizer('"+scaleRange+"','decrease');");
			this.addListener(fontnormalbtn,'onclick',"mySSIPFl.fontResizer('"+scaleRange+"','reset');");
			this.addListener(fontbigerbtn,'onclick',"mySSIPFl.fontResizer('"+scaleRange+"','increase');");
		}
		
		
		this.fontResizer = function(scaleRange,action){
			FLEid = this.getFLElement(scaleRange);
			
			if(!this.$(this.ssipFLE[FLEid]["name"]).style.fontSize){
				this.$(this.ssipFLE[FLEid]["name"]).style.fontSize = "1em";
			}
			
			switch (action){
				case 'decrease':
					zoomDegree = parseFloat(this.$(this.ssipFLE[FLEid]["name"]).style.fontSize)-this.ssipFLE[FLEid]["zoomSteps"] ;
					break;
				case 'reset':
					zoomDegree = 1;
					break;
				case 'increase':
					zoomDegree = parseFloat(this.$(this.ssipFLE[FLEid]["name"]).style.fontSize)+this.ssipFLE[FLEid]["zoomSteps"] ;
					break;
			}
			
			zoomDegree = zoomDegree *100;
			this.updatePageSize(scaleRange,zoomDegree);
		}
		
		
		/* Scroll Hand */
		
		this.scrollHand = function(scaleRange,scrollBtn,scrollBtnImg,scrollBtnImgActive,cursorSrc,atWindow){
			FLEid = this.getFLElement(scaleRange);
	
			this.ssipFLE[FLEid]["doScrollCapture"]     = false;
			this.ssipFLE[FLEid]["scrollBtn"]           = scrollBtn;
			this.ssipFLE[FLEid]["scrollBtnImg"]        = scrollBtnImg;
			this.ssipFLE[FLEid]["scrollBtnImgActive"]  = scrollBtnImgActive;
			this.ssipFLE[FLEid]["cursorSrc"]  		  = cursorSrc;
			this.ssipFLE[FLEid]["scrollActivatet"]     = false;
			if(atWindow != "div"){
				this.ssipFLE[FLEid]["appendToWindow"]  = true;
			}else{
	
				this.ssipFLE[FLEid]["appendToWindow"]  = false;
			}
			
			this.addListener(scrollBtn,'onclick',"mySSIPFl.activateScrollCaptureClick('"+scaleRange+"');");
		}
		
		
		this.activateScrollCaptureClick = function(scaleRange){
			FLEid = this.getFLElement(scaleRange);
	
			if(this.ssipFLE[FLEid]["scrollActivatet"] == false){
				this.addListener(scaleRange ,'onmousedown',"mySSIPFl.initScrollCapture('"+scaleRange+"');");
				this.addListener(scaleRange ,'onmouseup',"mySSIPFl.stopScrollCapture('"+scaleRange+"');");
				this.$(this.ssipFLE[FLEid]["scrollBtn"]).src = this.ssipFLE[FLEid]["scrollBtnImgActive"];
				this.ssipFLE[FLEid]["scrollActivatet"]  = true;
			}else{
				this.removeListener(scaleRange ,'onmousedown');
				this.removeListener(scaleRange ,'onmouseup')
				this.$(this.ssipFLE[FLEid]["scrollBtn"]).src =  this.ssipFLE[FLEid]["scrollBtnImg"];
				this.ssipFLE[FLEid]["scrollActivatet"]  = false;
			}	
		}
		
		
		this.initScrollCapture = function(scaleRange){
			FLEid = this.getFLElement(scaleRange);
			
			this.ssipFLE[FLEid]["doScrollCapture"]  = true;
			this.ssipFLE[FLEid]["mouseMoveAltX"] = "NaN";
			this.ssipFLE[FLEid]["mouseMoveAltY"] = "NaN";
			
			this.$(this.ssipFLE[FLEid]["name"]).style.cursor = 'url('+this.ssipFLE[FLEid]["cursorSrc"]+'), move';
			this.addListener(scaleRange,'onmousemove',"mySSIPFl.captureScrollMove(event.clientX,event.clientY,'"+this.ssipFLE[FLEid]["name"]+"');");
		}
		
		this.stopScrollCapture = function(scaleRange){
			FLEid = this.getFLElement(scaleRange);
			
			this.ssipFLE[FLEid]["doScrollCapture"]  = false;
			this.$(this.ssipFLE[FLEid]["name"]).style.cursor = 'auto';
			this.removeListener(scaleRange,'onmousemove');
		}
		
		
		this.captureScrollMove = function(moveX,moveY,scaleRange){
			FLEid = this.getFLElement(scaleRange);
			
			if(this.ssipFLE[FLEid]["doScrollCapture"]){
				setTimeout("mySSIPFl.doScroll('"+this.ssipFLE[FLEid]["name"]+"',"+moveX+","+moveY+")",1);
			}
		}
		
	
		this.doScroll = function(scaleRange,mouseX,mouseY){
			
			FLEid   = this.getFLElement(scaleRange);
			divX = mouseX-this.ssipFLE[FLEid]["mouseMoveAltX"];
			divY = mouseY-this.ssipFLE[FLEid]["mouseMoveAltY"];	
			
			
			if(!isNaN(divX) && !isNaN(divY)){
				/*if(navigator.appName.indexOf("Explorer") == -1){
					mouseX = window.pageXOffset+mouseX;
					mouseY = window.pageYOffset+mouseY;
				}*/
				if(this.ssipFLE[FLEid]["appendToWindow"]){
					window.scrollBy(divX,divY);
				}else{
					
					this.$(scaleRange).style.left = (-1*divX)+parseFloat(this.$(scaleRange).style.left) + "px";
					this.$(scaleRange).style.top = (-1*divY)+parseFloat(this.$(scaleRange).style.top) + "px";
				}
	
			}
			this.ssipFLE[FLEid]["mouseMoveAltX"] = mouseX;
			this.ssipFLE[FLEid]["mouseMoveAltY"] = mouseY;
		}
		
		
		
		/*General needed Functions*/
		
		this.addListener = function(element,type,expression){
			element = this.getListenerElement(element);
			if (navigator.appName.indexOf("Explorer") != -1){
				expression = expression;
			}
			element.setAttribute(type, expression);	
		}
		
	
		this.removeListener = function(element,type){
			element = this.getListenerElement(element);
			element.setAttribute(type, '');	
		}
		
		
		this.getListenerElement = function(wichelement){
			if(wichelement == 'body'){
				element = document.getElementsByTagName("body")[0];
			}else{
				element = this.$(wichelement);
			}
			return element;
		}
		
		
		this.$ = function(element) {
		  if (typeof element == 'string'){
			element = document.getElementById(element);
			return element;
		  }
		}
		
				
		this.getViewport = function(){	
			viewport = new Array()
			if (self.innerHeight) // all except Explorer
			{
				viewport[0] = self.innerWidth;
				viewport[1] = self.innerHeight;
			}
			else if (document.documentElement && document.documentElement.clientHeight)
				// Explorer 6 Strict Mode
			{
				viewport[0] = document.documentElement.clientWidth;
				viewport[1] = document.documentElement.clientHeight;
			}
			else if (document.body) // other Explorers
			{
				viewport[0] = document.body.clientWidth;
				viewport[1] = document.body.clientHeight;
			} 
			
			return viewport;
		}
		
		
		this.updatePageSize = function(scaleRange,zoomDegree){
			
			FLEid = this.getFLElement(scaleRange);
			
			this.ssipFLE[FLEid]["actualScale"] = zoomDegree;
			this.writeNewScaleSetup();
	
			this.$(scaleRange).style.fontSize=(zoomDegree/100)+"em";	
			if(!this.ssipFLE[FLEid]["appendToWindow"]){
	
				
				if(parseFloat(this.$(scaleRange).style.top) < -1*(this.$(scaleRange).offsetHeight)){
					this.$(scaleRange).style.top = -1*(this.$(scaleRange).offsetHeight-this.$(scaleRange).parentNode.offsetHeight)+"px";
				}
				if(parseFloat(this.$(scaleRange).style.left) < -1*(this.$(scaleRange).offsetWidth)){
					this.$(scaleRange).style.left = -1*(this.$(scaleRange).offsetWidth-this.$(scaleRange).parentNode.offsetWidth)+"px";
				}
			}
			
			
			mySSIP.updateSSIP();
	
			
			
			
			if(this.ssipFLE[FLEid]["snapNavigator"]){
				if(this.$(this.ssipFLE[FLEid]["snapNavigator"]).style.display == "block"){
					this.$(this.ssipFLE[FLEid]["snapNavigator"]).innerHTML = "";
					initSnapnavigator(scaleRange);
				}	
				
			}
	
			/*if(zoomDegree>100){
				this.$("fadenkreuz").style.width = 100-(zoomDegree-100) +"%";
				this.$("fadenkreuz").style.height = 100-(zoomDegree-100)+"%";
			}*/
		}
		
		
		
		/* SSIP Funlib Element Functions */
		
		this.getFLElement = function(name){
			identifier = this.checkExistofFLElement(name);
			if(identifier == "dosnotexsist"){
				identifier = this.addFLElement(name);
			}
			return identifier;
		}
		
		
		this.checkExistofFLElement = function(name){
			for (var i = 0; i < this.ssipFLE.length; i++) {
				if(this.ssipFLE[i]["name"] == name){
					return i;	
				}	
			}
			return "dosnotexsist";
		}
		
		
		this.addFLElement = function(name){
			if(this.ssipFLE.length){
				nextID = this.ssipFLE.length;
			}else{
				nextID = 0;
			}
	
			this.ssipFLE[nextID] = new Object();
			this.ssipFLE[nextID]["name"] = name;
			return nextID;
		}
		
		
		this.setFLEAttribute = function(FLEid,aname,value){
			this.ssipFLE[FLEid][aname][value];
		}
		
		this.writeNewScaleSetup = function(){
			
			ssipCrumbs = this.getSsipCrumbs();
			
			if(!ssipCrumbs){
				ssipCrumbs = new Array();	
			}
	
			for(d=0;d<this.ssipFLE.length;d++){
				notFound = true;
	
				if(ssipCrumbs){
					for(var c=0;c<ssipCrumbs.length;c++){
						if(ssipCrumbs[c]["name"]==this.ssipFLE[d]["name"]){
							ssipCrumbs[c]["value"]=this.ssipFLE[d]["actualScale"];
							notFound = false;
						}
					}
				}
				if(notFound){
					newValue = new Object();
					newValue["name"]  = this.ssipFLE[d]["name"];
					newValue["value"] = this.ssipFLE[d]["actualScale"];
					ssipCrumbs.push(newValue);
				}
			}
			
			ssipConfigString = "";
			
			for(var c=0;c<ssipCrumbs.length;c++){
				if(ssipCrumbs[c]["value"]){
					
					ssipConfigString += ssipCrumbs[c]["name"]+":"+ssipCrumbs[c]["value"]+"&";
					
				}
			}
			//document.cookie = "domain="+cookiedomain+";path="+cookiepath+";expires=Thu, 01-Jan-70 00:00:01 GMT";
			document.cookie="ssipconfig="+ssipConfigString+"; path=/;";
		}
		
		this.getSsipCrumbs = function(){
	
			ssipConfig = false;
			cookieArray = document.cookie.split(";");
			
			for(c=0;c<cookieArray.length;c++){
				cookiePair     = cookieArray[c].split("=");
				cookiePair[0]  = cookiePair[0].replace(/\s/g,"");
				if(cookiePair[0]=="ssipconfig"){
					ssipConfig =  cookiePair[1];
				}
			}
	
			if(ssipConfig){
				ssipCrumbsArray = ssipConfig.split("&");
				ssipCrumbs      = new Array();
				for(c=0;c<ssipCrumbsArray.length-1;c++){
					ssipConfigPair = ssipCrumbsArray[c].split(":");
					ssipCrumbs[c] = new Object();
					ssipCrumbs[c]["name"]=ssipConfigPair[0];
					ssipCrumbs[c]["value"]=ssipConfigPair[1];
				}
				
				return ssipCrumbs;
			}else{
				return false;	
			}
			
		}
		
		this.loadFunlibSettings = function(){
			
			ssipCrumbs = this.getSsipCrumbs();
			
			if(!ssipCrumbs){
				return;	
			}else{
				for(c=0;c<ssipCrumbs.length;c++){
					document.getElementById(ssipCrumbs[c]["name"]).style.fontSize = ssipCrumbs[c]["value"]/100 + "em";
				}
			}
		}
		
		/*if ( document.addEventListener ){ // for Firefox
			   window.addEventListener("load" , initFuntools, false);
		} else if (document.attachEvent){ // IE hack
			   window.attachEvent("onload" , initFuntools);
		}  	*/
		
		
	
	}


