var Browser = new Object();		
	Browser.isIE = (navigator.userAgent.toLowerCase().indexOf("msie")!=-1);
	Browser.isIE_7 = (navigator.userAgent.toLowerCase().indexOf("msie 7")!=-1);
	Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
	

/* 스크롤 */
var tpScr = function(obj,mIdx,sn,size){
    this.idx = 0;
	this.maxIdx = mIdx;
    this.scrollsize = size;
    this.scrName = sn;
	this.scrObj = document.getElementById(obj);
    this.scrObjN =obj;
    this.arrowImg ="";
    
   
	if (!(!(this.scrObj))){
		this.scrObj.style.left = 0;
	}

    if (obj == 'tView1'){
        this.arrowImg = 'tpbtm1';
        
    }else if (obj == 'tView3'){
        this.arrowImg = 'tpbtm2';
        
    }
    if (obj == 'tView1' || obj == 'tView3'){

        document.getElementById(this.arrowImg+'L').src = 'http://imgsrc.search.daum-img.net/search_all/show/arrow_01.gif';
        if (this.maxIdx > 1){
            document.getElementById(this.arrowImg+'R').src = 'http://imgsrc.search.daum-img.net/search_all/show/2008/arrow_02_on.gif';
        }else{
            document.getElementById(this.arrowImg+'R').src = 'http://imgsrc.search.daum-img.net/search_all/show/arrow_02.gif';
        }
    }else if(this.scrObjN == 'skinList'){
        document.getElementById('tpbtm3L').src = 'http://imgsrc.search.daum-img.net/search_all/show/skin_left1.gif';
        if (this.maxIdx > 1){
            document.getElementById('tpbtm3R').src = 'http://imgsrc.search.daum-img.net/search_all/show/skin_right.gif';
        }else{
            document.getElementById('tpbtm3R').src = 'http://imgsrc.search.daum-img.net/search_all/show/skin_right1.gif';
        }
    }
    
    this.scrObj.style.width = (this.scrollsize+1) * this.maxIdx;
    
}
	tpScr.prototype.imgChk = function(){
        if (this.scrObjN == 'tView1' || this.scrObjN == 'tView3'){
            if (this.idx == 0){
			    document.getElementById(this.arrowImg+'L').src = 'http://imgsrc.search.daum-img.net/search_all/show/arrow_01.gif';
                if (this.idx < (this.maxIdx-1)){
                    document.getElementById(this.arrowImg+'R').src = 'http://imgsrc.search.daum-img.net/search_all/show/2008/arrow_02_on.gif';
                }
            }else if (this.idx == (this.maxIdx-1)){
                document.getElementById(this.arrowImg+'R').src = 'http://imgsrc.search.daum-img.net/search_all/show/arrow_02.gif';
                if (this.idx > 0){
                    document.getElementById(this.arrowImg+'L').src = 'http://imgsrc.search.daum-img.net/search_all/show/2008/arrow_01_on.gif';
                }
            }else{
                document.getElementById(this.arrowImg+'L').src = 'http://imgsrc.search.daum-img.net/search_all/show/2008/arrow_01_on.gif';
                document.getElementById(this.arrowImg+'R').src = 'http://imgsrc.search.daum-img.net/search_all/show/2008/arrow_02_on.gif';
            }
        }else if (this.scrObjN == 'skinList'){
            if (this.idx == 0){
			    document.getElementById('tpbtm3L').src = 'http://imgsrc.search.daum-img.net/search_all/show/skin_left1.gif';
                if (this.idx < (this.maxIdx-1)){
                    document.getElementById('tpbtm3R').src = 'http://imgsrc.search.daum-img.net/search_all/show/skin_right.gif';
                }
            }else if (this.idx == (this.maxIdx-1)){
                document.getElementById('tpbtm3R').src = 'http://imgsrc.search.daum-img.net/search_all/show/skin_right1.gif';
                if (this.idx > 0){
                    document.getElementById('tpbtm3L').src = 'http://imgsrc.search.daum-img.net/search_all/show/skin_left.gif';
                }
            }else{
                document.getElementById('tpbtm3L').src = 'http://imgsrc.search.daum-img.net/search_all/show/skin_left.gif';
                document.getElementById('tpbtm3R').src = 'http://imgsrc.search.daum-img.net/search_all/show/skin_right.gif';
            }
        }
		
	}

	tpScr.prototype.scrollR = function(){
		if (this.idx != (this.maxIdx-1)){
			for (i =0 ; i <= this.scrollsize ; i++){
			 setTimeout(this.scrName+".scroll(-1);",i/1.5 );
			}
		this.idx++;
		}
        this.imgChk();
	}

	tpScr.prototype.scrollL = function(){
        if (this.idx != 0){
			for (i =0 ; i <= this.scrollsize ; i++){
			 setTimeout(this.scrName+".scroll(1);",i/1.5 );
			}
		this.idx--;
		}
        this.imgChk();
	}
	tpScr.prototype.scroll = function(val){
		this.scrObj.style.left = (parseInt(this.scrObj.style.left)+val) + 'px';
	}



var totalHtml = function(){

this.html = new Array();
	this.inHtml = function(ihtml){
		this.html[this.html.length] = ihtml;
        
	}
    
	this.outHtml = function(objId,clr){
		if (!(!(clr)))	{
			this.html[this.html.length] = '<br class="clr" />';
		}
        document.getElementById(objId).innerHTML = this.html.join('');
        
        
	}
	
	this.clear = function(){
		this.html = new Array();
	}
}

/*스킨 HTML*/
var tProVar = function(){
this.img = new Array();
this.link = new Array();
this.ihtml = new Array();
    

	this.insVal = function(imgV,linkV){
		this.img[this.img.length] = imgV;
		this.link[this.link.length] = linkV;
	}

	this.sHtml = function(){
		this.ihtml[this.ihtml.length] = '<dl>';
		for (i =0 ;i<this.img.length ;i++ )	{		
		this.ihtml[this.ihtml.length] = '<dd onClick="'+this.link[i]+'"><img src="'+this.img[i]+'" width="75" height="45"></dd>';
		}
		this.ihtml[this.ihtml.length] = '</dl>';
        return this.ihtml.join('');
	}
}

/* 템플릿 */
var tProVar2 = function(){
this.img = new Array();
this.code = new Array();
this.preview = new Array();
this.ihtml = new Array();
    

	this.insVal = function(imgV,codeV,preV){
        
		this.img[this.img.length] = imgV;
		this.code[this.code.length] = codeV;
		this.preview[this.preview.length] = preV;		
	}

	this.sHtml = function(){
		this.ihtml[this.ihtml.length] = '<dl>';
		for (i =0 ;i<this.img.length ;i++ )	{		
		this.ihtml[this.ihtml.length] = '<dd><div class="ImgArea"><a href="#" onclick="'+this.preview[i]+' return false;"><img src="'+this.img[i]+'" width="202" height="135"></a></div><div class="BtnArea"><a href="#" onclick="'+this.preview[i]+' return false;"><img src="http://imgsrc.search.daum-img.net/search_all/show/bt_004.gif" width="83" height="24" alt="크게보기" class="btn"></a><a href="#" onclick="'+this.code[i]+'return false;"><img src="http://imgsrc.search.daum-img.net/search_all/show/bt_005.gif" width="83" height="24" alt="만들기"></a></div></dd><dd class="hLine"></dd>';
		}
		this.ihtml[this.ihtml.length] = '</dl>';
        return this.ihtml.join('');
	}
}


/*탑 HTML*/
var tProVar3 = function(){
this.img = new Array();
this.kw = new Array();
this.daumname = new Array();
this.reply = new Array();
this.date = new Array();
this.ihtml = new Array();
this.ekw = new Array();    

	this.insVal = function(imgV,kwV,daumnameV,ekwV,replyV,dateV){
		this.img[this.img.length] = imgV;
		this.kw[this.kw.length] = kwV;
		this.daumname[this.daumname.length] = daumnameV;
		this.ekw[this.ekw.length] =ekwV;
		this.reply[this.reply.length] = replyV;
		this.date[this.date.length] =dateV;
	}

	this.sHtml = function(){

		this.ihtml[this.ihtml.length] = '<ul id="sViewList">';
		for (i =0 ;i<this.img.length ;i++ )	{
            var link = "http://search.daum.net/search?w=tot&q="+this.ekw[i];
            this.ihtml[this.ihtml.length] = '<li><div class="imgArea"><a href="'+link+'" target="new"><img src="'+this.img[i]+'" width="90" height="70" alt="" /></a></div><dl><dt><a href="'+link+'" target="new" class="base_12">'+this.kw[i]+'</a> <b>['+this.reply[i]+']</b></dt><dd class="id">'+this.daumname[i]+'</dd><dd class="date">'+this.date[i]+'</dd></dl><br class="clr_ns" /></li>';
		}
		this.ihtml[this.ihtml.length] = '</ul>';
        return this.ihtml.join('');
	}
}

var mObj = '';
var mText = '';
function selectImg(obj){
    if (mText){
        mObj.innerHTML =mText;
    }
    var text = obj.innerHTML;
    mText=text;
    text=text+'<div class="sel"></div>';
    obj.innerHTML =text;
    mObj=obj;
    
}



function chgBtn(obj,m,num){
    var imgUrl="http://imgsrc.search.daum-img.net/search_all/show/edit_i0";
    if (m==1){
        obj.src=imgUrl+num+"_on.gif";
    }else{
        obj.src=imgUrl+num+".gif";
    }
}


function fs_view(num){
	by.make.Template.activeEdit.setCurSelection();
    for (i=1; i<6; i++){
        document.getElementById('fontStyle'+i).style.display = "none";
    }
    document.getElementById('fontStyle'+num).style.display = "block";
}
function fs_hidden(num){
    document.getElementById('fontStyle'+num).style.display = "none";
}

function layView(id){
    document.getElementById(id).style.display="block";
}

function layHidden(id){
    document.getElementById(id).style.display="none";
}

function sampleView(templateid,image){
	//alert("준비중입니다.");
//    document.getElementById('exLayer').style.display="block";
//    document.getElementById('exImg').src = uri;
	by.main.Category.makePreview(templateid,image);
    /*
    if (tempX >750){
        document.getElementById('exLayer').style.left=tempX-310;
    }else{
        document.getElementById('exLayer').style.left=tempX;
    }

    if (tempY>400){
        document.getElementById('exLayer').style.top=tempY-225;
    }else{
        document.getElementById('exLayer').style.top=tempY+5;
    }
    */
}

function showfaq(){
	alert("준비중입니다.");
}

function showqna(){
	alert("준비중입니다.");
}

function sampleViewClose() {
	//document.getElementById('exLayer').style.display="none";
}

/* ActiveX */
function daumActiveX(obj,div){
	// generate html code
	// for ie obejct
	var html = '<object ';
	if (!obj.id && !obj.name){
		var r = Math.round(Math.random()*100);
		html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
	} else {
		if (obj.id) html += 'id="'+obj.id+'" ';
		else html += 'id="'+obj.name+'" ';
		if (obj.name) html += 'name="'+obj.name+'" ';
		else html += 'name="'+obj.id+'" ';
	}
	if (obj.type) html += 'type="'+obj.type+'" ';
	if (obj.classid) html += 'classid="'+obj.classid+'" ';
	if (obj.width) html += 'width="'+obj.width+'" ';
	if (obj.height) html += 'height="'+obj.height+'" ';
	if (obj.codebase) html += 'codebase="'+obj.codebase+'" ';
	// append events
	for (var i in obj.events){
		if (obj.events[i]){
			html += obj.events[i][0]+'="'+obj.events[i][1]+'" ';
		}
	}
	// end of object tag
	html += '>\n';
	// append params
	for (var i in obj.param){
		if(obj.param[i][0] != undefined ){
			html += '<param name="'+obj.param[i][0]+'" value="'+obj.param[i][1]+'"/>\n';
		}
	}

	// for ns embed
	html += '<embed ';
	if (!obj.id && !obj.name){
		var r = Math.round(Math.random()*100);
		html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
	} else {
		if (obj.id) html += 'id="'+obj.id+'" ';
		if (obj.name) html += 'name="'+obj.name+'" ';
	}
	if (obj.type) html += 'type="'+obj.type+'" ';
	if (obj.width) html += 'width="'+obj.width+'" ';
	if (obj.height) html += 'height="'+obj.height+'" ';
	// append params
	for (var i in obj.param){
		if (obj.param[i]){
			if (obj.param[i][0]=='movie' || obj.param[i][0]=='src'){
				var _src = obj.param[i][1];
			}
			html += obj.param[i][0]+'="'+obj.param[i][1]+'" ';
		}
	}
	html += '/>\n';
	html += '</object>';

	var isIE = (document.all)?true:false;
	if (isIE){
		document.getElementById(div).innerHTML = html;
	} else if (obj.type=='application/x-shockwave-flash' || obj.classid.toLowerCase()=='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'){
		// ie외의 브라우저에서 activex가 flash 경우만 노출
		document.getElementById(div).innerHTML = html;
	} else if (navigator.platform.indexOf('Win')>=0 && obj.classid.toLowerCase()=='clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95'){
		// Windows Media Player의 경우 windows platform에서만 노출
		document.getElementById(div).innerHTML = html;
	}
}
function DaumFlash(src,fv,width,height,div){
	var obj = new Object();
	obj.id = div+"_movie";
	obj.type = 'application/x-shockwave-flash';
	obj.classid = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
	obj.codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.c-ab#version=9,0,0,0';
	obj.width = width;
	obj.height = height;

	var param = [		
		['movie',src],
		['src',src],
		['quality','high'],
		['wmode','transparent'],
		['allowScriptAccess','always'],
		['bgcolor','#FFFFFF'],
		['FlashVars',fv]
	];
	obj.param = param;
	daumActiveX(obj,div);
}
function ShowFlash(src,fv,width,height,div){
	//DaumFlash(src,fv,width,height,div);
	embedSWF(src,fv,width,height,div);
}

function embedSWF(f, fv, w, h, div){
	var param = {
		id: "UIswf_" + f,
		quality: 'high',
		bgcolor: '#ffffff',
		allowScriptAccess: 'always',
		allowFullScreen: 'true'
	}
	
	var id = 'id="' + param.id + '"';
	var name = 'name="' + param.id + '"';
	var p = '', e = '';
	
	for (i in param) {
		if (i == 'id') 
			continue;
		p += '<param name="' + i + '" value="' + param[i] + '">\n';
		e += i + '="' + param[i] + '" ';
	}
	var s = '<object ' + id + ' width="' + w + '" height="' + h + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0">';
	s += '<param name="movie" value="' + f + '">' + p;
	s += '<embed ' + name + ' src="' + f + '" width="' + w + '" height="' + h + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" ' + e + '/>';
	s += '</object>';
	document.getElementById(div).innerHTML = s;
}

//select
function codeChange(code,num){
        document.getElementById(code).innerHTML=num;
    }
function bgChange(id,bg){
    id.style.background=bg;
}
function viewDiv(id){
    if (document.getElementById(id).style.display == "none"){
        document.getElementById(id).style.display="block";
    }else{
        document.getElementById(id).style.display="none";
    }
}

var tempX = 0; 
var tempY = 0; 

function getMouseXY(e,num) { 
    if (document.all) { 
        tempX = event.clientX + document.body.scrollLeft; 
        tempY = event.clientY + document.body.scrollTop; 
    } 
    else {  
        tempX = e.pageX; 
        tempY = e.pageY;        
    }   

    sampleView(num);
}

// 스킨선택 메뉴 //
function selTab(num){
    for (i=1;i<10 ;i++ ){
        document.getElementById("tMenu"+i).className = "tMenu"+i;
    }

    document.getElementById("tMenu"+num).className = "tMenu"+num+"_on";
}

/* 이미지 over,out */
function sImgOver(idx,name){
    idx.src="http://imgsrc.search.daum-img.net/search_all/show/"+name+"_on.gif";
}
function sImgOut(idx,name){
    idx.src="http://imgsrc.search.daum-img.net/search_all/show/"+name+".gif";
}


// 로그인 박스 //
function loginform_clearbg(type) {
	if (type == "id") {
		document.loginform.id.style.backgroundImage = "";
	} else if (type == "pw") {
		document.loginform.enpw.style.backgroundImage = "";
	}
}

// 검색창 @ check //
function aCheck(){
	var preKeyword = document.getElementById('q').value;
	if(preKeyword.substring(0,1)!= '@'){
		alert("@를 삭제 하실수 없습니다.");
		document.getElementById('q').value = "@"+preKeyword;
	}
}

