
function createPopupWindow(width)
{
	closePopupWindow();
	var elm=document.createElement("div");
	elm.style.position="fixed";
	elm.style.zIndex="10";
	elm.style.left="50%";
	elm.style.marginLeft=(-1*width/2)+"px";
	elm.style.marginRight="auto";
	elm.style.width=width+"px";
	//elm.style.height="750px"
	elm.style.border="thin solid rgb(0,0,0)";
	elm.style.top="10px";
	elm.style.maxHeight="100%";
	elm.style.overflow="hidden";
	elm.style.display="block";
	elm.style.backgroundColor="#FFFFFF";
	elm.id="popupwindow";
	
	document.body.appendChild(elm);
	
	return elm;
}

function closePopupWindow()
{
	var elm=document.getElementById("popupwindow");
	if(elm)
	{
		elm.parentNode.removeChild(elm);
		elm.id="";
	}
}

function setEditWindowContent(content)
{
	
	win=document.getElementById('popupwindow');
	win.style.height="";
	win.innerHTML=content;
	win.style.height=win.clientHeight+10+"px";
}

function makeEditWindow(id)
{
	var win=createPopupWindow(740);
	var text=ajaxRequestData("geteditcode "+id);
	setEditWindowContent(text)
	
	
}


function refreshBox(id)
{
	var box=document.getElementById("box_"+id);
	var parent=box.parentNode;
	var next=box.nextSibling;
	
	box.parentNode.removeChild(box);
	
	var nid=box.id;
	box.id="";
	box.removeChild(box.firstChild);
	
	shadow.innerHTML=ajaxRequestData("getboxcode "+id);
	if(!shadow.firstChild.style)
		shadow.removeChild(shadow.firstChild);
	box=shadow.firstChild;
	
	box.id=nid;
	
	
	makeModifiable(box);
	
	Boxes.push(box);
	
	refreshArrays();
	
	box.parentNode.removeChild(box);
	
	parent.insertBefore(box,next);
	
	activateBoxEditMode();
	
	fitRowSizes();
	
	
}

/*
function makeEditor(infoboxid)
{
	var oEdit1 = new InnovaEditor("oEdit1");
	//oEdit1.cmdAssetManager="modalDialogShow('_admin/Editor/assetmanager/assetmanager.php',640,445);";
	//oEdit1.btnSpellCheck=true;
	oEdit1.btnClearAll=true;
	oEdit1.btnMedia=true;
	oEdit1.btnFlash=true;
	oEdit1.REPLACE(infoboxid);
}
*/

//Color picker object
var cp;
function setupInlineEdit()
{
	cp=new ColorPicker;
	cp.writeDiv();
}

function popupPicker()
{
	var cpdiv=document.getElementById('colorPickerDiv');
	cpdiv.style.zIndex='20';
	cpdiv.style.position='fixed';
	
	cpdiv.style.top=mousePos.y+'px';
	cpdiv.style.left=mousePos.x+'px';
}

function loadSpecial()
{
	var loadcode=document.getElementById("loadspecial");
	
	if(loadcode)
		eval(loadcode.text);
}


