var oEditor;
var temp;
var sInitColor = null;
var szin;
var TempString;

function init()
{
	if (document.all)
	{
	frames['szerk'].document.designMode = "On";
	oEditor = frames['szerk'];
	}
	else
	{
	contentDocument = document.getElementById('szerk').contentDocument;
	contentDocument.designMode = "on";
	oEditor = document.getElementById('szerk').contentWindow;
    edit.document.close();
	}
}
function getszin()
{
	szin = Skala.ChooseColorDlg();
	var szin = szin.toString(16);
	if (szin.length < 6) 
		{
		var sTempString = "000000".substring(0,6-szin.length);
  		szin = sTempString.concat(szin);
		}
	return szin;
}

function formaz(milyen)
{
	switch (milyen)
	{
	case "felkover":
		oEditor.document.execCommand('bold', false, null);
		break;
	case "dolt":
		oEditor.document.execCommand('italic', false, null);
		break;
	}
}
function igazit(hova)
{
	switch (hova)
	{
	case "balra":
		oEditor.document.execCommand('justifyleft', false, null);
		break;
	case "kozepre":
		oEditor.document.execCommand('justifycenter', false, null);
		break;
	case "jobbra":
		oEditor.document.execCommand('justifyright', false, null);
		break;
	case "sorkizart":
		oEditor.document.execCommand('justifyfull', false, null);
		break;
	}
}
function szovegszin(szin)
{
	szin=getszin();
	var szelekt = document.selection.createRange();
	oEditor.focus();
	oEditor.document.execCommand("ForeColor","false", szin);
}
function betumeret(meret)
{
	
	if (meret==null)
	{
		meret = document.urlap.meret.value;
		oEditor.document.execCommand("FontSize",false,meret);
	}
	else
	{
		oEditor.document.execCommand("FontSize",false,meret);
	}
}
function betutipus(tipus)
{
		
	if (tipus==null)
	{
		tipus = document.urlap.tipus.value;
		oEditor.document.execCommand("FontName",false,tipus);
	}
	else
	{
		oEditor.document.execCommand("FontName",false,tipus);
	}

}
function hatterszin(szin)
{
	szin=getszin();
	var szelekt = document.selection.createRange();
	oEditor.focus();
	oEditor.document.execCommand("BackColor","false", szin);
}

function kep(helye)
{
	oEditor.focus();
	oEditor.document.execCommand('InsertImage', false, helye);
	oEditor.focus();
}

function kepbeszur()
{
	win2=window.open('includes/cikkkep.php','','width=300,height=500,left=150,top=0');
	win2.cel=document.getElementById('kepnev');
}

function hivatkozas(link)
{
	oEditor.focus();
	oEditor.document.execCommand('CreateLink', false, link);
}
function hiddenbe()
{
	adat = document.szerk.document.body.innerHTML;	
	document.urlap.adat.value = adat;
}