﻿function checkInput(e) {
    e = window.event || e;
    var evt = e.srcElement || e.target;
    evt.className = evt.value == "" ? "input_empty" : "input_fill";
}
function onFocus(e) {
    e = window.event || e;
    var evt = e.srcElement || e.target;
    if (evt.id == 'txtCName' && evt.value == '请填写公司名称') evt.value = "";
    if (evt.id == 'txtCPhone' && evt.value == '请填写联系电话') evt.value = "";
}
var tabType = {
    pnl1: [$('subguide1'), $('subguide2'), $('subguide3'), $('subguide4')],
    pnl2: [$('guidepnl1'), $('guidepnl2'), $('guidepnl3'), $('guidepnl4')],
    cidx: 0,
    init: function() {
        for (var i = 0; i < this.pnl1.length; i++) {
            this.pnl1[i].style.overflow = 'hidden';
            this.pnl2[i]._height = this.pnl2[i].getCoordinates().height;
            this.pnl2[i]._isHide = false;
        }
    },
    show: function(obj, id) {
        if (obj != null) obj.blur();
        
        this.cidx = id;
        
        if (this.pnl1[id].style.display == 'none') {
            this.pnl1[id].style.display = '';
        }
        var mobj = this.pnl1[id];
        var fx1 = new Fx.Styles(mobj, {duration: 500, transition: Fx.Transitions.linear, wait: false});
        
        var oh = parseInt(this.pnl2[id]._height);
        var marS = this.pnl2[id]._isHide ? 0 : oh;
        var marE = this.pnl2[id]._isHide ? oh : 0;
        
        fx1.start({
            'height': [marS, marE]
        }).chain(function() {
            if (!tabType.pnl2[tabType.cidx]._isHide) tabType.pnl1[tabType.cidx].style.display = 'none';
            tabType.pnl2[tabType.cidx]._isHide = !tabType.pnl2[tabType.cidx]._isHide;
        });
    }
};
var CurrentShowObj = $("d_objinfo_intro");
var ObjInfo = {
    pnl: [$('d_objinfo_intro'), $('d_objinfo_price')],
    show: function(obj, id) {
        if (obj != null) obj.blur();
        var nowObj = CurrentShowObj;
        var targetObj = this.pnl[id];
        var fx1 = new Fx.Styles(nowObj, {duration: 500, transition: Fx.Transitions.Quart.easeOut, wait: false});
        var fx2 = new Fx.Styles(targetObj, {duration: 500, transition: Fx.Transitions.Quart.easeIn, wait: false});
        
        fx1.start({
            'opacity': [1, 0]
        }).chain(function() {
            nowObj.setStyle('display', 'none');
            targetObj.setStyles({opacity: 0, display: ''});
            fx2.start({
                'opacity': [0, 1]
            });
            CurrentShowObj = targetObj;
        });
    }
};
var iShop = {
    pnl: [$('d_ishop_intro'), $('d_ishop_super'), $('d_ishop_type_price')],
    show: function(obj, id) {
        if (obj != null) obj.blur();
        var nowObj = CurrentShowObj;
        var targetObj = this.pnl[id];
        var fx1 = new Fx.Styles(nowObj, {duration: 500, transition: Fx.Transitions.Quart.easeOut, wait: false});
        var fx2 = new Fx.Styles(targetObj, {duration: 500, transition: Fx.Transitions.Quart.easeIn, wait: false});
        
        fx1.start({
            'opacity': [1, 0]
        }).chain(function() {
            nowObj.setStyle('display', 'none');
            targetObj.setStyles({opacity: 0, display: ''});
            fx2.start({
                'opacity': [0, 1]
            });
            CurrentShowObj = targetObj;
        });
    }
};
var AdService = {
    show: function(obj) {
        if (obj != null) obj.blur();
        var nowObj = CurrentShowObj;
        var targetObj = $("d_adservice");
        var fx1 = new Fx.Styles(nowObj, {duration: 500, transition: Fx.Transitions.Quart.easeOut, wait: false});
        var fx2 = new Fx.Styles(targetObj, {duration: 500, transition: Fx.Transitions.Quart.easeIn, wait: false});
        
        fx1.start({
            'opacity': [1, 0]
        }).chain(function() {
            nowObj.setStyle('display', 'none');
            targetObj.setStyles({opacity: 0, display: ''});
            fx2.start({
                'opacity': [0, 1]
            });
            CurrentShowObj = targetObj;
        });
    }
};
var Apply = {
    pnl: [$('d_apply_objinfo'), $('d_apply_adservice')],
    idx: 0,
    show: function(obj, id) {
        if (obj != null) obj.blur();
        var nowObj = CurrentShowObj;
        var targetObj = id == 2 ? this.pnl[1] : this.pnl[0];
        var fx1 = new Fx.Styles(nowObj, {duration: 500, transition: Fx.Transitions.Quart.easeOut, wait: false});
        var fx2 = new Fx.Styles(targetObj, {duration: 500, transition: Fx.Transitions.Quart.easeIn, wait: false});
        this.idx = id;
        
        fx1.start({
            'opacity': [1, 0]
        }).chain(function() {
            nowObj.setStyle('display', 'none');
            targetObj.setStyles({opacity: 0, display: ''});
            if (Apply.idx != 2) {
                if (Apply.idx == 1) {
                    $("d_btn_objinfo").style.display = 'none';
                    $("d_btn_ishop").style.display = '';
                }
                else {
                    $("d_btn_objinfo").style.display = '';
                    $("d_btn_ishop").style.display = 'none';
                }   
            }
            fx2.start({
                'opacity': [0, 1]
            });
            CurrentShowObj = targetObj;
            $("d_form_companyInfo_title").innerHTML = Apply.idx == 0 ? '电子地图标注服务申请（120元/年）' : '商家i-shop申请（1200元/年）';
        });
    }
};