﻿/*
+--------------------------------------------------------------------------+
| ※　(TTatbjs泰国旅游局北京办事处)          |   运行环境 : Asp.net环境    |
|                                            |   开发年月 : 2008年04月     |
|--------------------------------------------------------------------------|
|     程序设计 : 杨 华(Yanghua)   QQ:46643663  / Mobile:13728065163 (广州) |
|--------------------------------------------------------------------------|
|  声明:                                                                   |
|         本人保留本代码的原著权,擅自修改本程序造成的一切损失本人概不负责! |
|                                                      2008年04月01日      |
+--------------------------------------------------------------------------+
*/
/// <reference path="ajax.js" />
/// <reference path="control.js" />

var Tatbjs = new TTatbjs();

function TTatbjs() {
    var _arrItems = "";

    this.search = function() {
        /// <summary>栏目搜索</summary>
        /// <param name="key" type="String">关键字</param>
        Tatbjs.selectByOptions_values();
        Control.goUrl("/search/?place_id=" + getObjValue("inputSelectProvince") + "&value=" + _arrItems);
    }

    this.searchByGoogle = function() {
        /// <summary>google站内搜索</summary>
        var keyword = getObjValue("keyword");
        if (keyword) {
            var url = "http://www.google.cn/search?hl=zh-CN&ie=GB2312&q=site%3Atatbjs.org.cn+" + keyword + "&meta=&aq=f&oq=";
            window.open(url);
        }
        else {
            alert("主输入搜索内容");
        }
    }

    this.login = function(username, password) {
        /// <summary>会员登录</summary>
        /// <param name="username" type="String">用户名</param>
        /// <param name="password" type="String">口令</param>
        alert("用户登录!");
    }

    this.selectByRegion = function(value) {
        /// <summary>刷新下拉列表</summary>
        /// <param name="value" type="String">值</param>
        RefreshSelect("inputSelectProvince", value, 2, 6, 0);
    }

    this.selectByOptions_values = function() {
        var _arrItems = "";
        var Obj = getObj("txtInterest");
        if (Obj) {
            _arrItems = get_CheckValues("step6");
            Obj.value = _arrItems;
        }
        else {
            _arrItems = get_CheckValues("selectOption");
            var arrItems = _arrItems.split(',')
            var Obj1 = getObj("SelCount");
            if (Obj1) Obj1.innerHTML = arrItems.length;
        }
    }

    this.Step = function(index) {
        /// <summary>自定义行程选择步骤</summary>
        /// <param name="value" type="Integer">步骤索引</param>
        index = parseInt(index);
        var Obj;
        for (k = 1; k <= 6; k++) {
            Obj = getObj("step" + k);
            if (Obj) {
                Obj.style.display = k == index ? "" : "none";
            }
        }
    }

    this.SaveValue = function() {
        /// <summary>答题</summary>
        var value = ""
        value += get_CheckValues("A1");
        value += "|" + get_CheckValues("A2");
        value += "|" + get_CheckValues("A3");
        value += "|" + get_CheckValues("A4");
        value += "|" + get_CheckValues("A5");
        value += "|" + get_CheckValues("A6");
        value += "|" + get_CheckValues("B1");
        value += "|" + get_CheckValues("B2");
        value += "|" + get_CheckValues("B3");
        value += "|" + get_CheckValues("B4");
        value += "|" + get_CheckValues("C1");
        var _ajax = new Ajax();
        _ajax.request(6, 1, 0, "&id=" + Control.Request("id") + "&value=" + value);

    }

    this.LoadValue = function() {
        /// <summary>加载选项</summary>
        var _ajax = new Ajax();
        var value = _ajax.request(6, 2, 0, "&id=" + Control.Request("id"));
        arrValue = value.split("|");
        if (arrValue.length > 1) {
            set_CheckValues("A1", arrValue[0]);
            set_CheckValues("A2", arrValue[1]);
            set_CheckValues("A3", arrValue[2]);
            set_CheckValues("A4", arrValue[3]);
            set_CheckValues("A5", arrValue[4]);
            set_CheckValues("A6", arrValue[5]);
            set_CheckValues("B1", arrValue[6]);
            set_CheckValues("B2", arrValue[7]);
            set_CheckValues("B3", arrValue[8]);
            set_CheckValues("B4", arrValue[9]);
            set_CheckValues("C1", arrValue[10]);
        }
    }

    this.Print = function() {
        /// <summary>打印行程单</summary>
        Control.goUrl("/itinerary/printPreview.aspx?id=" + Control.Request("id"), "_blank");
    }

    this.eBook = function(Path, PageCount) {
        /// <summary>自定义行程选择步骤</summary>
        /// <param name="Path" type="String">步骤索引</param>
        /// <param name="PageCount" type="Integer">步骤索引</param>
        var i, content = "";
        PageCount = parseInt(PageCount);
        for (i = 1; i <= PageCount; i++) {

            content += "<img src='/upload/book/" + Path + "/" + (1000 + i).toString().substring(2, 4) + ".jpg' alt='第" + i + "页'/>\n";
        }

        var _ajax = new Ajax();
        var template = _ajax.request(6, 3, 0);
        template = template.replace("{$content}", content);
        var winname = window.open('', '_blank', 'height=1000,width=800,top=200,left=300, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
        winname.document.open('text/html', 'replace');
        winname.document.writeln(template);
        return false;
    }


    this.active = function(name, activeIndex) {
        /// <summary>激活选项卡</summary>
        /// <param name="name" type="String">前缀标识</param>
        /// <param name="index" type="Integer">索引</param>
        var index = 1;
        var sheet = getObj(name + index);
        while (sheet) {
            if (index == activeIndex) {
                sheet.style.display = "";
            }
            else {
                sheet.style.display = "none"
            }
            index++;
            sheet = getObj(name + index);
        }
    }
}

