
function setFormatDD(instance, rowformat,cellformat)
{

var ddobj = eval("document.all['" + instance+ "_AuthoringModeControlsContainer_formatdd']");
var scopeddobj = eval("document.all['" + instance+ "_AuthoringModeControlsContainer_formatscopedd']");

if (ddobj || scopeddobj)
{
	var c=0;
	var selindex = 0;
	var selType = "";
		
	if (rowformat!='')
	{
		
		for (c=0;c<ddobj.length;c++)
		{
			if (ddobj.options[c].value == rowformat)
			{
				selindex = c;
				ddobj.options[c].selected = true;
			}
		}
		selType = "row"


	}
	else if (cellformat!='')
	{
		for (c=0;c<ddobj.length;c++)
		{
			if (ddobj.options[c].value == cellformat)
			{
				selindex = c;
				ddobj.options[c].selected = true;
			}
		}
		selType = "col"
	}
	
	
	if (selindex==0)
		ddobj.options[selindex].selected = true;
	
	for (c=0;c<scopeddobj.length;c++)
	{
		if (scopeddobj.options[c].value == selType)
		{
			
			scopeddobj.options[c].selected = true;
		}
	}
}	
	
}

function setCellAsActive(instance, cellid,rowformat, cellformat)
{

	setFormatDD(instance, rowformat,cellformat);

	var obj = eval("document.all['" + instance + "_AuthoringModeControlsContainer_"+instance+"_active']");
		
	if (obj.value.length>0) 
	{
		var spanobjold = eval("document.all['"+obj.value+"']");
		spanobjold.style.background="#FFFFFF";
	}
	
	var spanobj = eval("document.all['"+cellid+"']");
	spanobj.style.background="#E6E6E6";
	
	
	obj.value = cellid;
	obj.designMode = "on";	
	obj.contentEditable = true;


	// Not implemented yet. We need to send information about active container..
	//obj.document.onkeydown = CtrlVCheck2;
	//obj.document.onkeyup = CtrlVCheck;
	//obj.document.oncontextmenu='return false;';

}

function setActive(instance)
{
	var obj = eval("document.all['" + instance + "_AuthoringModeControlsContainer_"+instance+"_active']");
	
	if (obj.value.length>0) 
	{
		var spanobj = eval("document.all['"+obj.value+"']");
		spanobj.style.background="#E6E6E6";
	}

}


function getActive(instance)
{
	var obj = eval("document.all['" + instance + "_AuthoringModeControlsContainer_"+instance+"_active']");
	if (obj.value.length>0) 
		{
			return obj.value;
		}
	else
	{
	return "";
	}
}

function saveTable(instance)
{

	if (eval("document.all['" + instance + "_edittable']"))
	{
		var objTable = eval("document.all['" + instance + "_edittable']");
		var tablecontent = new String(objTable.innerHTML);

		
		var objContainer = eval("document.all['" + instance + "_AuthoringModeControlsContainer_" + instance + "_tablecontent']");
		
		if (objContainer) 
			objContainer.value = tablecontent;
	}
	else
	{
	alert("Debug: Cant get access to edittable: layer");
	}	
	return true;
}