/*Copyright by Nguyen Duc Minh*/;
function mCopyright()
{
	try
    {
        if((''+top.location).indexOf('http://www.onip.vn/data/')>=0)top.location='http://www.onip.vn/vi/';
        document.getElementById('mEmbedAdv').style.display='block';
    }
    catch(e){}
	if((''+window.location).toLowerCase().indexOf('cache')>5)
	{
		window.status='Developed by Nguyen Duc Minh and mCMS group - http://www.onip.vn/';
		document.getElementById('mCMS').style.display='block'
	}
	else
		{
			var mc=0;
			mS = function()
			{
				mc=mc+1;
				if(mc>=18)
				{
				    window.status='Developed by Nguyen Duc Minh and mCMS group - http://www.onip.vn/';
    				if(mc==20){window.status='';mc=0;}
				}
				window.setTimeout('mS()',1000);
			}
			mS();
		}
}
var oIndex=0;
mCL = function ()
{
    document.getElementById('mT_'+oIndex).style.display='none';
    mItem(0);
}
function mMenu(k,i)
{
    if(k==1 || k==2)
    {
        //try
	    {
		    if(oIndex!=i)
		    {
			    try
                {
                    document.getElementById('mT_'+oIndex).style.display='none';
                    mItem(0);
                }
			    catch(es){}
			    oIndex=i;
		    }
            var M=document.getElementById('mT_'+oIndex);
		    if(M==null) return;
            var j=1;
		    mCL = function ()
		    {
			    if(j==2){M.style.display='none';mItem(0);}
			    else {M.style.display='block';mItem(1);}
		    }
		    if(k==1) 
		    {
			    var m8 =0, m9 = 0;
			    var P=document.getElementById('mPanel');
			    if (P.offsetParent) 
			    {
				    do 
				    {
					    m8 += P.offsetLeft
					    m9 += P.offsetTop
				    }
				    while (P = P.offsetParent);
			    }
                M.style.left=m8+'px';
                M.style.top=m9+'px';
			    setTimeout('mCL()','0');
		    }
		    else {j=2;setTimeout('mCL()','1000');}
	    }
	    //catch(e){}
    }
    else
    {
        mItem(k-2,i);
    }
}
function mItem(o,i)
{
    if(i==null) i=oIndex;
    if(o==1)
    {
         document.getElementById('mT'+i+'.1').style.display='none';
         document.getElementById('mT'+i+'.2').style.display='block';
    }
    else
    {
        document.getElementById('mT'+i+'.2').style.display='none';
        document.getElementById('mT'+i+'.1').style.display='block';
    }
}
function mMenuExt(i,j)
{
    if(j==1)
    {
        document.getElementById('mT_'+i+'.E0').style.display='none';
        document.getElementById('mT_'+i+'.E1').style.display='block';
    }
    else
    {
        document.getElementById('mT_'+i+'.E1').style.display='none';
        document.getElementById('mT_'+i+'.E0').style.display='block';
    }
}
function mLayer(o)
{
	var a=document.getElementById(o);
	var x = 0; var y=0;
	if (a.offsetParent) 
	{
		do
		{
			x += a.offsetLeft;
			y += a.offsetTop;
		}
		while (a = a.offsetParent);
	}
	a=document.getElementById(o+'_onip');
	a.style.left=x+'px';
	a.style.top=y+'px';
}
function mIE()
{
	if(document.all)
	{
		var o = document.getElementsByTagName('embed'); 
		for (var i = 0; i < o.length; i++)
			o[i].outerHTML = o[i].outerHTML; 
	}
}
function mVN(m)
{
	try
	{
		var i=1;
		C = function ()
		{
			if(i==2)
			{
				try{frames[0].window.document.mform.m[parent.mVm].checked=true;}
				catch(ef){}
				try{window.document.mform.m[mVm].checked=true;}
				catch(ep){}
				v.style.display='none';
			}
	        }
		v=document.getElementById('mVN');
		if(m==1) 
		{
			v.style.display='block';
			document.forms[0].m[mVm].checked=true;
		}
		else {i=2;setTimeout('C()','1000');}
	}
	catch(ee){}
}
function mVoteClick(p,l,i,n)
{
	var a='';var t=0;var o;
	if(p==1) o=document.getElementById('mL'+i);
	else if(p==3)o=document.getElementById('mR'+i);
	else o=document.getElementById('mM'+i);
	for(c=0;c<o.mVq.length;c++)
	{
		if(o.mVq[c].checked){++t;a=a+'T'+o.mVq[c].value;}
	}
	if(n==t)
	{
		o.mVoteBtn.disabled=true;
		if(l==8)
		{
			mAjax(null,'/vi/thamdo/');
            mAjax(null,'/vi/thamdo/'+i+'/','afor='+a);
            mViewClick(8,i);
		}
		else 
		{
			mAjax(null,'/en/poll/');
            mAjax(null,'/en/poll/'+i+'/','afor='+a);
            mViewClick(2,i);
		}
	}
	else
	{
		if(l==8)alert('Xin vui lòng chọn '+n+' đáp án!');
		else if(n==1) alert('Please select one answer!');
        else alert('Please select only '+n+' answers!');
	}
}
function mViewClick(l,i)
{
	if(l==8)mOpen('/vi/thamdo/'+i+'/','_mVoting');
	else mOpen('/en/poll/'+i+'/','_mVoting');
}
function mOpen(u,n,w,h)
{
    if(w==null)
    {
      if(n==null) n='_blank';
      window.showModalDialog(u,n,'center:yes;resizable:yes;scroll:no;status:no;dialogTop:100px;dialogLeft:200px;dialogHeight:180px;dialogWidth:425px;');
    }
    else
    {
        l=(screen.width-w)/2;if(l<0)l=0;
	    t=(screen.height-h-10)/2;if(t<0)t=0;
	    o=window.open(u,n,'width='+w+',height='+h+',left='+l+',top='+t+',status=no,toolbar=no,location=no,menubar=no,directories=no,resizable=no,scrollbars=yes,modal=yes');
	    if(!o.focus())o.focus(true);
    }
}
function mOpen_(u,n,w,h)
{
	x=(screen.width-w)/2;if(x<0)x=0;
	y=(screen.height-h-10)/2;if(y<0)y=0;
	o=window.open(u,n,'width='+w+',height='+h+',left='+x+',top='+y+',status=no,toolbar=no,location=no,menubar=no,directories=no,resizable=no,scrollbars=no');
	if(!o.focus())o.focus(true);
}
function onip()
{
    var a;
	try{a=new ActiveXObject('Msxml2.XMLHTTP');}
	catch(e)
	{
		try{a=new XMLHttpRequest();}
		catch (e)
		{
			try{a=new ActiveXObject('Microsoft.XMLHTTP');}
			catch(e)
			{
				alert('English: Error, Your browser do not support ajax.\n\nTiếng Việt: Lỗi, Trình duyệt của bạn không hỗ trợ ajax!');
				return null;
			}
		}
	}
    return a;
}
function mAjax(o,P,p)
{
	var a=onip();if(a==null) return;
	a.onreadystatechange=function()
	{
		if(a.readyState==4) if(o!=null) o.innerHTML=a.responseText;
	};
    if(p==null)
    {
	    a.open('GET',P,true);a.send(null);
    }
    else
    {
        a.open('POST',P,true);
        a.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        a.setRequestHeader('Content-length', p.length);
        a.send(p);
    }
}
function mGetLotteryData(o)
{
    if(typeof(oU)=='undefined')
    {
        window.location=window.location;
        return;
    }
    var a=onip();if(a==null) return;
    if(o<100) document.getElementById('mG'+o+'.0').innerHTML="<img src='/icons/wait.gif' class='x12'>Đang tải dữ liệu từ web site!";
	a.onreadystatechange=function()
	{
		if(a.readyState==4) 
        {
            ar=a.responseText.split('|');
            if(o<100)
            {
                if(ar.length>=9)
                {
                    if(o==0)
                    {
                        if(ar[0].length==8)
                        {
                           document.getElementById('mG0.0').innerHTML="<img src='/data/image/" + ar[0]+"/' class='x14'>";
                           if(ar[8]=='0') setTimeout('mGetLotteryData(0)',60000);
                        }
                        else {if(ar[7].length<2)mReturn(0,9);else mReturn(0,6);}
                        for(i=1;i<8;i++) document.getElementById('mG0.'+i).innerHTML="<table class='x05'><tr><td>"+ar[i].replace(/\//g,'</td><td>')+"</td></tr></table>";
                    }
                    else
                    {
                        if(ar[0].length==8)
                        {
                            document.getElementById('mG'+o+'.0').innerHTML="<img src='/data/image/" + ar[0]+"/' class='x14'>";
                            if(ar[9]=='0') setTimeout('mGetLotteryData('+o+')',60000);
                        }
                        else {if(ar[1].length<2)mReturn(o,9);else mReturn(o,6);}
                        for(i=1;i<9;i++) document.getElementById('mG'+o+'.'+i).innerHTML="<table class='x05'><tr><td>"+ar[i].replace(/\//g,'</td><td>')+"</td></tr></table>";
                    }
                    ar=ar.join('/').split('/');
                    var af = new Array();
                    var al = new Array();
                    var p='';
                    for(i=0;i<10;i++) {af[i]='';al[i]='';}
                    for(i=0;i<ar.length;i++)
                    {
                        p=ar[i];
                        if(p.length>1)
                        {
                            p=p.substring(p.length-2);
                            af[p.substring(0,1)]+=p+'<br>';
                            al[p.substring(1)]+=p+'<br>';
                        }
                    }
                    for(i=0;i<10;i++) {document.getElementById('mF'+o+'.'+i).innerHTML=af[i];document.getElementById('mL'+o+'.'+i).innerHTML=al[i];}
                }
                else {mReturn(o,9);}
            }
            else
            {
                if(ar.length==2)
                {
                    if(ar[1]=='0') setTimeout('mGetLotteryData('+o+')',30000);
                    if(ar[0].length>1)
                    {
                        if(o!=794) document.getElementById('mG'+o+'.0').innerHTML="<table class='x05'><tr><td>"+ar[0].replace(/\//g,'</td><td>')+"</td></tr></table>";
                        else document.getElementById('mG'+o+'.0').innerHTML = ar[0];
                    }
                }
            }
        }
	};
    var d = new Date();
	a.open('POST','/data/lottery/'+oU+'/?o='+d.getFullYear()+d.getMonth()+d.getDate()+d.getHours()+d.getMinutes()+d.getSeconds(),true);
    a.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    var p='q='+o;
	a.setRequestHeader('Content-length', p.length);
	a.send(p);
}
function mOnOff(o,i)
{
    if(i==1)
    {
        document.getElementById('mB'+o+'.1').style.display='block';
        document.getElementById('mB'+o+'.2').style.display='none';
    }
    else if(i==2)
    {
        document.getElementById('mB'+o+'.1').style.display='none';
        document.getElementById('mB'+o+'.2').style.display='block';
    }
    else
    {
        document.getElementById('mB'+o+'.1').style.display='none';
        document.getElementById('mB'+o+'.2').style.display='none';
    }
}
function mReturn(o,i)
{
    document.getElementById('mG'+o+'.0').innerHTML="<img src='/icons/sandclock.gif' class='x12'>Hệ thống tự động nạp lại dữ liệu sau <span id='sec."+o+"'>"+i+"</span> giây!";setTimeout('mCountdown('+o+','+i+')',1000);
}
function mCountdown(o,i)
{
	if(i>1) {--i;document.getElementById('sec.'+o).innerHTML=i;setTimeout('mCountdown('+o+','+i+')',1000);}
	else mGetLotteryData(o);
}
function mBookmarks()
{
	if (window.sidebar) {window.sidebar.addPanel('Kết quả xổ số OnIP','http://www.onip.vn/vi/xoso/','');} 
	else if(window.external) {window.external.AddFavorite('http://www.onip.vn/vi/xoso/','Kết quả xổ số OnIP');}
	else alert('Lỗi, không thêm được vào Bookmarks hoặc Favorites!');
}
var mGe=0;
function mGetExt(l,a,i,p)
{
	var o=document.getElementById('mContentExt');
	if(l==8)
	{
		switch(a)
		{
			case 1: if(o!=null)
                    {
                        if(mGe!=1) {o.innerHTML='<iframe src="/vi/guibanbe/" border="0" frameborder="0" class="m96"></iframe>';mGe=1;}
				        else {o.innerHTML='';mGe=0;}
                    }
				    break;
			case 2: if(mGe!=2) {o.innerHTML='<iframe src="/vi/phanhoi/banbientap/" border="0" frameborder="0" class="m97"></iframe>';mGe=2;}
				    else {o.innerHTML='';mGe=0;}
				    break;
			case 3: if(mGe!=3) {o.innerHTML='<iframe src="/vi/phanhoi/baiviet/'+i+'/" border="0" frameborder="0" class="m98"></iframe>';mGe=3;}
				    else {o.innerHTML='';mGe=0;}
				    break;
			case 4: if(mGe!=4) {if(p==null) p=1;mAjax(o,'/vi/phanhoi/baiviet/'+i+'/','p='+p);mGe=4;}
				    else {o.innerHTML='';mGe=0;}
				    break;
		}
	}
	else
	{
		switch(a)
		{
			case 1: if(mGe!=1) {o.innerHTML='<iframe src="/en/sendtofriend/" border="0" frameborder="0" class="m96"></iframe>';mGe=1;}
				    else {o.innerHTML='';mGe=0;}
				    break;
			case 2: if(mGe!=2) {o.innerHTML='<iframe src="/en/feedback/editorialstaff/" border="0" frameborder="0" class="m97"></iframe>';mGe=2;}
				    else {o.innerHTML='';mGe=0;}
				    break;
			case 3: if(mGe!=3) {o.innerHTML='<iframe src="/en/discussion/article/'+i+'/" border="0" frameborder="0" class="m98"></iframe>';mGe=3;}
				    else {o.innerHTML='';mGe=0;}
				    break;
			case 4: if(mGe!=4) {if(p==null) p=1;mAjax(o,'/en/discussion/article/'+i+'/','p='+p);mGe=4;}
				    else {o.innerHTML='';mGe=0;}
				    break;
		}
	}
}
function mToSearchPage(m,n)
{
    a=document.mform;
    if(n==0)
    {
        s=document.forms['mSP'].mPg;
        a.mPageId.value=s.options[s.selectedIndex].value;
    }
    else a.mPageId.value=n;
    a.mSubmit.click();
}
function mResize(id)
{
	mObj=document.getElementById(id);
    if(document.all)
    {
        window.dialogWidth=mObj.clientWidth+60+'px';
        window.dialogHeight=mObj.clientHeight+60+'px';
    }
    else
    {
	    this.window.resizeTo(mObj.clientWidth+60,mObj.clientHeight+80);
	    this.window.moveTo((screen.width-mObj.clientWidth-60)/2,(screen.height-mObj.clientHeight-80)/2);
    }
}
function mInOut(o,i)
{
    document.images[o].src='/mfiles/icons/'+i;
}
function mShowTab(i)
{
    if(i==1)
    {
        if(document.getElementById('m5561').style.display=='none')
        {
            document.getElementById('m5561').style.display='block';
            document.getElementById('m5552').className='m5552';
            document.getElementById('m5555').className='m5555';
            document.getElementById('m5562').style.display='none';
        }
    }
    else 
    {
        if(document.getElementById('m5562').style.display=='none')
        {
            document.getElementById('m5562').style.display='block';
            document.getElementById('m5552').className='m5553';
            document.getElementById('m5555').className='m5556';
            document.getElementById('m5561').style.display='none';
        }
    }
}
function mToPage(r)
{
    f=document.mPL;
    if(r){if(typeof(f.mPageId)=='object') f.mPageId.value=1;}
    f.submit();
}
function mResize_(id)
{
	mObj=document.getElementById(id);
	this.window.resizeTo(mObj.clientWidth+12,mObj.clientHeight+50);
	this.window.moveTo((screen.width-mObj.clientWidth-40)/2,(screen.height-mObj.clientHeight-50)/2);
	this.window.focus(true);
}
function mPlay(p,w,h)
{
		var mOk;
		if (window.ActiveXObject) 
		{
			try {mOk = new ActiveXObject("MediaPlayer.MediaPlayer.1");}
			catch(e){}
		}
		else if (window.GeckoActiveXObject)
		{
			try {mOk = new GeckoActiveXObject("MediaPlayer.MediaPlayer.1");}
			catch(e)
			{
				try{mOk = navigator.mimeTypes["application/x-mplayer2"].enabledPlugin;}
				catch(ee){}
			}
		}
		else
		{
			try{mOk = navigator.mimeTypes["application/x-mplayer2"].enabledPlugin;}
			catch(e){}
		}
		if(mOk) 
		{
			document.write('<object id="mPlayer" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" height="'+h+'" width="'+w+'"><param name="url" value="'+p+'"><param name="uiMode" value="full"><param name="mute" value="false"><PARAM NAME="volume" VALUE="100"><param name="ShowControls" value="1"><param name="ShowStatusBar" value="1"><param name="ShowDisplay" value="1"><embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="'+p+'" name="mPlayer" id="mPlayer" autostart="true" showcontrols="1" showstatusbar="1" showdisplay="0" height="'+h+'" width="'+w+'"></embed></object>');
		}
		else 
		{
			document.write('<p class="m9231">Lỗi, Trình duyệt hiện tại của bạn không hỗ trợ chạy trực tiếp file media. Xin vui lòng thiết lập các tham số phù hợp ho\u1EB7c chọn phiên bản ho\u1EB7c trình duyệt khác hỗ trợ ch\u1EE9c năng này. Bạn có thể chạy trực tiếp theo đư\u1EDDng d\u1EABn:<br><br> http://www.onip.vn' +p+'<br><br>Để có thêm thông tin xin liên hệ với ban quản tr\u1ECB website!');
		}
}
mIE();mCopyright();
            
