﻿document.writeln("<script src=\"/include/Ajax.js\" type=\"text/javascript\"></script>");
function $(id) { return typeof id == "string" ? document.getElementById(id) : id; }
function hasClass(name, type, elem) {
    var r = [];
    if (document.getElementsByClassName) {
        if (type) {
            alert(type);
        }
        else {
            r = (elem ? $(elem) : document).getElementsByClassName(name)
        }
    } else {
        var re = new RegExp("(^|\\s)" + name + "(\\s|$)");
        var e = (elem ? $(elem) : document).getElementsByTagName(type || "*");
        for (var i = 0; i < e.length; i++) {
            if (re.test(e[i].className)) r.push(e[i]);
        }
    }
    return r;
}
function ReadComNews(obj, val) {
    Ajax.UpdateObj = obj;
    Ajax.IsXML = false;
    Ajax.SendRequest("/AdminInfo/NewsManage.aspx", val, "POST", eval("CreateNewsDiv"));
}
function CreateNewsDiv(el, val) {
    var array = eval(val);
    $(el).innerHTML = "";
    for (var i = 0; i < array.length; i++) {
        if (i == 0) {
            $(el).innerHTML = "<img src='/NewsPhoto/" + array[i].newPhoto + "' alt='新闻图片' width='320' height='100'/>";
        }
        $(el).innerHTML += "<li><a href='/News/" + array[i].newPage + "' title='" + array[i].newTitle + "'>" + array[i].newTitle + "</a></li>";
    }
}
function ReadNewsType(obj, val) {
    Ajax.UpdateObj = obj;
    Ajax.IsXML = false;
    Ajax.SendRequest("/News/NewsList.aspx", val, "POST", eval("CreateNewsTypeLi"));
}
function CreateNewsTypeLi(el, val) {
    var array = eval(val);
    $(el).innerHTML = "";
    for (var i = 0; i < array.length; i++) {
        $(el).innerHTML += "<li><a href='/News/NewsList_" + array[i].typeId + ".aspx'>" + array[i].typeName + "</li>";
    }
}
function VisitLog(val) {
    Ajax.UpdateObj = new Object;
    Ajax.IsXML = false;
    try {
        Ajax.SendRequest("/AdminInfo/AjaxVistaLog.aspx", val, "POST", new Function());
    }
    catch (e)
    { }
}
function mousePosition(ev) {
    ev = ev || window.event;
    if (ev.pageX || ev.pageY) {
        return { x: ev.pageX, y: ev.pageY };
    }
    return {
        x: ev.clientX + document.body.scrollLeft - document.body.clientLeft,
        y: ev.clientY + document.body.scrollTop - document.body.clientTop
    };
}
/*****************************************************************************
主页仿FLASH切换图片脚本开始    需要function $(id){return document.getElementById(id);}
******************************************************************************/
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function moveElement(elementID, final_x, final_y, interval) {
    if (!document.getElementById) return false;
    if (!document.getElementById(elementID)) return false;
    var elem = document.getElementById(elementID);
    if (elem.movement) {
        clearTimeout(elem.movement);
    }
    if (!elem.style.left) {
        elem.style.left = "0px";
    }
    if (!elem.style.top) {
        elem.style.top = "0px";
    }
    var xpos = parseInt(elem.style.left);
    var ypos = parseInt(elem.style.top);
    if (xpos == final_x && ypos == final_y) {
        return true;
    }
    if (xpos < final_x) {
        var dist = Math.ceil((final_x - xpos) / 10);
        xpos = xpos + dist;
    }
    if (xpos > final_x) {
        var dist = Math.ceil((xpos - final_x) / 10);
        xpos = xpos - dist;
    }
    if (ypos < final_y) {
        var dist = Math.ceil((final_y - ypos) / 10);
        ypos = ypos + dist;
    }
    if (ypos > final_y) {
        var dist = Math.ceil((ypos - final_y) / 10);
        ypos = ypos - dist;
    }
    elem.style.left = xpos + "px";
    elem.style.top = ypos + "px";
    var repeat = "moveElement('" + elementID + "'," + final_x + "," + final_y + "," + interval + ")";
    elem.movement = setTimeout(repeat, interval);
}

function classNormal(iFocusBtnID, iFocusTxID) {
    var iFocusBtns = $(iFocusBtnID).getElementsByTagName('li');
    var iFocusTxs = $(iFocusTxID).getElementsByTagName('li');
    for (var i = 0; i < iFocusBtns.length; i++) {
        iFocusBtns[i].className = 'normal';
        iFocusTxs[i].className = 'normal';
    }
}

function classCurrent(iFocusBtnID, iFocusTxID, n) {
    var iFocusBtns = $(iFocusBtnID).getElementsByTagName('li');
    var iFocusTxs = $(iFocusTxID).getElementsByTagName('li');
    iFocusBtns[n].className = 'current';
    iFocusTxs[n].className = 'current';
}

function iFocusChange() {
    if (!$('ifocus')) return false;
    $('ifocus').onmouseover = function() { atuokey = true };
    $('ifocus').onmouseout = function() { atuokey = false };
    var iFocusBtns = $('ifocus_btn').getElementsByTagName('li');
    var listLength = iFocusBtns.length;
    iFocusBtns[0].onclick = function() {
        moveElement('ifocus_piclist', 0, 0, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 0);
    }
    if (listLength >= 2) {
        iFocusBtns[1].onclick = function() {
            moveElement('ifocus_piclist', 0, -225, 5);
            classNormal('ifocus_btn', 'ifocus_tx');
            classCurrent('ifocus_btn', 'ifocus_tx', 1);
        }
    }
    if (listLength >= 3) {
        iFocusBtns[2].onclick = function() {
            moveElement('ifocus_piclist', 0, -450, 5);
            classNormal('ifocus_btn', 'ifocus_tx');
            classCurrent('ifocus_btn', 'ifocus_tx', 2);
        }
    }
    if (listLength >= 4) {
        iFocusBtns[3].onclick = function() {
            moveElement('ifocus_piclist', 0, -675, 5);
            classNormal('ifocus_btn', 'ifocus_tx');
            classCurrent('ifocus_btn', 'ifocus_tx', 3);
        }
    }
}

//setInterval('autoiFocus()',5000);
var atuokey = false;
function autoiFocus() {
    if (!$('ifocus')) return false;
    if (atuokey) return false;
    var focusBtnList = $('ifocus_btn').getElementsByTagName('li');
    var listLength = focusBtnList.length;
    for (var i = 0; i < listLength; i++) {
        if (focusBtnList[i].className == 'current') var currentNum = i;
    }
    if (currentNum == 0 && listLength != 1) {
        moveElement('ifocus_piclist', 0, -225, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 1);
    }
    if (currentNum == 1 && listLength != 2) {
        moveElement('ifocus_piclist', 0, -450, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 2);
    }
    if (currentNum == 2 && listLength != 3) {
        moveElement('ifocus_piclist', 0, -675, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 3);
    }
    if (currentNum == 3) {
        moveElement('ifocus_piclist', 0, 0, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 0);
    }
    if (currentNum == 1 && listLength == 2) {
        moveElement('ifocus_piclist', 0, 0, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 0);
    }
    if (currentNum == 2 && listLength == 3) {
        moveElement('ifocus_piclist', 0, 0, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 0);
    }

}
addLoadEvent(iFocusChange);
/*****************************************************************************
主页仿FLASH切换图片脚本结束
******************************************************************************/
function ChangeNavSelect(id) {
    $(id).className = "NavSelect";
}
function CheckRequestForm() {
    if (document.forms[0].CompanyName.value == "") {
        alert("请填写公司名称");
        return false;
    }
    if (document.forms[0].CompanyAddress.value == "") {
        alert("请填写公司地址");
        return false;
    }
    if (document.forms[0].CompanyArea.value == "") {
        alert("请填写公司领域");
        return false;
    }
    if (document.forms[0].CompanyMoney.value == "") {
        alert("请填写公司注册资金");
        return false;
    }
    if (document.forms[0].CompanyChairMan.value == "") {
        alert("请填写公司法人代表");
        return false;
    }
    if (document.forms[0].ConnPop.value == "") {
        alert("请填写联系人姓名");
        return false;
    }
    if (document.forms[0].ConnDuty.value == "") {
        alert("请填写联系人职务");
        return false;
    }
    if (document.forms[0].ConnTel.value == "") {
        alert("请填写联系人电话");
        return false;
    }
    if (document.forms[0].ConnEmail.value == "") {
        alert("请填写联系电子邮箱");
        return false;
    }
    if (document.forms[0].OptCustomer.value == "") {
        alert("请填写主要客户资源情况");
        return false;
    }
    if (document.forms[0].OptSameProduce.value == "") {
        alert("请填写以前是否代理过同类产品");
        return false;
    }
    if (document.forms[0].OptMain.value == "") {
        alert("请填写主营业务及业绩");
        return false;
    }
    if (document.forms[0].OptNet.value == "") {
        alert("请填写上网情况及网络环境");
        return false;
    }
    if (document.forms[0].OptTech.value == "") {
        alert("请填写技术人员情况(人数,水平)");
        return false;
    }
    if (document.forms[0].OptServices.value == "") {
        alert("请填写服务人员情况(人数,水平)");
        return false;
    }
    if (document.forms[0].OptSeller.value == "") {
        alert("请填写营销人员情况(人数,水平)");
        return false;
    }
    if (document.forms[0].OptMarket.value == "") {
        alert("请填写开拓市场的简单计划");
        return false;
    }
    alert("该功能制作中!\r\n请您先拨打我们的联系电话!");
    return false;
}
/*****************************************************************************
折叠
******************************************************************************/
var ttf = function(options) {
    this.setOptions = function(options) {
        return {
            name: options["name"] || "",
            item: options["item"] || "",
            con: options["con"] || "",
            event: options["event"] || "click",
            visited: options["visited"] || "",
            initCon: options["initCon"] || "none",
            other: options["other"] || "hide",
            autorun: options["autorun"] || "",
            setTime: options["setTime"] || "2000",
            callback: options["callback"] || ""
        }
    }
    this.options = this.setOptions(options);
    this.init = function() {
        this.name = $(this.options.name);
        this.item = hasClass(this.options.item, "", this.name);
        this.con = hasClass(this.options.con, "", this.name);
        this.currentItem = 0;
        this.autorunTimer = null;
        if (!this.name || this.item.length == 0 || this.con.length == 0) {
            return;
        }
        this.resetCon();
        if (typeof this.options.initCon == "number") {
            this.ctlCon(this.options.initCon - 1);
        } else if (this.options.initCon == "show") {
            for (var i = 0, j = this.con.length; i < j; i++) {
                this.con[i].style.display = "";
            }
        };
        this.autorunFn();
        this.setIndex();
    }
    this.setIndex = function() {
        var _this = this;
        for (var i = 0, j = this.item.length; i < j; i++) {
            (function(n) {
                _this.item[n]["on" + _this.options.event] = function() {
                    if (_this.options.autorun) {
                        clearTimeout(_this.autorunTimer);
                        _this.autorunTimer = null;
                    }
                    _this.ctlCon(n);
                    _this.currentItem = n + 1 == j ? 0 : n + 1;
                    setTimeout(function() { _this.autorunFn() }, _this.options.setTime);
                }
            })(i);
        };
    }
    this.ctlCon = function(index) {
        if (this.options.other == "hide") {
            this.resetCon();
        }
        if (this.con[index].style.display == "none") {
            this.con[index].style.display = "";
        } else {
            this.con[index].style.display = "none";
        }
        if (this.options.visited) {
            this.ctlItem(index);
        }
        if (this.options.callback) {
            this.options.callback.call(this, index);
        }
    }
    this.ctlItem = function(index) {
        if (this.item[index].className.indexOf(this.options.visited) != -1) {
            var defaultClass = this.item[index].className.split(this.options.visited).join("");
        } else {
            var defaultClass = this.item[index].className;
        }
        if (this.options.other == "hide") {
            for (var i = 0, j = this.item.length; i < j; i++) {
                this.item[i].className = defaultClass;
            }
        }
        if (this.con[index].style.display == "none") {
            this.item[index].className = defaultClass;
        } else {
            this.item[index].className = defaultClass + " " + this.options.visited;
        }
    },
				this.resetCon = function() {
				    for (var i = 0, j = this.con.length; i < j; i++) {
				        this.con[i].style.display = "none";
				    }
				}
    this.autorunFn = function() {
        if (this.options.autorun) {
            var _this = this;
            this.ctlCon(this.currentItem);
            this.ctlItem(this.currentItem);
            this.currentItem > this.item.length - 2 ? this.currentItem = 0 : this.currentItem++;
            this.autorunTimer = setTimeout(function() { _this.autorunFn(); }, _this.options.setTime);
        }
    }
    this.init();
};

