﻿// 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 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();
    if(is_ie6){    
        psize.width = psize.width-22 <= sizemin ? sizemin : psize.width;
        $get("divCenter").style.width="770px";
        $get("divContent").style.width="550px";
        $get("divmain").style.width= "980px";       
    }
    else{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%";}}
}


////================Start photo
function viewImg(obj,albumid,imageId)
{    
    
    $get("imgAnhlon").src= url_photo + "PhotoHandler.ashx?ImageID=" + imageId + "&Size=2";
    $get("imgAnhlon").onclick = Function("javascript:location.href='"+ url_photo + "Details.aspx?AlbumID=" + albumid + "&ImageID=" + imageId+"'");                    
    $get("imgAnhlon").title=obj.title;    
    for(var i=0;i<6;i++)
    {
        if(i != obj.id)
        {            
            $get("kbd_"+i).className="ovf kcff";
            $get("kbd_"+i).onmouseover=Function("this.className='ovf kcovf'");
            $get("kbd_"+i).onmouseout=Function("this.className='ovf kcff'");
        }
        else
        {            
            $get("kbd_"+i).onmouseover="";
            $get("kbd_"+i).onmouseout="";
            $get("kbd_"+i).className="ovf kcovf";
        }
    }
}

function GetTypeCbophoto()
{
    var id= $get("select_photo").selectedIndex;  
    var type = $get("select_photo").options[id].value;
    return type;
}
function Click_btn_photo()
{                     
    var el=$get("txtphoto");                 
    if(el!=null && el.value!=="")
    {
        window.location.href= url_photo + "Search.aspx?type="+GetTypeCbophoto()+"&key="+el.value;
    }
}
function Enterphoto(evt)
{
    if(evt.keyCode == 13)
    {
        Click_btn_photo()
    }
}

////================End photo
////================Start dich
function topicIndex(){
    if ($get("radTransType1").checked==true) return 1;
    if ($get("radTransType2").checked==true) return 2;
    if ($get("radTransType3").checked==true) return 3;
    if ($get("radTransType5").checked==true) return 5;
    if ($get("radTransType6").checked==true) return 6;
    return -1;    
}
function onSelTransType(type){
    var el=$get("radTransType" + type);
    if(el){
        el.checked=true;        
    }
}
function Click_btn_dich()
{    
    var strName = trim($get("txtEnglish").value);
    if(strName!="")
    {
        location.href=url_mtd + "Default1.aspx?k=" + strName + "&t="+ topicIndex();                
    }
    else
    {
        alert("Vui lòng nhập nội dung cần dịch");
    }
}
function Click_btn_xoa(){$get("txtEnglish").value="";}
////================End dich
////================Start Vnh
var flag_mode_vnh=0;
function checkRadio_vnh(id)
{       
    $get(id).checked="checked";    
    flag_mode_vnh=$get(id).value;        
}
function setTypeMode(mode)
{
    flag_mode_vnh=mode;
}
function GetTypeCbo()
{
    var id= $get("select_vnh").selectedIndex;  
    var type = $get("select_vnh").options[id].value;
    return type;
}
function Click_btn_vnh()
{                     
    var el=$get("txtword_vnh");                 
    if(el!=null && el.value!=="")
    {
        window.location.href= url_vnh + "detail.aspx?pid="+""+"&key="+el.value+"&type="+GetTypeCbo()+"&stype="+ flag_mode_vnh;
    }    
}
function Entervnh(evt)
{
    if(evt.keyCode == 13)
    {
        Click_btn_vnh()
    }
}
////================End Vnh


////================Start mtd
function GetTypeCbomtd()
{
    var id= $get("select_mtd").selectedIndex;  
    var type = $get("select_mtd").options[id].value;
    return type;
}
function Click_btn_mtd()
{                     
    var el=$get("txtword");                 
    if(el!=null && el.value!=="")
    {
        window.location.href= url_mtd + "tu-dien-truc-tuyen.aspx?k="+el.value+"&t="+GetTypeCbomtd();
    }
}
function Entermtd(evt)
{
    if(evt.keyCode == 13)
    {
        Click_btn_mtd()
    }
}
////================End mtd

////================Start book
function GetTypeCbobook()
{
    var id= $get("select_book").selectedIndex;  
    var type = $get("select_book").options[id].value;
    return type;
}
function Click_btn_book()
{
    var el = $get("txtbook");                 
    if(el!=null && el.value!=="")
    {
        window.location.href= url_ebook + "search.aspx?id="+GetTypeCbobook()+"&bookname="+el.value;
    }
}
function Enterbook(evt)
{
    if(evt.keyCode == 13)
    {
        Click_btn_book()
    }
}
////================End book
////================Start book

function Click_btn_map()
{                     
    var el=$get("txtmap");                 
    if(el!=null && el.value!=="")
    {
        window.location.href= url_map + "Default.aspx?key="+el.value;
    }
}
function Entermap(evt)
{
    if(evt.keyCode == 13)
    {
        Click_btn_map()
    }
}
////================End book
 function ChooseProDisWar(obj) {
        var ob = obj.options[obj.selectedIndex];
       //var vl = ob.attributes["value"].value;
       //var wx = ob.attributes["wx"].value;
       //var wy = ob.attributes["wy"].value;
       //var proid = ob.attributes["proid"].value;
       var placeid = ob.attributes["placeid"].value;
       //var zoom = ob.attributes["zoom"].value;
       //location.href=url_map+"?key="+encodeURIComponent("Tỉnh")+"&pn="+encodeURIComponent(ob.innerHTML)+"&x="+wx+"&y="+wy+"&z="+zoom+"&cm="+vl;
       location.href = url_map + "default.aspx?key=" + encodeURIComponent(ob.innerHTML) + "&pid=" + placeid;                     
    }