//strGet
// ALL					Random Testimonial über alle Kategorien
// KA_<shortname>		Random Testimonial von einer bestimmten Kategorie
// AU_<ID>				Ausgabe eines bestimmten Testimonial

//iIntervall
//Intervall für den Aufruf in Milli Sekunden

function WriteTestimonial(strGet, iIntervall)
{
	document.write("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"100px\">");
	document.write("<colgroup>");
	document.write("	<col width=\"102px\">");
	document.write("	<col width=\"100%\">");
	document.write("</colgroup>");
	document.write("<tr height=\"15px\">");
	document.write("	<td><img src=\"images/0.gif\" width=\"102\" height=\"15\" alt=\"\" /></td>");
	document.write("	<td><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("	<td>");
	document.write("		<table width=\"102px\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
	document.write("		<colgroup>");
	document.write("			<col width=\"1px\">");
	document.write("			<col width=\"35px\">");
	document.write("			<col width=\"1px\">");
	document.write("			<col width=\"64px\">");
	document.write("			<col width=\"1px\">");
	document.write("		</colgroup>");
	document.write("		<tr height=\"1px\">");
	document.write("			<td style=\"background-color: #999999;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("			<td style=\"background-color: #999999;\"><img src=\"images/0.gif\" width=\"35\" height=\"1\" alt=\"\" /></td>");
	document.write("			<td style=\"background-color: #999999;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("			<td style=\"background-color: #999999;\"><img src=\"images/0.gif\" width=\"64\" height=\"1\" alt=\"\" /></td>");
	document.write("			<td style=\"background-color: #999999;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("		</tr>");
	document.write("		<tr height=\"130px\">");
	document.write("			<td style=\"background-color: #999999;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("			<td colspan=\"3\"><img id=\"pic_bild\" src=\"\" width=\"100\" height=\"130\" alt=\"\"></td>");
	document.write("			<td style=\"background-color: #999999;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("		</tr>");
	document.write("		<tr height=\"1px\">");
	document.write("			<td style=\"background-color: #999999;\" colspan=\"5\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("		</tr>");
	document.write("		<tr height=\"100%\">");
	document.write("			<td colspan=\"2\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("			<td style=\"background-color: #DADADA;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("			<td colspan=\"2\" style=\"background-color: #F5F4F3;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("		</tr>");
	document.write("		<tr height=\"1px\">");
	document.write("			<td colspan=\"2\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("			<td colspan=\"3\" style=\"background-color: #DADADA;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("		</tr>");
	document.write("		</table>");
	document.write("	</td>");
	document.write("	<td>");
	document.write("		<table width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
	document.write("		<colgroup>");
	document.write("			<col width=\"20px\">");
	document.write("			<col width=\"100%\">");
	document.write("			<col width=\"1px\">");
	document.write("		</colgroup>");
	document.write("		<tr height=\"35px\">");
	document.write("			<td colspan=\"3\" align=\"right\" valign=\"middle\"><a href=\"\" id=\"lnk_topic\"></a></td>");
	document.write("		</tr>");
	document.write("		<tr height=\"1px\">");
	document.write("			<td style=\"background-color: #DADADA;\"><img src=\"images/0.gif\" width=\"20\" height=\"1\" alt=\"\" /></td>");
	document.write("			<td style=\"background-color: #DADADA;\"><img src=\"images/0.gif\" width=\"100%\" height=\"1\" alt=\"\" /></td>");
	document.write("			<td style=\"background-color: #DADADA;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("		</tr>");
	document.write("		<tr height=\"60px\">");
	document.write("			<td style=\"background-color: #7AB0DF;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("			<td style=\"background-color: #7AB0DF;\" align=\"left\" valign=\"middle\"><font color=\"#FFFFFF\" face=\"Tahoma\" size=\"2.5px\"><b id=\"txt_datum\"></b></font><br /><font color=\"#FFFFFF\" face=\"Tahoma\" size=\"2.5px\" id=\"txt_name\"></font></td>");
	document.write("			<td style=\"background-color: #DADADA;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("		</tr>");
	document.write("		<tr height=\"1px\">");
	document.write("			<td colspan=\"3\" style=\"background-color: #DADADA;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("		</tr>");
	document.write("		<tr height=\"10px\">");
	document.write("			<td colspan=\"3\" style=\"background-color: #F5F4F3;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("		</tr>");
	document.write("		<tr height=\"100%\">");
	document.write("			<td style=\"background-color: #F5F4F3;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("			<td style=\"background-color: #F5F4F3;\" align=\"left\" valign=\"middle\"><font color=\"#003366\" face=\"Tahoma\" size=\"2.5px\"><i><b id=\"txt_text\"></b></i></font></td>");
	document.write("			<td style=\"background-color: #DADADA;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("		</tr>");
	document.write("		<tr height=\"10px\">");
	document.write("			<td colspan=\"3\" style=\"background-color: #F5F4F3;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("		</tr>");
	document.write("		<tr height=\"25px\">");
	document.write("			<td style=\"background-color: #F5F4F3;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("			<td style=\"background-color: #F5F4F3;\" align=\"right\" ><img src=\"images/pfeil_rechts.gif\" border=\"0\" alt=\"\" />&nbsp;&nbsp;<a href=\"\" id=\"lnk_proj\">erfahren sie mehr zu diesem Projekt</a>&nbsp;&nbsp;</td>");
	document.write("			<td style=\"background-color: #DADADA;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("		</tr>");
	document.write("		<tr height=\"1px\">");
	document.write("			<td colspan=\"3\" style=\"background-color: #DADADA;\"><img src=\"images/0.gif\" width=\"1\" height=\"1\" alt=\"\" /></td>");
	document.write("		</tr>");
	document.write("		</table>");
	document.write("	</td>");
	document.write("</tr>");
	document.write("<tr height=\"15px\">");
	document.write("	<td colspan=\"2\"><img src=\"images/0.gif\" width=\"1\" height=\"15\" alt=\"\" /></td>");
	document.write("</tr>");
	document.write("</table>");

	CallTestimonial(strGet, iIntervall);
}

function CallTestimonial (strGet, iIntervall)
{
	GetTestimonial(strGet);
	window.setTimeout("CallTestimonial(\"" + strGet + "\", " + iIntervall + ")", iIntervall);
}

function CTestimonial(id)
{
    this.id			= id;
    this.date		= "";
	this.person		= "";
	this.text		= "";
	this.bild		= "";
	this.link		= "";
}

function CTopic (shortname, longname, url)
{
	this.shortname	= shortname;
	this.longname	= longname;
	this.url		= url;
}

function GetTestimonial(strGet)
{
	xml = '';

        if (window.ActiveXObject)
        {
            xml = new ActiveXObject("Microsoft.XMLDOM");
            xml.async = false;
            xml.load("http://www.ebcom.ch/images/upload/Eintraege%20Testimonial_327.xml");
        }
        else if (document.implementation && document.implementation.createDocument)
        {
            xml = document.implementation.createDocument("","",null);
            xml.async = false;
            xml.onload = this.loadHash;
            xml.load("http://www.ebcom.ch/images/upload/Eintraege%20Testimonial_327.xml");
        }
        else
        {
            alert("Javascript wird bei Ihnen nicht vollständig unterstützt. Die Seite kann nicht mehr korrekt angezeigt werden.");
        }

        var topics = xml.documentElement.childNodes;
		var Topic = '';
		var statements = '';
		var Testimonial = '';

	switch (strGet.substring(0, 3))
	{
	case 'ALL':
		do 
		{
			i = Math.round(Math.random() * (topics.length -1))
		}
		while (topics[i].nodeType != 1);
	
		Topic = new CTopic(topics[i].getAttribute('shortname'), topics[i].getAttribute('longname'), topics[i].getAttribute('url'));
	case 'KA_':
		if (Topic == '')
		{
			for (var i = 0; i < topics.length; i++)
			{
				if (topics[i].nodeType == 1)
				{
					if (topics[i].getAttribute("shortname") == strGet.substring(3, strGet.length))
					{
						Topic = new CTopic(topics[i].getAttribute('shortname'), topics[i].getAttribute('longname'), topics[i].getAttribute('url'));
						break;
					}
				}
			}
		}

		statements = topics[i].childNodes;
		do 
		{
			r = Math.round(Math.random() * (statements.length -1))
		}
		while (statements[r].nodeType != 1);
		var statement = statements[r].childNodes;

		Testimonial = new CTestimonial(statements[r].getAttribute('id'));

		for (var k = 0; k < statement.length; k++)
		{
			if (statement[k].nodeType == 1)
			{
				eval("Testimonial." + statement[k].nodeName + ' = statement[k].childNodes[0].nodeValue');
			}
		}

		break;
	case 'AU_':
		alert("Funktion für Anzeige eines einzigen Testimonials noch nicht implementiert!");
		break;
	}
	SetTestimonial (Testimonial, Topic);
}

function SetTestimonial(Testimonial, Topic)
{
	var element = '';

	element = document.getElementById("lnk_topic");
	if (element.childNodes.length > 0)
		element.removeChild(element.firstChild);
	element.appendChild(document.createTextNode(Topic.longname));
	element.setAttribute('href', Topic.url);

	element = document.getElementById("txt_datum");
	if (element.childNodes.length > 0)
		element.removeChild(element.firstChild);
	element.appendChild(document.createTextNode(Testimonial.date));

	element = document.getElementById("txt_name");
	if (element.childNodes.length > 0)
		element.removeChild(element.firstChild);
	element.appendChild(document.createTextNode(Testimonial.person));

	element = document.getElementById("txt_text");
	if (element.childNodes.length > 0)
		element.removeChild(element.firstChild);
	element.appendChild(document.createTextNode(Testimonial.text));

	element = document.getElementById("lnk_proj");
	element.setAttribute('href', Testimonial.link);

	element = document.getElementById("pic_bild");
	element.setAttribute('src', Testimonial.bild);
}