function pollIt(whichId,prompt,captureResult,a1,c1,a2,c2,a3,c3)
{
	
	result=(captureResult!="");
	if (result)	{
		s="<div style='margin: 0 0 0 0;'>";
	} else {
		captureResult=document.getElementById(whichId).firstChild.data;
		s="<form style='margin: 0 0 0 0;' name='noPoll' method='post' action='javascript:pollIt(\""+whichId+"\",\""+prompt+"\",\""+captureResult+"\",\""+a1+"\",\""+c1+"\",\""+a2+"\",\""+c2+"\",\""+a3+"\",\""+c3+"\")'>";
	}

	s+="<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
	s+="<tr>";
	s+="<td colspan='2'>";

	s+="<div class='s1'>";
	s+="<div style='clear:left;color:white;' class='s1'>";
	s+="<div style='float:left;padding-top:0px;'><img style='padding:0;padding-top:-16px;border:0;' src='wp-includes/images/tae/umfrage.gif' alt='Symbol Umfrage'/></div><h6 style='margin:0;margin-left:30px;color:#fff;font-size:11px;font-weight:normal;'>Entscheidung  des Tages</h6>";
	s+="</div>";

	s+="</td>";
	s+="</tr>";
	s+="<tr>";
	s+="<td colspan='2' class='s0'>";

	s+="<div class='s0' style='padding:13px;'>";
	s+=prompt;
	s+="</div>";
	
	s+="</td>";
	s+="</tr>";

	if (result) {
	
		s+="<tr>";
		s+="<td colspan='2' class='s0'>";
		s+="<div class='s0' style='padding-left:8px;padding-top:0px;padding-bottom:3px;'>";
		s+="<p style='font-weight:bold;'>"+captureResult+":</p>";
		s+="</div>";

		s+="</td>";
		s+="</tr>";

		tn=Math.floor(Math.random()*1000);
		n1=tn;
		n2=0;
		n3=0;
		if ((a2) && (a2!="undefined"))
		{
			n1=Math.floor(Math.random()*tn);
			n2=tn-n1;
			if ((a3) && (a3!="undefined"))	{
				n2=Math.floor(Math.random()*n2);
				n3=tn-n1-n2;
			}
		}

		p1=((n1/tn)*100).toFixed(1);
		p2=((n2/tn)*100).toFixed(1);
		p3=((n3/tn)*100).toFixed(1);

		r1=Math.round((n1/tn)*100);
		r2=Math.round((n2/tn)*100);
		r3=Math.round((n3/tn)*100);

	} else {
		s+="<tr><td colspan='2' class='s0'><br/>";
		s+="</td></tr>";
	}


	s+="<tr>";

	if (result) {
		s+="<td width='170px' class='s0' valign='top'><span style='font-size:11px;padding-left:10px;vertical-align:4px;'><img style='padding:0;border:0;' src='wp-includes/images/tae/eef6ee.gif' alt='"+p1+"' height='10' width='"+r1+"' title='"+n1+" von "+tn+"'/>&nbsp;&nbsp;"+p1+"%&nbsp;&nbsp;</span>";
	
	} else {
		s+="<td width='40px' class='s0'><span style='font-size:11px;padding-left:10px'><input name='youRang' value='0' type='radio'/></span>";
	}

	s+="</td><td width='*' class='s0'>";

	s+="<span class='s0' style='font-size:11px;padding-left:0px;vertical-align:4px;' title='"+c1+"'>"+a1+"</span><br/>";

	s+="</td></tr>";
	
	if ((a2) && (a2!="undefined"))
	{
		s+="<tr>";
		if (result) {
			s+="<td width='170px' valign='top' class='s0'><span class='s0' style='padding-left:10px;vertical-align:4px;'><img style='padding:0;border:0;' src='wp-includes/images/tae/eef6ee.gif' alt='"+p2+"' height='10' width='"+r2+"' title='"+n2+" von "+tn+"'/>&nbsp;&nbsp;"+p2+"%&nbsp;&nbsp;</span>";
		} else {
			s+="<td width='40px' valign='top' class='s0'><span class='s0' style='font-size:11px;padding-left:10px;'><input name='youRang' value='1' type='radio'/></span>";
		}
		s+="</td><td width='*' class='s0'>";
		s+="<span class='s0' style='font-size:11px;padding-left:0px;vertical-align:4px;' title='"+c2+"'>"+a2+"</span><br/>";
		s+="</td></tr>";
	
		if ((a3) && (a3!="undefined"))	{
			s+="<tr>";
			if (result) {
				s+="<td width='170px' valign='top' class='s0'><span font-size:11px;class='s0' style='padding-left:10px;vertical-align:4px;'><img style='padding:0;border:0;' src='wp-includes/images/tae/eef6ee.gif' alt='"+p3+"' height='10' width='"+r3+"' title='"+n3+" von "+tn+"'/>&nbsp;&nbsp;"+p3+"%&nbsp;&nbsp;</span>";
			} else {
				s+="<td width='40px' valign='top' class='s0'><span class='s0' style='padding-left:10px;'><input name='youRang' value='2' type='radio'/></span>";
			}
			s+="</td><td width='*' class='s0'>";
			s+="<span class='s0' style='font-size:11px;padding-left:0px;vertical-align:4px;' title='"+c3+"'>"+a3+"</span><br/>";
			s+="</td></tr>";
		}
	}

	s+="<tr><td colspan='2' class='s0'>"
	s+="<div class='s0' style='display:inline;float:right;padding-left:20px;padding-top:12px;padding-right:10px;'>";
	
	if (!result) {
		s+="<div class='s0' style='display:inline;float:right;padding-left:20px;padding-top:0px;padding-right:10px;'>";
		s+="<input style='background-color:inherit;border-style:solid;border-width:0px;font-size:11px;margin-bottom:2px;' value='Abstimmen' type='submit'/>";
		s+="<input value='Abstimmen' src='wp-includes/images/tae/absenden.gif' type='image'>";
	}

	s+="</div>";
	s+="<div style='padding-top:4px;clear:both;'></div>";
	s+="</div>";





	s+="</td>";
	s+="</tr>";
	s+="</table>";




	
	if (result) {
		s+="</div><br/>";
	} else {
		s+="</form><br/>";
	}

	document.getElementById(whichId).innerHTML=s;
}

function newElement(name, attributes) {
	var theElement=document.createElement(name);
	if (attributes)	{
		var attribs=attributes.split(";;");
		for (var i=0; i<attribs.length; i++) {
			var attrib=attribs[i].split("::");
			if (theElement.getAttributeNode(attrib[0])) {
				atts=attrib[1].split(";");
				if (theElement.getAttributeNode(attrib[0]).length>1)
				{
					for (l=0;l<atts.length;l++) {
						att=atts[l].split(":");
						theElement.setAttribute(att[0],att[1]);
					}
				} else {
					theElement.setAttribute(attrib[0],attrib[1]);
				}
			} else {
				theElement.setAttributeNode(newAttribute(attrib[0],attrib[1]));
			}
		}
	}
	return theElement;
}

function newAttribute(name, value) {
	var theAttribute=document.createAttribute(name);
	theAttribute.value=value;
	return theAttribute;
}


function newTR(attribs) {
	return newElement("tr", attribs);
}


function newTD(attribs) {
	return newElement("td", attribs);
}


function newDIV(attribs) {
	return newElement("div", attribs);
}



function poll(whichId,attributes) {

	var input;
	var form=document.getElementById(whichId);

	if (attributes) {
		attribs=attributes.split(";;");
		for (j=0;j<attribs.length;j++) {
			attrib=attribs[j].split("::");
			if (form.childNodes[j+1])
				form.childNodes[j+1].setAttribute("value",attrib[1]);
			else {
				input=newElement("input","type::hidden;;id::"+attrib[0]+";;value::"+attrib[1]);
				form.appendChild(input);
			}
				
		}
	}
	

	var div=form.childNodes[0];
	var style=div.getAttribute("style");
	div.setAttribute("style","");
	div.setAttribute("class","s0");
	var caption=form.childNodes[1].getAttribute("value");
	var prompt=form.childNodes[2].getAttribute("value");
	var prompt_alt=form.childNodes[3].getAttribute("value");
	var result=form.childNodes[4].getAttribute("value");
	var result_alt=form.childNodes[5].getAttribute("value");
	var answers=(form.childNodes.length-6)/2;
	var res=(div.childNodes[0]!=null);
	var table=newElement("table", "border::0;;cellpadding::0;;cellspacing::0;;width::100%");
	var tr=newTR();
	table.appendChild(tr);


	var td=newTD("colspan::2");
	tr.appendChild(td);

	var newDiv=newDIV("class::s1");

	if ((caption) && (caption!="")) 
		td.appendChild(newDiv);
	

	var yad=newDIV("class::s2");
	newDiv.appendChild(yad)
	
	var img=newElement("img", "src::wp-includes/images/tae/umfrage.gif;;alt::Hochsymbolische Umfrage;;class::s3"); 

	yad.appendChild(img);
	
	var h6=newElement("h6", "class::s4");

	newDiv.appendChild(h6);
	h6.appendChild(document.createTextNode(caption));


	tr=newTR();
	table.appendChild(tr);
	td=newTD("colspan::2");
	tr.appendChild(td);

	newDiv=newDIV("title::"+prompt_alt+";;class::s5");
	td.appendChild(newDiv);
	newDiv.innerHTML=prompt;

	tr=newTR();
	table.appendChild(tr);

	td=newTD("colspan::2;;class::s7");
	tr.appendChild(td);

	var tn;
	var n;
	var p;
	var r;
	var a=new Array(answers);
	var c=new Array(answers);
	if (res) {
		if (result!='') {
			newDiv=newDIV("class::s8");
			td.appendChild(newDiv);
			p=newElement("p", "class::s9")
			newDiv.appendChild(p);
			p.innerHTML=result;
		} else {
			td.appendChild(newElement("br"));
		}

		tn=Math.floor(Math.random()*1000);
		pp=Math.random();

		n=new Array(answers);
		p=new Array(answers);
		r=new Array(answers);

		for (i=0; i<answers; i++) {
			n[i]=tn;
			if (i>0) {
				n[i-1]=Math.floor(Math.random()*n[i-1]*pp);
				for (k=0;k<=(i-1);k++) {
					n[i]=n[i]-n[k];
				}
			}
			
		}
		for (i=0;i<answers;i++) {
			p[i]=((n[i]/tn)*100).toFixed(1);
			r[i]=Math.round((n[i]/tn)*100);
		}


	} else {
		td.appendChild(newElement("br"));
	}

	for (i=0;i<answers;i++) {


		a[i]=form.childNodes[(i*2+6)].getAttribute("value");
		c[i]=form.childNodes[(i*2+7)].getAttribute("value");

		tr=newTR();
		table.appendChild(tr);

		td=newTD("valign::top;;class::s7;;nobreak::nobreak");
		tr.appendChild(td);

		width=document.createAttribute("width");
		
		if (res)
			width.value="170px";
		else
			width.value="40px";

		td.setAttribute("width", width.value);
		
		var span=newElement("span")
		td.appendChild(span);
		
		var style=document.createAttribute("class");

		if (res) { 
			style.value="s10";
			img=newElement("img", "src::wp-includes/images/tae/eef6ee.gif;;height::10;;width::"+r[i]+";;alt::"+p[i]+";;title::"+n[i]+" von "+tn+";;class::s3a");
			span.appendChild(img);
			span.appendChild(document.createTextNode("  "+p[i]+"%  "));
		} else {
			style.value="s11"
			input=newElement("input","type::radio;;value::"+i);
			span.appendChild(input);
		}

		if (span.getAttribute("style"))
			span.setAttribute("style",style.value);
		else
			span.setAttributeNode(style);

		td=newTD("width::*;;class::s7");
		tr.appendChild(td);
		if (res)
			span=newElement("div", "title::"+c[i]+";;class::s12");
		else
			span=newElement("div", "title::"+c[i]+";;class::s12a");
		td.appendChild(span);
		span.innerHTML=a[i];
			
	}

	if (!res) {

	
		tr=newTR();
		table.appendChild(tr);

		td=newTD("colspan::2");
		tr.appendChild(td);

		newDiv=newDIV("class::s13");
		td.appendChild(newDiv);

		input=newElement("input", "type::submit;;value::Abstimmen ;;class::s14");
		newDiv.appendChild(input);

		input=newElement("input", "type::image;;value::Abstimmen;;src::wp-includes/images/tae/absenden.gif;;class::s16");
		newDiv.appendChild(input);

	}
	
	tr=newTR();
	table.appendChild(tr);

	td=newTD("colspan::2");
	tr.appendChild(td);

	newDiv=newDIV("class::s15");
	td.appendChild(newDiv);

		
	if (res) 
		div.innerHTML="";
	div.appendChild(table);
	//div.appendChild(document.createTextNode(table.outerHTML));
	div.innerHTML=div.innerHTML;
	//alert(div.innerHTML);
/**/
}

	function togglePatch(patch) {
		var elem=document.getElementById(patch);
		checkBoxes=elem.form.elements;
		for (var i=0;i < checkBoxes.length;i++) {
			checkBoxes[i].checked=elem.checked;
		}
		updatePatch(patch);
	}
	
	function updatePatch(patch) {
		var elem=document.getElementById(patch);
		checkBoxes=elem.form.elements;
		var count=0;
		for (var i=1;i < checkBoxes.length;i++) {
			if (checkBoxes[i].type=='checkbox' && checkBoxes[i].checked)
				count++;
		}
		document.getElementById(patch+'r').innerHTML="Insgesamt ausgew&auml;hlt: "+count+" Update"+ ((count!=1) ? "s" : "");
		document.getElementById(patch+'i').disabled=(count==0);
	}



function toggleOpen (whichID) {
	infoBoxId=whichID.substring(0,whichID.indexOf("-"));
	element=document.getElementById(whichID);
	className=element.className;
	if (className=="nocontent") {
		for (var i=0; i < element.parentNode.childNodes.length;i++) {
			if (element.parentNode.childNodes[i].attributes) {
				if (element.parentNode.childNodes[i].getAttribute("id")) {
					if (element.parentNode.childNodes[i].getAttribute("id").substring(0,whichID.indexOf("-"))==infoBoxId) {
						//gruff();
						element.parentNode.childNodes[i].className="nocontent";
					}
				}
			}
		}
		element.className="content";
	}
	else {
		document.getElementById(whichID.substring(0,whichID.indexOf("-"))+"-0").className="content";
		document.getElementById(whichID).className="nocontent";
	}
}

function toggleFront(tabId, contentId) {
	infoBoxId=tabId.substring(0,tabId.indexOf("-"));
	element=document.getElementById(tabId);
	className=element.className;
	if (className=="tab") {
		for (var i=0; i < element.parentNode.childNodes.length;i++) {
			if (element.parentNode.childNodes[i].attributes) {
				if (element.parentNode.childNodes[i].getAttribute("id")) {
					if (element.parentNode.childNodes[i].getAttribute("id").substring(0,tabId.indexOf("-"))==infoBoxId) {
						element.parentNode.childNodes[i].className="tab";
					}
				}
			}
		}
		element.className="tab_front";
	}
	element=document.getElementById(contentId);
	className=element.className;
	if (className=="nocontent") {
		for (var i=0; i < element.parentNode.childNodes.length;i++) {
			if (element.parentNode.childNodes[i].attributes) {
				if (element.parentNode.childNodes[i].getAttribute("id")) {
					if (element.parentNode.childNodes[i].getAttribute("id").substring(0,contentId.indexOf("-"))==infoBoxId) {
						element.parentNode.childNodes[i].className="nocontent";
					}
				}
			}
		}
		element.className="content";
	}
	
	

}

function loeschen(id) {
	var span=document.getElementById(id);
	a=span.innerHTML;
	b="<span class='durchgestrichen'>"+span.innerHTML+"</span><span class='kursiv'>&#160;gel&#246;scht</span>";
	span.title="gelöscht";
	span.innerHTML=b;
}
function getSeconds() {
	var then=new Date();
	with (then) {
		setFullYear(2015);
		setMonth(2);
		setDate(3);
		setHours(20);
		setMinutes(7);
		setSeconds(23);
	}
	document.getElementById("countdown").innerHTML=Math.floor((then-(new Date()).getTime())/1000);
	window.setTimeout("getSeconds()", 1000);
}

function alles() {
	hint('steuer');
	hint('socken');
	hint('spinat');
	hint('pralinen');
	hint('saufen');
	hint('singen');
	hint('brunnen');
}

function hint(element) {
	elem=document.getElementById(element);
	innerHTML="--&gt;";
	innerHTML+=elem.innerHTML;
	innerHTML+="&lt;-- Richtig! (100 Punkte)";
	elem.innerHTML=innerHTML;
	elem.className="hint";
	input=document.getElementsByName(element)[0];
	input.checked=true;
}

function auswertung(formID) {

	form=document.getElementById(formID);
	elements=form.elements;
	result=0;
	for (i=0;i<elements.length;i++) {
		element=elements[i];
		if ((element.type=="radio") && (element.checked))
			result+=Number(element.value);
	}
	return result;
}


	function showNext(id) {
		nextId=Number(id.split('#')[1]);
		nextId++;
		nextId=id.split('#')[0] + '#' + ((nextId<10) ? '00'+nextId : (nextId<100) ? '0'+nextId : nextId);
		miniPost=document.getElementById(nextId);
		if (miniPost) {
		} else {
			nextId=id.split('#')[0] + '#001';
			miniPost=document.getElementById(nextId);
		}
		document.getElementById(id).className="shortnewshidden";
		miniPost.className="shortnewsvisible";
	}

	function showPrev(id) {
		prevId=Number(id.split('#')[1]);
		prevId--;
		if (prevId>0) {
			prevId=id.split('#')[0] + '#'+ ((prevId<10) ? '00'+prevId : (prevId<100) ? '0'+prevId : prevId);
			miniPost=document.getElementById(prevId);
			document.getElementById(id).className="shortnewshidden";
			miniPost.className="shortnewsvisible";
		}
	}

	function toggle(id) {
		div=document.getElementById(id+'_header');
		if (div.className=="shortnewsheaderopen")
			closeShortNews(id);
		else
			openShortNews(id);
	}

	function closeShortNews(id) {
		header=document.getElementById(id+'_header');
		header.className="shortnewsheaderclosed";
		body=document.getElementById(id+'_body');
		body.className="shortnewsclosed";
	}
	
	function openShortNews(id) {
		news=document.getElementsByName("ShortNews");
		for (i=0;i<news.length;i++) {
			k=i+1;
			shortNewsID=(k<10) ? '00'+k : (k<100) ? '0'+k : k;
			closeShortNews("ShortNews"+shortNewsID);
		}
		header=document.getElementById(id+'_header');
		header.className="shortnewsheaderopen";
		body=document.getElementById(id+'_body');
		body.className="shortnewsopen";
	}
	
function toggleChecked(image) {
	if (image.src.indexOf('unchecked')>0) 
		image.src="/tae/wp-includes/images/tae/checked.PNG";
	else
		image.src="/tae/wp-includes/images/tae/unchecked.PNG";
	
}
	
function strafarbeit() {
	if ( typeof strafarbeit.counter == 'undefined' ) 
        strafarbeit.counter = 0;
	strafarbeit.counter++;
	document.getElementById("strafarbeit").innerHTML+="<li><img src='wp-content/themes/oulipo/images/strafarbeit3.PNG' style='border:0;'/></li>";
	if (strafarbeit.counter<125)
		window.setTimeout("strafarbeit()",5000);
}	


