//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Array und Objecte sind in types.js definiert
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//
//
//
// Alle News 
function all_news()
{
	document.write("<br><b>Alle News</b><br><br>");
	if(News)
	{
		News.sort(Datesort);
		var t;
		for (i = 0; i< News.length; i++)
		{
			t = GetNewsItem(i);
			print_newsItem(t);
		}
	}
}
//--------------------------------------------------------------------------------------------------------------------------------------------
//
//
//
//
//
// News nach aktuellem Datum
function news_afterNow()
{
	var nDay, nMonth, nYear;
	var D = new Date();
	
	//nDay = D.getDate();
	//nMonth = D.getMonth() + 1;
	//nYear = D.getYear();
	
	if(News)
	{
		var t;
		var a,b,count;
		var x,y;
		
		News.sort(DatesortD);
		
		document.write("<table cellspacing='1' height='' width='100%' cellpadding='0' border='0' background='Bilder/rot.gif'>");
		document.write("<tr>");
		document.write("<td>");
		
		document.write("<table cellspacing='0' height='' width='100%' cellpadding='5' border='0' background='Bilder/weiss.jpg'>");

		count = 0;
		for (i = 0; i< News.length; i++)
		{
			t = News[i];	//GetNewsItem(i);
			if (t.Datum != "")
			{
				a = t.Datum.split(".");
				b = new Date();
				b.setDate(a[0]);
				b.setMonth(a[1]-1);
				b.setYear(a[2]);
				
				x = t.DatumBis.split(".");
				y = new Date();
				y.setDate(x[0]);
				y.setMonth(x[1]-1);
				y.setYear(x[2]);
				
				
				if ((Date.parse(b.toGMTString()) <= Date.parse(D.toGMTString())) && (Date.parse(y.toGMTString()) >= Date.parse(D.toGMTString())) )
				{
					showitem(t,count);
					count++;
					
				}
					
				
			}
		}
		
		document.write("</table>");
		
		document.write("</td>");
		document.write("</tr>");
		document.write("</table>");
	}
}
//--------------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------------------
//
//
//
//
//
// News nach aktuellem Datum
function news_afterNow_abteilung(strAbteilung)
{
	var nDay, nMonth, nYear;
	var D = new Date();
	
	//nDay = D.getDate();
	//nMonth = D.getMonth() + 1;
	//nYear = D.getYear();
	
	//alert(strAbteilung);
	
	if(News)
	{
		var t;
		var a,b,count;
		var x,y;
		
		News.sort(DatesortD);
		
		document.write("<table cellspacing='1' height='' width='100%' cellpadding='0' border='0' background='Bilder/rot.gif'>");
		document.write("<tr>");
		document.write("<td>");
		
		document.write("<table cellspacing='0' height='' width='100%' cellpadding='5' border='0' background='Bilder/weiss.jpg'>");

		count = 0;
		for (i = 0; i< News.length; i++)
		{
			t = News[i];	//GetNewsItem(i);
			
			if(t.Abteilung == strAbteilung)
			{	
				
				if (t.Datum != "")
				{
					a = t.Datum.split(".");
					b = new Date();
					b.setDate(a[0]);
					b.setMonth(a[1]-1);
					b.setYear(a[2]);
				
					x = t.DatumBis.split(".");
					y = new Date();
					y.setDate(x[0]);
					y.setMonth(x[1]-1);
					y.setYear(x[2]);
				
					// Auf der Abteilungsseite sollen Nachrichten unbegrenzt angezeigt werden!!
					showitem(t,count);
					count++;
										
				} // if (t.Datum != "")
				
			} // if(t.Abteilung == strAbteilung)
			
		} // for (i = 0; i< News.length; i++)
		
		document.write("</table>");
		
		document.write("</td>");
		document.write("</tr>");
		document.write("</table>");
	} // If (news)
}

//--------------------------------------------------------------------------------------------------------------------------------------------
//
//
//
// NEU
// Anzeige eines News Items mit zugehörigen Links
function showitem(t, count)
{
	document.write("<tr>");
							
	if (count % 2 == 0 )
	{
		document.write("<td class='mtxt' width='11px' valign='top' background='Bilder/hrot.gif'><img src='Bilder/maknews.gif'></td>");
		document.write("<td class='mtxt' background='Bilder/hrot.gif'>");
	}
	else
	{	
		document.write("<td class='mtxt' width='11px' valign='top' background=''><img src='Bilder/maknews.gif'></td>");
		document.write("<td class='mtxt' background=''>");
	}
	document.write("<table cellspacing='2' cellpadding='0' class='mtxt'>");
	document.write("<tr><td colspan='2' height='' class='mtxt'><b>" + t.Titel + "</b></td></tr>");
	document.write("<tr><td colspan='2' height='5px' class='mtxt'></td></tr>");
	document.write("<tr>");
	document.write("<td></td>");
	document.write("<td>");
	document.write(t.Text);
	document.write("</td>");
	document.write("</tr>");
	if (t.Links.length > 0)
	{
		document.write("<tr><td colspan='2' height='5px' class='mtxt'></td></tr>");
		for(x=0;x < t.Links.length;x++)
		{
			if (t.Links[x]["LinkAdress"] != "")
			{
				document.write("<tr>");
				document.write("<td colspan='2' valign='top'><a class='maa' href ='" +t.Links[x]["LinkAdress"] + "' ");
				if (t.Links[x]["LinkTarget"] != "")
					document.write(" target = '" +t.Links[x]["LinkTarget"] + "' ");
				document.write(">" + t.Links[x]["Link"] + "</a>");
				document.write("</td");
				document.write("</tr>");
			}
		}
	}
	if (t.ImgLinks.length > 0)
	{
		document.write("<tr><td colspan='2' height='5px' class='mtxt'></td></tr>");
		document.write("<tr>");
		document.write("<td colspan='2' valign='top'>");
		document.write("<table cellspacing='5' cellpadding='0' border='0'>");
		document.write("<tr>");
							
		for(x=0;x < t.ImgLinks.length;x++)
		{
			if (t.ImgLinks[x]["LinkAdress"] != "")
			{
				document.write("<td valign='top' align='center'>");
				document.write("<a class='maa' href ='" +t.ImgLinks[x]["LinkAdress"] + "' ");
				if (t.ImgLinks[x]["LinkTarget"] != "")
					document.write(" target = '" +t.ImgLinks[x]["LinkTarget"] + "' ");
				document.write("><img src='" + t.ImgLinks[x]["LinkImage"] + "' border='0' align='absmiddle'></a>");
				
				if (t.ImgLinks[x]["LinkTitel"])
				{
				if (t.ImgLinks[x]["LinkTitel"] != "")
				{
					document.write("<br/><a class='maa' style='font-weight:normal;' href ='" +t.ImgLinks[x]["LinkAdress"] + "' ");
					if (t.ImgLinks[x]["LinkTarget"] != "")
						document.write(" target = '" +t.ImgLinks[x]["LinkTarget"] + "' ");
					document.write(">" + t.ImgLinks[x]["LinkTitel"] + "</a>");
				}
				}
				
				document.write("</td>");
				if((x+1) % 4 == 0)	document.write("</tr><tr>");
			}
		}
	
		document.write("</tr>");
		document.write("</table>");
		document.write("</td");
		document.write("</tr>");
	}
	
	document.write("<tr><td colspan='2' height='5px'></td></tr>");
	document.write("</table>");
	document.write("</td>");
	document.write("</tr>");
}









//--------------------------------------------------------------------------------------------------------------------------------------------
//
//
//
// News nach aktuellem Datum
function news_afterNow_short()
{
	var nDay, nMonth, nYear;
	var D = new Date();
	
	nDay = D.getDate();
	nMonth = D.getMonth() + 1;
	nYear = D.getYear();
	
	if(News)
	{
		var t;
		var a,b,x,y,count;
		var temp = "aktuel_main.html"
		
		News.sort(DatesortD);
		
		document.write("<table cellspacing='1' height='100%' width='300px' cellpadding='0' border='0' background='Bilder/rot.gif'>");
		document.write("<tr>");
		document.write("<td>");
		
		document.write("<table cellspacing='0' height='100%' width='100%' cellpadding='5' border='0' background='Bilder/weiss.jpg'>");

		count = 0;
		for (i = 0; i< News.length; i++)
		{
			t = News[i];	//GetNewsItem(i);
			if (t.Datum != "")
			{
				a = t.Datum.split(".");
				b = new Date();
				b.setDate(a[0]);
				b.setMonth(a[1]-1);
				b.setYear(a[2]);
				
				x = t.DatumBis.split(".");
				y = new Date();
				y.setDate(x[0]);
				y.setMonth(x[1]-1);
				y.setYear(x[2]);
				
				if ((Date.parse(b.toGMTString()) <= Date.parse(D.toGMTString())) && (Date.parse(y.toGMTString()) >= Date.parse(D.toGMTString())) )
				{
					document.write("<tr>");
					
					if (count % 2 == 0 )
					{
						document.write("<td class='mtxt' width='11px' valign='top' background='Bilder/hrot.gif'><img src='Bilder/maknews.gif'></td>");
						document.write("<td class='mtxt' background='Bilder/hrot.gif'>");
					}
					else
					{
						document.write("<td class='mtxt' width='11px' valign='top' background=''><img src='Bilder/maknews.gif'></td>");
						document.write("<td class='mtxt' background=''>");
					}
					document.write("<table cellspacing='2' cellpadding='0' class='mtxt'>");
					document.write("<tr><td colspan='2' height='' class='newstitel'><b>" + t.Titel + "</b></td></tr>");
					document.write("<tr><td colspan='2' height='2px' class='newstext'></td></tr>");
					document.write("<tr>");
					document.write("<td>");
					
					if (t.ImgLinks.length > 0)
					{
						if (t.ImgLinks[0]["LinkAdress"] != "")
						{
							document.write("<a class='maa' href ='" + temp + "' ");
							document.write("><img src='" + t.ImgLinks[0]["LinkImage"] + "' height='100px' border='0' align='absmiddle'></a>");
						}
					}
					
					document.write("</td>");
					document.write("<td valign='top' class='newstext'>");
					if(t.Text.length > 100)
						document.write(t.Text.substring(0,90) + " ...");
					else
						document.write(t.Text + " ...");
					document.write("<br><a class='maa' href ='" + temp + "'>&nbsp;mehr&nbsp;&gt;</a>");
					document.write("</td>");
					document.write("</tr>");
					document.write("<tr><td colspan='2' height='5px'></td></tr>");
					document.write("</table>");
					document.write("</td>");
					document.write("</tr>");
					count++;
					
					
				}
					
				
			}
			if(count>=3) break;
		}
		
		document.write("</table>");
		
		document.write("</td>");
		document.write("</tr>");
		document.write("</table>");
	}
}
//--------------------------------------------------------------------------------------------------------------------------------------------


