function OpenFoto(img){
foto= new Image();
foto.src=(img);
ControlFoto(img);
}

function ControlFoto(img){
if((foto.width!=0)&&(foto.height!=0)){
ViewFoto(img);
}
else{
interval_a="ControlFoto('"+img+"')";
interval_b=setTimeout(interval_a,20);
}
}
function ViewFoto(img){
width=foto.width+20;
height=foto.height+24;

try {
if (output.closed == false) throw "offen";
}
catch (e) {
if (e=="offen") {
output.close();
}
}
output=window.open("","output","left=40,top=40,width="+width+",height="+height+",location=no,toolbar=no,menubar=no,status=no,scrol lbars=no,resizable=no");
output.document.writeln("<html><head><title>..:: Foto ::..<\/title><\/head>");
output.document.writeln("<body bgcolor=\"white\" text=\"white\" link=\"white\" vlink=\"white\" alink=\"white\" leftmargin=\"0\" marginwidth=\"0\" topmargin=\"0\" marginheight=\"0\">");
output.document.writeln("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"100%\">");
output.document.writeln("<tr><td width=\"100%\" height=\"100%\" align=\"left\" valign=\"top\"><p><a href=\"javascript:self.close()\"><img src=\""+img+"\" width=\""+foto.width+"\" height=\""+foto.height+"\" border=\"10\" alt=\"click here to close the window\"></a><\/p><\/td><\/tr>");
output.document.writeln("<\/table><\/body><\/html>");
output.focus();
}

function imgviewer(nShow,cIDDiv,cIDBild)
{
var o;
var cx;
var cfoto;

	odivfoto = document.getElementById( cIDDiv );
	if (nShow==0)
	{
		odivfoto.style.visibility="hidden";
	}
	else
	{
		o = document.getElementById( cIDBild );
		cx = o.src;
		cx = cx.toLowerCase();
		if (cx.search( "klein.jpg" ) > 0) {
			cfoto = cx.replace( "klein.", "gross." );
			foto = new Image();
			foto.src = cfoto;
			
			fotocomplete();
			
			document.getElementById("imgviewer_bildgross").src = foto.src;
			nxdiv = 20;
			nydiv = 20;
			odivfoto.style.height = nydiv+'px';
			odivfoto.style.width = nxdiv+'px';
			foto.width;
			foto.height;
			showfoto(cfoto);
		}
	}
}
function fotocomplete() {
	if (!foto.complete)
	{
		setTimeout( "fotocomplete()", 100 );
	}
}

function showfoto(cfoto) {
var odiv;
var y;

	nx = foto.width;
	ny = foto.height;
	/*document.getElementById("imgviewer_bildgross").src = cfoto;*/

	if (typeof window.pageYOffset != 'undefined') {
	   y = window.pageYOffset;
	}
	else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
	   y = document.documentElement.scrollTop;
	}
	else if (typeof document.body != 'undefined') {
	   y = document.body.scrollTop;
	}
	y += 20;
	odivfoto.style.top = y+'px';
	odivfoto.style.left = 20+'px';
	
	if (nx > 0)
	{
		odivfoto.style.visibility="visible";
	}
	if ( nx==0 || nxdiv < nx || nydiv < ny )
	{
		if ( nxdiv < nx )
		{
			nxdiv+=20;
			nxdiv = Math.min(nxdiv,nx);
			odivfoto.style.width = nxdiv+'px';
		}
		if ( nydiv < ny )
		{
			nydiv+=20;
			nydiv = Math.min(nydiv,ny);
			odivfoto.style.height = nydiv+20+'px';
		}
		setTimeout( "showfoto()", 10 );
	}
}

function xToNumeric(o)
{
	o.value = eval( o.value * 1 )
	if (o.value=="NaN")
		o.value = 0;
	return true;
}

function bildgross( cidlupe, cidziel )
{
var cx;

	o = document.getElementById( cidziel );
	olupe = document.getElementById( cidlupe );

	cx = o.src;
	cx = cx.toLowerCase();
	if (cx.search( "klein.jpg" ) > 0) {
		o.src = cx.replace( "klein.", "gross." );
		if (olupe != null) {
			olupe.src = "../images/lupe_minus.gif";
		}
	}
	else {
		o.src = cx.replace( "gross.", "klein." );
		if (olupe != null) {
			olupe.src = "../images/lupe_plus.gif";
		}
	}
}

function updownmenge(x,cidziel,ncount,lover)
{
var o;
var nx;

	if (cidziel != null)
	{
		o = document.getElementById( cidziel );
		nx = o.value * 1;
		nx += ncount;
		if (nx<=0) {
			nx = "";
		}
		o.value = nx;
	}

	if (lover==1)
	{
		if (ncount>0)
		{
			x.src = "../images/pfeil_up_red.gif";
		}
		else if (ncount<0)
		{
			x.src = "../images/pfeil_down_red.gif";
		}
	}
	else
	{
		if (ncount>0)
		{
			x.src = "../images/pfeil_up.gif";
		}
		else if (ncount<0)
		{
			x.src = "../images/pfeil_down.gif";
		}
	}
return true;
}
function focusrc(x,infocus)
{ //v2.0
var nrows;
var ncols;
var i,j;
var o;
var cid;
var nCodeA;

	cid = x.id;
//	if ( cid.substr(0,1)=="A" || (cid.substr(1,1)=="1" && cid.length == 2) ) //(cid == "A1")
//		return false;

	for (i=1;i<=100;i++)
	{
		o = document.getElementById("A"+i);
		if (o==null)
		{
			nrows=i;
			i=1000;
		}
	}

	for (i=1;i<=100;i++)
	{
		o = document.getElementById( String.fromCharCode(64+i)+"3" );
		if (o==null)
		{
			ncols=i;
			i=1000;
		}
	}
	ncols--;
	
	for (j=1;j<=ncols;j++)
	{
		if ( cid.substr(1,2) != "1" )
		{
			if (infocus==1)
			{
				if (j==1)
				{
					document.getElementById( String.fromCharCode(64+j)+cid.substr(1,2) ).className="td_in_cap_left";	
				}
				else
				{
					document.getElementById( String.fromCharCode(64+j)+cid.substr(1,2) ).className="td_in";	
				}
			}
			else
			{
				if (j==1)
				{
					document.getElementById( String.fromCharCode(64+j)+cid.substr(1,2) ).className="td_out_cap_left";	
				}
				else
				{
					document.getElementById( String.fromCharCode(64+j)+cid.substr(1,2) ).className="td_out";	
				}
			}
		}
	}
	for (i=1;i<nrows;i++)
	{
		if ( cid.substr(0,1) != "A" )
		{
			if (infocus==1)
			{
				if (i==1)
				{
					document.getElementById( cid.substr(0,1)+i ).className="td_in_cap";	
				}
				else
				{
					document.getElementById( cid.substr(0,1)+i ).className="td_in";	
				}
			}
			else
			{
				if (i==1)
				{
					document.getElementById( cid.substr(0,1)+i ).className="td_out_cap";	
				}
				else
				{
					document.getElementById( cid.substr(0,1)+i ).className="td_out";	
				}
			}
		}
	}

	if ( cid.substr(0,1)=="A" || (cid.substr(1,1)=="1" && cid.length == 2) ) //(cid == "A1")
		return true;

	if (infocus==1)
	{
		x.className="td_focus";
	}
	
	return true;
}

function validateform( cname, cpflichtfelder, calert ) {
	var cx;
	var nlen;
	var oform;
	var i;

	oform = document.forms[cname]; 	
	nlen = oform.elements.length;
	

	for ( i = 0; i < nlen; i++ )
	{
		lx = true;
		cx = oform.elements[i].name;
		if ( oform.elements[i].value.length == 0 || oform.elements[i].value == '-' )
		{
			if ( cpflichtfelder.indexOf(cx) > 0 )
			{
				alert(calert);
				oform.elements[i].focus();
				return false;	
			}
		}
		if (cx == "email")
		{
			oform.cwFromAdress.value = oform.elements[i].value;
		}
	}
return true;
}

function sleep(ms){
var zeit=(new Date()).getTime();
var stoppZeit=zeit+ms;
while((new Date()).getTime()<stoppZeit){};
} 
