/**
 * inSiteEditor 1.0, written by iN-MEDiA Freibeuter e.K. OKT 2009. Licensed to Dr. Ulrich Schnorrenberg, 1 License.
 **/

var winlocation = window.location;
var editorExpression = /#bearbeiten/gi;
var editoractive = editorExpression.test(winlocation);
var editorid = "editorView";
var backup = "";

var ie = (document.all && document.getElementById) ? true : false; // muss leider so gesetzt werden, ie erhaelt sonst object

// write needed editor layer into HTML code
document.open();
document.write("<div id=\"editorView\" style=\"position: absolute; top: 230px; left: 0px; " +  // war absolute
				"width: 640px; height: 400px; background-color: white; border: 4px solid red; " +
				"padding: 0px; display: none; z-index: 100;\"></div>\n");
document.close();

function setEditoractive(boo){
	window.onresize = setEditoractive;
    var view = document.getElementById("editorView");    
	var content = document.getElementById("ContentE");
	view.style.display = (editoractive) ? "" : "none";
	
	if(editoractive){
    
        var width = (ie) ? document.body.clientWidth : window.innerWidth;
        var height = (ie) ? document.body.clientHeight : window.innerHeight;
        view.style.left = (((width-1060)/2)+370) + "px";
		view.style.height = (height-275) + "px";		

		if(!boo){
			backup = (backup == "") ? content.innerHTML : backup;
			content.innerHTML = "";
			view.innerHTML = "<iframe frameborder=no border=0 framespacing=0 marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 style=\"width:100%;height:100%;\" scrolling=no src=\"edit_or/site_editor.php?q=test\"></iframe>"		
		}

	} 
	else {
		if(backup != ""){
			content.innerHTML = backup;
		}
	}
}

function setupResizeBehaviour(){
	window.onresize=setEditoractive(true);
}