﻿
var tourcat='in';
var cur_sukien='sukien_0';
var cur_chuyende='chuyende_0';
var cur_hangtuan='hangtuan_0';
var cur_tuhcm='tuhcm_out_0';
var cur_tuhanoi='tuhanoi_out_0';
var _tmp='sukien';
var _tmp1='tuhcm';
var curentcatalogin='sukiencatalogin';
var curentcatalogout='tourtuhcm';
function disableSelection(target)
{
    if(typeof(target.onselectstart)!="undefined") //For IE
        target.onselectstart=function(){return false}
    else if(typeof(target.style.MozUserSelect)!="undefined") //For Firefox
        target.style.MozUserSelect="none"
    else //All other route (For Opera)
        target.onmousedown=function(){return false}
    target.style.cursor = "default"
}

function hiliteRow(row, mouseOver)
{
    if(row.checked) return;
    if(mouseOver)
        row.style.backgroundColor = "#ffffe6";
    else
        row.style.backgroundColor = "";
}

function showsubcat(cat,id,slide)
{
    if(cat=='in')
    {
        if(_tmp=='sukien')
        {
            if(cur_sukien!=id)
            {
                document.getElementById(id).style.display='block';
                document.getElementById(cur_sukien).style.display='none';
                //alert(cur_sukien);
                cur_sukien=id;
            }
        }
        if(_tmp=='chuyende')
        {
            if(cur_chuyende!=id)
            {
                document.getElementById(id).style.display='block';
                document.getElementById(cur_chuyende).style.display='none';
                cur_chuyende=id;
            }
        }
        if(_tmp=='hangtuan')
        {
            if(cur_hangtuan!=id)
            {
                document.getElementById(id).style.display='block';
                document.getElementById(cur_hangtuan).style.display='none';
                cur_hangtuan=id;
            }
        }
    }
    else
    {
        if(_tmp1=='tuhcm')
        {
            if(cur_tuhcm!=id)
            {
                document.getElementById(id).style.display='block';
                document.getElementById(cur_tuhcm).style.display='none';
                cur_tuhcm=id;
            }
        }
        if(_tmp1=='tuhanoi')
        {
            if(cur_tuhanoi!=id)
            {
                document.getElementById(id).style.display='block';
                document.getElementById(cur_tuhanoi).style.display='none';
                cur_tuhanoi=id;
            }
        }
    }
    AP.Core.JS.PhotoSlide.init({id:''+slide+'', autoStart: false, animation: true});
    return false;
}

function viewcatalog(id)
{
    if(id=='in')
    {
        document.getElementById('tour_'+id).style.display='block';
        document.getElementById('catalog_'+id).style.display='block';
        document.getElementById('playlist_'+id).style.display='block';
        document.getElementById('tour_out').style.display='none';
        document.getElementById('catalog_out').style.display='none';
        document.getElementById('playlist_out').style.display='none';
        AP.Core.JS.PhotoSlide.init({id:'sukien_slide_0', autoStart: false, animation: true});
    }
    else
    {
        document.getElementById('tour_'+id).style.display='block';
        document.getElementById('catalog_'+id).style.display='block';
        document.getElementById('playlist_'+id).style.display='block';
        document.getElementById('tour_in').style.display='none';
        document.getElementById('catalog_in').style.display='none';
        document.getElementById('playlist_in').style.display='none';
        AP.Core.JS.PhotoSlide.init({id:'tuhcm_out_slide_0', autoStart: false, animation: true});
    }
    return false;
}

function showcatalogin(id,cat)
{
    if(cat!='') _tmp=cat;
    if(id!=curentcatalogin)
    {
        document.getElementById(id).style.display='block';
        document.getElementById(curentcatalogin).style.display='none';
        curentcatalogin=id;
    }
    if(cat=='sukien') {AP.Core.JS.PhotoSlide.init({id:'sukien_slide_0', autoStart: false, animation: true});}
    if(cat=='chuyende') {AP.Core.JS.PhotoSlide.init({id:'chuyende_slide_0', autoStart: false, animation: true});}
    if(cat=='hangtuan') {AP.Core.JS.PhotoSlide.init({id:'hangtuan_slide_0', autoStart: false, animation: true});}
    if(cat=='tuhanoi') {AP.Core.JS.PhotoSlide.init({id:'tuhanoi_slide_0', autoStart: false, animation: true});}
    return false;
}

function showcatalogout(id,cat)
{
    if(cat!='') _tmp1=cat;
    if(id!=curentcatalogout)
    {
        document.getElementById(id).style.display='block';
        document.getElementById(curentcatalogout).style.display='none';
        curentcatalogout=id;
    }
    if(cat=='tuhcm') {AP.Core.JS.PhotoSlide.init({id:'tuhcm_out_slide_0', autoStart: false, animation: true});}
    if(cat=='tuhanoi') {AP.Core.JS.PhotoSlide.init({id:'tuhanoi_out_slide_0', autoStart: false, animation: true});}
    return false;
}

function TraCuuTour()
{
    if($('ddlkhoihanh').selectedIndex==0)
    {
        alert("Chọn thông tin điểm khởi hành"); return false;
    }
    if($('ddldiemden').selectedIndex==0)
    {
        alert("Chọn thông tin điểm đến"); return false;
    }
    else
    {
        if($('rdnuocngoai').checked==true)
        {
            //alert('trong nuoc');
            window.location="/tim-kiem-tour-trong-nuoc/"+$('ddlkhoihanh').value+"/"+$('ddldiemden').value+"/";
        }
        else
        {
            //alert('nuoc ngoai');
            window.location="/tim-kiem-tour-nuoc-ngoai/"+$('ddlkhoihanh').value+"/"+$('ddldiemden').value+"/";
        }
    }
}

function TraCuuTour1()
{
    if($('rdkhachsan').checked==false)
    {
        if($('ddlkhoihanh').selectedIndex==0)
        {
            alert("Chọn thông tin điểm khởi hành"); return false;
        }
        if($('ddldiemden').selectedIndex==0)
        {
            alert("Chọn thông tin điểm đến"); return false;
        }
        else
        {
            if($('rdnuocngoai').checked==false)
            {
                //alert('trong nuoc');
                window.location="/tim-kiem-tour-nuoc-ngoai/"+$('ddlkhoihanh').value+"/"+$('ddldiemden').value+"/";
            }
            else
            {
                //alert('nuoc ngoai');
                window.location="/tim-kiem-tour-trong-nuoc/"+$('ddlkhoihanh').value+"/"+$('ddldiemden').value+"/";
            }
        }
    }
    else
    {
        TimKSTrongNuoc1();
    }
}

var d2,d3,d4,d5,d6,d7; d2=d3=d4=d5=d6=d7=true;
function expand(divid,id)
{                
    if(id)
    {
        $('div_'+divid).style.display='block';
        if(divid=='d3')
        {$('linhvuc').style.height = $('linhvuc').clientHeight + 710 + 'px'}
        if(divid=='d4')
        {$('linhvuc').style.height = $('linhvuc').clientHeight + 1245 + 'px'}
        if(divid=='d5')
        {$('linhvuc').style.height = $('linhvuc').clientHeight + 433 + 'px'}
        if(divid=='d6')
        {$('linhvuc').style.height = $('linhvuc').clientHeight + 910 + 'px'}
        if(divid=='d7')
        {$('linhvuc').style.height = $('linhvuc').clientHeight + 1960 + 'px'}
        loadpage();
    }
    else
    {
        $('div_'+divid).style.display='none';
        if(divid=='d3')
        {$('linhvuc').style.height = $('linhvuc').clientHeight - 710 + 'px';
            $('mainpage').style.height = $('mainpage').clientHeight - 710 + 'px'
        }
        if(divid=='d4')
        {$('linhvuc').style.height = $('linhvuc').clientHeight - 1245 + 'px'
        $('mainpage').style.height = $('mainpage').clientHeight - 1245 + 'px'}
        if(divid=='d5')
        {$('linhvuc').style.height = $('linhvuc').clientHeight - 433 + 'px'
        $('mainpage').style.height = $('mainpage').clientHeight - 433 + 'px'}
        if(divid=='d6')
        {$('linhvuc').style.height = $('linhvuc').clientHeight - 910 + 'px'
        $('mainpage').style.height = $('mainpage').clientHeight - 910 + 'px'}
        if(divid=='d7')
        {$('linhvuc').style.height = $('linhvuc').clientHeight - 1960 + 'px'
        $('mainpage').style.height = $('mainpage').clientHeight - 1960 + 'px'}
    }
}

function loadpage()
{
    if(browser_version=='IE6')
    {
        $('mainpage').style.height = $('top5').offsetTop - 30 + 'px';
        if(typeof(blog)=='undefined')
            $('linhvuc').style.height = $('top5').offsetTop - $('mainmenu').clientHeight - 260 + 'px';        
        else
            $('linhvuc').style.height = $('top5').offsetTop - $('mainmenu').clientHeight - 190 + 'px';        
    }
    else
    {
        var right = $('mainpage').clientHeight;
        var total = $('tracuu').clientHeight + $('leftcontent').clientHeight + $('linhvuc').clientHeight + 100;
        if ( right < total)
        {			    
            $('mainpage').style.height = total + 15 + 'px';
        }
        else
        {
            $('linhvuc').style.height = $('linhvuc').clientHeight + (right-total-15) + 'px';
        }
    }
}

function resetkh()
{ 
    $('ddlkhoihanh').selectedIndex=0;
    $('ddldiemden').selectedIndex=0;
}

function resetks()
{ 
    $('ddlvungmien').selectedIndex=0;
    $('ddltinhthanh').selectedIndex=0;
    $('ddlcapdo').selectedIndex=0;
}

var language='vn';
function view()
{
    if(language!='vn')
    {
        language='vn';
        $('div_vn').style.display='block';
        $('div_en').style.display='none';
        if($('view_en_button'))
        {	$('view_en_button').innerHTML='Click here to see English version'; }
        loadpage();
        return;
    }
    else
    {
        language='en';
        $('div_en').style.display='block';
        $('div_vn').style.display='none';
        if($('view_en_button'))
        {	$('view_en_button').innerHTML='Click here to see Vietnamese version'; }
        loadpage();
        return;
    }
}

function dk_nhantin()
{
    if($('email_nhantin').value=='')
    {
        alert('Bạn phải điền thông tin địa chỉ email để nhận thông tin từ FIDITOUR');
        $('email_nhantin').focus();
        return false;
    }
    else if(!isEmail($('email_nhantin').value))
    {
        alert('Thông tin địa chỉ email không hợp lệ');
        $('email_nhantin').focus();
        return false;
    }
    else
    {
        dangky_nhantin($('email_nhantin').value);
        return false;
    }
    return false;
}
function TimKSTrongNuoc()
{
    if($('ctl00_ddlvungmien').selectedIndex==0)
    {
        alert("Vui lòng chọn thông tin vùng miền cần tìm"); return false;
    }
    if($('ddltinhthanh').selectedIndex==0)
    {
        alert("Vui lòng chọn thông tin tỉnh thành cần tìm"); return false;
    }
    else
    {
        //alert('nuoc ngoai');
        window.location="/tim-khach-san-trong-nuoc/"+$('ddltinhthanh').value+"/"+$('ddlcapdo').value+"/";
    }
}

function TimKSTrongNuoc1()
{
    if($('ddlvungmien').selectedIndex==0)
    {
        alert("Vui lòng chọn thông tin vùng miền cần tìm"); return false;
    }
    if($('ddltinhthanh').selectedIndex==0)
    {
        alert("Vui lòng chọn thông tin tỉnh thành cần tìm"); return false;
    }
    else
    {
        //alert('nuoc ngoai');
        window.location="/tim-khach-san-trong-nuoc/"+$('ddltinhthanh').value+"/"+$('ddlcapdo').value+"/";
    }
}

function TimKSNgoaiNuoc()
{
    if($('ctl00_ddlquocgia').selectedIndex==0)
    {
        alert("Vui lòng chọn thông tin quốc gia cần tìm"); return false;
    }
    else
    {
        window.location="/tim-khach-san-nuoc-ngoai/"+$('ctl00_ddlquocgia').value+"/"+$('ddlcapdo1').value+"/";
    }
}

function Chat(list)
        {
            if(list!=""?list.length>0:false)
            {
                var tmp=list.split(';');
                for(var i=0; i<tmp.length;i++)
                {
                    if(tmp[i]!='')
                    {
                        var type=tmp[i].split(':');
                        if(type[0]=='skype')
                        {    writeSupport(type[1],'skype','/images_new/skype.gif'); }
                        else
                        {    writeSupport(type[1],'yahoo','2'); }
                    }
                }
            }
        }