/**
 * 로그인 창 Class
 * isFirst : 최초 로그인 여부 확인
 */
Ext.namespace("Ext.ux.hansub.window.AddReplyWindow");

Ext.ux.hansub.window.AddReplyWindow = function(obj, parent){
	
	this.obj = obj;
	this.parent = parent;
	
	this.commentTextArea = new Ext.form.TextArea({
		//fieldLabel: '댓글',
        name: 'content',
        anchor:'100%',
        width:250,
        height : 130, 
		hideLabel:true,
        allowBlank:false
	});
	
	this.formPanel = new Ext.form.FormPanel({
       // baseCls: 'loginForm',
        labelAlign:'top',
        labelWidth: 60,
        frame:true,
        method: 'POST',
        items: [this.commentTextArea]        
    });
	
	Ext.ux.hansub.window.AddReplyWindow.superclass.constructor.call(this, {
		title: '댓글 작성하기',
		id:'AddReplyWindowID',
		closable:true,
		iconCls:'add',
		resizable:false,
        width: 600,
        height:240,
        layout: 'fit',
        plain:true,
        modal:true,
        bodyStyle:'padding:5px;',
        buttonAlign:'right',
        items: this.formPanel,
        closeAction: 'hide',
        buttons: [
        {
            text: '저장',
            type:'submit',
            scope:this,
            handler: this.submit
        },{
            text: '취소',
            type:'cancel',
            scope:this,
            handler: this.cancel
        }]
	});
	
	//this.on('show', this.checkAuthor, this);
	
	
	
};

Ext.extend(Ext.ux.hansub.window.AddReplyWindow, Ext.Window, {
	/**
	checkAuthor : function(){
		// 등록 권한 습득
		Ext.Ajax.request({
			url: './src/api/Interface.php',
			params:{
					'class':'User',
					'method':'isLogin'
					},
			scope:this,
			success:function(response, options){
				
				var json = Ext.decode(response.responseText);
				
				if(json.success){
					
					islogin = true;
            		
            	}else{
					islogin = false;
					Ext.MessageBox.alert('오류', '댓글은 회원만 작성이 가능합니다.')
					Ext.getCmp('mainToolbarID').login();
					this.close();
				}
			},
			failure:function(response, options){
				islogin = false;
				Ext.MessageBox.alert('오류', '서버에 응답이 없습니다. 잠시 후 다시 접근해 주세요.')
			}
			            	
					
		});	
		
		
	
	},
	**/
	submit : function(){
		//var loginWindow = Ext.getCmp('loginWindow');
		if(this.formPanel.getForm().isValid()){
			this.formPanel.form.submit(
			{	waitMsg: '댓글 등록 중...',
				url:'./src/api/Interface.php',
				params :{
							'class':'Camping',
							method:'setInlineBlogReply', 
							uid:this.obj.uid
							
						},
				scope:this,
				success: function(form, action) {
					this.parent.reload();
					this.commentTextArea.reset();
					this.hide();
  										
				},
				failure: function(form, action) { 
					Ext.MessageBox.alert('Error', '항목등록 오류가 발생 했습니다.')
				}
			});
            		//loginWindow.close();
		}
		
	},
	
	cancel : function(){
		this.hide();
	},
	
	init : function(obj, parent){	
		this.obj = obj;
		this.parent = parent;
	},
	
	reset : function(){
		this.commentTextArea.reset()
	}
	




});

