function show_popup(page,w,h,sb,rs,titel)
{
	if(sb==1)
	{
		sbv = "yes";	
	}
	else
	{
		sbv = "no";	
	}
	if(rs==1)
	{
		rsv = "yes";	
	}
	else
	{
		rsv = "no";	
	}
	
	myleft=(screen.width)?(screen.width-w)/2:100;
	mytop=(screen.height)?(screen.height-h)/2:100;
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=" + sbv + ",location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=" + rsv + "";
	win=window.open('popup.php?cmd=' + page,titel,settings);
	win.focus();
}

function gen_newsletter(id)
{
	myleft = (screen.width)?(screen.width-700)/2:100;
	mytop = (screen.height)?(screen.height-600)/2:100;

	settings="width=700,height=600,top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	win=window.open('popup.php?cmd=nletter_gen&id=' + id,'ShowNletter',settings);
	win.focus();
}

function verschickt(id)
{
	myleft = (screen.width)?(screen.width-400)/2:100;
	mytop = (screen.height)?(screen.height-250)/2:100;

	settings="width=400,height=250,top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	win=window.open('popup.php?cmd=sendinfo&id=' + id,'Verschickt',settings);
	win.focus();
}

function show_rech(nr,typ)
{
	myleft = (screen.width)?(screen.width-700)/2:100;
	mytop = (screen.height)?(screen.height-550)/2:100;

	settings="width=700,height=550,top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	win=window.open('popup.php?cmd=show_rech&typ=' + typ + '&nr=' + nr,'Rechnung',settings);
	win.focus();
}

function show_storno(nr,typ)
{
	myleft = (screen.width)?(screen.width-700)/2:100;
	mytop = (screen.height)?(screen.height-550)/2:100;

	settings="width=700,height=550,top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	win=window.open('popup.php?cmd=show_storno&typ=' + typ + '&nr=' + nr,'StornoRechnung',settings);
	win.focus();
}

function show_gutschrift(nr,typ)
{
	myleft = (screen.width)?(screen.width-700)/2:100;
	mytop = (screen.height)?(screen.height-550)/2:100;

	settings="width=700,height=550,top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	win=window.open('popup.php?cmd=show_gutschrift&typ=' + typ + '&nr=' + nr,'Gutschrift',settings);
	win.focus();
}

function mail_rech(nr)
{
	myleft = (screen.width)?(screen.width-700)/2:100;
	mytop = (screen.height)?(screen.height-550)/2:100;

	settings="width=700,height=550,top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	win=window.open('popup.php?cmd=mail_rech&nr=' + nr,'RechnungMailen',settings);
	win.focus();
}

function advice_article(id)
{
	myleft = (screen.width)?(screen.width-500)/2:100;
	mytop = (screen.height)?(screen.height-370)/2:100;

	settings="width=500,height=370,top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	win=window.open('advice.php?id=' + id,'ArtAdvice',settings);
	win.focus();
}

function edit_abwlief(id)
{
	myleft = (screen.width)?(screen.width-500)/2:100;
	mytop = (screen.height)?(screen.height-370)/2:100;

	settings="width=500,height=370,top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	win=window.open('abwlief.php?cmd=edit&id=' + id,'AbwLief',settings);
	win.focus();
}

function add_abwlief()
{
	myleft = (screen.width)?(screen.width-500)/2:100;
	mytop = (screen.height)?(screen.height-370)/2:100;

	settings="width=500,height=370,top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	win=window.open('abwlief.php?cmd=add','AbwLief',settings);
	win.focus();
}

function show_newsletter(id)
{
	myleft = (screen.width)?(screen.width-700)/2:100;
	mytop = (screen.height)?(screen.height-600)/2:100;

	settings="width=700,height=600,top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	win=window.open('popup.php?cmd=nletter_show&id=' + id,'ShowNletter',settings);
	win.focus();
}

function get_PageSize()
{
	var xScroll, yScroll;
			
	if (window.innerHeight && window.scrollMaxY)
	{	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if(document.body.scrollHeight > document.body.offsetHeight)
	{ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else
	{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
			
	var windowWidth, windowHeight;
			
	if (self.innerHeight)
	{	// all except Explorer
		if(document.documentElement.clientWidth)
		{
			windowWidth = document.documentElement.clientWidth; 
		}
		else
		{
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	}
	else if(document.documentElement && document.documentElement.clientHeight)
	{ // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if(document.body)
	{ // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
			
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	}
	else
	{ 
		pageHeight = yScroll;
	}
		
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth)
	{	
		pageWidth = xScroll;		
	}
	else
	{
		pageWidth = windowWidth;
	}
	return [pageWidth,pageHeight];
}

function gdiv_size()
{
	if(document.getElementById('glob_div'))
	{
		var arrayPageSize = get_PageSize();
		var h = arrayPageSize[1] + 'px';
		var w = arrayPageSize[0] + 'px';
		document.getElementById('glob_div').style.width=w;
		document.getElementById('glob_div').style.height=h;
	}
	else
	{
		return false;
	}
}

function omover(x,y)
{
	x.className='ns_on';
	document.getElementById(y).className='sn2';
}

function omout(x,y)
{
	x.className='ns_off';
	document.getElementById(y).className='sn';
}

function getX(elm)
{
	x = elm.offsetLeft;
	if(!elm.offsetParent) return x;
	else return (x+getX (elm.offsetParent));
}

function changePos(elm1,elm2,elm3)
{
	var x = getX(document.getElementById(elm1));
	/*document.getElementById(elm2).style.left=x;*/
}

function hide_menu_all(mall)
{
	for(var i=1;i<=mall;i++)
	{
		hide_menu(i);
	}
}
   
function hide_menu(submenu)
{
	document.getElementById(submenu).style.visibility = 'hidden';
}
   
function menu(submenu,mall)
{
	/*hide_menu_all(mall);*/
	document.getElementById(submenu).style.visibility = 'visible';
}

function checkAll(action) 
{ 
	var allChecks = document.getElementsByTagName("input");
	var action;
		 
	if(action == true)
	{
		for(var i=0; i < allChecks.length; i++) 
		{ 
			if(allChecks[i].type == "checkbox") 
			{ 
				allChecks[i].checked = "true"; 
			}
		}
	}
	else
	{
		for(var i=0; i < allChecks.length; i++) 
		{ 
			if(allChecks[i].type == "checkbox") 
			{ 
				allChecks[i].checked = ""; 
			}
		}      
	}
}

function return_confirm(cont,page)
{
	var cont = cont;
	var returnpath = page + '&action=clear';
	if(confirm(cont))
	{
		document.location.href=returnpath;
	}
	else
	{
		return "";
	}	
}

function goto_page(page)
{
	document.location.href='web.php?cmd=' + page;
}

function counterPath()
{
	var ScreenW = screen.width;
	var ScreenH = screen.height;
	var ScreenD = screen.colorDepth;
	
	var countbox = "sw=" + ScreenW + "&sh=" + ScreenH + "&sd=" + ScreenD;
	var retcode = "stats/counter.php?" + countbox;
	document.getElementById('statscount').src = retcode;
}
