function GetDialogWin(my_url,win_name,width_x,height_y,top_pos,left_pos,scrollbars)
 {
 var editwin = "";editwin = editwin + "width=" + width_x;editwin = editwin + ",height=" + height_y;editwin = editwin + ",resizable=yes";	editwin = editwin + ",scrollbars=yes";editwin = editwin + ",menubar=no";editwin = editwin + ",toolbar=no";editwin = editwin + ",directories=no";editwin = editwin + ",location=no";editwin = editwin + ",status=no";editwin = editwin + ",top=" + top_pos;editwin = editwin + ",left=" + left_pos;editwin_win = window.open(my_url,win_name,editwin);editwin_win.focus();editwin_win.opener = self;return (editwin_win);
}

var sT 
function changeUrl(surl)
{
	if(surl == "")
		return(false);
	sT.text = "<a href=\"" +surl+ "\" target=_blank>"+ sT.text + "</a>";
	return(true);
}

function createLink()
{
	sT = document.selection.createRange();	
	sTxt = sT.text;  
	if(!sTxt.length > 0)
	{
		alert("select the text that you want to use as link!");
		return( false);
	}
	var mywin = GetDialogWin('','tetst',350,110,50,150,'no');
	mywin.document.title="Insert Link";	
	mywin.document.writeln("<font face=\"verdana\" size=1>");
	mywin.document.writeln("<b>" + sTxt + "</b>");
	mywin.document.writeln("<br />Type the link address:");
	mywin.document.writeln("<br /><input type=text name=\"vtxt2\" size=\"35\" value=\"http://www.web-graphics.net\">");
	mywin.document.writeln("<input type=button value=\"Ok\" onClick=\"opener.changeUrl(vtxt2.value);window.close();\">");
	mywin.document.writeln("<br><input type=button value=\"CheckLink\" onClick=\"opener.GetDialogWin(vtxt2.value,'CheckUrl',550,310,150,250,'no');\">");
	
}

function makeBold()
{
	sT = document.selection.createRange();	
	sTxt = sT.text;  
	if(!sTxt.length > 0)
	{
		alert("select the text that you want to format first!");
		return( false);
	}
	sT.text = "<strong>" + sTxt + "</strong>";
}
function makeItalic()
{
	sT = document.selection.createRange();	
	sTxt = sT.text;  
	if(!sTxt.length > 0)
	{
		alert("select the text that you want to format first!");
		return( false);
	}
	sT.text = "<i>" + sTxt + "</i>";
}
function makeBigger()
{
	sT = document.selection.createRange();	
	sTxt = sT.text;  
	if(!sTxt.length > 0)
	{
		alert("select the text that you want to format first!");
		return( false);
	}
	sT.text = "<big>" + sTxt + "</big>";
}
function makeSmaller()
{
	sT = document.selection.createRange();	
	sTxt = sT.text;  
	if(!sTxt.length > 0)
	{
		alert("select the text that you want to format first!");
		return( false);
	}
	sT.text = "<small>" + sTxt + "</small>";
}

function unFormat()
{
	var outtext = "";
	var flag = 0;
	var i = 0;
	sT = document.selection.createRange();	
	sTxt = sT.text; 
	if(!sTxt.length > 0)
	{
		alert("select the text that you want to un-format first!");
		return( false);
	}
	while(i <= sTxt.length)
	{	
		c = sTxt.charAt(i)
		if(c == "<")
			flag++;
		if(flag==0)
			outtext += c;
		if(c == ">")
			flag--;		
		i++;
	}
	if(flag==0)
		sT.text = outtext;
	else 
		alert("error");
}
function insertsmily(smilyface)
{
	document.write.meddelande.value+=smilyface;
}
