<!--
/* 	####################################################################################################################################
	FABPRO - WMS JS Function Lib.
	Copyright (c) M.F. Wieland
	Ver   : 1.0
	Date  : 2004-2011
	####################################################################################################################################*/

	// vars..
	var OverFlowState = '';
	var PaddingRightState = '';
	var popupImageActive = false;
	var oldOnResizeEvent = "";
	var oldOnScrollEvent = "";
	
	//Preload spin-indicator..
	var tmpSpinImg = new Image();
	tmpSpinImg.src = '/wmspub/var/general/images/spin-loader2.gif';
	
	
/*### Position Function ###*/	
	function findPosX( obj ) { var xPos = 0;var el = obj;while(el) { xPos+= el.offsetLeft; el = el.offsetParent; } return xPos; }
	function findPosY( obj ) { var yPos = 0;var el = obj;while(el) { yPos+= el.offsetTop; el = el.offsetParent; } return yPos; }
	
	function getWindowSize() {
		var winHeight = 0;   
		var winWidth = 0;   
		// Non-IE
		if( typeof( window.innerWidth ) == 'number' )
		{
			winWidth	= window.innerWidth;
			winHeight 	= window.innerHeight;
		}
		// IE 6 +
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
		{
			winWidth 	= document.documentElement.clientWidth;   
			winHeight 	= document.documentElement.clientHeight;   
		} 
		// IE 4 compatible
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
		{
			winWidth 	= document.body.clientWidth; 
			winHeight 	= document.body.clientHeight; 
		}
		return Array(winWidth,winHeight);
	}
	
	function getDocumentSize()
	{
		var docWidth = Math.max(
			Math.max(document.body.scrollWidth, document.documentElement.scrollWidth),
			Math.max(document.body.offsetWidth, document.documentElement.offsetWidth),
			Math.max(document.body.clientWidth, document.documentElement.clientWidth)
		);
		var docHeight = Math.max(
			Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
			Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
			Math.max(document.body.clientHeight, document.documentElement.clientHeight)
		);
		return Array(docWidth,docHeight);
	}
	
	function scrollPosY() 
	{
		var ypos = 0
		// Non-IE
		if(window.pageYOffset) ypos = window.pageYOffset;
		// IE 6 +
		else if(document.documentElement.scrollTop) ypos = document.documentElement.scrollTop;
		// IE 4 compatible
		else if(document.body.scrollTop) ypos = document.body.scrollTop;
		return ypos;
	}
	
/*### Various Function ###*/
	Array.prototype.inArray = function(value) 
	{
		var i;
		for(i=0; i < this.length; i++){
			if(this[i] === value) return true;
		};
		return false;
	}
	
    function checkBrowser()
    {
        var agent = navigator.userAgent.toLowerCase();
        var browser = "";
        if( agent.indexOf("opera") != -1 ) browser = "opera";
        if( agent.indexOf("gecko") != -1 ) browser = "gecko";
        if( ( agent.indexOf("msie") != -1 ) && ( agent.indexOf("opera") == -1 ) ) browser = "msie";
        if( agent.indexOf("netscape") != -1 ) browser = "ns";
        if( agent.indexOf("firefox") != -1 ) browser = "ff";
        return browser;
    }

/*### Cookies Functions ###*/
	function writeCookie(name,value,expiredays) 
	{
		var today = new Date();
		var expire = new Date();
		expire.setTime(today.getTime() + 3600000*24*expiredays); // day
		document.cookie = name+"="+value+";expires="+expire.toGMTString();
	}
	function readCookie(name) 
	{
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) 
		{
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}	
	
    function showFlash( flashurl,w,h )
    {
          document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="750" height="100" align="middle">');
          document.write('<param name="allowScriptAccess" value="sameDomain" />');
          document.write('<param name="movie" value="'+ flashurl +'" />');
          document.write('<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />');
          document.write('<embed src="'+ flashurl +'" quality="high" bgcolor="#ffffff" width="'+ w +'" height="'+ h +'" name="foo" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
          document.write('</object>');
    }

/*### WMS ImagePopup Functions ###*/

	function positionPopupImage(imgWidth,imgHeight)
	{
		var imgPop = document.getElementById('imgPopup');
		if(imgPop) 
		{
			var marginTop 				= 0;
			var winsize 				= getWindowSize();
			var winWidth 				= parseInt(winsize[0]);
			var winHeight				= parseInt(winsize[1]);
			var ypos 					= parseInt(scrollPosY());
			imgPop.style.width 			= imgWidth+90+'px';
			imgPop.style.left 			= Math.floor( (winWidth-(imgWidth+150))/2 ) + 'px';

			if(winHeight<imgHeight+40) marginTop = 0;
					else marginTop = Math.floor( (winHeight-(imgHeight+40))/2);
			
			imgPop.style.top = ypos + marginTop + "px";

			imgPop.style.display= 'block';
		}
		//Background
		var imgPopBack = document.getElementById('imgPopupBack');
		if(imgPopBack) 
		{
			var docSize 				= getDocumentSize();
			imgPopBack.style.width 		= docSize[0] + "px";
			imgPopBack.style.height		= docSize[1] + "px";
			imgPopBack.style.display	= '';
		}
	}

	function showImage(imageSrc,imgWidth,imgHeight)
	{
		var size = 0;
		imgWidth = parseInt(imgWidth);
		imgHeight = parseInt(imgHeight);
		if(imgWidth>imgHeight) size = imgWidth; else size = imgHeight;

		var imgPop = document.getElementById('imgPopup');
		if(!imgPop)
		{
			var divPopup = document.createElement("div");
			divPopup.id = "imgPopup";
			divPopup.style.backgroundColor = "#fff";
			divPopup.style.top 		= "10px";
			divPopup.style.margin 	= "0 auto";
			divPopup.style.position = "absolute";
			divPopup.style.zIndex = "1000";
			divPopup.style.border = "1px solid #222";
			divPopup.style.borderRight = "3px  solid #333";
			divPopup.style.borderBottom = "3px  solid #333";
			divPopup.style.color = "#222";
			divPopup.style.padding = "20px";
			divPopup.style.align = "center";
			divPopup.style.display = "none";
			divPopup.innerHTML = "<center><img style='cursor:pointer;' align=left src='/wmspub/var/general/images/btClose.png' onClick='hideImgPopup();'>"+
								 "<img style='cursor:pointer;' id=imgpopupImage border=0 src='/wmspub/var/general/images/spin-loader2.gif' onClick='hideImgPopup();'>"+
								 "</center>";
			document.body.appendChild(divPopup);
			
			// Background
			var divPopupBack = document.createElement("div");
			divPopupBack.id = "imgPopupBack";
			divPopupBack.style.position = "absolute";
			divPopupBack.style.left		= "0px";
			divPopupBack.style.top		= "0px";
			divPopupBack.style.zIndex = "999";
			divPopupBack.style.border = "0px";
			divPopupBack.style.padding = "0px";
			divPopupBack.style.backgroundColor = "#000";
			divPopupBack.style.opacity = '0.7';
			divPopupBack.style.filter = 'alpha(opacity=70)';
			divPopupBack.style.display = "none";
			document.body.appendChild(divPopupBack);
		}
		//position image..
		//positionPopupImage(imgWidth,imgHeight);
		
		// View image
		if(!popupImageActive)
		{
			popupImageActive = true;
			var randomnumber=Math.floor(Math.random()*100);
			var obj = document.getElementById('imgpopupImage');
			var tmpImg = new Image();
			tmpImg.onload = function() { obj.src = tmpImg.src; }
			tmpImg.src = "/wmspub/scripts/thumb.php?size="+size+"&imgFile="+imageSrc+"&"+randomnumber;
			if(!tmpImg.onload) obj.src = tmpImg.src;
			
			oldOnScrollEvent = window.onscroll;
			oldOnResizeEvent = window.onresize;

			addOnScrollEvent(function(){positionPopupImage(imgWidth,imgHeight);});
			addOnResizeEvent(function(){positionPopupImage(imgWidth,imgHeight);});
			
			positionPopupImage(imgWidth,imgHeight);
			
		}
	}
	
	function hideImgPopup()
	{
		var imgPop = document.getElementById('imgPopup');
		if(imgPop) 
		{
			imgPop.style.display='none';
		}
		var imgPopBack = document.getElementById('imgPopupBack');
		if(imgPopBack) 
		{
			imgPopBack.style.display='none';
		}
		var imgObj = document.getElementById('imgpopupImage');
		if(imgObj)
		{
			imgObj.src= '/wmspub/var/general/images/spin-loader2.gif';
		}
		popupImageActive = false;
		window.onscroll = oldOnScrollEvent;
		window.onresize = oldOnResizeEvent;
		
	}	
	
	function addOnResizeEvent(func)
	{
		var resizes = 0;
		var existing = window.onresize;
		window.onresize = function() 
		{
			if (existing) {	existing(); }
			func();
		}
	}
	
	function addOnScrollEvent(func)
	{
		var resizes = 0;
		var existing = window.onscroll;
		window.onscroll = function() 
		{
			if (existing) {	existing(); }
			func();
		}
	}
-->
