﻿/*
========================
     Index Send Mail
@author: HONG,Lane-Chang
@dates:  2009/03/10
@update: 
========================
*/

var fIMail = null;

Ext.onReady(function(){
	
	fIMail = new Ext.form.FormPanel({
		border:false,
		applyTo:'divIMail',
		bodyStyle:'background-color:#efefef',
		items: [
			new Ext.form.TextField({
                  labelSeparator: '：',
                  allowBlank: true,                  
                  readOnly: true,
                  disabled:true,
                  width:20,
                  minLength:2,
                  maxLength:20,
                  fieldClass: 'field_null',
				  fieldLabel:'您的姓名'
			}),
			new Ext.form.TextField({
			      id:'IMail_name',
                  hideLabel:true,
                  msgTarget: 'side',
                  width: 160,                
                  allowBlank: false
			}),
			new Ext.form.TextField({
                  labelSeparator: '：',
                  allowBlank: true,
                  disabled:true,                  
                  readOnly: true,
                  width:20,
                  fieldClass: 'field_null',
				  fieldLabel:'聯絡電話'
			}),
			new Ext.form.TextField({
				  id:'IMail_phone',
                  hideLabel:true,
                  msgTarget: 'side',
                  width: 160,
                  allowBlank: true
			}),
			new Ext.form.TextField({
                  labelSeparator: '：',
                  allowBlank: true,
                  disabled:true,                  
                  readOnly: true,
                  width:20,
                  fieldClass: 'field_null',
				  fieldLabel:'聯絡信箱'
			}),
			new Ext.form.TextField({
				  id:'IMail_Mail',
                  hideLabel:true,
                  msgTarget: 'side',
                  width: 160,
                  vtype: 'email',
                  allowBlank: true
			}),
			new Ext.form.TextField({
                  labelSeparator: '：',
                  allowBlank: true,                  
                  readOnly: true,
                  disabled:true,
                  width:20,
                  fieldClass: 'field_null',
				  fieldLabel:'服務需求'
			}),
			new Ext.form.CheckboxGroup({				   
                   hideLabel:true,
                   allowBlank:true,
                   width:180,
                   vertical: false,
                   columns: 1,
                   items: [
                        {
                                name: 'ckServ',
                                inputValue: '網站平台',
                                boxLabel: '網站平台',                                
                   				itemCls:'ckitem',
                                checked: true
                        }, {
                                name: 'ckServ',
                                inputValue: '互動導覽',
                                boxLabel: '互動導覽',
                  				itemCls:'ckitem'
                        }, {
                                name: 'ckServ',
                                inputValue: '影片動畫',
                                boxLabel: '影片動畫',
                                itemCls:'ckitem'
                        }, {
                                name: 'ckServ',
                                inputValue: '數位學習',
                                boxLabel: '數位學習',
                                 itemCls:'ckitem'
                         }, {
                                name: 'ckServ',
                                inputValue: '行銷設計 ',
                                boxLabel: '行銷設計 ',
                                 itemCls:'ckitem'
                         }, {
                                name: 'rioService',
                                inputValue: '展場建置 ',
                                boxLabel: '展場建置 ',
                                 itemCls:'ckitem'
                         }
                   ]
            }),
            new Ext.form.TextField({
                  labelSeparator: '：',
                  allowBlank: true,                  
                  readOnly: true,
                  width:20,
                  fieldClass: 'field_null',
				  fieldLabel:'需求說明'
			}),
			new Ext.form.TextArea({
                  id: 'IMail_content',
                  msgTarget: 'side',
                  hideLabel:true,
                  width: 180,
                  height: 100,
                  maxLength: 512
           })
		],
		buttons:[
			 {
                id: 'btnIMail_submit',
                text: '確定送出',
                handler: fnIMail_Submit
             }, {
                id: 'btnIMail_clear',
                text: '清除重填',
                handler: function() {
                fnShowQ_YN('系統訊息', '您確定要清除已填寫的資料嗎?', 'btnIMail_clear', fnIMail_Clear);
              }
           }
		]
	});
	
	
	//送出表單
	function fnIMail_Submit(){
		 if (fIMail.getForm().isValid()) {
            fIMail.getForm().submit({
                method: 'POST',
                url: 'Handle.aspx?fn=send_Index_mail',
                waitMsg: '資料傳送中，請稍候...',
                waitTitle: '系統訊息',
                reset: true,
                success: function(form, action) {
                    try {
                       oJson = Ext.util.JSON.decode(action.response.responseText);                    
                    } catch (e) {
                            fnShowWar(e);
                    }
                    
                        if (oJson.success == true) {
                            fnShowInfo('系統訊息',oJson.msg, 'btnIMail_submit','');
                        }
                        else {
                            fnShowErr(oJson.msg, 'btnIMail_submit', '');
                        }
                },
                failure: function(form, action) {
                    try {
                       oJson = Ext.util.JSON.decode(action.response.responseText);
                    }
                    catch (e) {
                            fnShowWar(e);
                    }
                    
                    fnShowErr(oJson.msg, 'btnIMail_submit', '');
                }
            });
        }
	}
	
	
	
	 //清除資料
    function fnIMail_Clear(id) {
        if (id == "yes") {
            fIMail.getForm().reset();
        }
    }
});
