/// <reference path="./../../typings/tsd.d.ts" />
interface IEle {
    tagRle: any;
    x: number;
    y: number;
    RGB: string;
    time: number;
}
interface IRote {
    iele: IEle;
    next: IRote;
    downOut: boolean;
    showText?: boolean;
}
const infoDefine = [
	{
		home_index_view:{
            showing:'展示中...',
            install:'客户端安装',
            question:'疑问解答',
            question_aboutus:'关于Vpn.Email',
            question_aboutus_1:'Vpn.Email是“加拿大Vpn.Email网络安全技术有限公司”开发的一项产品和服务。我们的目标是通过我们掌握的专业知识，服务于我们的客户使其处于安全可靠的网络环境。我们是一家全私有资本的公司，没有任何政府背景或从属于任何组织团体。'+
                '',
            question_private:'关于信息安全',
            question_private_1:'客户信息的安全是本公司赖以生存的基本。我们尽我们的所有力量保护客户的信息，虽然客户在本公司的信息只有Email帐号。客户的支付信息是合作方银行所有的，我们这里得到的信息只是某个Email地址和已支付的金额。'+
                '本公司不记录客户产生的具体通讯内容信息。我们保存着期限为3个月的日志文件，内容仅限于: 日期和时间, 目标服务器DNS及IP地址, 链接协议, '+
                    '客户端的email地址和通讯字节数，我们会对这些数字进行各类统计和分析工作, 以帮助我们改进并提供更好的服务。为了反恐的需要, 我们会配合持有加拿大法院令的加拿大执法机构提供此日志文件。联系方式为：<a href="mailto:administrator@Vpn.Email" class="fg-hover-lighterBlue">administrator@Vpn.Email</a>。如果您是加拿大以外地区的执法机构并有这方面信息披露的需求，请联系加拿大外交部：<a href="http://www.international.gc.ca" class="fg-hover-lighterBlue" target="_blank">http://www.international.gc.ca/</a>',
            
            question_service:'如何屏蔽我们的服务',
            question_service_1:'某些机构不希望使用我们的服务，询问如何屏蔽。我们理解这方面的要求，但非常遗憾的是这不是我们单方面能够完成的。我们建议您屏蔽本公司的域名：Vpn.Email，使用防火墙内部Email系统，并禁止防火墙外部的email IMAP连接，过滤掉含有 Vpn.Email 域名的信件。',
			question_production1:'客户端对应哪些系统',
            question_production1_1:'Vpn.Email客户端依赖NodeJS环境，而NodeJS可在Windows, MacOS, Linux等系统运行。我们在检讨浏览器插件方式的客户端，和迷你型可随身携带的无线路由器。',
            info:'Vpn.Email是一种安全通讯手段，通过eMail的IMAP协议建立一个虚拟的专用通道，连接客户端和代理服务器，它的奇妙之处在于客户端和服务器彼此不用知道相互的IP地址，而是通过共用一个eMail账号' +
                '进行数据交换，Vpn.Email系统把VPN包加密后，利用IMAP进行通讯，能最大限度的保护您的网络通讯不被检测和干扰，建立一个私密的网络安全环境。',
            info1:'Vpn.Email从原理上和OpenVPN很像，但OpenVPN是把VPN伪装成HTTP或HTTPS，让防火墙误以为使用者是在看一个网站，但它的软肋，就是终端和服务器双方必须知道对方的IP，' +
                '而且在使用中过程中通讯信息的指纹明显，容易被现代化的智能防火墙检出和干扰，以致用户不得不经常更新服务器IP地址列表，来和防火墙玩猫抓老鼠的游戏。'+
                'Vpn.Email让终端可以链接任何的Email服务器，像Outlook, Yahoo, iCloud,GMX等免费Email服务，来进行VPN通讯。事实上很难甄别普通Email和Vpn.Email通讯Email之间的区别。防火墙又很难封锁这些著名的服务商。' +
                '',
            info2:'Vpn.Email通讯的私密优势',
            info3:'当您注册为正式用户后，服务器会24小时联机您的通讯Email账户上，随时等待您的连接，而您只要连接上您的Email，就可以进行网络通讯了。通讯采用OpenPGP加密协议，'+
                '只有您自己的密匙才能打开Email内容，Vpn.Email系统不保留任何客户的密匙，这意味着Vpn.Email无法检测您的通讯内容。在通讯时，系统会即时删除通讯时遗留的Email。'+
                '由于IMAP通讯的特点，您和Vpn.Email交换内容的Email上，是找不到任何您的IP地址信息的。这意味着，不管您在哪里，只要您能连接到您的Email账户，就可以使用Vpn.Email服务，Vpn.Email也不能够知道，您从哪里来。',
			info4:'铜墙铁壁般的数据中心',
            info5:'Vpn.Email数据中心采用云结构的服务器集群，分散处理和去中心化设计，会根据客户数量，动态的自动增减处理器数量，每个Vpn.Email服务器均采用经过特殊优化处理的Linux系统，只保留了最基本的系统功能。' +
                '所以Vpn.Email服务器能带给客户良好的体验。Vpn.Email在全球各大洲均有代理服务器，可满足大部分客户的需要。'+
                'Vpn.Email数据中心还为商业级客户提供其独占的大流量高速服务器，具有强大的计算能力和独享千兆级数据出口。由于Vpn.Email系统结构的特点，我们的数据中心的'+
                '服务器集群和数据库服务器集群，均通过IMAP协议相互之间进行通讯，没有任何开放的可供访问的端口，可有效的防治不法入侵，保护客户数据安全。',
            welcome: '从此您将可以勇敢地冒险！',
            price_title: '注册用户类型',
            price_free_1_1:'免费用户',
            price_free_1_2:'每月1GB限定流量(最高100MB/天)',
            price_free_1_3:'免费',
            price_free_2_1:'基本用户',
            price_free_2_2:'每月10GB限定流量',
            price_free_2_3:'<small class="fg-white">us$</small>1.99<small class="fg-white">/每月</small>',
            price_free_3_1:'标准用户',
            price_free_3_2:'每月100GB限定流量',
            price_free_3_3:'<small class="fg-white">us$</small>5.99<small class="fg-white">/每月</small>',
            price_free_4_1:'高级用户',
            price_free_4_2:'每月1TB限定流量',
            price_free_4_3:'<small class="fg-white">us$</small>9.99<small class="fg-white">/每月</small>',
            price_free_5_1:'小型商业用户',
            price_free_5_2:'每月2TB,独享主机千兆网络',
            price_free_5_3:'<small class="fg-white">us$</small>19.99<small class="fg-white">/每月</small>',
            price_free_6_1:'标准商业用户',
            price_free_6_2:'每月4TB,独享高速主机千兆网络',
            price_free_6_3:'<small class="fg-white">us$</small>39.99<small class="fg-white">/每月</small>',
            install_step1_title:'Vpn.Email是依赖于nodeJS环境，能够运行nodeJS的所有系统，都可作为Vpn.Email客户端。请打开nodeJS的安装页面，挑选对应您的系统的nodeJS安装。',
            install_step1:'下载并安装NodeJS',
            install_step2:'打开终端，windows系统打开DOS窗口(CMD)'
		}
	},{
		home_index_view:{
            showing:'上演中...',
            install:'ソフトインストール',
            question:'問題及答え',
            question_aboutus:'Vpn.Emailとは',
            question_aboutus_1:'我々はカナダVpn.Emailネットワークセキュリティー技術有限会社です。Vpn.Emailは我々の開発した製品とサービスです。我々はプロフェッショナルサービスを提供して、お客様のお大事な',
			info:'Vpn.Emailとは、eMailの通信プロトコルIMAPを使用して、端末とサーバの間に、仮想のネットワークトンネルを構築し、さらにVPNをカプセル化にしたことで、どんな端末からも利用することができます。' +
                'Vpn.Emailの一番重要な特徴は，端末とサーバの通信がIPアドレスではなく、一つのeMailアカウントを使います。それによって'+
                '世界中に安全と自由な通信ができるようになります。',
            info1:'OpenVPNはVPNをカプセル化にしてHTTP又はHTTPSを使用して通信をするですが、基本的には伝統的な端末からVPNサーバへアクセスような特徴を持って変わらないですから、'+
                '現代的なファイアウォールはそれを簡単に認識し、通信を破壊されてしまう。Vpn.EmailはOpenVPNに似たような、VPNをカプセル化にして、'+
                'IMAPポロトコルで作ったトンネルに、通信を行います。Outlook, Yahoo, iCloudなどのフリーEmailアカウントを使っています、ファイアウォールは'+
                '普通のEmailとVpn.EmailのEmailを区分することは難しいでしょう。',
			welcome:'これから、勇気づけられたネットワークのエクスプローラの旅にしましょう。',
            info2:'Vpn.Emailの特徴',
            info3:'商用ユーザにはVpn.Emailは24時間、あなたの通信専用Emailアカウントに接続をしています，いつでもVPNセクション立ち上げが可能です。通信データはOpenPGPで暗号化されて、'+
                '暗号強度は4096までできます。端末とVpn.Emailサーバの間は同じeMailアカウントでコミュニティをしますから、端末とサーバのIPアドレス交換することは不要です。IMAPで書かれたeMail中身にもIPアドレスはないですから、'+
                'Vpn.Emailはユーザが今現在どこから利用していることを、技術的検出することもできないです。',
			info4:'金城鉄壁とするデータセンター',
            info5:'従来のVPNサーバはIPアドレスをユーザに教えて、端末からVPNの接続を待ちます。Vpn.EmailサーバはユーザeMailアカウントに接続をしますから、Vpn.EmailサーバIPアドレスの公開必要がないです。'+
                '従って、Vpn.Emailデータセンターはデータアクセスポートを全部閉じています。外から一切接続を拒否します。サーバの間もIMAPを使って通信をしますから、最もセキュリティーの強いサーバになっています。' +
                'Vpn.Emailサーバは必要の最低限、最適されたLinuxOSをベースに、クラウド技術を使用しています、分散化したクラスターを一つのクラスタリングにします。ユーザのニーズに従って' +
                '自動的オンデマンドでサーバの数を増減に対応します。特に通信量の多いと通信速度を追求したビジネスユーザにも、独占専用のパワーフルサーバも用意しております。',
            price_title: 'アカンウトタイプ',
            price_free_1_1:'フリーユーザー',
            price_free_1_2:'1GBまで (Max100MB/日)',
            price_free_1_3:'フリー',
            price_free_2_1:'普通ユーザー',
            price_free_2_2:'10GBまで',
            price_free_2_3:'<small class="fg-white">us$</small>1.99<small class="fg-white">/月</small>',
            price_free_3_1:'プレミアムユーザー',
            price_free_3_2:'100GBまで',
            price_free_3_3:'<small class="fg-white">us$</small>5.99<small class="fg-white">/月</small>',
            price_free_4_1:'パワーユーザー',
            price_free_4_2:'1TBまで',
            price_free_4_3:'<small class="fg-white">us$</small>9.99<small class="fg-white">/月</small>',
            price_free_5_1:'スモールビジネス',
            price_free_5_2:'2TB 独占サーバ',
            price_free_5_3:'<small class="fg-white">us$</small>19.99<small class="fg-white">/月</small>',
            price_free_6_1:'ビジネスユーザー',
            price_free_6_2:'4TB 独占高速サーバ',
            price_free_6_3:'<small class="fg-white">us$</small>39.99<small class="fg-white">/月</small>',
            install_step1:'インストール　NodeJS'
		}
	},{
		home_index_view:{
			info:'Vpn.Email is the one of the powerful and easiest VPN software. Vpn.Email use email IMAP protocol to make a virtual tunnel that exchanges VPN packets between '+
                'VPN clients and VPN servers. The excellent point is Vpn.Email exchanges data by a email account, client and server do not need IP address. Nobody know where you from even Vpn.Email system. ',
			welcome:"Lets explore the world without fear!",
            install:'Install',
            question_aboutus:'About us',
            question_aboutus_1:'Vpn.Email network security technolog Canada Ltd',
            question:'Question & answer',
            showing:'Showing...',
            info1:'Vpn.Email is similar as OpenVPN. OpenVPN uses HTTPS protocol in order to establish a VPN tunnel. let firewall think it is normal http access. But OpenVPN have a lot of commercial trait when used be established through firewalls. ' +
                "Even the firewall do not need know what is the detail. So OpenVPN clients need reflash gatway server's IP list and find out the working one. Vpn.Email package VPN to a email use IMAP protocol commercial between server and client. " +
                " Client can use a lot of popular free email provider like Yahoo, Outlook, GMX for use Vpn.Email system transparency for firewalls.",
            info2:'Vpn.Email feature',
            info3:"The Vpn.Email server will connect the client email account 24 hours when you have a paid account. The server always wait client establish VPN connection. The append email via IMAP protocol have not any IP address detail in mail header. You can use Vpn.Email " +
                " whatever you are from just you can access your email account. Also Vpn.Email have no means can reach your IP address. Vpn.Email system use OpenPGP to encrypt & decrypt each email. Vpn.Email have not record any client's privkey and password.  ",
            info4:'Strong data center',
            info5:"Vpn.Email provides cloud server cluster that is base with clients needs (on-demand). It isolate between each clients. It use security IMAP protocol commercial transactions between database center and client servers." +
                 "Each server used lightweight, security, ultra-optimized, based on the Linux kernel. Only the minimal functionality required. " +
                 "Vpn.Email have multiple datacenter locations. Provides business users powerfull and TB bandwidth network private hosting.",
            price_title: 'Account type',
            price_free_1_1:'Free User',
            price_free_1_2:'1GB/Mouth(Max 100MB/day)',
            price_free_1_3:'Free',
            price_free_2_1:'Basic User',
            price_free_2_2:'10GB/Mouth',
            price_free_2_3:'<small class="fg-white">us$</small>1.99<small class="fg-white">/mouth</small>',
            price_free_3_1:'Premium User',
            price_free_3_2:'100GB<small class="fg-white">/Mouth</small>',
            price_free_3_3:'<small class="fg-white">us$</small>5.99<small class="fg-white">/mouth</small>',
            price_free_4_1:'Power User',
            price_free_4_2:'1TB/Mouth',
            price_free_4_3:'<small class="fg-white">us$</small>9.99<small class="fg-white">/mouth</small>',
            price_free_5_1:'Small Business',
            price_free_5_2:'2TB/M Exclusive Host',
            price_free_5_3:'<small class="fg-white">us$</small>19.99<small class="fg-white">/mouth</small>',
            price_free_6_1:'Business',
            price_free_6_2:'4TB/M Exclusive Fast Host',
            price_free_6_3:'<small class="fg-white">us$</small>39.99<small class="fg-white">/mouth</small>',
            install_step1:'Install　NodeJS'
		}
	}
]
const cookieName = 'langEH'
enum lang { 'zh', 'ja', 'en' }
const initLanguageCookie = () => {
    var cc: string = $.cookie( cookieName );
    
    if (cc == undefined || cc == "") {
        cc = window.navigator.language;
    }

    if (cc == undefined || cc == "")
        cc = 'en';
    cc = cc.substr(0, 2).toLocaleLowerCase();
    switch (cc) {
        case 'zh':
            break;
        case 'en':
            break;
        case 'ja':
            break;
        default:
            cc = 'en';
    }
    $.cookie("langEH", cc, { expires: 180, path: '/' });
    $("html").trigger('languageMenu',cc);
    return cc;
}
const eleFlash = (ele, red: boolean, returnColor, length: number) => {
    for (let i = 0; i < length; i ++) {
        setTimeout (() => {
            ele.animate ({ fill: red ? 'red' : 'green' }, 7, null, () => {
                ele.attr ({ fill: returnColor })
            })
        }, i * 50 )
    }
}
class svgAnimation1 {
    private y = Snap('#snapVpn')
    private ele1 = $('#snapVpn')
    private weight = (this.ele1.width() > 200)
        ? this.ele1.width() - 200
        : 300;
    static rgb_firewall = 'rgba(255,80,80,0.1)'
    static rgb_client = 'rgba(255,255,255,.5)'
    static rgb_client1 = 'rgba(255,70,0,.5)'
    private showInfo1 = this.y.g().attr ({ fill: 'rgba(255,255,00,.7)', "font-size": "18px", opacity:1 });
    private showInfo2 = this.y.g().attr ({ fill: 'red', "font-size": "18px", opacity:1 });
    private localRbgServerPoint = 0;
    
    static rbgServer = [
        'rgba(255,70,0,.5)','rgba(255,70,255,.5)','rgba(255,250,70,.5)'
    ]
    private fireWallWorking = false;
    private fireWall: IEle = {
        tagRle: this.y.group().attr({ fill: svgAnimation1.rgb_firewall, class: 'mouse-pointer' }),
        x: this.weight * 0.5,
        y: 40,
        RGB: svgAnimation1.rgb_firewall,
        time: 1000
    }
    private vpnviaEmail: IEle = {
        tagRle: this.y.group().attr({ fill: svgAnimation1.rgb_client, opacity: 0, class:'mouse-pointer' }),
        x: this.weight * .9,
        y: 150,
        RGB: svgAnimation1.rgb_client,
        time: 500
    }
    private client: IEle = {
        tagRle: this.y.group().attr({ fill: svgAnimation1.rgb_client, class:'mouse-pointer' }),
        x: 50,
        y: 40,
        RGB: svgAnimation1.rgb_client,
        time: 1000
    }
    private mailServer: IEle = {
        tagRle: this.y.group().attr({ fill: '#FFFFFF', opacity: 0, class:'mouse-pointer' }),
        x: this.weight,
        y: 40,
        RGB:'#FFFFFF',
        time: 1000
    }
    private server: IEle = {
        tagRle: this.y.group().attr({ fill: svgAnimation1.rgb_client, class:'mouse-pointer' }),
        x: this.weight,
        y: 40,
        RGB: svgAnimation1.rgb_client,
        time: 1000
    }

    
    constructor() {
        
        this.y.attr({ height: 200 })
        Snap.load('/images/client_1.svg',(f)=> {
            const t = new Snap.Matrix()
            t.scale(2)
            t.translate(10,10)
            this.client.tagRle.append(f)
            this.client.tagRle.transform(t)
            
            
        })
        Snap.load ('/images/svg_firewall.svg',(f)=>{
            const t = new Snap.Matrix()
            t.scale(2)
            const point = this.weight * 0.2;
            t.translate (point,0)
            this.fireWall.tagRle.append(f);
            this.fireWall.tagRle.transform(t)
        })
        Snap.load ('/images/vpnemail.svg',(f) => {
            const t = new Snap.Matrix()
            t.translate(this.weight ,0)
            t.scale(2)
            this.mailServer.tagRle.append(f)
            this.mailServer.tagRle.transform(t)

        })
        Snap.load ('/images/svg_server1.svg', (f) => {
            //const t = new Snap.Matrix()
            //t.translate(this.weight * .85, 100)
            //t.scale(2)
            this.vpnviaEmail.tagRle.append(f);
            //this.vpnviaEmail.tagRle.transform(t);
            this.vpnviaEmail.tagRle.transform('translate('+ this.weight * .85+',100) scale(2)');
        })
        Snap.load ('/images/svg_server1.svg',(f) => {
            //const t = new Snap.Matrix()
            //t.translate (this.weight ,0)
            //t.scale (2)
            
            this.server.tagRle.append(f)
            this.server.tagRle.transform('translate('+ this.weight+') scale(2)');
            //this.server.tagRle.transform(t)
            //this.vpnviaEmail.tagRle.animate ({x:this.weight * .85, y:100, scale: 2})
        })
    }
    private goNext (textEle, rote: IRote, time, length: number, callback) {

        textEle.animate ({ x: rote.iele.x, y: rote.iele.y, fill: 'rgba(255,255,255,.1)' }, time, null, () => {
            if (rote.showText){
                if (this.fireWallWorking) {
                    if (this.showInfo2) {
                        Snap.animate( 0, 1, (v) => {
                            this.showInfo2.attr ({ 'font-size': v * 40, opacity: v })
                        }, 1500, mina.bounce, () => {
                            this.showInfo2.attr({opacity:0})
                        });
                    }
                } else {
                    Snap.animate( 0, 1, (v) => {
                        this.showInfo1.attr ({ 'font-size': v * 50, opacity: v })
                    }, 1500, mina.bounce, () => {
                        this.showInfo1.attr ({ opacity: 0})
                    });
                }
            }
            eleFlash ( rote.iele.tagRle, rote.downOut && this.fireWallWorking, rote.iele.RGB, length)

            if (rote.downOut && this.fireWallWorking) {
                
                return textEle.animate ({ y: 150}, 200, null, callback)
            }
            if ( rote.next )
                return this.goNext ( textEle, rote.next, rote.next.iele.time, length, callback)
            textEle.remove()
            callback()
        })
        

    }
    private goData ( rotes: IRote, length: number, callback ) {
        const myGroup = this.y.g().attr ({ fill: 'rgba(255,255,255,0)', "font-size": "18px" });

        for ( let i = 0; i < length; i ++ ) {
            let n = myGroup.text (rotes.iele.x, rotes.iele.y, Math.round(Math.random()).toString())
            setTimeout (() => {
                this.goNext ( n, rotes, rotes.iele.time, length, () =>{
                    n.remove()
                    if (i === length - 1)
                        return callback()
                })
            }, i * 50)
            
        }
        
    }
    private showServer () {
        this.server.tagRle.animate({transform:`translate(${this.weight + 200}) scale(2)`}, 500, mina.easeinout, ()=> {
            this.server.tagRle.attr({fill: svgAnimation1.rbgServer[this.localRbgServerPoint]});
            this.server.RGB = svgAnimation1.rbgServer[this.localRbgServerPoint]
            this.localRbgServerPoint ++;
            if (this.localRbgServerPoint == svgAnimation1.rbgServer.length)
                this.localRbgServerPoint = 0;
            this.server.tagRle.animate({transform:`translate(${this.weight}) scale(2) `}, 500, mina.easein)
        })
    }
    private outServer () {
        this.server.tagRle.animate({transform:`translate(${this.weight+400}) scale(2)`}, 1000, mina.easeinout)
    }
    public vpn = (showText: string, wText=null, callback) => {
        
        this.fireWallWorking = false;
        const FirewallRoute: IRote = {
            iele: this.fireWall,
            downOut: true,
            next: {
                iele: this.client,
                downOut: false,
                next: null
            }
            
        }
        const VpnViaEmail = showText === 'Vpn.Email'
        const serverToClinet = VpnViaEmail
            ? {
                iele: this.vpnviaEmail,
                downOut: false,
                next: {
                    iele: this.mailServer,
                    downOut: false,
                    next: FirewallRoute
                }
            }
            : {
                iele: this.server,
                downOut: false,
                next: FirewallRoute
            }
        const afterFireWallRoute: IRote = VpnViaEmail
            ? {
                iele: this.mailServer,
                downOut: false,
                next: {
                    iele: this.vpnviaEmail,
                    downOut: false,
                    next: serverToClinet
                }
            }
            : {
                iele: this.server,
                downOut: false,
                next: serverToClinet
            }
        

        const cliectToServer: IRote = {
                iele: this.client,
                downOut: false,
                
                next: {
                    iele: this.fireWall,
                    downOut: true,
                    next: afterFireWallRoute,
                    showText: true
                }
            }
        this.showInfo1.remove();
        this.showInfo2.remove();
        this.showInfo1 = this.y.g().attr ({ fill: 'rgba(255,255,00,1)', "font-size": "18px", opacity: 0 });
        this.showInfo2 = this.y.g().attr ({ fill: 'red', "font-size": "18px", opacity: 0});
        this.server.RGB = svgAnimation1.rgb_client;
        if ( VpnViaEmail ) {
            //this.server.tagRle.animate({opacity: 0}, 1000, mina.easeinout)
            this.outServer()
            this.vpnviaEmail.tagRle.animate ({ opacity: 1 },1000, mina.easein)
            this.mailServer.tagRle.animate ({ opacity: 1 },1000, mina.easein)
            
            
            this.showInfo1.text(this.weight * 0.5, 50, 'email?')
        } else {
            //this.server.tagRle.animate({opacity: 1}, 1000, mina.easein)
            this.showServer()
            this.showInfo1.text(this.weight * 0.5, 50, 
                (showText === 'VPN')
                ? '??'
                : 'http?')
            this.showInfo2.text(this.weight * 0.5, 50, showText+'!');
            this.vpnviaEmail.tagRle.animate ({ opacity: 0 }, 1000, mina.easeout)
            this.mailServer.tagRle.animate ({ opacity: 0 }, 1000, mina.easeinout)
        }
        let i = 0;
        
        const callBack = () => {
            i ++
            if (!VpnViaEmail && i == 2 ) {
                this.fireWallWorking = true
            }
            if (!VpnViaEmail && i == 4 ) {
                this.fireWallWorking = false
                this.showServer()
                
            }
            if (!VpnViaEmail && i == 6 ) {
                this.fireWallWorking = true
            }
            if (i < 10)
                return this.goData ( cliectToServer,5, callBack)
            callback()
        }

        this.goData ( cliectToServer, 5, callBack)
        
        
    }
}

module view_layout {
	export class view {
		static tLang = initLanguageCookie ();
		static Menu = {                                                        
            'zh':[{
                LanguageJsonName: 'zh',
                showName: '中文',
                icon: 'flag-icon-cn'
            },
            {
                LanguageJsonName: 'en',
                showName: '英文/English',
                icon: 'flag-icon-gb'
            },
            {
                LanguageJsonName: 'ja',
                showName: '日文/日本語',
                icon: 'flag-icon-jp'
            }],
            'ja': [{
                LanguageJsonName: 'ja',
                showName: '日本語',
                icon: 'flag-icon-jp'
            },
            {
                LanguageJsonName: 'en',
                showName: '英語/English',
                icon: 'flag-icon-gb'
            },
            {
                LanguageJsonName: 'zh',
                showName: '中国語/中文',
                icon: 'flag-icon-cn'
            }],
            'en': [{
                LanguageJsonName: 'en',
                showName: 'English',
                icon: 'flag-icon-gb'
            },
            {
                LanguageJsonName: 'ja',
                showName: 'Japanese/日本語',
                icon: 'flag-icon-jp'
            },
            {
                LanguageJsonName: 'zh',
                showName: 'Chinese/中文',
                icon: 'flag-icon-cn'
            }
            ]
        }
        static svgAnimation = new svgAnimation1();
        constructor(){}
        
		private languageIndex =ko.observable ( lang[view.tLang] )
		private dataJson = ko.observable ( infoDefine [ this.languageIndex () ]);
        private languageList = ko.observableArray ( view.Menu [ view.tLang ])
		public home_index_view = ko.observable ( this.dataJson ().home_index_view )
        public currentSelected = ko.observable ( this.languageList()[0] )
        public VpnRunning = ko.observable (false);
        public VpnViaEmailRunning = ko.observable (false);
        public OpenVPNlRunning = ko.observable (false);
        public language = ko.observable(initLanguageCookie ())
        public selectItem = ( that, site: languageMenu ) => {
            var self = this
                this.language (site.LanguageJsonName)
                view.tLang = site.LanguageJsonName
                self.languageIndex(lang[view.tLang])
                self.dataJson(infoDefine[self.languageIndex()])
                self.home_index_view(self.dataJson().home_index_view)
                self.languageList (view.Menu[view.tLang]);
                self.currentSelected( self.languageList()[0]);
                $("html").trigger('languageMenu',view.tLang)
                $.cookie("langEH", view.tLang, { expires: 180, path: '/' });
        }
        
        public vpnViaEmailClick () {
            this.VpnViaEmailRunning ( true )
            view.svgAnimation.vpn ('Vpn.Email','email', () => {
                this.VpnViaEmailRunning ( false )
            })
            
            
        }
        public vpnClick () {
            this.VpnRunning (true);
            view.svgAnimation.vpn ( 'VPN','', () => {
                this.VpnRunning(false)
            })
        }
        public openVenClick () {
            this.OpenVPNlRunning (true);
            view.svgAnimation.vpn ( 'OpenVPN','html', () => {
                this.OpenVPNlRunning(false)
            })
        }
	}
}

var viewLayout = new view_layout.view ()
ko.applyBindings ( viewLayout, document.getElementById ("html"))

initLanguageCookie()