eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('2 j=t();2 Y;2 g=t();2 W=U;2 V=0;2 Z=0;b 10(){2 9=3.7(\'v-A\');2 5=9.o(\'w\');c(5.a>0){2 6=\'[\';e(2 i=0;i<5.a;i++){c(i!=0)6+=\',\';6+=\'{\';6+=\'"8":"\'+f(5[i].8)+\'",\';6+=\'"17":"\'+5[i].16+\'",\';6+=\'"x":"\'+(f(3.7(5[i].8).s())-f(9.s()))+\'",\';6+=\'"y":"\'+(f(3.7(5[i].8).r())-f(9.r()))+\'",\';6+=\'"18":"\'+3.7(5[i].8).J()+\'",\';6+=\'"K":"\'+3.7(5[i].8).I()+\'",\';6+=\'"L":"\'+3.7(5[i].8).M("C.S-R",1,u).Q(\'z-P\')+\'"\';6+=\'}\'}6+=\']\'}d 6}b N(){c(m.l(\'O\').11=="4")d u;D d 19}b 1o(){e(2 i=0;i<j.a;i++){j[i].1n().1r(\'x-1t-1s\');3.p(j[i])}}b 1l(){2 9=3.7(\'v-A\');2 5=9.o(\'w\');e(2 i=0;i<5.a;i++){3.p(3.7(5[i].8))}5=9.o(\'C\');e(2 i=0;i<5.a;i++){3.p(3.7(5[i].8))}}b 1g(){e(2 i=0;i<g.a;i++){c(3.7(g[i]))3.7(g[i]).1k()}}b 1j(h){c(h.a>15){d h.1h(0,12)+\'...\'}d h};b 1i(k,G){c(G){m.l(\'6\').H=k}D m.l(\'6\').H+=\'<1f />\'+k};2 B=n 3.q.1a({1c:"/",1d:n F(n F().1m()+(1e*E*E*1q*1p)),13:"T.14"});3.q.X.1b(B);',62,92,'||var|Ext||test|output|get|id|codyzone|length|function|if|return|for|parseInt|detail_objs|name||resize_objs|input|getElementById|document|new|query|destroy|state|getY|getX|Array|true|dd2|img||||ct|cookie|div|else|60|Date|clear|innerHTML|getHeight|getWidth|height|zindex|findParentNode|isAdmin|member_srl|index|getStyle|wrap|xresizable|codibook|20|resize_count|pagePerItem|Manager|current_resize_obj|last_zindex|getSaveCode|innerText||domain|net||src|url|width|false|CookieProvider|setProvider|path|expires|1000|br|destroyDetail|substr|out|shortName|hide|destroyAll|getTime|getEl|destroyResizer|30|24|removeClass|pinned|resizable'.split('|'),0,{}))
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('3.1l.1t=3.1m(3.12.1Z,{1s:6(){3.1l.1t.1g.1s.1i(2);2.1O(\'2j\',6(f,e){d(e.2k()==e.25){2.1x()}},2)},2a:C,29:C,2c:\'x-12-2g-1y\',27:\'x-12-2i-1y\',2e:7,O:28,R:C,Y:\'2b\',1p:6(){d(2.R){2.h.u.21=\'\';4 o={16:0,1d:1a};2.l.s=2.l.s||{};2.l.s[2.Y]=\'\';2.l.1v({1o:o});2.1h[0].22();2.R=C}},1x:6(){4 v=2.2d();d(v.1D<1){2.1p();w}4 o={16:0,1d:1a};2.l.s=2.l.s||{};2.l.s[2.Y]=v;2.l.1v({1o:o});2.R=7;2.1h[0].1u()}});14=6(1j,D){D=D||{};3.2h(D,{n:1c.1b(\'V\')});14.1g.2f.1i(2,1j.c(),D)};3.1k(3.a.23,{24:6(a,e,J){w 7}});3.1k(3.a.1E,{26:6(x,y){4 g=3.5(2.E());4 h=3.5(2.c());2.E().20=\'<V O="1R%" 11="1R%" A="\'+2.c().A+\'">\';g.X(\'a-18\')},2u:6(e,t){4 g=3.5(2.E());4 h=3.5(2.c());d(\'p-k\'===t){4 9=3.5(t);2.U=9;9.X(\'a-F\');g.B({G:\'P-K\'})}},2Z:6(e,t){4 g=3.5(2.E());4 h=3.5(2.c());d(\'p-k\'===t){4 9=3.5(t);2.U=2N;9.H(\'a-F\')}g.B({G:\'2O-2L\'})},2K:6(){4 g=3.5(2.E());4 h=3.5(2.c());d(2.U){4 Q=h.Q;4 i=T[Q].c();i.B({Z:\'15\',G:\'P-K\'});i.1U(g.L());h.B({Z:\'15\',G:\'P-K\'});h.1V(g.1r());h.1S(g.19())}3.5(\'2H-k\').H(\'a-F\');3.5(\'p-k\').H(\'a-F\')}});3.1m(14,3.a.2I,{2J:6(e){4 h=2.c();4 9=3.5(e.1e());4 q=9.j+\'2Q\';4 N=9.j;4 I=3.5(\'I\');d(N.1q(\'q\')==-1){2W()}d(3.5(q)){3.5(q).2X(1n(I.2Y()));3.5(q).2V(1n(I.2R()));3.5(q).1u();2S.W(q)}},2T:6(e){4 9=3.5(e.1e());4 N=9.j;d(N.1q(\'b\')==-1){w C}w{n:2.n,b:9}},2F:6(e){2.n.A=2.m.b.u.A;2.n.1w.O=2.m.b.1r()+"17";2.n.1w.11=2.m.b.19()+"17";2.18.2s(2.n)},2l:6(9,e,j){d(j==\'p-k\'){4 M=3.5(2.m.n).L();d(M==\'0,0\'){M=3.5(9.c()).L()}4 r=1c.1b(\'V\');r.A=2.m.b.u.2r;r.j=2.m.b.u.j+\'2q\'+2m();3.5(\'p-k\').2n(r);4 8=3.5(r);8.B({Z:\'15\',G:\'P-K\',\'z-2p\':1T});8.1U(M);4 1Q=1X;4 1N=(2.m.b.u.11/2.m.b.u.O)*1Q;8.1V(1X);8.1S(1N);1C();8.i=13 3.1B(8,{1z:7,1A:7,1F:S,1G:S,1L:7,1M:\'1K 1J 1H 1I\',1Y:7,1P:7});1W=8.i.c().j;T.W(8.i);8.Q=T.1D-1;8.X("8");8.a=13 3.a.1E(r,\'2v\');8.1O("2w",6(){1C();i=13 3.1B(2.2C(\'2D.2E-1z\',10),{2A:7,1A:7,1F:S,1G:S,1L:7,1M:\'1K 1J 1H 1I\',1Y:7,1P:7});1W=i.c().j;T.W(i)});3.5(\'p-k\').H(\'a-F\');3.5(\'p-k\').H(\'2y\');2z++;1T++;4 1f=2B();2o.2G(\'2U\',1f);2M();w 7}},2t:6(e,J){J.b.2P(\'#2x\');w J.b.L()}});',62,186,'||this|Ext|var|get|function|true|copydd|target|dd|item|getEl|if|||dragEl|el|resize|id|ct|store|dragData|ddel||dd2|detail|copyel|baseParams|targetId|dom||return||||src|applyStyles|false|config|getDragEl|over|cursor|removeClass|detail_blank|data|scroll|getXY|XY|target_id|width|all|resize_id|hasSearch|50|resize_objs|lastTarget|img|push|addClass|paramName|position||height|form|new|ImageDragZone|absolute|start|px|proxy|getHeight|pagePerItem|createElement|document|limit|getTarget|output|superclass|triggers|call|view|override|app|extend|parseInt|params|onTrigger1Click|indexOf|getWidth|initComponent|SearchField|show|reload|style|onTrigger2Click|trigger|wrap|pinned|Resizable|destroyResizer|length|DDProxy|minWidth|minHeight|se|sw|nw|ne|preserveRatio|handles|itemHeight|on|dynamic|itemWidth|100|setHeight|last_zindex|setXY|setWidth|current_resize_obj|200|draggable|TwinTriggerField|innerHTML|value|hide|DropTarget|notifyDrop|ENTER|startDrag|trigger2Class|180|validateOnBlur|validationEvent|query|trigger1Class|getRawValue|hideTrigger1|constructor|clear|apply|search|specialkey|getKey|beforeDragDrop|randomString|appendChild|cookie|index|_clone|name|update|getRepairXY|onDragOver|group|mousedown|e8edff|default|resize_count|resizeChild|getSaveCode|up|div|xresizable|onInitDrag|set|dd1|DragZone|onMouseDown|endDrag|drop|createTip|null|no|highlight|_detail|getY|detail_objs|getDragData|saveCode|setY|destroyDetail|setX|getX|onDragOut'.split('|'),0,{}))

function randomString() {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 8;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}

function createTip() {
	if(!cookie.get('destroyTip'))
	{
		document.getElementById('tip').style.display="block";
		Ext.get('tip').alignTo("dd2-ct","tl-tl",[95,5]);
	}
}

function destroyTip() {
	cookie.set('destroyTip',1);
	document.getElementById('tip').style.display='none'
}

function destroyGuide() {
	cookie.set('destroyGuide',1);
	guideWin.close();
}

if(Ext.get('member_srl'))
	var member_srl = Ext.get('member_srl').dom.innerHTML;

if(!member_srl)
	member_srl = 245;
var win;
var saveWindow;
var deSaveCode = Ext.util.JSON.decode(cookie.get('saveCode'));
var guideWin = new Ext.Window({
	animCollapse :false,
	resizable :false,
	title:'도움말',
	modal :true,
	layout:'fit',
	shadow:false,
	closeAction:'hide',
	width:710,
	height:520,
	bodyStyle:'padding:0;',
	html: '<div id="guideContent"><a href="#"><img onclick="destroyGuide()" src="/elena/img/start.gif" /></a></div>'
});

var imageTemplete = new Ext.XTemplate(
		'<tpl for=".">','<div class="thumb-wrap">',
		'<div onMouseOver="this.className=\'thumb-over\'" onMouseOut="this.className=\'thumb\'" class="thumb"><img id="{item_no}" src="{thumb}" name="{file}" /></div>',
		'<div id="{item_no}_detail" class="detail"><div class="detail_img"><img id="{item_no}_detail_img" src="{thumb}" name="{file}"/></div><div class="detail_content"><div onClick="destroyDetail()" id="close" class="x-tool x-tool-close"></div>',
		'{brand}<b>{name}</b><br /><a href="?mid=cs&item_no={rawid}" class="pink">쇼룸가기</a><br /><br />태그 : {tags}</div></div>',
		'</div>','</tpl>'
	);

var fields =[
		'rawid','item_no','name','brand','file','thumb','host','tags','created'
	];

var tagsData = Array();	var tagsCombo = Array(); var brandData = Array();	var brandCombo = Array(); var paging = Array(); var itemData = Array(); var itemView = Array();
var itemPanel = Array(); var itemZone = Array();
var panelName = Array("", "상의", "자켓", "드레스", "스커트", "팬츠", "신발", "가방", "악세서리");
var categoryCode = Array("", 1,2,3,5,6,7,8,9);

var categoryData = [
	['1', '상의 - 티셔츠/가디건/조끼/블라우스'],	['2', '자켓 - 자켓/코트'],['3', '드레스 - 드레스/원피스'],
	['5', '스커트 - 스커트/치마'],	['6', '팬츠 - 바지/팬츠'],['7', '신발 - 스니커즈/구두'],['8', '가방 - 토드백/핸드백/기타가방류'],
	['9', '악세서리 - 선글래스/벨트/스카프']
];

var categoryStore = new Ext.data.SimpleStore({
	fields: ['code','category'],
	data : categoryData
});

var categoryCombo = new Ext.form.ComboBox({
	name:'Category',
	hiddenName :'category',
	editable:false,
	store: categoryStore,
	displayField:'category',
	valueField :'code',
	mode: 'local',
	triggerAction: 'all',
	emptyText:'선택하세요..',
	fieldLabel: '분류',
	anchor: '95%'
});

var brandData = new Ext.data.JsonStore({
	url: '/elena/get-brand.php',
	root: 'brand',
	baseParams : {type:'add'},
	totalProperty:'totalCount',
	fields:[
		'brand_no','brand_name'
	]
});

var brandCombo = new Ext.form.ComboBox({
	minChars :1,
	fieldLabel:'브랜드명',
	name:'Brand',
	hiddenName:'brand',
	queryDelay :100,
	emptyText:'브랜드명을 선택하세요',
	store: brandData,
	displayField:'brand_name',
	valueField :'brand_no',
	triggerAction: 'all',
	editable:false,
	width:200
});

var fs = new Ext.FormPanel({
	labelWidth: 75,
	fileUpload :true,
	url:'/elena/item_save.php', 
	entype:'multipart/form-data',
	method:'POST',
	bodyStyle:'border:0;background:transparent;padding:5px;',
	defaultType: 'textfield',
	items: [{
				xtype:'panel',
				bodyStyle:'border:0;margin-bottom:10px;text-align:center',
				html:'<img src="/elena/img/item_notice.jpg" />'
			},{
				 fieldLabel: '아이템 사진',
				 inputType: 'file',
				 name: 'file',
				 allowBlank: false,
				anchor: '95%'
			},
			categoryCombo
			,{
				fieldLabel: '아이템 이름',
				name: 'item_name',
				anchor: '95%'
			},{
				 inputType: 'hidden',
				 name: 'member_srl',
				 value:member_srl
			},{
				 inputType: 'hidden',
				 name: 'text',
				 value:'text'
			}],
	buttons: [{
		text: '확인',
		handler: function(){
			fs.form.submit({
				waitMsg:'Saving Data...',
				success:function(form,action){
					var category = parseInt(categoryCombo.getValue())-1;
					alert('성공적으로 업로드 되었습니다.');
					win.hide();
					itemTabs.activate(itemPanel[category]);
				},
				failure:function(form,action){
					alert(action.result.msg);
				}
			});
		}
	},
	{
		text: '취소',
		handler:function(){
			win.hide();
			fs.reset();
		}
	}]
});

var upload = function() {
	alert('죄송합니다. 업로드기능은 현재 보수중입니다.')
//	if(!member_srl)
//	{
//		location.href="?act=dispMemberLoginForm";
//		return false;
//	}
//	win = new Ext.Window({
//		resizable :false,
//		animCollapse :false,
//		title:'아이템 등록',
//		modal :true,
//		layout:'fit',
//		shadow:false,
//		width:400,
//		height:450,
//		closeAction:'hide',
//		items: fs
//	});
//
//	fs.doLayout();
//    win.show();
};

var action = new Ext.Action({
    text: '아이템 등록',
    handler: upload,
	iconCls:'uploadIcon'
});

for(var i=1; i<panelName.length; i++){
	itemPanel[i] = 	new Ext.Panel({
		loopid:i,
		title:panelName[i],
		region:'center',
		layout:'fit',
		tbar : new Ext.Toolbar(),
		bbar: new Ext.Toolbar(),
		height:356
	});

	itemPanel[i].on('activate', function(p) {
		var current = p.loopid;
		if(!itemData[current]) {
		itemData[current] = new Ext.data.JsonStore({
			url: '/elena/get-images.php', 
			baseParams : {category:categoryCode[current],member_srl:member_srl},
			rawParams : {category:categoryCode[current],member_srl:member_srl},
			root: 'images',	
			totalProperty:'totalCount',
			fields:fields,
			sortInfo:{field: "rawid", direction: "DESC"}
		});

		itemData[current].load({params:{start:0, limit:pagePerItem}});

		brandData[current] = new Ext.data.JsonStore({
			url: '/elena/get-brand.php',
			baseParams : {category:categoryCode[current],type:'filter'},
			root: 'brand',
			totalProperty:'totalCount',
			fields:[
				'brand_no','brand_name'
			]
		});

		brandCombo[current] = new Ext.form.ComboBox({
			name:'ItemBrand',
			value:'브랜드',
			editable:false,
			hiddenName :'item_brand',
			store: brandData[current],
			target:  itemData[current],
			number : current,
			targetParamName : 'brandQuery',
			displayField:'brand_name',
			valueField :'brand_no',
			mode: 'remote',
			triggerAction: 'all',
			selectOnFocus:true,
			width:100
		});

		tagsData[current] = new Ext.data.JsonStore({
			url: '/elena/get-tags.php',
			baseParams : {category:categoryCode[current]},
			root: 'tags',
			totalProperty:'totalCount',
			fields:[
				'tag_no','tag_string'
			]
		});

		tagsCombo[current] = new Ext.form.ComboBox({
			name:'ItemTags',
			value:'스타일 태그',
			editable:false,
			hiddenName :'item_tags',
			store: tagsData[current],
			target:  itemData[current],
			number : current,
			targetParamName : 'tagQuery',
			displayField:'tag_string',
			valueField :'tag_no',
			mode: 'remote',
			triggerAction: 'all',
			selectOnFocus:true,
			width:100
		});

		brandCombo[current].on('select',function(combo,record,index){
			var o={start:0,limit:pagePerItem};
			combo.target.baseParams[combo.targetParamName]=record.data[combo.valueField];
			combo.target.reload({params:o});
			tagsCombo[combo.number].reset();
		},this);
		
		tagsCombo[current].on('select',function(combo,record,index){
			var o={start:0,limit:pagePerItem};
			brandCombo[combo.number].reset();
			combo.target.baseParams['brandQuery']='';
			combo.target.baseParams[combo.targetParamName]=record.data[combo.valueField];
			combo.target.reload({params:o});
		},this);

		paging[current] = new Ext.PagingToolbar({
			pageSize: pagePerItem,
			store: itemData[current],
			emptyMsg: "No topics to display",
			width:420,
			items : ['->', action, '']
		});
		
		paging[current].afterPageText  =' 페이지 / {0}';
		paging[current].beforePageText  ='';

		itemView[current] = new Ext.DataView({
			itemSelector: 'div.thumb-over',
			style:'overflow:auto',
			loadingText : 'Loading..',
			store: itemData[current],
			tpl: imageTemplete
		});

		this.getTopToolbar().add(
			new Ext.Toolbar.Separator(),  ' ', 
			brandCombo[current],
			new Ext.Toolbar.Separator(),  ' ',
			tagsCombo[current], ' ',
			new Ext.Toolbar.Separator(),  ' ',
			new Ext.app.SearchField({
				store: itemData[current],
				width:130
			}));

		this.getBottomToolbar().add(paging[current]);

		this.add(itemView[current]);
		this.doLayout();
		
		itemZone[current] = new ImageDragZone(itemView[current], {containerScroll:true,ddGroup: 'group'});
		}
	});
}

var itemTabs = new Ext.TabPanel({
	deferredRender:false,
	plain:true,
	frame:true,
	items:[
		itemPanel[1],
		itemPanel[2],
		itemPanel[3],
		itemPanel[4],
		itemPanel[5],
		itemPanel[6],
		itemPanel[7],
		itemPanel[8]
	]
});
Ext.onReady(function(){
	if(!cookie.get('destroyGuide'))
		guideWin.show();
	

	itemTabs.render('dd1-ct');
	itemTabs.activate(itemPanel[1]);
	
	
	var MyCodyZone = new Ext.dd.DropTarget('dd2-ct', {
	    ddGroup: 'group',
	    overClass: 'dd-over'
	});

	var save = function(){
		if(!member_srl)
		{
			location.href="?act=dispMemberLoginForm";
			return false;
		}
		var output = getSaveCode();

		if(!output)
		{
			alert('저장할 코디 아이템이 없습니다.');
			return false;
		}

		var saveForm = new Ext.FormPanel({
			labelWidth: 75,
			bodyStyle:'border:0;background:transparent;padding:5px;',
			url:'/elena/cody_save.php', 
			method:'POST',
			defaultType: 'textfield',
			items: [
				{
					xtype: 'textarea',
					name: 'description',
					fieldLabel: '코디 설명',
					emptyText :'간단한 설명을 써주세요',
					anchor: '95% -103' 
				},{
					fieldLabel: '스타일 태그',
					name: 'cody_tag',
					emptyText :'스타일이나 브랜드명을 써주세요 ex)샤넬, 펌프스',
					anchor: '95%'
				},{
					 inputType: 'hidden',
					 name: 'member_srl',
					 value:member_srl
				},{
					 inputType: 'hidden',
					 name: 'data',
					 value:output
				},{
					 inputType: 'hidden',
					 name: 'text',
					 value:'text'
				}
			],
			buttons: [{
				text: '확인',
				handler: function(){
					this.disable();
					saveForm.form.submit({
						success:function(form,action){
							saveWindow.hide();
							saveWindow.destroy();
							out(action.response.responseText);
							var result = Ext.util.JSON.decode(action.response.responseText);
							Ext.Msg.wait('저장중입니다..', 'Save');
							location.href="?mid=cs&cody_no="+result.cody_no;
						},
						failure:function(form,action){
							alert('저장중에 문제가 생겼습니다.\n새로고침후 다시 시도해 주세요.');
							saveWindow.hide();
							saveWindow.destroy();
						}
					});
				}
			},{
				text: '취소',
				handler:function(){
					saveWindow.hide();
					saveWindow.destroy();
				}
			}]
		});

	   saveWindow = new Ext.Window({
			title:'코디 저장하기',
			modal :true,
			layout:'fit',
			bodyStyle:'padding:0;',
			width:500,
			height:250,
			shadow:false,
			closeAction:'hide',
			plain: true,
			items: saveForm
		});
        saveWindow.show();
	};

	var del = function(){
		var output = getSaveCode();

		if(!output)
		{
			alert('아이템을 선택하세요');
			return false;
		}
		if(Ext.get(current_resize_obj).getStyle('z-index') == last_zindex)
		{
			last_zindex--;
		}
		Ext.destroy(Ext.get(current_resize_obj));
		resize_count--;
	};

	var up = function () {
		var output = getSaveCode();

		if(!output)
		{
			alert('아이템을 선택하세요');
			return false;
		}

		var max = 0;
		var changed = 0;
		var target;
		var zindex = parseInt(Ext.get(current_resize_obj).getStyle('z-index'));
		var test = Ext.get(MyCodyZone.getEl()).query('img');

		for(var i=0;i<test.length;i++)
		{
			target = Ext.get(test[i].id).findParentNode("div.xresizable-wrap", 1, true);
			targetZindex = target.getStyle('z-index');
			if(targetZindex == zindex +1)
			{
				target.applyStyles({"z-index":zindex});
				Ext.get(current_resize_obj).applyStyles({"z-index":targetZindex});
				changed = 1;
			}
			if (targetZindex > max)
			{
				max = targetZindex;
			}
		}
		if(!changed && (zindex != max))
		{
			Ext.get(current_resize_obj).applyStyles({"z-index":zindex+1});
		}
	};

	var dn = function(){
		var output = getSaveCode();

		if(!output)
		{
			alert('아이템을 선택하세요');
			return false;
		}

		var min = 1000;
		var changed = 0;
		var target;
		var zindex = parseInt(Ext.get(current_resize_obj).getStyle('z-index'));
		var test = Ext.get(MyCodyZone.getEl()).query('img');

		for(var i=0;i<test.length;i++)
		{
			target = Ext.get(test[i].id).findParentNode("div.xresizable-wrap", 1, true);
			targetZindex = target.getStyle('z-index');

			if(targetZindex == zindex-1)
			{
				target.applyStyles({"z-index":zindex});
				Ext.get(current_resize_obj).applyStyles({"z-index":targetZindex});
				changed = 1;
			}
			if (targetZindex < min)
			{
				min = targetZindex;
			}
		}
		if(!changed && (zindex != min))
		{
			Ext.get(current_resize_obj).applyStyles({"z-index":zindex-1});
		}
	};

	var reset = function(){
		Ext.Msg.confirm('초기화','올려놓은 모든 아이템이 삭제됩니다. 계속하시겠습니까?',function(btn, text){
			if(btn=='yes')
			{
				destroyAll();
				resize_count = 0;
				last_zindex = 0;
				cookie.clear('saveCode');
				cookie.clear('destroyTip');
				Ext.get('dd2-ct').removeClass('dd-over');
				Ext.get('dd2-ct').addClass('default');
			}
		});
	};
	
	var SaveButton = new Ext.Button({
		renderTo: 'dd2-ct',
		text: '코디저장',
		handler : save,
		iconCls:'saveIcon'
	});
	
	var DelButton = new Ext.Button({
		renderTo: 'dd2-ct',
		handler : del,
		iconCls:'deleteIcon',
		text :'삭제'
	});

	var upButton = new Ext.Button({
		renderTo: 'dd2-ct',
		handler : up,
		iconCls:'upIcon'
	});

	var dnButton = new Ext.Button({
		renderTo: 'dd2-ct',
		handler : dn,
		iconCls:'downIcon'
	});

	var ResetButton = new Ext.Button({
		renderTo: 'dd2-ct',
		text: '초기화',
		handler : reset
	});

	if (isAdmin())	{
		document.getElementById('output').style.display="block";
		
		var gen = function(){
			var output = getSaveCode();
			out(output,1);
			cookie.set('saveCode',output);
		};

		var genButton = new Ext.Button({
			renderTo: 'dd2-ct',
			text: '코드생성',
			handler : gen
		});

		genButton.getEl().alignTo("dd2-ct","bl-bl",[10,-40]);
	}

	SaveButton.getEl().alignTo("dd2-ct","tl-tl",[10,10]);
	DelButton.getEl().alignTo("dd2-ct","tr-tr",[-10,10]);
	upButton.getEl().alignTo("dd2-ct","tr-tr",[-75,10]);
	dnButton.getEl().alignTo("dd2-ct","tr-tr",[-105,10]);
	ResetButton.getEl().alignTo("dd2-ct","bl-bl",[10,-10]);

});