function notyet()
{
    alert("under construction");
}

var div_counter = 0;
var act_function;


function debug(k)
{
    document.getElementById("debug").display = "";
    document.getElementById("debug").innerHTML += k + "<br/>";
}

function yesno(msg, action_function)
{
    act_function = action_function;
    msg = msg + "<br /><br /><a href='#' onclick=\"yesno_yes();return false;\"><font color='white'>예</a> | <a href='#' onclick=\"yesno_no();return false;\"><font color='white'>아니오</a>";
    document.getElementById("div_yesno_inner").innerHTML = msg;
    document.getElementById("div_yesno").style.visibility = "visible";
    
    document.getElementById("div_yesno").style.left = (document.documentElement.scrollLeft + 150).toString() + "px";
    document.getElementById("div_yesno").style.top = (document.documentElement.scrollTop + 150).toString() + "px";

    
}

function yesno_yes()
{
    act_function();
    document.getElementById("div_yesno").style.visibility = "hidden";
}

function yesno_no()
{
    document.getElementById("div_yesno").style.visibility = "hidden";
}


function get_url_group(to_url,url , name)
{
    div_counter++
    document.write ("<div style=\"clear:both;\"  class=\"user_img\"><a href=\"http://" + to_url + "/\" style=\"background:url('" + url + "') 0 0 no-repeat;\" class=\"user_image\" onmouseover=\"div_open('user_img_temp_" + div_counter + "')\" onmouseout=\"div_close('user_img_temp_" + div_counter + "')\" ><div id=\"user_img_temp_" + div_counter + "\" style=\"visibility:hidden;margin-top:20px;width:60px;height:18px;overflow:hidden;background-color:#000000;opacity:0.5;filter:Alpha(Opacity=50);\" align='center'><font color='white'>" + name + "</font></text></div></a></div>");
}

function get_url_theme(to_url,url , name)
{
    div_counter++
    document.write ("<div style=\"clear:both;\"  class=\"user_img\"><a href=\"http://" + to_url + "/\" style=\"background:url('" + url + "') 0 0 no-repeat;\" class=\"user_image\" onmouseover=\"div_open('user_img_temp_" + div_counter + "')\" onmouseout=\"div_close('user_img_temp_" + div_counter + "')\" ><div id=\"user_img_temp_" + div_counter + "\" style=\"visibility:hidden;margin-top:20px;width:60px;height:18px;overflow:hidden;background-color:#000000;opacity:0.5;filter:Alpha(Opacity=50);\" align='center'><font color='white'>" + name + "</font></text></div></a></div>");
}

function get_url_book(to_url,url , name, id)
{
    div_counter++
    document.write ("<a href=\"" + to_url + "\" style=\"background:url('" + url + "') 0 0 no-repeat;\" class=\"book_image\" onmouseover=\"div_open('user_img_temp_" + div_counter + "');\" onmouseout=\"div_close('user_img_temp_" + div_counter + "')\" ><div id=\"user_img_temp_" + div_counter + "\" style=\"visibility:hidden;margin-top:0px;width:85px;height:136px;overflow:hidden;background:url('/media/img_common/tr30.png');\" align='center'><div style=\"height:80px;overflow:hidden;\"><font color='white'>" + name + "</font></div><input type=\"button\" value=\"구매\" onclick=\"alert('under construction.');return false;\"/> <br /><input type=\"button\" value=\"광장\"  onclick=\"location.href='/square/" + id + "/';return false;\" /></div></a>");
}

function get_url_user(to_url,url , name)
{
    div_counter++
    document.write ("<div style=\"clear:both;\"  class=\"user_img\"><a href=\"http://" + to_url + "/\" style=\"background:url('" + url + "') 0 0 no-repeat;\" class=\"user_image\" onmouseover=\"div_open('user_img_temp_" + div_counter + "')\" onmouseout=\"div_close('user_img_temp_" + div_counter + "')\" ><div id=\"user_img_temp_" + div_counter + "\" style=\"visibility:hidden;margin-top:20px;width:60px;height:68px;overflow:hidden;background-color:#000000;opacity:0.5;filter:Alpha(Opacity=50);\" align='center'><font color='white'>" + name + "</font></text></div></a></div>");
}

function to_HTML(org)
{
    org = org.split(">").join("&gt;");
    org = org.split("<").join("&lt;");
    org = org.split(" ").join("&nbsp;");
    return org.split("\n").join("<br />");
}

function to_plain(org)
{
    return org.split("<br />").join("\n");
}

function div_close(div_name)
{
    document.getElementById(div_name).style.visibility = "hidden";
}

function div_open(div_name)
{
    //alert(1);
    document.getElementById(div_name).style.visibility = "visible";
}

function div_open_up(div_name)
{
    document.getElementById(div_name).style.visibility = "visible";
    document.getElementById(div_name).style.position = "relative";
}

function div_close_down(div_name)
{
    document.getElementById(div_name).style.visibility = "hidden";
    document.getElementById(div_name).style.position = "absolute";
}

function div_toggle(div_name)
{
    //alert(1);
    if (document.getElementById(div_name).style.visibility == "visible")
    {
        document.getElementById(div_name).style.visibility = "hidden";
        document.getElementById(div_name).style.position = "absolute";
    }
    else
    {
        document.getElementById(div_name).style.visibility = "visible";
        document.getElementById(div_name).style.position = "relative";
    }
}

function div_open_from(div_name, other1, other2)
{
    if (document.getElementById(div_name).style.visibility == "hidden")
    {
        document.getElementById(div_name).style.visibility = "visible";
        document.getElementById(other1).style.visibility = "hidden";
        document.getElementById(other2).style.visibility = "hidden";
    }
    else
    {
        document.getElementById(div_name).style.visibility = "hidden";
        document.getElementById(other1).style.visibility = "hidden";
        document.getElementById(other2).style.visibility = "hidden";
    }
}

function trim(value) {
    return value.replace(/^\s+|\s+$/g,"");
}


function open_help(topic)
{
    window.open("/help/" + topic + "/", "userstorybook_help", "width=400,height=500,toolbar=false")
}


function selectAll(where, like, count)
{
    var i;
    for (i=1;i<= count;i++)
    {
        document.getElementById(where + "_" + i).checked = document.getElementById(like).checked;
    }
    
}

var fadeout_counter = 0;

function show_and_fadeout_status(text, duration)
{
    document.getElementById("div_status_inner").innerHTML = text;
    document.getElementById("div_status").style.visibility = "visible";
    
    document.getElementById("div_status").style.left = (document.documentElement.scrollLeft + 150).toString() + "px";
    document.getElementById("div_status").style.top = (document.documentElement.scrollTop + 150).toString() + "px";
    fadeout_counter = (duration / 30) + 100;
    fade_out();
}

function fade_out()
{
    fadeout_counter--;
    //document.getElementById("div_status").style.opacity = fadeout_counter * 0.01;
    //document.getElementById("div_status").style.filter = "Alpha(opacity=" + fadeout_counter +");";
    if (fadeout_counter>0) setTimeout(fade_out, 10); else document.getElementById("div_status").style.visibility = "hidden";
}

var slide_target = "" ;
var slide_counter = 22;

function slide_in(div_name)
{
    if (slide_counter> 22 && div_name == slide_target) return;
    slide_counter = 40;
    
    slide_target = div_name
    document.getElementById(slide_target).style.visibility = "visible";
    document.getElementById(slide_target).style.marginTop = "0px";
    slide_in_progress();
}


function slide_in_progress()
{
    slide_counter--;
    var pc = slide_counter + "px";
    document.getElementById(slide_target).style.marginTop = pc;
    if (slide_counter>22) setTimeout(slide_in_progress, 10);
}

var Base64 = {

	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;

		input = Base64._utf8_encode(input);

		while (i < input.length) {

			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}

			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

		}

		return output;
	},
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;

		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

		while (i < input.length) {

			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));

			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;

			output = output + String.fromCharCode(chr1);

			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}

		}

		output = Base64._utf8_decode(output);

		return output;

	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	},
	
	URLEncode : function (string) {   
        return escape(this._utf8_encode(string));   
    },   
  
    // public method for url decoding   
    URLDecode : function (string) {   
        return this._utf8_decode(unescape(string));   
    }
}




var JINDO = new Object();
JINDO.xml2obj = function(xml)
{
 var obj = {}, que = [], depth = 0;

 // attribute를 해석하기 위한 함수 
 var parse_attr = function(oobj, str) {
  str.replace(/([^=\s]+)\s*=\s*"([^"]*)"/g, function(a0,a1,a2) {
   oobj[a1] = a2;
  });
 }
 
 // 주석, XML선언, 태그 사이 공백 등의 의미 없는 코드를 삭제
 xml = xml.replace(/<(\?|\!-)[^>]*>/g,'').replace(/>\s+</g, '><');
 
 // 하위 노드가 없는 태그는 하나의 닫힌 태그로 수정
 xml = xml.replace(/<([^!][^ >]+)(\s[^>]*)?><\/\1>/g, '<$1$2 />').replace(/^\s+|\s+$/g, '');

 // 함수 객체를 정규 표현식 처리의 인자로 줘서 iterator로 사용
 xml = xml.replace(/<\/?([^\!][^ >]*)(\s[^>]*)?>(<\/$1>|<\!\[CDATA\[(?:(.|\s)*?)\]\]>|[^<>]*)/g, function(a0,a1,a2,a3)
 {
  // IE에서 일치하는 내용이 없으면 undefined로 전달되므로
  // 빈 문자열로 변경해 다른 브라우저와의 호환성을 맞춤
  if (typeof a1 == 'undefined') a1 = '';
  if (typeof a2 == 'undefined') a2 = '';
  if (typeof a3 == 'undefined') a3 = '';
  
  if (a0.substr(1,1) == '/') { // 현재 태그가 닫는 태그라면,
   // 깊이를 1만큼 감소
   depth--;
  } else if (que.length == 0) { // 객체 큐에 객체가 없다면,
   que[depth] = obj; // 초기의 객체를 큐에 넣고
   parse_attr(obj, a2); // attribute를 해석
  } else {
   var k  = a1, o = {}, is_closed = false;
   
   is_closed = (a2.substr(-1,1) == '/');
   if (a3.length > 0 || is_closed) { // 텍스트 노드가 있다면
    o = a3; // 추가할 객체는 문자열 객체
    
    // CDATA라면 전달받은 그대로 리턴하고
    // 그렇지 않다면 decode 해서 리턴
    if (o.substr(0,9) == '<![CDATA[' && o.substr(-3,3) == ']]>') o = o.substring(9, o.length-3);
    else o = o.replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&');
   }
   
   // 객체를 할당하기 전에 태그 이름이 이미 존재하는지 살펴보고
   // 이전에 존재하는 태그라면, 배열로 만든다. 이미 배열이라면 현재의 객체를 배열에 추가
   if (typeof que[depth][k] == 'undefined') {
    que[depth][k] = o;
   } else {    
    var v = que[depth][k];
    if (que[depth][k].constructor != Array) que[depth][k] = [v];
    que[depth][k].push(o);
   }

   // attribute를 해석
   parse_attr(o, a2);
   
   if (!is_closed) que[++depth] = o; 
  }
  
  return '';
 });
 
 return obj;
}


var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-16274324-1");
pageTracker._trackPageview();
} catch(err) {}

