﻿var domain = 'http://vitinfo.com.vn'
function setHomepage()
{
    if (document.all)
    {
        document.body.style.behavior='url(#default#homepage)';
        document.body.setHomePage(domain);
    }
    else if (window.sidebar)
    {
        if(window.netscape)
        {
            try
            {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch(e)
            {
                alert("Xin lỗi!\nTrình duyệt của bạn không cho phép tự động đặt trang chủ\nNhấn Ctrl + D để lưu VITINFO vào BookMarks");
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage',domain);
        }
} 

function redirectURL(url)
{
    var Furl = domain + url;
    window.open(Furl);
}

function OntxtKeyPress(txtname)
{
    var e;
    e = window.event.keyCode;
    if(e == 13)
    {
        redirect_search(txtname);
        return;
    }
}

function redirect_search(txtname)
{
    var txt = document.getElementsByName(txtname);
    var url = domain + '/search/?ch=' + txtname.value + '&page=1&d=1&c=7';
    window.location=url;
}
function redirect_day(day,month,year,lienquan)
{ 
    var val= document.forms['form1'].elements['lienquan'].options[document.forms['form1'].elements['lienquan'].selectedIndex].value;     
    var x=new Array();
    var url; 
        x=val.split(';');    
     if(x[0]=='1')
        url = domain + '/DMuctin/Day/'+ day.value + '_' + month.value + '_' + year.value +'_' + x[1] +'/1/default.htm';
     else if(x[0]=='2' && x[1]!='0')    
        url=domain + '/CMuctin/Chuyende/'+ day.value + '_' + month.value + '_' + year.value +'_' + x[1] +'/1/default.htm';         
     else if(x[0]=='3' && x[1]!='0')    
        url=domain + '/CMuctin/Tindacbiet/'+ day.value + '_' + month.value + '_' + year.value +'_' + x[1] +'/1/default.htm';  
     else if(x[0]=='4' && x[1]!='0')    
        url=domain + '/CMuctin/Quantamykien/'+ day.value + '_' + month.value + '_' + year.value +'_' + x[1] +'/1/default.htm';  
     else  if(x[0]=='0' && x[1]=='0')      
        url=domain + '/Home/'+ month.value  + '_' + day.value + '_' + year.value + '/default.htm';
     else  if(x[0]=='51' && x[1]=='51')      
        url=domain + '/Ykien/'+ day.value + '_' + month.value + '_' + year.value + '/1/default.htm';
     else
        url=domain + '/Pages/Error/default.htm';
    window.location=url;
}
function redirect_lienquan(day,month,year,lienquan)
{ 
    var val= document.forms['form1'].elements['lienquan'].options[document.forms['form1'].elements['lienquan'].selectedIndex].value;          
    var x=new Array(); 
    var url; 
        x=val.split('_'); 
    if(x[0]=='1' && x[1]!='0')
      url=domain + '/CMuctin/Chuyende/'+ day.value + '_' + month.value + '_' + year.value +'_' + x[1] +'/1/default.htm';
    else if(x[0]=='2')
       url=domain + '/DMuctin/Day/'+ day.value + '_' + month.value + '_' + year.value +'_' + x[1] +'/1/default.htm';
    else if(x[0]=='3' && x[1]!='0' )    
       url=domain + '/CMuctin/Tindacbiet/'+ day.value + '_' + month.value + '_' + year.value +'_' + x[1]  +'/1/default.htm';                            
    else if(x[0]=='4' && x[1]!='')
      url=domain + '/LMuctin/Lienquan/'+x[1]+'/1/default.htm';  
    else if(x[0]=='5' && x[1]!='0')    
       url=domain + '/CMuctin/Quantamykien/'+ day.value + '_' + month.value + '_' + year.value +'_' + x[1] +'/1/default.htm';      
    else if(x[0]=='6' && x[1]=='0')
        url = domain + '/DMuctin/Day/'+ day.value + '_' + month.value + '_' + year.value +'_' + '0' +'/1/default.htm';
    else  if(x[0]=='0' && x[1]=='0')      
        url=domain + '/Home/'+ (month.value>=10?month.value+'':'0'+month.value) + '_' + (day.value>=10?day.value+'':'0'+day.value) + '_' + year.value + '/default.htm';
    else  if(x[0]=='51' && x[1]=='51')      
        url=domain + '/Ykien/'+ day.value + '_' + month.value + '_' + year.value + '/1/default.htm';
    else
        url=domain + '/Pages/Error/default.htm'; 
    window.location=url;
}

function thamdoykien(macauhoi,chieucao)
{ 
     var url = domain + '/Dichvu/Ketquathamdo.aspx?ch=' + macauhoi;
     var property;
     if (navigator.userAgent.indexOf('Firefox') != -1)
     {
        property ='help:no;status=0;center:Yes;resizable:no;dialogHeight:' + (chieucao * 22 + 180) + 'px;dialogWidth:600px;';
     }
     else
     {
        property ='help:no;status=0;center:Yes;resizable:no;dialogHeight:' + (chieucao * 22 + 220) + 'px;dialogWidth:600px;';
     }
     window.showModalDialog(url,'Biểu đồ',property);  
}

function updatetraloi(macauhoi,radiotraloi,chieucao)
{
    var property;
    var tl ='';
    var rdo = document.getElementsByName(radiotraloi);
    for(var i=0;i<rdo.length;i++)
    {
        if(rdo[i].checked)
        {
            tl += rdo[i].value + ',';
        }
     }
    if(tl=='')
    {
        alert('Vui lòng chọn một phương để biểu quyết');
        return;
    }
    var url = domain + '/Dichvu/Ketquathamdo.aspx?ch=' + macauhoi + '&tl=' + tl;
    if (navigator.userAgent.indexOf('Firefox') != -1)
    {
        property ='help:no;status=0;center:Yes;resizable:no;dialogHeight:' + (chieucao * 22 + 180) + 'px;dialogWidth:600px;';
    }
    else
     {
         property ='help:no;status=0;center:Yes;resizable:no;dialogHeight:' + (chieucao * 22 + 220) + 'px;dialogWidth:600px;';
     }
    window.showModalDialog(url,'',property); 
}
