﻿// JScript File
var is_ie = ( /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) );
var is_ie5 = ( is_ie && /msie 5\.0/i.test(navigator.userAgent) );
var is_ie6 = ( is_ie && /msie 6\.0/i.test(navigator.userAgent) );
var is_ie7 = ( is_ie && /msie 7\.0/i.test(navigator.userAgent) );
var is_opera = /opera/i.test(navigator.userAgent);
var is_khtml = /Konqueror|Safari|KHTML/i.test(navigator.userAgent);
var is_xp=/windows NT 5\.1/i.test(navigator.userAgent);
function LTrim( value ) {var re = /\s*((\S+\s*)*)/;return value.replace(re, "$1");}
function RTrim( value ) {var re = /((\s*\S+)*)\s*/;return value.replace(re, "$1");}
function trim( value ) {return LTrim(RTrim(value));}
function $get(id) {return document.getElementById(id);}
function selectTab(id){$get(id+"l").className="tsl fl";$get(id+"c").className="tsc fl ar s10 b clg d";$get(id+"r").className="tsr fl";}

  function m_over(id)
    {
        $get(id).style.display="";
    }
    function m_out(id)
    {
        $get(id).style.display="none";
    }
    function fmenu_over(obj)
    {
        obj.className="lcb u";
    }
    function fmenu_out(obj)
    {
        obj.className="lcb";
    }    
    
function M_OverMenu(obj){obj.className="tmnuOver fl p";}
function M_OutMenu(obj){obj.className="tmnuOut fl p";}    

//function M_OverMenucon(){$get(divlistNewspapers).style.display="";}
//function M_OutMenucon(){$get(divlistNewspapers).style.display="none";}    

//function fmenu_over(obj){obj.className="lcb u";}
//function fmenu_out(obj){obj.className="lcb";}

function viewByType(id){window.location.href="dich-tu-dong.aspx?newsid=" + id; }

function offsetView(){var offsetWidth = document.body.offsetWidth;var offsetHeight=window.document.body.clientHeight;offsetWidth=(offsetWidth > 0 ? offsetWidth : 1);offsetHeight=(offsetHeight > 0 ? offsetHeight : 1);return {width:offsetWidth, height:offsetHeight};}
var sizemin=980;
function resizecontent(){    
    var psize=offsetView();psize.width = psize.width <= sizemin ? sizemin : psize.width;                
    if($get("divmain")!=null){if(psize.width <= sizemin ){$get("divmain").style.width=sizemin + "px";}else{$get("divmain").style.width="100%";}}
}

function startIntervalChat()
{    
    timeGetMsg = window.setInterval("cht_GetMessages();", gReqTimeOut);    
}

function stopIntervalChat()
{
     try{                                 
        if(timeGetMsg!==null)
        {
            clearInterval(timeGetMsg);         
        }
    }catch(ex){}    
}


function chat_an_hien(an_hien_chat) {    
    if(an_hien_chat==0)
    {
        
        stopIntervalChat();
        write_cookie("cookie_chat", 0);
        $get("idm210r_uc_chat").style.display="none";
        $get("idm210r_btn_chat").style.display="";
        $get("idm210r_tab_chat").className="tle";                
        $get("idm210r_cnt_chat").className="kc4 p5l";                        
        if($get("idhdsdung")){$get("idhdsdung").className="";}
        
    }
    else if(an_hien_chat==1)
    {
        write_cookie("cookie_chat", 1);
        startIntervalChat();
        $get("idm210r_uc_chat").style.display="";
        $get("idm210r_btn_chat").style.display="none";
        $get("idm210r_tab_chat").className="tle m210r";                
        $get("idm210r_cnt_chat").className="kc4 m210r p5l";        
        if($get("idhdsdung")){$get("idhdsdung").className="m210r";}
    }
    else
    {
        $get("idm210r_btn_chat").style.display="";
    }
    var elvn=$get("txtVietnameseMt");                                            
    var elen=$get("txtEnglish");                   
    if(elvn)
    {
        elen.style.height=180+"px";
        elvn.style.height=180+"px";
        elen.style.overflowY="hidden";
        elvn.style.overflowY="hidden";        
        setHeight(elvn,elen);                
    }
    
}
function fChat() {
    var showhide = read_cookie("cookie_chat");
    showhide = (showhide == null) ? 1 : showhide;
    chat_an_hien(showhide);    
    //read_cookie("cookie_chat");
}
/*
function write_cookie(name, value)
{                
  AjaxFuncs.write_cookie(name,value+"").value;
}
function cb_write_cookie(res){
    return res.value;
}
*/
/*function read_cookie(name)
{        
  AjaxFuncs.read_cookie(name,cb_read_cookie);
}
function cb_read_cookie(res){
    chat_an_hien(res.value);
}*/
/*function delete_cookie(name)
{        
   AjaxFuncs.delete_cookie(name).value;
}*/

function write_cookie(name, value, path) {
    // Build the expiration date string:
    var expiration_date = new Date();
    expiration_date.setYear(expiration_date.getYear() + 1);
    expiration_date = expiration_date.toGMTString();

    // Build the set-cookie string:
    var cookie_string = escape(name) + "=" + escape(value) + "; expires=";// + expiration_date;
    if (path != undefined || path != null) {
        cookie_string += "; path=" + path;
    }
    // Create/update the cookie:
    document.cookie = cookie_string;
}

function read_cookie(key, skips) {
    // Set skips to 0 if parameter was omitted:
    if (skips ==undefined || skips == null)
        skips = 0;

    // Get cookie string and separate into individual cookie phrases:
    var cookie_string = "" + document.cookie;
    var cookie_array = cookie_string.split("; ");

    // Scan for desired cookie:
    for (var i = 0; i < cookie_array.length; ++i) {
        var single_cookie = cookie_array[i].split("=");
        if (single_cookie.length != 2) {
            continue;
        }
        var name = unescape(single_cookie[0]);
        var value = unescape(single_cookie[1]);

        // Return cookie if found:
        if (key == name) {// && skips-- == 0)
            return value;
        }
    }

    // Cookie was not found:
    return null;
}

function delete_cookie(name, path) {
    // Build expiration date string:
    var expiration_date = new Date();
    expiration_date.setYear(expiration_date.getYear() - 1);
    expiration_date = expiration_date.toGMTString();

    // Build set-cookie string:
    var cookie_string = escape(name) + "=; expires=" + expiration_date;
    if (path != undefined || path != null) {
        cookie_string += "; path=" + path;
    }
    // Delete the cookie:
    document.cookie = cookie_string;
}
function OnSelLanguage(){};

