function InsertVideoTag(type)
{
	switch (type)
	{
		case 'mthai':
		case 'youtube':
		{
			var newWindow=window.open('#','',"top=100,left=100,width=250,height=100");
			newWindow.document.write("<title>Insert Video Tag</title>");
			newWindow.document.write("<script type='text/javascript'>function foo(){ var url=document.getElementById('url').value;					window.opener.AddVideoTag('"+type+"',url); window.self.close(); }</script>");
			newWindow.document.write("Link: <input type='text' id='url' value='ใส่ีURLของyoutubeที่นี่'/><input type='button' value='OK' onclick='foo();'/>");
		}break;
	}
}

function AddVideoTag(type,url)
{
	var str="["+type+"]"+url+"[/"+type+"]";
	var startpos=$e('Msg').selectionStart;
	var endpos=$e('Msg').selectionEnd;
	$e('Msg').value=$ev('Msg').substr(0,startpos)+str+$ev('Msg').substr(endpos);
	$e('Msg').setSelectionRange(startpos+str.length+1,startpos+str.length+1);
}
function $e(e){
	return document.getElementById(e);	
}
function $ev(e){
	return $e(e).value;	
}
