﻿var cbase = '../mviet/';
////mviet
var MVOnButton = "<img name='onbutton' src='./mviet/on.gif' + onClick='MVOff = true ;MVietOnOff.innerHTML=MVOffButton;' alt='Turn On'>";
var MVOffButton = "<img name='offbutton' src='./mviet/off.gif'  onClick='MVOff = false; MVietOnOff.innerHTML=MVOnButton;' alt='Turn Off'>";

function hiliAll(){

editor.focusEditor();
var txtHtml = editor.getSelectedHTML();
if (txtHtml==null ||txtHtml.length==0) { 
   if(document.all){ var srcG=editor._doc.body; 
     text = srcG.createTextRange(); //for htnlArea
     text.select(); 
   } else {alert('Please hi-light by mouse'); return;}
   return( editor.getSelectedHTML());
}
}

function checkBDCD(){
var bdcn = BoDauMV;
editor.focusEditor();
var txtHtml = editor.getSelectedHTML();
if (txtHtml==null ||txtHtml.length==0) { 
   if(document.all){ var srcG=editor._doc.body; 
     text = srcG.createTextRange(); //for htnlArea
     text.select(); 
   } else {alert('Please hi-light by mouse'); return;}
   txtHtml=editor.getSelectedHTML();
}

if (txtHtml!=null) {
   txtHtml = txtHtml.replace(/&nbsp;/ig, " ");
   txtHtml = txtHtml.replace(/&quot;/ig, '"');
   txtHtml = txtHtml.replace(/&amp;/ig, "&");
   
   editor.insertHTML(document.VietInterface.getViet(txtHtml, 1, 0, bdcn, 0), 0);
   }
}

function DisplayBDCN (){
	
var bD = BoDauMV.split('|');
var bDTit= "&nbsp;Sắc&nbsp;|&nbsp;Huyền&nbsp;|&nbsp;Hỏi&nbsp;|&nbsp;Ngã&nbsp;|&nbsp;Nặng&nbsp;|&nbsp;Nón&nbsp;|&nbsp;Móc&nbsp;|&nbsp;Trăng&nbsp;|&nbsp;Gạch&nbsp;|&nbsp;Xóa&nbsp;|&nbsp;Thoát&nbsp;|&nbsp;Thay&nbsp;|<font color=Red>&nbsp;SOS&nbsp;</font>".split('|');
var strBDCN="<table border='1' cellspacing='0' cellpadding='0'><tr>"; 
    var headMV = "<td align='center' bgcolor='#E7e7e7'>" + "<SPAN CLASS='TitleDau'> ";
    var headRedMV = "<td align='center' bgcolor='#FFe7e7'>" + "<SPAN CLASS='TitleDau'> ";
   var tailMV = "</SPAN><br><SPAN CLASS='Dau'>";
   var endMV = "</SPAN></td>";
for (var i =0; i< 11; i++){ 
  if (bD[i].length==0) bD[i]="&nbsp;";
  strBDCN  += headMV+ bDTit[i]+ tailMV+ bD[i]+ endMV; 
}
strBDCN  += headRedMV+ bDTit[11]+ tailMV
strBDCN  += "<img src='mviet/images/n_pencil.gif' onClick=\"showboxMV();if (document.all) showimage.innerHTML=Kh1+iFr1+mvKG+iFr2+Kh2; else document.getElementById('showimage').innerHTML=Kh1+iFr1+mvKG+iFr2+Kh2;\" alt='Kiểu gõ'  width='12' height='15'>" + endMV; 
strBDCN  += headMV+ "<input name='SOS' type='button' value='SOS' class='mvbutton2' onClick='window.focus();checkBDCD();'>" +tailMV
	
strBDCN  += "</tr></table>";
  return strBDCN;	
}

var LoadChonDau  = "<APPLET code=VietInterfaceIE5.class height=1 width=1 NAME=VietInterface ARCHIVE = 'VT70.jar' ALT='Your browser understands the applet tag but is not displaying any applet.' codebase='"+cbase+"'><param name='code' value='VietInterfaceIE5.class'><param name='height' value='1'><param name='width' value='1'><param name='name' value='VietInterface'><param name='archive' value='VT70.jar'><param name='alt' value='our browser understands the applet tag but is not displaying any applet.'><param value='codebase' value='"+cbase+"'></APPLET>";

function MVietOnOffButton (){
  if (MVOff) {
     MVietOnOff.innerHTML=MVOffButton;
   } else {
     MVietOnOff.innerHTML=MVOnButton;
   }
}

var Kh1 ="<table border='0' bgcolor='#92BACF' cellspacing='0' cellpadding='1'><tr><td width='100%'><table border='0' width='100%' cellspacing='0' cellpadding='0' height='36'><tr><td id='dragbar' style='cursor:hand' width='100%' height='17'><ilayer width='100%' nSelectStart='return false'><layer width='100%' onMouseover='dragswitch=1;if (ns4) drag_dropns(showimage)' onMouseout='dragswitch=0' id='mvlayer'><a href='http://mviet.cjb.net' target='0' style='text-decoration:none'><font face='Verdana' color='#FFFFFF'><strong><small>&nbsp;MViet</small></strong></font></a></layer></ilayer></td><td style='cursor:hand'><a href='#' onClick='hidebox();parent.HNWindow=0; return false'><img src='mviet/images/n_close.gif' width='14' height='14' border=0 style='position:relative;left:-1'></a></td></tr><tr><td width='100%' class='mvtable' style='padding:4px' colspan='2'>";
var Kh3="<table bgcolor='white' cellspacing='0' border='0' align='center'><tr><td width='380' height='135' nowrap align='center' valign='middle'>";

var Kh2 ="</td></tr></table></td></tr></table>";
var iFr1 ="<iframe src='" + "mviet/features/"; 
var mvKG = "kieugo.htm' width=380 height=100 align=center";
var mvTK = "tocky.htm' width=400 height=135 align=center";
var mvHN = "hoinga.htm' width=400 height=125 align=center";
var mvTD = "tudien.htm' width=140 height=90 align=center";
var mvHC = "hoanchuyen.htm' width=230 height=95 align=center";
var mvTT = "timthe.htm' width=220 height=95 align=center";
var iFr2 = " frameborder='0' id='mvframe' marginwidth='0' marginheight='0' scrolling='no'></iframe>";

//Popup Box- By Jim Silver @ jimsilver47@yahoo.com
//http://www.dynamicdrive.com
var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById && !document.all
var iens6=document.all||document.getElementById;
//drag drop function for NS 4////
var dragswitch=0
var nsx
var nsy
var nstemp


function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for ie4+ and NS6////

function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx
crossobj.style.top=tempy+e.clientY-offsety
return false
}
}

function initializedrag(e){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage

var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "HTML" : "BODY"

while (firedobj.tagName!=topelement&&firedobj.id!="dragbar"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}

if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")

////drag drop functions end here//////

function hidebox(){
var crossobj=ns6? document.getElementById("showimage") : document.all.showimage

crossobj.style.visibility="hidden";

}

function showboxMVX(){
	//alert("here");
if (ie4||ns6){
var crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage;
//alert("here");
  crossobj.style.visibility="visible";
}else if (ns4)
document.showimage.visibility="visible"
}
