var w1;
var varID;

function OpenNewProjectWindow(id, name, desc)
{
	this.varID = id;
	//project.php?action=getText&id=18
	
	if(this.varID != "-1")
	{
		var header = "Projekt Bearbeiten";
		Load("project.php?action=getText&id="+id, "data");
	}
	else
	{
		var header = "Neues Projekt";
	}
	
	
	w1 = new UI.Window({ theme: 'vista', width: 500, height:670, top:10, left:((window.innerWidth/2)-250)});
	w1.setContent('<div id="result" style="margin-top:10px; margin-left:10px; margin-right:10px;"><h1>'+header+'</h1>'+
				'<form name="frmData">'+
				'<p>'+
				'<br />'+
				'<div><li>Projektname:</li></div><div><input type="text" name="name" value="'+name+'" width="80%"/></div><br />'+
				'<div>Projektbeschreibung:</div><div><textarea id="data" name="value"></textarea></div>'+
				'</p>'+
				'<p>'+
				'<center><a href="#" onmouseover="return overlib(\'Speichern\');" onmouseout="return nd();">'+
				'<img src="images/icons/ok.png" alt="save" onclick="Save(\'project\');" style="align:center;"/></a>'+
				'<a href="#" onmouseover="return overlib(\'Abbrechen\');" onmouseout="return nd();">'+
				'<img src="images/icons/cancel.png" alt="cancel" onclick="w1.close();" style="align:center;"/></a></center>'+
				'</p>'+
				'</form></div>'); 
//
	w1.superflousEffects = true;
	w1.observe("destroyed", function(event) {self.location.href="index.php?site=project";});
	
	w1.show(true).focus();
	CKEDITOR.replace("value");
}

function OpenNewNewsWindow(id, name, desc)
{
	this.varID = id;
	//project.php?action=getText&id=18
	
	if(this.varID != "-1")
	{
		var header = "News Bearbeiten";
		Load("news.php?action=getText&id="+id, "data");
	}
	else
	{
		var header = "Neue News";
	}
	
	
	w1 = new UI.Window({ theme: 'vista', width: 500, height:670, top:10, left:((window.innerWidth/2)-250)});
	w1.setContent('<div id="result" style="margin-top:10px; margin-left:10px; margin-right:10px;"><h1>'+header+'</h1>'+
				'<form name="frmData">'+
				'<p>'+
				'<br />'+
				'<div><li>Name:</li></div><div><input type="text" name="name" value="'+name+'" width="80%"/></div><br />'+
				'<div>Text:</div><div><textarea id="data" name="value"></textarea></div>'+
				'</p>'+
				'<p>'+
				'<center><a href="#" onmouseover="return overlib(\'Speichern\');" onmouseout="return nd();">'+
				'<img src="images/icons/ok.png" alt="save" onclick="Save(\'news\');" style="align:center;"/></a>'+
				'<a href="#" onmouseover="return overlib(\'Abbrechen\');" onmouseout="return nd();">'+
				'<img src="images/icons/cancel.png" alt="cancel" onclick="w1.close();" style="align:center;"/></a></center>'+
				'</p>'+
				'</form></div>'); 
//
	w1.superflousEffects = true;
	w1.observe("destroyed", function(event) {self.location.href="index.php?site=news";});
	
	w1.show(true).focus();
	CKEDITOR.replace("value");
}

function Save(site)
{	
	var varName = document.frmData.name.value;
	var varValue = CKEDITOR.instances.data.getData(); 
	varValue = varValue.replace(/&/g, "%");
	
	if(this.varID != "-1")
	{
		//LoadPost(url, parameters, target); 
		LoadPost(site+".php", "action=saveedit&id="+varID+"&name="+varName+"&value="+varValue, "result");
	}
	else
	{
		LoadPost(site+".php", "action=save&name="+varName+"&value="+varValue, "result");
	}
	
	w1.setSize(120, 90, 20);
	w1.setPosition((window.innerHeight/2)-100,  (window.innerWidth/2)-100);
	window.setTimeout("w1.close();", 3000);
	
	window.setTimeout("self.location.href=\"index.php?site="+site+"\"", 3100);
}

