function chkFormular()
 {
 	var correct;
 	correct = true;
 	var i = 0;
	for(i=0;i<arguments.length;i++) 
 	{
 		document.getElementsByName(arguments[i])[0].style.background = '#FFFFFF';
 		if(document.getElementsByName(arguments[i])[0].value == "")
  		{
  			document.getElementsByName(arguments[i])[0].style.background = '#FFA2A2';
  			correct = false;
  		}
	}
	if (correct == false)
	{
	   	alert("Bitte alle Pflichtfelder ausfüllen!");
   		return false;			
	}
}


function ConvertToHTML(strifrm,target)
{
	document.getElementById(target).value = document.getElementById(strifrm).contentWindow.document.getElementsByTagName('body')[0].innerHTML;
}

function insertHTML(strifrm)
{
	html = prompt("Bitte HTML Code eingeben!",'');
	document.getElementById(strifrm).contentWindow.document.execCommand('insertHTML', false,html);	
}

function show(strifrm)
{
	//alert(strifrm);
    document.getElementById(strifrm).contentWindow.document.execCommand('useCSS', false,false);
	document.getElementById(strifrm).contentWindow.document.execCommand('justifyleft', false,null);
	//document.getElementById(strifrm).contentWindow.document.execCommand(useCSS, false,true);
//	var innertext = document.getElementById(strifrm).contentWindow.document.getSelection();
//	var text = innertext.text;
//	alert(innertext);	
}

function insertTable(cols,rows,strifrm)
{

	var table = "<table style='border:1px solid black;'>";
	var i = 0; var j = 0;
	for(i=0;i<rows;i++)
	{
		table = table+"<tr style='border:1px solid black;'>";
		for(j=0;j<cols;j++)
		{
			table = table+"<td style='border:1px solid black;'></td>";
		}
		table = table+"</tr>";	
	}
	table = table+"</table>";
	document.getElementById(strifrm).contentWindow.document.execCommand('insertHTML',false,table);
}

function selection(strifrm)
{
//	text = document.getElementById(strifrm).contentWindow.document.getSelection();
  //if (document.getElementById(strifrm).contentWindow.document.getSelection) {
alert(document.getElementById(strifrm).contentWindow.document.getElementsByTagName('body')[0].innerHTML);
 // } else if (document.getElementById(strifrm).contentWindow.document.selection) {
  //alert(document.getElementById(strifrm).contentWindow.document.selection);//createRange().text);
 // }
}

function formatText(action,strifrm)
{
	var sel = document.getElementById('size').childNodes;
	sel = sel[1];
	var arg = sel.options[sel.selectedIndex].firstChild.data;
	document.getElementById(strifrm).contentWindow.document.execCommand(action, false,null);
}

function setTextSize(strifrm,id)
{
	var sel = document.getElementById(id).childNodes;
	sel = sel[1];
	var arg = sel.options[sel.selectedIndex].firstChild.data;
	document.getElementById(strifrm).contentWindow.document.execCommand('FontSize', false,arg);
}

function setTextType(strifrm,id)
{
	var sel = document.getElementById(id).childNodes;
	sel = sel[1];
	var arg = sel.options[sel.selectedIndex].firstChild.data;
	document.getElementById(strifrm).contentWindow.document.execCommand('FontName', false,arg);
}

function insertImage(strifrm)
{
	url = prompt("Bitte die URL des Bildes eingeben!",'http://127.0.0.1/cms/cms/images/head.jpg');
	document.getElementById(strifrm).contentWindow.document.execCommand('InsertImage', false,url);	
}

function insertLink(strifrm)
{
	link = prompt("Bitte geben sie das Ziel ein!",'http://www.google.de');
	document.getElementById(strifrm).contentWindow.document.execCommand('createlink', false,link);	
	links = document.getElementById(strifrm).contentWindow.document.getElementsByTagName("a");
	for (var i = 0; i < links.length;i++) {
		links[i].setAttribute('target','_blank');
	}
}	

function setFontColor(color,strifrm)
{
	document.getElementById(strifrm).contentWindow.document.execCommand('foreColor', false,color);		
}

function setHiliteColor(color,strifrm)
{	
	//alert(navigator.appName);
	if (navigator.appName == 'Microsoft Internet Explorer')
		document.getElementById(strifrm).contentWindow.document.execCommand('BackColor', false,color);		
	else
		document.getElementById(strifrm).contentWindow.document.execCommand('hiliteColor', false,color);
}

		var bn_who="";
		var helpID="";
		var scriptSource="";
		var parent="";
	function imageInserter(s,script)
	{	
			document.getElementById('image_frame').style.top=(yPos-150) + "px";
			document.getElementById('image_frame').style.left=(xPos-190) + "px";
			document.getElementById('image_frame').style.display='block';	
			bn_who=s;
			scriptSource=script;	
			
	}
		
	
	function videoInserter(s,script)
	{	
			document.getElementById('video_frame').style.top=(yPos-150) + "px";
			document.getElementById('video_frame').style.left=(xPos-190) + "px";
			document.getElementById('video_frame').style.display='block';	
			bn_who=s;
			scriptSource=script;		
	}

	function htmlInserter(s,script)
	{	
			document.getElementById('html_frame').style.top=(yPos-150) + "px";
			document.getElementById('html_frame').style.left=(xPos-190) + "px";
			document.getElementById('html_frame').style.display='block';	
			bn_who=s;
			scriptSource=script;		
	}
			
	function rightsManager(s,script,frame,parent,user)
	{	
		//	alert(user);
			document.getElementById(frame).style.top=(yPos-150) + "px";
			document.getElementById(frame).style.left=(xPos-190) + "px";
			document.getElementById(frame+'Frame').src = 'scripts/rightsManager/rightsManager.php?id='+parent+'&user='+user;	
			document.getElementById(frame).name = parent;
			document.getElementById(frame).style.display='block';	
			parent=parent;
		//  alert(parent);
		//	bn_who=s;
		//	scriptSource=script;	
		//	alert("TEST")			
	}
	
		
	function showHelp(hi)
	{	
			document.getElementById('help_frame').style.top=(xPos) + "px";
			document.getElementById('help_frame').style.left=(yPos) + "px";
			document.getElementById('help_frame').style.display='block';	
			helpID=hi;
			//alert("hier: ");
		}

		
		init_mousemove();
		
		var xPos="";
		var yPos="";
		var x2="";
		var y2="";
		var x3="";
		var y3="";
		var docEl = (   typeof document.compatMode != "undefined" && 
		                 document.compatMode        != "BackCompat"
		                )? "documentElement" : "body";
		
		function init_mousemove() 
		{    if(document.layers) document.captureEvents(Event.MOUSEMOVE);
		    document.onmousemove =	dpl_mouse_pos;
		}
		
	
		function dpl_mouse_pos(e) 
		{  xPos    =  e? e.pageX : window.event.x;
		  	yPos    =  e? e.pageY : window.event.y;
		
			if (document.all && !document.captureEvents && docEl) 
			{   xPos    += document[docEl].scrollLeft;
			    yPos    += document[docEl].scrollTop;
			}  
		    
		    if (document.layers) routeEvent(e);

		}
		
		
var newslist=new Array();
var cnt=0;			// current news item
var curr = "";
var i=-1;			// current letter being typed


//newslist[0]=new Array("Die Homepage-AG w?nscht allen an der Schule Arbeitenden einen guten Start")
//newslist[1]=new Array("neu auf der Homepage: Aktion Achtung-Auto, Einschulungsfeier,Lehrerseiten")
//newslist[2]=new Array("Sch?lerkalender 2007-2008 ausverkauft - Umfrage zu Nachbestellungen")

function newsticker()
{
     var kids = document.getElementsByTagName('input');
     for (j in kids)
     { 	
	      if (kids[j].className == 'newslist')
				newslist[j]=new Array(kids[j].value);
	 }
	
	
	
//	newslist[0] = new Array(document.getElementById('news').value);
	// next character of current item
	if (i < newslist[cnt][0].length - 1)
	{
		i++;
		temp1 = newslist[cnt][0];	
		temp1 = temp1.split('');	
  		curr = curr+temp1[i];
		temp2 = newslist[cnt][1];	
  		document.getElementById('mtxt').innerHTML = "<small><font style='font-weight:bold;' color='#000000'>"+curr+"</small></font>";
  		setTimeout('newsticker()',25)
		return;
	}

	// new item
	i = -1; curr = "";
	if (cnt<newslist.length-1)
		cnt++;
	else
		cnt=0;
	setTimeout('newsticker()',4500)

}
