if(!window.by) window.by = new Object();
if(!window.by.make) window.by.make = new Object();
by.make.Template = {
emailid :"",
types :["image","edit","movie"],
TEMPLATEDIV : "byTemplate",
TEMPLATEDIVTOP :  "byTemplateTop",
TEMPLATEDIVBOTTOM :  "byTemplateBottom",
TEMPLATEDIVBACKGROUND :  "box_back",
TRANS_BOX_PREFIX : "trans_",
edit : [],
activeEdit : null,
badTemplate : function(){
alert("잘못된 템플릿입니다.");
},
init : function(){
daum.debug("domain");
this.templateDiv = $(this.TEMPLATEDIV);
if(this.templateDiv == null ||this.templateDiv == undefined){
this.badTemplate();
return;
}
this.seq = this.templateDiv.getAttribute("seq");
//this.imageContainer = $(this.templateDiv.getAttribute("imageContainer"));
},
trans : function(){
by.make.boxes.EditBox.init();
var boxes = this.getBoxDivs(this.templateDiv );
for(var i=0;i<boxes.length;i++){
var f = this.getFunction(boxes[i]);
daum.debug(f);
f.trans(boxes[i]);
}
document.domain="daum.net";
},
backTrans : function(){
by.make.boxes.EditBox.init();
var boxes = this.getBoxDivs(this.templateDiv );
for(var i=0;i<boxes.length;i++){
var f = this.getFunction(boxes[i]);
daum.debug(f);
f.backTrans(boxes[i]);
};
},
check :function(){
var boxes = this.getBoxDivs(this.templateDiv );
for(var i=0;i<boxes.length;i++){
var f = this.getFunction(boxes[i]);
var ret = f.check(boxes[i]);
if(ret == false) return false;
};
return true;
},
previewTrans : function(){
by.make.boxes.EditBox.init();
var boxes = this.getBoxDivs(this.templateDiv );
for(var i=0;i<boxes.length;i++){
var f = this.getFunction(boxes[i]);
daum.debug(f);
f.previewTrans(boxes[i]);
}
},
previewBackTrans : function(){
by.make.boxes.EditBox.init();
var boxes = this.getBoxDivs(this.templateDiv );
for(var i=0;i<boxes.length;i++){
var f = this.getFunction(boxes[i]);
daum.debug(f);
f.previewBackTrans(boxes[i]);
}
},
add : function(type){
var container = this.getContainerByType(type);
daum.debug(container);
var max = this.getContainerAttribute(container,"maxcnt");
var cnt = this.getBoxDivs(container).length;
if(max > cnt){
this.getFunctionByType(type).add();
}else{
alert("더이상 추가하실 수 없습니다.");
}
},
createDiv : function(t){
var s = ++this.seq;
var id = "by_box"+s;
var div = document.createElement("DIV");
if(t == "edit"){
div.setAttribute("type","edit");
var ui = by.make.ImageBox.ui();
}else if(t == "image"){
div.setAttribute("type","image");
var ui = by.make.ImageBox.ui();
div.className = "imgObj";
}
div.id = id;
div.innerHTML = ui;
return div;
},
deleteBox : function(id){
var box = $(id);
var min = this.getContainerAttributeByBox(box,"mincnt");
var cnt = this.getBoxDivs( this.getContainer(box)).length;
daum.debug("cnt:"+cnt);
if(cnt > min){
Element.remove(this.TRANS_BOX_PREFIX+id);
}else{
alert("최소"+min+"개 이상 있어야합니다.");
}
},
getBoxDivs : function(elements){
var ret = [];
if(elements == null || elements == undefined) return ret;
var c = elements.getElementsByTagName("DIV");
for(var i=0;i<c.length;i++){
for(var j=0; j<this.types.length;j++){
if(c[i].getAttribute("type") == this.types[j]){
ret.push(c[i]);
}
}
}
return ret;
},
getContainerAttributeByBox : function(d,attribute,defaultValue){
var container = this.getContainer(d);
return this.getContainerAttribute(container,attribute,defaultValue);
},
getContainerAttribute : function(container,attribute,defaultValue){
var ret = container.getAttribute(attribute);
if(ret == null) return defaultValue;
return ret;
},
getContainer : function(d){
daum.debug("by.make.Template.getContainer");
var p = d.parentNode;
if(p == null){
return null;
}else{
var a =p.getAttribute("type");
if(a == null) this.getContainer(p);
if(a == "container"){
return p;
}else{
return this.getContainer(p);
}
}
},
getContainerByType : function(type){
daum.debug("by.make.Template.getContainerByType");
if(type == "image")
return this.imageContainer;
else if(type == "edit")
return this.editContainer;
else if(type == "movie")
return this.movieContainer;
},
getFunction : function(box){
daum.debug("by.make.Tempate.getFunction");
daum.debug(box);
daum.debug(by.make.boxes.ImageBox);
var attribute = box.getAttribute("type");
return this.getFunctionByType(attribute);
},
getFunctionByType : function(type){
var attribute = type;
if(attribute == "image")
return by.make.boxes.ImageBox;
else if(attribute == "edit")
return by.make.boxes.EditBox;
else if(attribute == "movie")
return by.make.boxes.MovieBox;
return null;
},
mapOpen : function(){
var w = window.open("http://local.daum.net/sShow/","map","width=668,height=570");
//this.map();
},
map : function(n,x,y,params){
daum.debug("n");
daum.debug(n);
daum.debug(x);
daum.debug(y);
if( n == undefined || n == null || n == ""){
var n = "";
}
if(params == undefined || params == null || params == ""){
params = "";
}
this.mapui(n,n,x,y,params);
},
mapCallback : function(ret,n,x,y,params){
this.mapui(ret,n,x,y,params);
//<a href="http://local.daum.net/include/urlencoding.jsp?rurl=/map/cityntot/map.jsp?S_NAME=&E_X=505752&E_Y=1110712&E_NAME=서울시 중구">길찾기</a>
},
mapui : function(ret,n,x,y,params){
if(params == undefined || params == null || params == ""){
params = "";
}
var l ='<a href="http://local.daum.net/include/urlencoding.jsp?rurl=/map/cityntot/map.jsp?pos='+x+'|'+y+params+'" target="_blank">'+n +' 지도 보기</a>';
this.activeEdit.doc.body.innerHTML =this.activeEdit.doc.body.innerHTML +l;
},
change :function(id,mode){
if(confirm("다른 템플릿을 선택하시면 작성하시던 내용이 삭제됩니다. 다른 템플릿을 선택하시겠습니까?")){
var f = document.makeForm;
f.target="";
if(mode == 0)
f.action="/by/make/third.daum";
else
f.action="/by/mypage/modify.daum";
f["byBean.by_template_id"].value = id;
f.submit();
}
}
}
if(!window.by) window.by = new Object();
if(!window.by.sms) window.by.sms = new Object();
by.sms.Check = {
MAX_SIZE : 80,
PRE_SIZE : 0,
OLD_CNT : 1,
initMsgLen : function(preWordId, msgLenId) {
var objPreWord = document.getElementById(preWordId);
var objMsgLen = document.getElementById(msgLenId);
var nbytes = this.lenText(preWordId);
objMsgLen.innerHTML = nbytes;
this.PRE_SIZE = nbytes;
},
chkTextLength : function(textId, msgLenId) {
var curSize = this.PRE_SIZE + this.lenText(textId);
var cnt = 0;
if(curSize % this.MAX_SIZE == 0)
cnt = parseInt(curSize / this.MAX_SIZE);
else
cnt = parseInt(curSize / this.MAX_SIZE) + 1;
var objText = document.getElementById(textId);
var objMsgLen = document.getElementById(msgLenId);
var len = this.lenText(textId);
if (curSize > 0 && this.OLD_CNT < cnt && this.OLD_CNT >0 ) {
alert((this.OLD_CNT * this.MAX_SIZE) + "byte가 초과하여 " + cnt + "개의 문자로 나누어 보냅니다.");
//objText.value = objText.value.replace(/\r\n$/, "");
//objText.value = this.astText(maxSize, textId, msgLenId);
}
this.OLD_CNT = cnt;
objMsgLen.innerHTML = this.PRE_SIZE + this.lenText(textId);
},
lenText : function(textId) {
var str = document.getElementById(textId).value;
var nbytes = 0;
for (i = 0, len = str.length; i < len; i++) {
var ch = str.charAt(i);
if(escape(ch).length > 4) {
nbytes += 2;
} else if (ch == '\n') {
if (str.charAt(i-1) != '\r') {
nbytes += 1;
}
} else {
nbytes += 1;
}
}
return nbytes;
},
astText : function(maxSize, textId, msgLenId) {
var str = document.getElementById(textId).value;
var objMsgLen = document.getElementById(msgLenId);
var inc = 0;
var nbytes = 0;
var text = "";
for (i=0, len = str.length; i < len; i++) {
var ch = str.charAt(i);
if (escape(ch).length > 4) {
inc = 2;
} else if (ch == '\n') {
if (str.charAt(i-1) != '\r') {
inc = 1;
}
} else {
inc = 1;
}
if ((nbytes + inc) > maxSize) {
break;
}
nbytes += inc;
text += ch;
}
objMsgLen.innerHTML = nbytes; //현재 byte수를 넣는다
return text;
},
isNumbers : function(textId) {
var objText = document.getElementById(textId);
var str = objText.value;
var numcheck = /\d/;
var text = "";
for(i=0, len = str.length; i < len; i++) {
var ch =str.charAt(i);
if(!numcheck.test(ch)) {
return false;
}
}
return true;
},
checkForm : function() {
var maxSize = this.MAX_SIZE - this.PRE_SIZE;
var objFromsms = document.getElementById("fromsms");
if(objFromsms.value == "" || !this.isNumbers("fromsms")) {
alert("보내는 사람 전화번호를 입력하여 주십시오.");
return false;
} else {
var cnt = 0;
for(i =0; i < 10; i++) {
var objTosms = document.getElementById("tosms" + i);
if(objTosms.value == "") {
cnt++;
}
if(objTosms.value != "" && !this.isNumbers("tosms" + i)) {
alert("받는 사람 전화번호를 입력하여 주십시오.");
return false;
}
}
if(cnt == 10) {
alert("받는 사람 전화번호를 입력하여 주십시오.");
return false;
}
}
document.list.submit();
},
clearForm : function() {
var frm = document.list;
frm.contents.value= "";
for(i = 0; i < 10; i++)
frm["smsBeanList[" + i + "].tosms"].value = "";
frm.fromsms.value = "";
this.chkTextLength('contents', 'msgLen');
return false;
}
}
if(!window.by) window.by = new Object();
if(!window.by.make) window.by.make = new Object();
if(!window.by.make.boxes) window.by.make.boxes = new Object();
by.make.boxes.EditBox = {
beforeGap : 0,
init : function(){
this.beforeGap = 0;
},
trans : function(box){
//box = $('byTemplate');
daum.debug("trans");
var height = box.getAttribute("originalheight");
var edit = new by.edit.Editor(box.id,{height:height });
by.make.Template.edit[box.id] = edit;
by.make.Template.activeEdit = edit;
if(!by.Common.isEmpty(height)){
this.setSize(box,this.calGap(false,box.offsetHeight,box.getAttribute("originalheight")));
}
},
backTrans : function(box){
var edit = by.make.Template.edit[box.id];
edit.updateContent();
this.setSize(box,this.calGap(true,box.getAttribute("originalheight"),box.offsetHeight));
//this.resize(box,b,true);
},
previewBackTrans : function(box){//미리보기할때
var edit= by.make.Template.edit[box.id];
edit.viewContent();
var b = $(edit.EDIT_VIEW+edit.editDiv.id);
//			this.resize(box,b,true);
daum.debug("------------------");
daum.debug(b);
daum.debug(b.offsetHeight);
this.setSize(box,this.calGap(true,box.getAttribute("originalheight"),b.offsetHeight));
},
previewTrans : function(box){//미리보기에서 돌아올때.
var edit= by.make.Template.edit[box.id];
this.setSize(box,this.calGap(false,box.offsetHeight,box.getAttribute("originalheight")));
//			this.resize(box,b,false);
edit.viewEdit();
},
setSize : function(box,cal){
if(cal.to <box.getAttribute("originalheight")){
cal.to = box.getAttribute("originalheight");
}
var container = by.make.Template.getContainer(box);
var background = $("box_back");
var containerDim = daum.dom.Element.getDimension(container);
var backgroundDim = daum.dom.Element.getDimension(background);
var boxDim = daum.dom.Element.getDimension(box);
daum.dom.Element.setDimension(box,boxDim.x ,cal.to )
daum.dom.Element.setDimension(container,containerDim.x ,containerDim.y + cal.gap )
daum.dom.Element.setDimension(background,backgroundDim.x ,backgroundDim.y + cal.gap )
},
calGap : function(isPlus , from ,to){
var gap = to - from;
if(isPlus){
if(gap > this.beforeGap){
var temp = gap;
gap = gap - this.beforeGap;
this.beforeGap = temp;
}else{
gap = 0;
}
}else{
if(gap < this.beforeGap){
var temp = gap;
gap = gap - this.beforeGap;
this.beforeGap = temp;
}else{
gap = 0;
}
}
daum.debug("gap:"+gap);
daum.debug("to:"+to);
return {gap:gap,to:to};
},
resize :function(box,b,mode){
var edit = by.make.Template.edit[box.id];
daum.debug(b);
var container = by.make.Template.getContainer(box);
var background = $(box.id+"_back");
var containerDim = daum.dom.Element.getDimension(container);
var boxDim = daum.dom.Element.getDimension(b);
var backgroundDim = daum.dom.Element.getDimension(background);
var gap = 0;
if(mode){
var height = boxDim.y;
/*
alert("height:"+height);
alert("h:"+edit.doc.body.scrollHeight);
alert("2:"+edit.doc.documentElement.scrollHeight);
*/
gap = height - edit.original_size ;
if(gap <0) gap = 0;
daum.debug("height:"+height);
daum.debug("gap:"+gap);
daum.debug(edit.original_size);
edit.gap = gap;
//		daum.debug(edit.doc.body.clientHeight);
//		daum.debug(edit.doc.documentElement.clientHeight);//
//		daum.debug(edit.doc.documentElement.scrollHeight);//
//		daum.debug(edit.doc.body.scrollHeight);
//		daum.debug(edit.doc.documentElement.offsetHeight);
//		daum.debug(boxDim.y);
}else{
gap = (edit.gap ) * (-1);
}
//		alert(containerDim.y + gap);
//		alert(backgroundDim.y + gap );
daum.dom.Element.setDimension(box,boxDim.x ,boxDim.y )
daum.dom.Element.setDimension(container,containerDim.x ,containerDim.y + gap )
daum.dom.Element.setDimension(background,backgroundDim.x ,backgroundDim.y + gap )
},
check : function(box){
var edit = by.make.Template.edit[box.id];
if(edit.isLineOver()){
alert("100줄 이하의 내용만 등록 가능합니다.");
return false;
}
if(!edit.hasImage()){
if(edit.textLength()<30){
alert("더 자세하게 알려보세요!\n(30자 이상인 경우 신청가능합니다.)");
return false;
}
}
return true;
}
}
if(!window.by) window.by = new Object();
if(!window.by.mypage) window.by.mypage = new Object();
by.mypage.Mypage = {
selectedCheckBox : false,
del : function(id){
if(confirm("정말로 삭제하시겠습니까?")){
var f = document.list;
f.id.value = id;
f.mode.value ="delete";
f.submit();
}else{
return;
}
},
modify : function(id){
var f = document.f;
f.action="/by/mypage/modify.daum";
f.id.value = id;
f.submit();
},
changeStatus : function(){
var f = document.f;
var s = document.getElementById("byStatus");
f.action="/by/mypage/list.daum";
f.status_code.value = s[s.selectedIndex].value;
f.page.value = "1";
f.submit();
},
preview : function(id){
//var w = window.open("/by/mypage/preview.daum?id="+id,this.BYPREVIEW,"width=850,height=570,scrollbars=yes");
var w = window.open("/by/mypage/preview.daum?id="+id,this.BYPREVIEW,"");
},
goPage : function(page){
var f = document.f;
f.action="/by/mypage/list.daum";
f.page.value = page;
f.submit();
},
delAll : function(){
if(confirm("정말로 삭제하시겠습니까?")){
var f = document.list;
f.mode.value ="delete";
f.submit();
}
},
selectAllCheckBox : function(){
if(this.selectedCheckBox) this.selectedCheckBox = false;
else this.selectedCheckBox = true;
var f = document.list;
if(f.ids.length >0){
for(var i=0;i<f.ids.length;i++){
f.ids[i].checked = this.selectedCheckBox;
}
}else{
f.ids.checked = this.selectedCheckBox;
}
},
extendPeriod : function(id){
var f = document.f;
if(confirm("1개월 연장하시겠습니까?")){
f.action="/by/mypage/extendPeriod.daum";
f.id.value = id;
f.submit();
}
},
cancel : function(id){
var f = document.f;
if(confirm("정말 게재 중지 하시겠습니까?")){
f.action="/by/mypage/changeStatus.daum";
f.mode.value="cancel";
f.id.value = id;
f.submit();
}
}
}
if(!window.by) window.by = new Object();
if(!window.by.main) window.by.main = new Object();
daum.include("by.dao.ByDAO")
by.main.Category = {
now_category : 2,
categories :{
2 :{
on : "http://imgsrc.search.daum-img.net/search_all/show/tab_01_on.gif",
off :"http://imgsrc.search.daum-img.net/search_all/show/tab_01.gif"
},
3 :{
on : "http://imgsrc.search.daum-img.net/search_all/show/tab_02_on.gif",
off :"http://imgsrc.search.daum-img.net/search_all/show/tab_02.gif"
},
4 :{
on : "http://imgsrc.search.daum-img.net/search_all/show/tab_03_on.gif",
off :"http://imgsrc.search.daum-img.net/search_all/show/tab_03.gif"
},
5 :{
on : "http://imgsrc.search.daum-img.net/search_all/show/tab_04_on.gif",
off :"http://imgsrc.search.daum-img.net/search_all/show/tab_04.gif"
},
6 :{
on : "http://imgsrc.search.daum-img.net/search_all/show/tab_05_on.gif",
off :"http://imgsrc.search.daum-img.net/search_all/show/tab_05.gif"
},
7 :{
on : "http://imgsrc.search.daum-img.net/search_all/show/tab_07_on.gif",
off :"http://imgsrc.search.daum-img.net/search_all/show/tab_07.gif"
},
1 :{
on : "http://imgsrc.search.daum-img.net/search_all/show/tab_06_on.gif",
off :"http://imgsrc.search.daum-img.net/search_all/show/tab_06.gif"
}
},
uis : null,
tpHtml :  new totalHtml(),//html 수집
load : function(by_category_id){
daum.debug(by_category_id);
by.dao.ByDAO.selectUis(by_category_id,this.callback.bind(this));
},
callback : function(ret){
daum.debug("callback");
//		daum.debug(ret);
daum.debug(ret.size());
this.uis = ret;
this.tProVar();
},
tProVar : function(){
var tts = new Array();
if(this.uis!=null){
var k = 1;
var tt =  new tProVar2();
tts.push(tt);
for(var i=0;i<this.uis.size();i++){
daum.debug(this.uis[i]);
tt.insVal(this.image_path(this.uis[i].thumbnail),"by.main.Category.make('"+this.uis[i].by_ui_id+"');","by.main.Category.preview('"+this.uis[i].by_ui_id+"', '"+this.image_path(this.uis[i].image)+"');");
/*
if(k == 3){
tt = new tProVar2();
tts.push(tt);
}
*/
k++;
}
this.tpHtml.clear();
for(var i=0;i<tts.length;i++){
this.tpHtml.inHtml(tts[i].sHtml());
}
this.tpHtml.outHtml('tView1',1);
var listNum = Math.ceil(this.uis.size()/3);
this.ttp = new tpScr('tView1',listNum, 'by.main.Category.ttp', 743);
}
},
changeList : function(id){
daum.debug("changeList"+id);
$("by_category_"+this.now_category).src = this.categories[this.now_category].off;
$("by_category_"+id).src = this.categories[id].on;
this.now_category = id;
var by_category_id = id;
this.load(by_category_id);
},
make : function(id){
location.href="/by/make/second.daum?preId="+id;
},
make_pop : function(id) {
opener.location.href="/by/make/second.daum?preId="+id;
window.close();
},
preview : function(id, image,isMake){
if(isMake == undefined) isMake = 0;
window.open("/by/top/preview.daum?id="+id + "&image="+image+"&make="+isMake,"preview","width=840,height=620");
},
makePreview : function(id, image){
by.main.Category.preview(id,image,1);
},
image_path : function(image){
if (by.Common.isEmpty(image)) return "";
if(image.indexOf("http")>-1){
return image;
}else{
return "http://show.daum.net/show_image/"+image;
}
}
}
if(!window.by) window.by = new Object();
if(!window.by.dao) window.by.dao = new Object();
by.dao.ByDAO = {
selectByByKeyword: function (kword,callback) {
var service = daum.net.DWRService.getService("by.services.ByService");
service.selectByByKeyword(kword,{
callback: function (ret) {
callback(ret);
}
});
},
updateSms: function (bean,callback) {
daum.debug("updateSms");
daum.debug(bean);
var service = daum.net.DWRService.getService("by.services.ByService");
service.updateSms(bean,{
callback: function (ret) {
callback(ret);
}
});
},
getDataXML : function (by_main_id, callback) {
var service = daum.net.DWRService.getService("by.services.ByService");
service.getDataXML(
by_main_id,
{
callback: function(ret) {
callback(ret);
}
}
);
},
selectSkins : function (id,mode, callback) {
var service = daum.net.DWRService.getService("by.services.ByService");
service.selectSkins(
id,
mode,
{
callback: function(ret) {
callback(ret);
}
}
);
},
selectUis : function (by_category_id, callback) {
var service = daum.net.DWRService.getService("by.services.ByService");
service.selectUis(
by_category_id,
{
callback: function(ret) {
callback(ret);
}
}
);
},
selectPresents : function (by_category_id, callback) {
var service = daum.net.DWRService.getService("by.services.ByService");
service.selectPresents(
by_category_id,
{
callback: function(ret) {
callback(ret);
}
}
);
},
encode : function (str,x,y, callback) {
var service = daum.net.DWRService.getService("by.services.ByService");
service.encode(
str,
{
callback: function(ret) {
callback(ret,str,x,y);
}
}
);
},
show : function (id,by_main_id, callback) {
var service = daum.net.DWRService.getService("by.services.ByService");
service.show(
id,by_main_id,
{
callback: function(ret) {
callback(ret);
}
}
);
},
selectShowByKowrd : function (kword, callback) {
var service = daum.net.DWRService.getService("by.services.ByService");
service.selectShowByKowrd(
kword,
{
callback: function(ret) {
callback(ret);
}
}
);
}
}
if(!window.by) window.by = new Object();
if(!window.by.make) window.by.make = new Object();
by.make.Sms  = {
insert : function(){
var id = $('byId').value;
var n1 = $('bySms1');
var n2 = $('bySms2');
var n3 = $('bySms3');
if(by.Common.isEmpty(n1.value) || !by.Common.isNumber(n1.value)){
alert("번호를 정확히 입력해주세요.");
n1.focus();
return;
}
if(by.Common.isEmpty(n2.value) || !by.Common.isNumber(n2.value)){
alert("번호를 정확히 입력해주세요.");
n2.focus();
return;
}
if(by.Common.isEmpty(n3.value) || !by.Common.isNumber(n3.value)){
alert("번호를 정확히 입력해주세요.");
n3.focus();
return;
}
var sms = n1.value+n2.value+n3.value;
by.dao.ByDAO.updateSms({"id":id,"sms":sms},this.callback.bind(this));
},
callback : function(ret){
if(ret>0){alert("저장 되었습니다.");}else{alert("저장에 실패하였습니다.");};
}
}
if(!window.by) window.by = new Object();
if(!window.by.mypage) window.by.mypage = new Object();
by.mypage.Option = {
insertRecommand : function(){
this.kword = $("recommandKword").value;
var cnt = parseInt($("recommandCount").value);
if(cnt > 3){
alert("3개이상 등록하실 수 없습니다.");
return;
}
if(this.kword.trim() == ""){
alert("검색어를 입력해주세요.");
return;
}
by.dao.ByDAO.selectShowByKowrd(this.kword,this.callback.bind(this));
},
callback : function(ret){
if(ret == null){
alert("다음 검색에 검색쇼가 나오고 있는 검색어만 등록 가능합니다.");
}else{
var f =document.option;
f["byBean.real_kword"].value = this.kword;
f.action="/by/option/insertRecommand.daum";
f.submit();
}
},
change : function(){
var f =document.option;
f.action="/by/option/update.daum";
f.submit();
}
}
if(!window.by) window.by = new Object();
if(!window.by.make) window.by.make = new Object();
daum.include("by.dao.ByDAO")
by.make.Skin = {
skins : null,
skinList : {},
loadSkinList : function(id,mode){
daum.debug("key:"+this.key());
if(this.skinList[this.key()] == null){
by.dao.ByDAO.selectSkins(id,mode,this.callbackLoadSkinList.bind(this));
}else{
this.skins = this.skinList[this.key()];
this.html();
}
},
key : function(){
return this.mode+"_"+this.id;
},
callbackLoadSkinList : function(ret){
daum.debug("callbackLoadSkinList");
this.skins = ret;
this.skinList[this.key()] = ret;
this.html();
},
html : function(){
if(this.skins.html == undefined){
this.tProVar();
}else{
this.skins.html.outHtml('skinList',1);
this.ttp = this.skins.ttp;
}
},
tProVar : function(){
var tts = new Array();
var tpHtml =  new totalHtml();//html 수집
if(this.skins!=null){
var k = 1;
var tt =  new tProVar();
tts.push(tt);
for(var i=0;i<this.skins.size();i++){
//				daum.debug(this.skins[i]);
tt.insVal(this.skins[i].thumbnail,"by.make.Skin.changeSkin('"+i+"');");
k++;
}
tpHtml.clear();
for(var i=0;i<tts.length;i++){
tpHtml.inHtml(tts[i].sHtml());
}
tpHtml.outHtml('skinList',1);
daum.debug(this.skins.size());
var listNum = Math.ceil(this.skins.size()/8);
this.ttp = new tpScr('skinList',listNum, 'by.make.Skin.ttp', 695);
this.skins.ttps =this.ttp;
this.skins.html = tpHtml;
}
},
changeSkinList : function(id,mode){
this.id = id;
this.mode = mode;
//		var by_category_id = $('byCategory')[$('byCategory').selectedIndex].value;
this.loadSkinList(id,mode);
/*
if(mode == 0){
this.skins = this.skinListCategory[id];
}else{
this.skins = this.skinListSkinCategory[id];
}
* */
this.tProVar();
},
changeSkin : function(skin){
var s = this.skins[skin];
daum.debug(s);
daum.debug(s.bg1);
daum.debug(s.bg2);
daum.debug(s.image_style);
var template = $(by.make.Template.TEMPLATEDIV);
var templateTop = $(by.make.Template.TEMPLATEDIVTOP);
var templateBottom = $(by.make.Template.TEMPLATEDIVBOTTOM);
var back = $(by.make.Template.TEMPLATEDIVBACKGROUND);
template.style.background = "url("+s.bg1+") repeat-y";
templateTop.style.background= "url("+s.bg2+") no-repeat top";
daum.debug(s.bg3);
templateBottom.style.background= "url("+s.bg3+") bottom no-repeat";
var background = "background3";
daum.debug("eeeeeeeeee");
daum.debug(s.edit_style);
if(s.edit_style !=null)
background = "background"+s.edit_style;
if(back != undefined && back !=null)
back.className = background;
var box = by.make.Template.getBoxDivs(by.make.Template.templateDiv);
for(var i=0;i<box.length;i++){//border
var b = box[i];
var t = b.getAttribute("type")
if( t  == "image"){
daum.debug("change_skin_border");
var borderColor ="#EBEBEB";
if(s.image_style != null)
borderColor = s.image_style;
b.style.borderColor = borderColor;
}
}
}
}
if(!window.by) window.by = new Object();
if(!window.by.main) window.by.main = new Object();
by.main.Show = {
goPage : function(page){
var f = document.f;
f.action="/by/top/show.daum";
f.page.value = page;
f.submit();
}
}
if(!window.by) window.by = new Object();
if(!window.by.report) window.by.report = new Object();
by.report.Chart = {
divCnt : null,
divNum : null,
goPage : function(page){
var f = document.f;
f.action="/by/report/list.daum";
f.page.value = page;
f.submit();
},
getReportRange : function(divCnt, divNum, by_main_id) {
this.divCnt = divCnt;
this.divNum = divNum;
this.getDataXML(by_main_id, this.getDataXMLCallback.bind(this));
},
getDataXML : function(by_main_id, c) {
by.dao.ByDAO.getDataXML(by_main_id, c);
},
getDataXMLCallback : function(dataXML) {
var chart1 = new FusionCharts("/by/charts/Column2D.swf", "Chart_" + this.divNum, "400", "200", "0", "1");
chart1.setDataXML(dataXML);
chart1.render("chart_" + this.divNum);
this.showChart();
},
showChart : function() {
for(i = 1; i <= this.divCnt; i++)
if(i == this.divNum)
if(document.getElementById("tr_" + i).style.display == "")
document.getElementById("tr_" + i).style.display = "none";
else
document.getElementById("tr_" + i).style.display = "";
else
document.getElementById("tr_" + i).style.display = "none";
}
}
if(!window.by) window.by = new Object();
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
return this.replace(/\s+$/,"");
}
by.Common = {
isNumber : function(n){
if (!n) return false;
for (var i=0;i<n.length;i++) {
var c=n.charAt(i);
if ((c<"0" || c>"9") && (c!=".")) return false;
}
return true;
},
getValue : function(value, nullValue){
if(value == undefined || value == null){
return nullValue;
}
return value;
},
isEmpty :  function(value){
if(value == undefined || value == null || value ==""){
return true;
}
return false;
}
}
if(!window.by) window.by = new Object();
if(!window.by) window.by = new Object();
if(!window.by.message) window.by.message = new Object();
by.message.Message = {
show : function(id,by_main_id){
by.dao.ByDAO.show(id,by_main_id,this.callback.bind(this));
},
callback : function(ret){
var msg='';
if (ret == null|| ret==""){
msg ='<div class="noKw">검색쇼가 없습니다.</div>'
}else{
msg ='<ul>';
for (var i=0;i<ret.size() ;i++ ){
msg=msg+'<li onMouseOver="this.style.background=\'#ebebeb\';"  onMouseOut="this.style.background=\'#ffffff\';"><a href="http://search.daum.net/search?w=tot&q='+ret[i].encode_real_kword+'" onFocus="this.blur();" target="_new">'+ret[i].real_kword+'</a></li>';
}
msg +='</ul>';
}
document.getElementById('kwDiv').innerHTML = msg;
document.getElementById('kwDiv').style.top = this.My -2;
document.getElementById('kwDiv').style.left = this.Mx -2;
document.getElementById('kwDiv').style.display="block";
},
viewKw : function(e,id,by_main_id){
this.Mx = (!document.all) ? e.pageX : event.clientX + document.body.scrollLeft;
this.My = (!document.all) ? e.pageY : event.clientY + document.body.scrollTop;
this.show(id,by_main_id);
}
}
if(!window.by) window.by = new Object();
if(!window.by.make) window.by.make = new Object();
by.make.Check = {
BYSTYLE : "byStyle",
BYCONTENT : "byContent",
BYPRESENT : "byPresent",
BYMESSAGE : "byMessage",
BYPREVIEW : "byPreview",
PREKEYWORD : "preKeyword",
SUFKEYWORD : "sufKeyword",
KWORD : "byKeyword",
PATTERN : "@",
MIN_LENGTH : 0,
checked : false,
stepSecondCheck : function(){
if(this.preCheck() && this.sufCheck() && this.periodCheck()){
this.keywordCheck(this.stepSecondCheckCallback.bind(this));
}
},
stepSecondKeywordCheck : function(){
if(this.preCheck() && this.sufCheck()){
this.keywordCheck(this.stepSecondKeywordCheckCallback.bind(this));
}
},
modify : function(){
if(!this.isChecked()) {
alert("미리보기를 하셔야 신청이 가능합니다.");
return false;
}else if(by.make.Template.check()){
by.make.Template.backTrans();
var f = document.makeForm;
f.target="";
f.action="/by/mypage/modifyUpdate.daum";
var content = $(this.BYCONTENT).innerHTML;
f["byBean.content"].value = this.transMovie(content);
var present_yn = "N";
var hasMessage = "N";
if($(this.BYPRESENT).checked) present_yn = "Y";
if($(this.BYMESSAGE).checked) hasMessage = "Y";
f["byBean.present_yn"].value =present_yn;
f["byBean.hasMessage"].value =hasMessage;
f.submit();
}
},
stepThirdCheck : function(){
if(!this.isChecked()) {
alert("미리보기를 하셔야 신청이 가능합니다.");
return false;
}else if(by.make.Template.check()){
if(confirm("이 내용으로 신청하시겠습니까?")){
by.make.Template.backTrans();
var f = document.makeForm;
f.target="";
f.action="/by/make/complete.daum";
var content = $(this.BYCONTENT).innerHTML;
f["byBean.content"].value = this.transMovie(content);
var present_yn = "N";
var hasMessage = "N";
if($(this.BYPRESENT).checked) present_yn = "Y";
if($(this.BYMESSAGE).checked) hasMessage = "Y";
f["byBean.present_yn"].value =present_yn;
f["byBean.hasMessage"].value =hasMessage;
f.submit();
}
}
},
editCheck : function(){
var ret = true;
for(var vo in by.make.Template.edit){
if(vo.indexOf("by_box")>-1){
var edit = by.make.Template.edit[vo];
if(edit.isLineOver()){
ret = false;
break;
}
}
}
if(!ret){
alert("100줄 이하의 내용만 등록 가능합니다.");
}
return ret;
},
preCheck : function(){
var preKeyword = document.getElementById(this.PREKEYWORD);
if(preKeyword.value.trim() == "" || preKeyword.value.trim() == "@"){
alert("키워드를 입력해주세요");
return false;
}
return true;
},
periodCheck : function(){
var f = document.makeForm["byBean.enddt"];
for(var i=0;i<f.length;i++){
if(f[i].checked)
return true;
}
alert("기간선택");
return false;
},
patternCheck : function(){
var preKeyword = document.getElementById(this.PREKEYWORD).value;
p = preKeyword.trim();
if(p.substring(0,1)!= this.PATTERN){
alert(this.PATTERN+"를 삭제하실 수 없습니다.");
document.getElementById(this.PREKEYWORD).value = "@"+preKeyword;
}
},
sufCheck : function(){
var check = false;
var preKeyword = document.getElementById(this.PREKEYWORD).value;
preKeyword = preKeyword.ltrim();
preKeyword = preKeyword.rtrim();
if(preKeyword.substring(0,1)== this.PATTERN) return true;
else{
for(var i=0;i<bySufKeyword.length;i++){
var k = preKeyword.lastIndexOf(bySufKeyword[i]);
daum.debug(k);
if(k> -1 && preKeyword.length == k+bySufKeyword[i].length){
var trimPreKeyword = preKeyword.substring(0,k).trim();
daum.debug(trimPreKeyword);
if(trimPreKeyword.length<this.MIN_LENGTH){
alert("길이가 너무 짧습니다.");
return false;
}
daum.debug("ok");
check = true;
break;
}
}
if(!check){
//				alert("@를 앞에 붙이시거나 다른 패턴어를 뒤에 붙이셔야 합니다.");
alert("@를 반드시 붙이셔야 합니다.");
return false;
}
}
return true;
},
sufKeyword : function(keyword){
var preKeyword = document.getElementById(this.PREKEYWORD).value;
var k = preKeyword.ltrim();
k = preKeyword.rtrim();
if(k.length == 0) return false;
if(k.substring(0,1) == "@"){
k = k.substring(1,k.length);
}
for(var i=0;i<bySufKeyword.length;i++){
var p = k.lastIndexOf(bySufKeyword[i]);
if(p > -1 && k.length == p+bySufKeyword[i].length){
k = k.substring(0,p);
}
}
k = k.ltrim();
k = k.rtrim();
k = k + " " + keyword;
document.getElementById(this.PREKEYWORD).value = k;
},
keywordCheck : function(c){
var preKeyword = document.getElementById(this.PREKEYWORD).value;
by.dao.ByDAO.selectByByKeyword(preKeyword,c);
},
stepSecondKeywordCheckCallback : function(ret){
if(ret == 1){
alert("이미 있는 키워드 입니다.");
}else if(ret == 3){
alert("상업용 키워드 입니다.");
}else if(ret == 2){
alert("성인  키워드 입니다.");
}else if(ret == 0){
alert("사용 가능한 키워드 입니다.");
}else if(ret == -1){
alert("알수 없는 에러입니다.");
}
return false;
},
stepSecondCheckCallback : function(ret){
if(ret == 1){
alert("이미 있는 키워드 입니다.");
}else if(ret == 0){
this.confirm();
}else if(ret == 3){
alert("상업용 키워드 입니다.");
}else if(ret == 2){
alert("성인  키워드 입니다.");
}else if(ret == -1){
alert("알수 없는 에러입니다.");
}
return false;
},
confirm : function(){
var	f = document.getElementById("makeForm");
f.submit();
},
preview : function(){
//		daum.debug(this.transMovie(""));
by.make.Template.previewBackTrans();
//var w = window.open("",this.BYPREVIEW,"width=850,height=570,scrollbars=yes");
var w = window.open("",this.BYPREVIEW,"");
var	f = document.makeForm;
f.action = "/by/make/preview.daum";
var hasMessage = "N";
if($(this.BYMESSAGE).checked) hasMessage = "Y";
var content = $(this.BYCONTENT).innerHTML;
f["byBean.content"].value = this.transMovie(content);
f["byBean.hasMessage"].value =hasMessage;
f["byBean.reg"].value = "true";
//alert(f["byBean.content"].value);
f.target =this.BYPREVIEW;
f.submit();
by.make.Template.previewTrans();
this.checked = true;
},
transMovie : function(str){
/*
str = '<OBJECT\nid=daumActiveXObject42 codeBase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.c-ab#version=9,0,0,0 type=application/x-shockwave-flash height=296 width=367 classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 name=daumActiveXObject42><PARAM NAME="_cx" VALUE="9710"><PARAM NAME="_cy" VALUE="7832"><PARAM NAME="FlashVars" VALUE=""><PARAM NAME="Movie" VALUE="http://flvs.daum.net/flvPlayer.swf?vid=2YRZRl2jRm8$"><PARAM NAME="Src" VALUE="http://flvs.daum.net/flvPlayer.swf?vid=2YRZRl2jRm8$"><PARAM NAME="WMode" VALUE="Transparent"><PARAM NAME="Play" VALUE="0"><PARAM NAME="Loop" VALUE="-1"><PARAM NAME="Quality" VALUE="High"><PARAM NAME="SAlign" VALUE="LT"><PARAM NAME="Menu" VALUE="-1"><PARAM NAME="Base" VALUE=""><PARAM NAME="AllowScriptAccess" VALUE="always"><PARAM NAME="Scale" VALUE="ShowAll"><PARAM NAME="DeviceFont" VALUE="0"><PARAM NAME="EmbedMovie" VALUE="0"><PARAM NAME="BGColor" VALUE="FFFFFF"><PARAM NAME="SWRemote" VALUE=""><PARAM NAME="MovieData" VALUE=""><PARAM NAME="SeamlessTabbing" VALUE="1"><PARAM NAME="Profile" VALUE="0"><PARAM NAME="ProfileAddress" VALUE=""><PARAM NAME="ProfilePort" VALUE="0"><PARAM NAME="AllowNetworking" VALUE="all"><PARAM NAME="AllowFullScreen" VALUE="false">'
+'<embed id="daumActiveXObject25" name="daumActiveXObject25" type="application/x-shockwave-flash" width="367" height="296" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" undefined="undefined" movie="http://flvs.daum.net/flvPlayer.swf?vid=2YRZRl2jRm8$" src="http://flvs.daum.net/flvPlayer.swf?vid=2YRZRl2jRm8$" play="1" quality="high" wmode="transparent" allowScriptAccess="always" bgcolor="#FFFFFF" FlashVars="" />'
+'</OBJECT></DIV></DIV></DIV>';
*/
var str = str.replace(/<object(\n|.)*<\/object>/i,"");
str = str.replace(/<script(\n|.)*<\/script>/i,"");
var div = document.getElementById("by_movie_by_box1");
if(div == undefined || div == null){
}else{
var vid = div.getAttribute("vid");
var did = div.getAttribute("did");
var x = div.getAttribute("x");
var y = div.getAttribute("y");
str +="<script type='text/javascript'>ShowFlash('http://flvs.daum.net/flvPlayer.swf?vid="+vid+"','',"+x+","+y+",'"+did+"');</script>";
}
daum.debug(str);
//str = str.replace(/(<!--SHOW\[(.*)\]SHOW-->)/,'$1 $2');
return str;
},
selectMy : function(){
var	f = document.make;
if(f["byBean.by_template_id"].length >0){
for(var i=0;i<f["byBean.by_template_id"].length;i++){
f["byBean.by_template_id"][i].checked = false;
}
}else{
f["byBean.by_template_id"].checked = false;
}
},
isChecked : function() {
return this.checked;
},
selectTemplateId : "by_template_id_15",
selectTemplate : function(id){
sampleViewClose();
var	f = document.make;
if(f["preId"]){
if(f["preId"].length >0){
for(var i=0;i<f["preId"].length;i++){
f["preId"][i].checked = false;
}
}else{
f["preId"].checked = false;
}
}
before = this.selectTemplateId;
this.selectTemplateId = id;
this.selectTemplateOut(before);
$(id).checked = true;
},
selectTemplateOver: function(id){
$(id+"_img").style.display = "none";
$(id+"_img_on").style.display = "";
},
selectTemplateOut : function(id){
if(this.selectTemplateId != id){
$(id+"_img_on").style.display = "none";
$(id+"_img").style.display = "";
}
},
go:function(num){
if(confirm("이전 단계로 돌아가시면 작성하시던 내용이 삭제됩니다. 이전 단계로 돌아가시겠습니까?")){
history.go(num);
}
},
goStep1:function(){
if(confirm("다른 템플릿을 선택하시면 작성하시던 내용이 삭제됩니다. 다른 템플릿을 선택하시겠습니까?")){
location.href="/by/make/first.daum";
}
},
makeSample: function(id){
opener.by.make.Check.selectTemplate('by_template_id_'+id);
opener.document.make.submit();
window.close();
}
}
if(!window.by) window.by = new Object();
if(!window.by.make) window.by.make = new Object();
if(!window.by.make.boxes) window.by.make.boxes = new Object();
by.make.boxes.MovieBox = {
IMAGEUPLOADDIV : "by_imageupload_",
MOVIEDIV : "by_movie_",
movieUpladed : false,
trans : function(box){
this.setMovieUpladed(box);
this._createDiv(box);
},
backTrans : function(box){
//by.make.Template.getContainer(box).appendChild(box);
Element.remove(this.IMAGEUPLOADDIV+box.id);
},
previewBackTrans : function(box){
this.backTrans(box);
},
previewTrans : function(box){
this.trans(box);
},
add : function(){
},
setMovieUpladed: function(d){
daum.debug(d.id+"_movie");
var movie = document.getElementById(this.MOVIEDIV+d.id);
daum.debug(movie);
if(movie != null ) this.movieUpladed = true;
},
del : function(id){
by.make.Template.deleteBox(id);
},
_createDiv : function(d){
daum.debug(d);
//		var container =	by.make.Template.getContainer(d);
//var div = document.createElement("DIV");
//div.id = by.make.Template.TRANS_BOX_PREFIX+d.id;
//div.className = "imgObj";
//		daum.debug(this.getContainerAttribute(d,"del"));
d.style.position ="relative";
if(by.make.Template.getContainerAttributeByBox(d,"del",false) == "true"){
var delDiv = document.createElement("DIV");
delDiv.innerHTML="삭제";
delDiv.onclick = this.del.bind(this,d.id);
d.appendChild(delDiv);
}
var imageAddDiv = document.createElement("DIV");
var movieFile ="<img id='movieUploadImg' src='http://imgsrc.search.daum-img.net/search_all/show/bt_009.gif' alt='동영상올리기'>";
if(this.movieUpladed){
movieFile ="<img id='movieUploadImg' src='http://imgsrc.search.daum-img.net/search_all/show/bt_009_1.gif' alt='동영상변경하기'>";
}
var imageUploadUI = "<a href='#' onclick=\"by.make.boxes.MovieBox.upload('"+d.id+"');return false\">"
+movieFile+"</a>"
var imageAddDiv = document.createElement("DIV");
imageAddDiv.id = this.IMAGEUPLOADDIV+d.id;
imageAddDiv.innerHTML=imageUploadUI;
imageAddDiv.style.cursor = "pointer";
imageAddDiv.className = "imgUpload";
var dim = daum.dom.Element.getDimension(d);
imageAddDiv.style.top = parseInt((dim.y - 20)/2)+"px";
imageAddDiv.style.left = parseInt((dim.x - 64)/2)+"px";
d.appendChild(imageAddDiv);
//div.appendChild(d);
//container.appendChild(div);
},
upload :function(id){
this.id = id;
window.open("/by/movie/movie_upload.html","moveUpload","width=500,height=480");
},
check : function(box){
if(this.movieUpladed == true){
return true;
}else{
alert("동영상을 올려주세요.");
return false;
}
},
viewer : function(vid){
var img = document.getElementById('movieUploadImg');
img.src = "http://imgsrc.search.daum-img.net/search_all/show/bt_009_1.gif";
img.alt="동영상변경하기";
var dim = daum.dom.Element.getDimension($(this.id));
var div = $(this.MOVIEDIV+this.id);
if(div == null || div == undefined){
div = document.createElement("DIV");
div.id = this.MOVIEDIV+this.id;
$(this.id).appendChild(div);
}
div.setAttribute("vid",vid);
div.setAttribute("x",dim.x-2);
div.setAttribute("y",dim.y-2);
div.setAttribute("did",div.id);
DaumFlash("http://flvs.daum.net/flvPlayer.swf?vid="+vid,'',dim.x-2,dim.y-2,div.id);
//		div.innerHTML = div.innerHTML+"<!--SHOW[<script type='text/javascript'>ShowFlash('http://flvs.daum.net/flvPlayer.swf?vid="+vid+"','',"+(dim.x-2)+","+(dim.y-2)+",'"+div.id+"');</script>]SHOW-->";
}
}
function byMovieUpload(imgurl,vid,duration){
daum.debug("by.make.boxes.MovieBox.callbackUpload");
by.make.boxes.MovieBox.viewer(vid);
}
if(!window.by) window.by = new Object();
if(!window.by.edit) window.by.edit = new Object();
by.edit.Editor = daum.create();
by.edit.Editor.prototype = {
EDIT_VIEW :"edit_view",
initialize : function(content,options){
if(typeof(content)=='string'){
this.editDiv = $(content);
}else{
this.editDiv = content;
}
Object.extend( options, {
command : false,
maxline : 100
}
);
this.options = options;
this.create();
},
create : function(){
this.createDiv();
this.createIFrame();
},
createDiv :function(){
this.mainDiv  =document.createElement("div");
},
createIFrame : function(){
//document.domain = document.domain;
//document.domain = document.domain;
this.iframe  =document.createElement("iframe");
this.iframe.id = "iframe_"+this.editDiv.id;
var content = this.editDiv.innerHTML;
this.editDiv.innerHTML = "";
this.iframe.style.width="100%";
this.iframe.name=this.iframe.id;
daum.debug(this.options.height);
this.iframe.style.height= this.options.height;
this.iframe.style.background="#ffffff";
this.iframe.scrolling = "auto";
this.iframe.marginWidth=0;
this.iframe.marginHeight=0;
//	this.iframe.style.border = "1px solid #d7d7d7;";
this.mainDiv.appendChild(this.iframe);
this.editDiv.appendChild(this.mainDiv);
//		this.doc = this.iframe.contentWindow.document;
this.doc = this.getIframeDocumentObj(this.iframe.id);
this.doc.designMode = 'On';
this._setInitContent(content);
//		this.setContent(content);
//		this.loadStyle("/by/css/editor.css");
//		document.domain="daum.net";
try {this.doc.execCommand("enableInlineTableEditing", false, false)} catch(ignored) {daum.debug("e")}
if(this.options.command){
}
//this.iframe.contentWindow.focus = this._focus;
//Event.observe(this.doc, 'blur', this._blur.bindAsEventListener(this));
//Event.observe(this.doc, 'focus', this._focus.bindAsEventListener(this));
daum.debug("focus event observe");
Event.observe(this.iframe.contentWindow, 'focus', this._focus.bindAsEventListener(this));
Event.observe(this.iframe.contentWindow.document, 'focus', this._focus.bindAsEventListener(this));
//this.iframe.contentWindow.document.focus = this._focus;
if(this.isIE()){
this.doc.domain = "daum.net";
}
//this.doc.focus = this._focus();
this.setFocus();
},
setFocus : function(){
this.iframe.contentWindow.focus();
this.iframe.focus();
},
_blur : function(event){
daum.debug("blur");
//alert("0k");
//this.doc.designMode = 'On';
Event.stop(event);
},
_focus : function(event){
daum.debug("focus");
//alert("focus()");
by.make.Template.activeEdit = this;
Event.stop(event);
},
setCurSelection : function(){
this.curSelection = this.getSelect();
},
_keypress : function(event){
daum.debug("click");
by.make.Template.activeEdit = this;
Event.stop(event);
},
_setInitContent:function(content){
var doc = this.doc;
doc.open();
doc.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">');
doc.write('<html');
doc.write('<head>');
doc.write('<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />');
doc.write('<title>Editor</title>');
doc.write('<style type="text/css">');
doc.write('.editorBody {scrollbar-3dlight-color:#FFF;scrollbar-arrow-color:#A6A6A6;scrollbar-darkshadow-color:#FFF;scrollbar-face-color:#FFF;scrollbar-highlight-color:#D0D0D0;scrollbar-shadow-color:#D0D0D0;scrollbar-track-color:#E7E7E7;}');
doc.write('.editorBody p {padding:0px; margin:0px; border:0px; font-size:12px; color:#333333; font-family:돋움; line-height :1.6em;} div {padding:0px; margin:0px; border:0px; font-size:12px; color:#333333; font-family:돋움; line-height :1.6em; } body {padding:5px; margin:0px;  font-size:12px; color:#333333; font-family:돋움; line-height :1.6em; } ');
doc.write('</style>');
doc.write('</head>');
doc.write('<body class="editorBody">'+content+'</body>');
doc.write('</html>');
doc.close();
},
setContent : function(content){
this.doc.body.innerHTML = content;
//		daum.debug(this.iframe.contentWindow.document.body.innerHTML);
},
updateContent : function(){
this.changeATagTarget();
this.editDiv.innerHTML = this.doc.body.innerHTML;
this.editDiv.style.height = null;
},
changeATagTarget : function(){
var a = this.doc.getElementsByTagName("A");
daum.debug(a);
for(var i=0;i<a.length;i++){
a[i].target="_blank";
}
},
viewContent : function(){
daum.debug("viewContent");
var div  =document.createElement("div");
div.id=this.EDIT_VIEW+this.editDiv.id;
this.changeATagTarget();
div.innerHTML = this.doc.body.innerHTML;
this.editDiv.appendChild(div);
this.iframe.style.display = "none";
},
viewEdit : function(){
daum.debug("viewEdit");
Element.remove($("edit_view"+this.editDiv.id));
this.iframe.style.display ="";
},
loadStyle : function(url){
var css = this.doc.createElement("link");
css.rel = "Stylesheet";
css.type="text/css";
css.href = url;
this.doc.getElementsByTagName("HEAD")[0].appendChild(css);
},
execCreatelink : function(createlink){
daum.debug("createlink"+createlink);
if (this.isIE()) {
this.curSelection.select();
}
this.doc.execCommand("createlink", false, createlink);
/*
if(this.isIE()){
this.curSelection.parentElement().target="_new";
}else{
this.curSelection.anchorNode.parentNode.target="_new";
}
*/
},
execInsertImage : function(url,width){
daum.debug("insertImage");
var i = "<img src='"+url+"' width='"+width+"' /><br/>";
this.doc.body.innerHTML = this.doc.body.innerHTML +i;
//		this.doc.execCommand("insertimage", false, url);
daum.debug("insertImage end");
},
execBold : function(){
daum.debug("bold");
this.doc.execCommand("Bold", false, null);
},
execUnderline : function(){
daum.debug("underline");
this.doc.execCommand("underline", false, null);
},
execJustifyleft :function(){
daum.debug("justifyleft");
this.doc.execCommand("justifyleft", false, null);
},
execJustifycenter :function(){
daum.debug("justifycenter");
this.doc.execCommand("justifycenter", false, null);
},
execJustifyright :function(){
daum.debug("justifyright");
this.doc.execCommand("justifyright", false, null);
},
execRedo : function(){
daum.debug("redo");
this.doc.execCommand("redo", false, null);
},
execUndo : function(){
daum.debug("undo");
this.doc.execCommand("undo", false, null);
},
execOutdent : function(){
daum.debug("outdent");
this.doc.execCommand("outdent", false, null);
},
execIndent : function(){
daum.debug("indent");
this.doc.execCommand("indent", false, null);
},
execItalic : function(){
daum.debug("italic");
this.doc.execCommand("italic", false, null);
},
execInsertorderedlist : function(){
daum.debug("insertorderedlist");
this.doc.execCommand("insertorderedlist", false, null);
},
execInsertunorderedlist : function(){
daum.debug("insertunorderedlist");
this.doc.execCommand("insertunorderedlist", false, null);
},
execFontname : function(fontname){
daum.debug("fontname:"+fontname);
this.doc.execCommand("fontname", false, fontname);
},
execFontsize : function(fontsize){
daum.debug("fontsize:"+fontsize);
this.doc.execCommand("fontsize", false, fontsize);
},
execForecolor : function(forecolor){
if (this.isIE()) {
this.curSelection.select();
}
daum.debug("forecolor:"+forecolor);
this.doc.execCommand("forecolor", false, forecolor);
},
execHilitecolor : function(hilitecolor){
var com = "hilitecolor";
if (this.isIE()) {
this.curSelection.select();
com = "backcolor";
}
daum.debug(com+":"+hilitecolor);
if(hilitecolor =="#FFFFFF" ||hilitecolor =="#ffffff"){
//	this.doc.execCommand(com, false, hilitecolor);
//	this.doc.execCommand(com, false, null);
this.doc.execCommand(com, false, "transparent");
}else{
this.doc.execCommand(com, false, hilitecolor);
}
},
lineCount : function(){
daum.debug(this.doc.body.innerHTML);
var c = this.doc.body.innerHTML;
var i = -1;
var k = -1;
var cnt = 0;
var b = 0;
c = c.toLowerCase();
while((i = c.indexOf("<br",i+3))  > -1){
cnt++;
b++;
if(b>50)break;
}
b=0;
while((k = c.indexOf("<p",k+3))  > -1){
cnt++;
b++;
if(b>50)break;
}
daum.debug("cnt:"+cnt);
return cnt;
},
isLineOver : function(){
if(this.lineCount() >= this.options.maxline){
return true;
}
return false;
},
hasImage : function(){
var c = this.doc.body.innerHTML;
if(c.toLowerCase().indexOf("<img") >-1){
return true;
}
return false;
},
textLength : function(){
var c = this.doc.body.innerHTML;
c = c.stripTags();
c = c.replace(/&nbsp;/g,"");
c = c.replace(/\n/g,"");
c = c.replace(/\s/g,"");
return c.length;
},
getIframeDocumentObj: function(id){
if ( $(id).contentWindow ){
return $(id).contentWindow.document;
} else {
return frames[this.iframe.id].document;
}
},
isIE : function(){
var clintAgent = navigator.userAgent;
if ( clintAgent.indexOf("MSIE") > -1 ){
return true;
}
return false;
},
getSelect :function() {
if (this.isIE()) {
//		alert(this.iframe.document.selection);
return this.doc.selection.createRange();
//		return eval(this.iframe.id+".document.selection.createRange()");
} else {
return this.iframe.contentWindow.getSelection();
}
}
}
if(!window.by) window.by = new Object();
if(!window.by.make) window.by.make = new Object();
if(!window.by.make.boxes) window.by.make.boxes = new Object();
by.make.boxes.ImageBox = {
id : null,
IMAGEUPLOADDIV : "by_imageupload_",
imageUploaded : {},
imageUploaderMode : "0",
trans : function(box){
this.setImageUploaded(box);
this._createTransImageDiv(box);
},
previewBackTrans : function(box){
this.backTrans(box);
},
previewTrans : function(box){
this.trans(box);
},
backTrans : function(box){
daum.debug("by.make.boxes.ImageBox.backTrans");
// var ret = by.make.Template.getContainer(box);
// ret.appendChild(box);
Element.remove(this.IMAGEUPLOADDIV+box.id);
},
add : function(){
var s = ++by.make.Template.seq;
var id = "by_box"+s;
var div = document.createElement("DIV");
div.setAttribute("type","image");
var html = "<img src='' width='148' height='130'>";
div.innerHTML =html;
div.className = "imgObj";
div.id = id;
by.make.Template.imageContainer.appendChild(div);
this.trans(div);
},
del : function(id){
by.make.Template.deleteBox(id);
},
setImageUploaded: function(d){
var imgs = d.getElementsByTagName("IMG");
if(imgs == null || imgs[0] == null) return;
if(imgs[0].src.indexOf("imgsrc")==-1){ // 기본이미지가 아닌경우
this.imageUploaded[d.id] = true;
}
},
_createTransImageDiv : function(d){
daum.debug("_createTransImageDiv");
daum.debug(d);
d.style.position ="relative";
// var container = by.make.Template.getContainer(d);
// var div = document.createElement("DIV");
// div.id = by.make.Template.TRANS_BOX_PREFIX+d.id;
// div.className = "imgObj";
// daum.debug(this.getContainerAttribute(d,"del"));
// container.appendChild(div);
if(by.make.Template.getContainerAttributeByBox(d,"del",false) == "true"){
var delDiv = document.createElement("DIV");
delDiv.innerHTML="삭제";
delDiv.onclick = this.del.bind(this,d.id);
div.appendChild(delDiv);
}
var imgFile = "<img id='imageUploadImg"+this.id+"' src='http://imgsrc.search.daum-img.net/search_all/show/bt_008.gif' width='54' height='20' alt='사진등록'>";
if(this.imageUploaded[d.id]){
imgFile = "<img id='imageUploadImg"+this.id+"' src='http://imgsrc.search.daum-img.net/search_all/show/bt_008_1.gif' width='54' height='20' alt='사진변경'>";
}
var imageUploadUI = "<a href='#' onclick=\"by.make.boxes.ImageBox."+this.getImageUploaderType(d)+"('"+d.id+"');return false\">"+imgFile
+"</a>"
var imageAddDiv = document.createElement("DIV");
imageAddDiv.id = this.IMAGEUPLOADDIV+d.id;
imageAddDiv.innerHTML=imageUploadUI;
imageAddDiv.className = "imgUpload";
var dim = daum.dom.Element.getDimension(d);
daum.debug(d);
daum.debug(dim);
if(dim.x < 100) {
imageAddDiv.style.top = parseInt((dim.y -20)*3/7)+"px";
imageAddDiv.style.left = parseInt((dim.x - 54)/2)+"px";
} else {
imageAddDiv.style.top = parseInt((dim.y -20)/2 - 5)+"px";
imageAddDiv.style.left = parseInt((dim.x - 54)/2)+"px";
}
// imageAddDiv.style.cursor = "pointer";
// imageAddDiv.onclick = this.upload.bind(this,d.id);
// div.appendChild(d);
d.appendChild(imageAddDiv);
},
getImageUploaderType : function(div){
var multi = div.getAttribute("multi");
daum.debug(multi);
if(multi){
return "multiUpload";
}else{
return "upload";
}
},
upload : function(id){
this.id = id;
this.openUploader('0',1);
// ifr_direct_upload.window.browse_flash();
// this.openUploader();
},
multiUpload : function(id){
this.id = id;
this.openUploader('0',10);
},
callbackUploadEdit : function(imageURL){
daum.debug("mode:2");
var imageURLs = imageURL.split("|");
daum.debug(imageURLs.length);
var width = by.make.Template.templateDiv.getAttribute("thumbnail");
for (var i=0; i < imageURLs.length ; i++) {
daum.debug(imageURLs[i]);
by.make.Template.activeEdit.execInsertImage(imageURLs[i],width);
}
return;
},
callbackUpload : function(imageURL){
daum.debug("updateImage");
daum.debug(this.id);
var imgs = this.getImages();
if(imgs[0] == null || imgs[0] == undefined){
by.make.Tempalte.badTemplate();
return;
}
for(var i=0;i<imgs.length;i++){
if(i!=0){
Element.remove(imgs[i]);
}
}
var imageURLs = imageURL.split("|");
daum.debug("imageURLs:"+imageURLs.length);
for (var i=0; i < imageURLs.length ; i++) {
if(i == 0){
daum.debug("first");
imgs[i].src = this.thumbnail(imageURLs[i]);
}else{
daum.debug("clone");
var cloneImage = imgs[0].cloneNode(true);
cloneImage.style.display = "none";
cloneImage.src = this.thumbnail(imageURLs[i]);
$(this.id).appendChild(cloneImage);
}
// if(imgs[i] == null || imgs[i] == undefined || imgs[i].id ==
// "imageUploadImg"){
// var cloneImage = imgs[0].cloneNode(true);
// cloneImage.style.display = "none";
// cloneImage.src = imageURLs[i];
// $(this.id).appendChild(cloneImage);
// }else{
// imgs[i].src = imageURLs[i];
// }
}
this.imageUploaded[this.id] = true;
return;
},
getImages :function(){
var d = $(this.id);
var imgs = d.getElementsByTagName("IMG");
var ret = new Array();
var k=0;
for(var i=0;i<imgs.length;i++){
if(imgs[i].id.indexOf("imageUploadImg")>-1){
imgs[i].src = "http://imgsrc.search.daum-img.net/search_all/show/bt_008_1.gif";
imgs[i].alt = "사진변경";
}else{
ret[k] = imgs[i];
k++;
}
}
return ret;
},
submit : function(){
var domain = document.domain;
ifr_direct_upload.window.submit_flash();
},
thumbnail : function(originalURL){
var t = $(this.id).getAttribute("thumbnail");
if(t == null) t = "thumbnail";
if (t == "show_t_1")
t = "S231x209"
else if( t == "show_t_2")
t= "S69x75"
else if( t == "show_t_3")
t = "S231x296"
else if (t == "show_t_4")
t = "S153x137"
else if (t == "show_t_5")
t =  "S211x128"
else if (t == "image")
t = "image"
else if (t == "thumbnail")
t = "S231x296"
var ret = originalURL.replace("/image/","/"+t+"/");
return ret;
},
openUploader :function(mode,cnt){
this.imageUploaderMode = mode
if(by.Common.isEmpty(this.imageUploaderMode)) this.imageUploaderMode = "0";
// var sid=by.make.Template.emailid;
// var sname="show";
// var dest =
// "http://imageupload.show.daum.net/cfu/show_image_upload_popup.php?sid=" + sid
// + "&sname=" + sname;
// var dest =
// "http://imageupload.show.daum.net/ifu/show_editor_popup.php?sid=" + sid +
// "&sname=" + sname +"&mode="+mode+"&maxImageCount="+cnt;
var dest = "/by/coca_edit_popup.html?cnt="+cnt;
var width = "0";
var height = "0";
oneshot = window.open(dest, "popup", "scrollbars=no,toolbar=no,location=no,directories=no,width="+width+",height="+height+",resizable=no,mebar=no");
oneshot.focus();
},
check : function(box){
if(this.imageUploaded[box.id] == true){
return true;
}else{
alert("이미지를 올려주세요.");
return false;
}
}
}
function insert_file_info(originalURL, imageURL, attachURL, infoURL, thumbnailURL, filesizeList, filenameList, mimetypeList) {
by.make.boxes.ImageBox.callbackUpload(imageURL);
}
function insert_tmpFile_info(originalURL, imageURL, attachURL, infoURL, thumbnailURL, filesizeList, filenameList, mimetypeList) {
daum.debug(thumbnailURL);
by.make.boxes.ImageBox.callbackUpload(imageURL);
}
function insert_image_func(imageURL) {
var image = parse_image_url(imageURL);
if(by.make.boxes.ImageBox.imageUploaderMode == "2"){
by.make.boxes.ImageBox.callbackUploadEdit(image);
}else{
by.make.boxes.ImageBox.callbackUpload(image);
}
return;
}
function parse_image_url(result){
return result[0];
}
if(!window.by) window.by = new Object();
if(!window.by.main) window.by.main = new Object();
daum.include("by.dao.ByDAO")
by.main.Present = {
now_category : 7,
uis : null,
tpHtml :  new totalHtml(),//html 수집
load : function(by_category_id){
by.dao.ByDAO.selectPresents(by_category_id,this.callback.bind(this));
},
callback : function(ret){
daum.debug("callback");
daum.debug(ret);
daum.debug(ret.size());
this.uis = ret;
this.tProVar();
},
tProVar : function(){
var tts = new Array();
if(this.uis!=null){
var k = 1;
var tt =  new tProVar3();
tts.push(tt);
for(var i=0;i<this.uis.size();i++){
daum.debug(this.uis[i]);
tt.insVal(by.main.Category.image_path(this.uis[i].thumbnail),this.uis[i].kword,this.uis[i].name,this.uis[i].encode_real_kword,this.uis[i].msg_cnt,this.uis[i].regdttm);
if(k == 6){
tt = new tProVar3();
tts.push(tt);
}
k++;
}
this.tpHtml.clear();
for(var i=0;i<tts.length;i++){
this.tpHtml.inHtml(tts[i].sHtml());
}
this.tpHtml.outHtml('tView3',1);
var listNum = Math.ceil(this.uis.size()/6);
this.ttp = new tpScr('tView3',listNum, 'by.main.Present.ttp', 720);
}
},
changeList : function(id){
$("by_present_"+this.now_category).src = by.main.Category.categories[this.now_category].off;
$("by_present_"+id).src = by.main.Category.categories[id].on;
this.now_category = id;
var by_category_id = id;
this.load(id);
},
make : function(id){
daum.debug("make");
location.href="/by/make/second.daum?preId="+id;
},
preview : function(image){
daum.debug("preview");
window.open(image,"preview","width=1024;height=768");
}
}
