/*
===============================================================================

MEIER CONSULT GmbH

===============================================================================
*/

function getObj(elementID)
{
	return document.getElementById(elementID)
}

function setVisible(elementID)
{
	getObj(elementID).style.display = 'block';
}

function setInvisible(elementID)
{
	getObj(elementID).style.display = 'none';
}

function initForm()
{
	var formOK = true;
	var formItems = new Array("Firma", "Name", "Tel", "Email")
		
	for (var i = 0; i <= formItems.length - 1; i++)
	{
		if (getObj(formItems[i]).value == '')
		{
			setErrorColor(formItems[i])
			formOK = false;
		}
		else
		{
			setNormalColor(formItems[i])
		}
	}


	if (formOK) 
	{
		setInvisible('errorMsg')
		document.Form1.submit();
	}
	else
	{
		setVisible('errorMsg')
	}

}

function setErrorColor(elementID)
{
	getObj(elementID).style.border = 'solid 1px #F00';
	getObj('Label' + elementID).style.color = '#F00';
}

function setNormalColor(elementID)
{
	getObj(elementID).style.border = 'solid 1px #CCCCCC';
	getObj('Label' + elementID).style.color = '#333333';
}

/*----------------------------------------*/

function toBold(mItem)
{
	mItem.style.backgroundColor = "#cccccc";
}

function toItem(mItem)
{
	mItem.style.backgroundColor = "#E8E6D0";
}

function setT()
{
	//window.t0.className = 'hDot_titel'; window.t1.className = 'hItem_bold'
}

function toBold2(mItem, dot)
{
	mItem.style.backgroundColor = dot.style.backgroundColor = "#cccccc";
}

function toItem2(mItem, dot)
{	
	mItem.style.backgroundColor = dot.style.backgroundColor = "#EEEEEE";
}

function subToBold(subItem, dot)
{
	subItem.style.borderBottomColor = "#CCCCCC"; 
	subItem.style.backgroundColor = dot.style.backgroundColor = "#CCCCCC";
}

function subToItem(subItem, dot)
{
	subItem.style.borderBottomColor = "#E8E6D0"; 
	subItem.style.backgroundColor = dot.style.backgroundColor = "#FFFFFF";
}

/*----------------------------------------*/

function doPrint(mItem) 
{
	getObj('p1').style.display = 'none';
	getObj('prT').style.display = 'none';
	window.print();
}

function OpenFormWidthHeight(isFix, url, width, height)
{
	var left = (window.screen.availWidth - width) / 2;
	var top = (window.screen.availHeight - height) / 2;
	var windowName = "FIX";
	
	if (!isFix)
	{
		var iFirst = url.lastIndexOf("/");
		var iLast = url.indexOf(".");
		windowName = url.substring(iFirst + 1, iLast - 1);
	}
	
	var newWindow =  window.open(url, windowName, "height=" + height + ",width=" + width +
		",left=" + left + ",top=" + top +
		",location=no,menubar=yes,status=no,toolbar=no,resizable=yes,scrollbars=yes");

	if (newWindow != null) 
	{
		newWindow.resizeTo(width, height);
		//newWindow.moveTo(left, top);
		newWindow.focus();
	}		
	else //TODO: Popupblocker??
		alert("Popupblocker verhindert dass neue Fenster geoeffnet werden koennen!");
}

var pWidth = 730;
var pHeight = 630;

function preparePrintHTML(url)
{
	OpenFormWidthHeight(false, url + '?print',pWidth, pHeight);
}

function preparePrint()
{
	OpenFormWidthHeight(false, 'index.htm?print',pWidth, pHeight);
}

function preparePrintFamaxxDesktop()
{
	OpenFormWidthHeight(false, 'desktop.htm?print',pWidth, pHeight);
}

function preparePrintFamaxxPDA()
{
	OpenFormWidthHeight(false, 'pda.htm?print',pWidth, pHeight);
}

function preparePrintReferenzen()
{

	//OpenFormWidthHeight(true, 'http://rechner05/mc/print.aspx', pWidth, pHeight);
	OpenFormWidthHeight(true, 'http://itrixx-software.de/mc/print.aspx', pWidth, pHeight);
}

function preparePrintReferenzenIMG()
{

	//OpenFormWidthHeight(true, 'http://rechner05/mc/print.aspx?img=display', pWidth, pHeight);
	OpenFormWidthHeight(true, 'http://itrixx-software.de/mc/print.aspx?img=display', pWidth, pHeight);
}

function preparePrintMehr()
{
	OpenFormWidthHeight(false, 'mehr.htm?print',pWidth, pHeight);
}