// START CONST

var cheat_breite=16; // popup breite 
var cheat_hoehe=27;  // popup hoehe
var appname="eweb";  // appname

// END CONST

// build popup box with title
function unquote_plus(txt)
{
	return unescape(txt).replace(/\+/g, ' ')
}

function lst(txt)
{
	var txt = $w(txt);
	var s = '';

	if (txt[1])
		s += '<div class="popupHead">'+unquote_plus(txt[1])+'</div>';
	if (txt[3])
		s += '<div class="popupBody">'+unquote_plus(txt[3])+'</div>';
	$('popup').innerHTML = s;
}

function registerElement(el)
{
	el.title = '';

	Event.observe(el, 'mouseout', function(){
		// remove popup and highlight
		$('popup').hide();
	});
	Event.observe(el, 'mouseover', function(){
		// show popup and highlight
		if ($('popup').innerHTML)
			$('popup').show();
		else
			$('popup').hide();
	});
	Event.observe(el, 'mousemove', function(e){
		// move popup along the mouse
		var x = Event.pointerX(e) + 15;
		var y = Event.pointerY(e) + 15;
		$('popup').setStyle({'left':x+'px', 'top':y+'px'});
	});
}

function registerPageHighlighter()
{
	// register handler for each article highlight
	$$('area.articleElement').each(registerElement);
	$$('a.articleElement').each(registerElement);
	$$('a.articleElementNoBorder').each(registerElement);
}

function eP_ext(url, width, height)
{
	var screenWidth = screen.width;
	var screenHeight = screen.height;

	if (width>screenWidth)
		width = screenWidth - 24;

	if (height>screenHeight)
		height = screenHeight - 16;

	var left = (screenWidth-width)/2;
	var top = (screenHeight-height)/2;

	width += cheat_breite;
	height += cheat_hoehe;

	eP_extwin = window.open(url, 'extwin', 'scrollbars=yes,locationbar=no,menubar=no,resizable=yes,status=no,dependent=yes,width='+width+',height='+height+',left='+left+',top='+top);

	return false;
}

function eP_ext2(url, width, height)
{
	var screenWidth = screen.width;
	var screenHeight = screen.height;

	if (width>screenWidth)
		width = screenWidth - 24;

	if (height>screenHeight)
		height = screenHeight - 16;

	var left = (screenWidth-width)/2;
	var top = (screenHeight-height)/2;

	width += cheat_breite;
	height += cheat_hoehe;

	eP_extwin = window.open(url, 'extwin', 'scrollbars=yes,locationbar=no,menubar=no,resizable=yes,status=no,dependent=yes,width='+width+',height='+height+',left='+left+',top='+top);

	return false;
}

function eP_ext3(url, width, height)
{
	var screenWidth = screen.width;
	var screenHeight = screen.height;

	var left = (screenWidth-width)/2;
	var top = (screenHeight-height)/2;

    zurl = '/'+appname+'/printview/'+escape(url)+'/'+width+'/'+height+'/pview/';

	width += cheat_breite; // 
	height += cheat_hoehe;
		
	size = ',width='+width+',height='+height+',left='+left+',top='+top;
	eP_extwin = window.open(zurl, 'extwin', 'locationbar=no,menubar=no,resizable=yes,status=no,dependent=yes,scrollbars=yes'+size);

	return false;
}

function eP_fullimg(url, print, maxSize)
{
	var size = '';

	var screenWidth = screen.width;
	var screenHeight = screen.height;

	if (maxSize && maxSize!='SCREEN')
	{
		if (maxSize<=screenWidth)
		{
			var w = 0, h = 0;

			if (maxSize=='640') { w=630; h=440; }
			if (maxSize=='800') { w=790; h=560; }
			if (maxSize=='1024') { w=1014; h=728; }
			if (maxSize=='1280') { w=1270; h=984; }
			if (maxSize=='1600') { w=1590; h=1160; }

			if (w && h)
			{
				var left = (screenWidth-w)/2;
				var top = (screenHeight-h)/2;
				
				w += cheat_breite;
				h += cheat_hoehe;
				
				size = ',width='+w+',height='+h+',left='+left+',top='+top;
			}
		}
	}
	else
	{
		if (screenWidth && screenHeight)
		{
			var w = screenWidth - 10;
			var h = screenHeight - 40;
			var left = (screenWidth-w)/2;
			var top = (screenHeight-h)/2;

			w += cheat_breite;
			h += cheat_hoehe;
			
			size = ',width='+w+',height='+h+',left='+left+',top='+top;
		}
	}
	
	// var url = '/common/include/image.php?url='+escape(url);
	var zurl = '/'+appname+'/imageview/'+escape(url)+'/'+w+'/'+h+'/view/';
	if(print==1)
	  zurl = '/'+appname+'/imageprint/'+escape(url)+'/'+w+'/'+h+'/print/';
	if(print==2)
	  zurl = '/'+appname+'/printview/'+escape(url)+'/'+w+'/'+h+'/pview/';
		
	eP_extwin = window.open(zurl, 'extwin', 'locationbar=no,menubar=no,resizable=yes,status=no,dependent=yes,scrollbars=yes'+size);

	return false;
}

function showPrintView(url, w, h)
{
	var screenWidth = screen.width;
	var screenHeight = screen.height;

	var left = (screenWidth-w)/2;
	var top = (screenHeight-h)/2;

	w += cheat_breite; // beite 
	h += cheat_hoehe; // hoehe
	
	size = ',width='+w+',height='+h+',left='+left+',top='+top;
	zurl = '/'+appname+'/imageview/'+escape(url)+'/'+w+'/'+h+'/view/';
	this.blur();
	eP_extwin = window.open(zurl, 'extwin', 'locationbar=no,menubar=no,resizable=yes,status=no,dependent=yes,scrollbars=yes'+size);

	return false;
}

function eP_extimg(url, width, height)
{
  // return eP_ext('/common/include/image.php?url='+escape(url), width, height);

  // /'+appname+'/image/test.jpg/100/200/view/

  return eP_ext('/'+appname+'/image/'+escape(url)+'/'+width+'/'+height+'/view/', width, height);
}

function eP_unesc(text)
{
	if(text)
		return escape(text.split(' ').join('+'));
	else
		return '';
}
 
function eP_esc(text)
{
	if(text)
		return escape(text.split('+').join(' '));
	else
		return '';
}


function showPicture(url, w, h)
{
	var screenWidth = screen.width;
	var screenHeight = screen.height;

	var left = (screenWidth-w)/2;
	var top = (screenHeight-h)/2;

	w += cheat_breite; // breite 
	h += cheat_hoehe;  // hoehe
	
	size = ',width='+w+',height='+h+',left='+left+',top='+top;
	zurl = '/'+appname+'/viewpic/'+escape(url)+'/'+w+'/'+h+'/view/';
	eP_extwin = window.open(zurl, 'extwin', 'locationbar=no,menubar=no,resizable=yes,status=no,dependent=yes,scrollbars=yes'+size);

	return false;
}


