/**
* ÆÄÀÏ¸í: lib.html.js
* ¼³  ¸í: HTML ±âº» ¶óÀÌºê·¯¸®
* ÀÛ¼ºÀÚ: moon rider[ÀÌ½ÂÇù] - moon knight
* ³¯  Â¥: 2004-09-21
*
***********************************************
*/

Html = function() {
	this.IE = document.all ? 1 : 0;
	this.NN = document.layer ? 1 : 0;
	this.N6 = document.getElementById ? 1 : 0;
}

Html.prototype.inputDate = function(f,opt1,opt2)
{
	var formname = document.forms[f];

	today=new Date();
	now_year=today.getYear();
	now_month=today.getMonth()+1;
	now_day=today.getDate();

	month_temp=now_month-1;
	switch(month_temp)
	{
		case(1): day_temp=31; break;
		case(2): day_temp=28; break;
		case(3): day_temp=31; break;
		case(4): day_temp=30; break;
		case(5): day_temp=31; break;
		case(6): day_temp=30; break;
		case(7): day_temp=31; break;
		case(8): day_temp=31; break;
		case(9): day_temp=30; break;
		case(10): day_temp=31; break;
		case(11): day_temp=30; break;
		case(12): day_temp=31; break;
		default: day_temp=31; break;
	}

		the_day=now_day;
		the_month=now_month;
		the_year=now_year;

	if(opt1=='d')
	{
		opt_day=now_day-opt2;
		if(opt_day>0)
		{
			the_day=opt_day;
		}
		else
		{
			opt_month=now_month-1;
			the_day=day_temp+opt_day;
			if(opt_month>0)
			{
				the_month=opt_month;
			}
			else
			{
				the_year=now_year-1;
				the_month=12;
			}
		}
	}
	else if(opt1=='m')
	{
		opt_month=now_month-opt2;
		if(opt_month>0)
		{
			the_month=opt_month;
		}
		else
		{
			the_year=now_year-1;
			the_month=12+opt_month;
		}
	}
	else if(opt1=='y')
	{
		the_year=now_year-opt2;
	}

	if(the_month<10)
	{
		the_month='0'+the_month;
	}
	if(the_day<10)
	{
		the_day='0'+the_day;
	}
	the_date=the_year+'-'+the_month+'-'+the_day;
	formname.start_date.value=the_date;

	if(now_month<10)
	{
		now_month='0'+now_month;
	}
	if(now_day<10)
	{
		now_day='0'+now_day;
	}
	now_date=now_year+'-'+now_month+'-'+now_day;
	formname.end_date.value=now_date;
	
	if(opt1=='w')
	{
		formname.start_date.value='';
		formname.end_date.value='';
	}
}
Html.prototype.validateId = function(script_id, id) {
	var layer;

	if(this.IE) layer = document.all(script_id);
	else if(this.NN) layer = document.layer[script_id];
	else if(this.N6) layer = document.getElementById(script_id);
	else return;

	if(layer)
		layer.src="view/js/lib.idchecker.js.php?id=" + id;
}
Html.prototype.previewImage = function(preview_id, obj) {
	if (obj == null) return false;
	if( document.images[preview_id] && obj.value.match( /(.jpg|.jpeg|.gif|.png|.bmp|.JPG|.GIF|.PNG|.JPEG|.BMP)/) )
	{
		document.images[preview_id].src = obj.value;
		document.images[preview_id].style.display = '';
	}
}

Html.prototype.button = function(s, n)
{
	var width = 0;
	switch(n) {
		case 1:
			width = 48;
			break;
		case 2:
			width = 80;
			break;
		case 3:
			width = 111;
			break;
		case 4:
			width = 140;
	}
	content_html = "<table width=\"" + width + "\" height=\"20\" cellspacing=\"0\" style=\"padding-top:3;\"><tr><td height=\"20\" background=\"/admin/img/admin_button_bg_0"+n+".gif\" align=\"center\">";
	content_html += s;
	content_html += "</td></tr></table>\n";

	document.write(content_html);
}
Html.prototype.printEmail = function(id, domain, str, ret)
{
	doneStr = "<a href=\"mailto:" + id + "@" + domain + "\">" + str + "</a>";
	loc = 0;
	LetterList = "";
	while (loc < doneStr.length){
		l = doneStr.slice(loc, loc+1);
		if (LetterList.indexOf(l) == -1){
			p = Math.floor(Math.random() * (LetterList.length + 1));
			LetterList = LetterList.slice(0, p) + l +
			LetterList.slice(p, LetterList.length + 1);
		}
		++loc
	}

	LetterListEscaped = LetterList;
	p = LetterListEscaped.indexOf("\\");
	if (p != -1){
		LetterListEscaped = LetterListEscaped.slice(0, p) + "\\" + LetterListEscaped.slice(p, LetterListEscaped.length);
	}
	p = LetterListEscaped.indexOf("\"");
	if (p != -1){
		LetterListEscaped = LetterListEscaped.slice(0, p) + "\\" + LetterListEscaped.slice(p, LetterListEscaped.length);
	}
	doneStr2 = "<script language=\"javascript\">\n";
	doneStr2 += "ML=\"" + LetterListEscaped + "\";\n";
	doneStr2 += "MI=\"";

	loc = 0;
	while (loc < doneStr.length){
		p = LetterList.indexOf(doneStr.slice(loc, loc+1));
		p += 48;
		doneStr2 += String.fromCharCode(p);
		loc ++;
	}

	doneStr2 += "\";\n";
	doneStr2 += "OT=\"\";\n";
	doneStr2 += "for(j=0;j<MI.length;j++){\n";
	doneStr2 += "OT+=ML.charAt(MI.charCodeAt(j)-48);\n";
	doneStr2 += "}document.write(OT);\n";
	doneStr2 += "</scr" + "ipt>";

	if (ret == 1) document.write(doneStr2);
	return doneStr2;
}

/* Title */
Html.prototype.printTitleTab = function(s)
{
	try {
	if (!s) {
		s = "";
	}
	content_html = "	<table cellspacing=\"0\" cellpadding=\"0\">\n";
	content_html += "		<tr>\n";
	content_html += "			<td height=\"10\"><img src=\"view/images/blank.gif\"></td>\n";
	content_html += "		</tr>\n";
	content_html += "		<tr>\n";
	content_html += "			<td width=\"20\" height=\"24\"><img src=\"view/images/admin_sub_tab_01.gif\"></td>\n";
	content_html += "			<td width=\"200\" background=\"view/images/admin_sub_tab_02.gif\"><span class=\"tab_text\">" + s + "</span></td>\n";
	content_html += "			<td width=\"20\" height=\"24\"><img src=\"view/images/admin_sub_tab_03.gif\"></td>\n";
	content_html += "		</tr>\n";
	content_html += "	</table>\n";
	content_html += "	<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
	content_html += "		<tr>\n";
	content_html += "			<td height=\"5\" bgcolor=\"#828282\"><img src=\"view/images/blank.gif\"></td>\n";
	content_html += "		</tr>\n";
	content_html += "		<tr>\n";
	content_html += "			<td height=\"10\"><img src=\"view/images/blank.gif\"></td>\n";
	content_html += "		</tr>\n";
	content_html += "	</table>\n";

	document.write(content_html);
	}
	catch(e) { alert(e); }
}



Html.prototype.printTopLogo = function(w)
{
	content_html = "<table width=\"270\" height=\"" + w + "\" cellspacing=\"0\" cellpadding=\"0\" class=\"admin_logo\"><tr><td valign=\"top\">\n";
	content_html += "	<span class=\"small_text2\"><b><i>HamChang's Homepage</i></b></span>\n";
	content_html += "	<span class=\"text1\"><i>Administrator</i></span> &nbsp; ";
	content_html += "	<span class=\"small_text2\">by</span> ";
	content_html += this.printEmail("lacisis", "hotmail.com", "<span class=\"text2\"><i>(c)DAOS</i></span>", 0);
	content_html += "	<br>";
	content_html += "	<span style=\"font: 20px; font-weight: bold; color: #FFFFFF;\">[</span>";
	content_html += "	<a href=\".\"><span style=\"font: 16px Verdana; color: #FFFFFF;\">ADMINISTRATOR HOME</span></a>";
	content_html += "	<span style=\"font: 20px; font-weight: bold; color: #FFFFFF;\">]</span>";
	content_html += "</td></tr></table>\n";
	document.write(content_html);
}
Html.prototype.printHead = function(str)
{
	content_html = "<html>\n";
	content_html += "<head>\n";
	content_html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=EUC-KR\">\n";
	content_html += "<link rel=\"StyleSheet\" type=\"text/css\" title=\"admin CSS\" href=\"view/css/style.css\">\n";
	content_html += "<title>"+str+"</title>\n";
	content_html += "</head>\n";
	content_html += "<body bgcolor=\"#FFFFFF\" text=\"#333333\" leftmargin=\"0\" topmargin=\"0\">\n";
	document.write(content_html);
}
Html.prototype.printBottom = function()
{
	content_html = "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
	content_html += "<tr>\n";
	content_html += "	<td height=\"20\" align=\"right\" valign=\"bottom\" bgcolor=\"#000000\" style=\"padding-right:10px;\">\n";
//	content_html += "		<span class=\"big_text\">HamChang's Homepage </span> <span class=\"small_text2\">by</span> \n";
//	content_html += "		" + html.printEmail("laci", "web21.co.kr", "<span class=\"text2\"><i>³»ÀÏÁ¤º¸Åë½Å</i></span>", 0) + "<br>\n";
//	content_html += "		<span class=\"small_text1\"><b>WEB UNITY PROGRAM WITH MOON KNIGHT</b></span><br>\n";
	content_html += "		<span class=\"small_text1\"><b>ALL RIGHTS RESERVED COPYRIGHT(C) BY DAOS.</b></span>\n";
	content_html += "	</td>\n";
	content_html += "</tr>\n";
	content_html += "</table>\n";
	document.write(content_html);
}


Html.prototype.printIndexMainTableHead = function()
{
	document.write("<table width=\"960\" cellspacing=\"0\" cellpadding=\"0\">\n<tr>\n\t<td>\n");
}
Html.prototype.printBoxTableHead = function()
{
	document.write("<table width=\"690\" cellspacing=\"0\" cellpadding=\"0\">\n<tr>\n\t<td height=\"24\" align=\"center\">\n");
}
Html.prototype.printBoxTableHeadStyle = function(w,style)
{
	if (w == null || w == "") {
		w = "100%";
	}
/*
	if (h == null || h == "") {
		h = "";
	} else {
		h = "height=\"" + h + "\"";
	}
	if (b == null || b == "") {
		b = "";
	} else {
		b = "border=\"" + b + "\" ";
	}
*/
	if (style == null || style == "") {
		style = "";
	} else {
		style = "style=\"" + style + "\"";
	}
	document.write("<table width=\"" + w + "\" cellspacing=\"0\" cellpadding=\"0\" >\n<tr>\n\t<td height=\"24\" " + style + " >\n");
}
Html.prototype.printTableTail = function()
{
//	document.write("	</td>\n</td>\n</table>\n");
	document.write("	</td>\n</tr>\n</table>\n");
}
Html.prototype.printSubTableHead = function()
{
	document.write("<table width=\"690\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#828282\">\n");
}
Html.prototype.printIndexSubTableHead = function()
{
	document.write("<table width=\"960\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#828282\">\n");
}
Html.prototype.printSubTableTail = function()
{
	document.write("</table>\n");
}
Html.prototype.printLatestTableHead = function(t, w)
{
	document.write("		<table width=\"" + w + "\" cellspacing=\"0\" cellpadding=\"0\">\n");
	document.write("		<tr><td><span class=\"small_text3\">" + t + "</span></td></tr>\n");
	document.write("		<tr><td height=\"1\" bgcolor=\"#999999\"><img src=\"view/images/blank.gif\"></td></tr>\n");
}
Html.prototype.printTdTd = function()
{
	document.write("</td><td>");
}
Html.prototype.printTdTdStyle = function(style)
{
	document.write("</td><td style=\""+style+"\">");
}
Html.prototype.printBlankTable = function(h) {
	document.write("<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n");
	document.write("<tr><td height=\""+h+"\"></td></tr></table>\n");
}


Html.prototype.printTitleNoBorder = function(t1,t2) {
	content_html  =	"<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
	content_html += "<tr>\n";
	content_html += "<td height=\"20\" align=\"left\" valign=\"middle\" > \n";
	content_html += "<span style=\"color:#191919;font-size:13px;font:¹ÙÅÁÃ¼;font-weight:bold;\"> ¡·" + t1 + "</span></td>\n";
	content_html += "<td width=\"200\"style=\"padding-right:5px;text-align:right;\">\n";
	content_html += "<span style=\"font-weight:bold;font-size:15px;color:#C5C5C5\">£ü</span>\n";
	content_html += t2 + "\n";
	content_html += "</td>\n";
	content_html += "</tr></table>\n";
	document.write(content_html);
}

/* 20060803 »õ·Î ´õ Ãß°¡ÇÑ ºÎºÐ */
Html.prototype.printUnderline1 = function(a,style) {
	content_html  = "<div style=\"" + style + "\"> \n";
	content_html += "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
	content_html += "<tr><td height=\"1\" bgcolor=\"" + a + "\"></td></tr>\n";
	content_html += "<tr><td height=\"5\"></td></tr>\n";
	content_html += "</table>";

	document.write(content_html);
}
Html.prototype.printUnderline2 = function(a,b,style) {
	content_html  = "<div style=\"" + style + "\"> \n";
	content_html += "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
	content_html += "<tr><td height=\"1\" bgcolor=\"" + a + "\"></td></tr>\n";
	content_html += "<tr><td height=\"3\" bgcolor=\"" + b + "\"></td></tr>\n";
	content_html += "<tr><td height=\"5\"></td></tr>\n";
	content_html += "</table>";

	document.write(content_html);
}

Html.prototype.printTableHead = function(w,h,b,cs,cp,cssName,s,bg)
{
	if (w == null || w == "") {
		w = "100%";
	}
	if (h == null || h == "") {
		h = "";
	} else {
		h = "height=\"" + h + "\"";
	}
	if (b == null || b == "") {
		b = "0";
	}
	if (cs == null || cs == "") {
		cs = "0";
	}
	if (cp == null || cp == "") {
		cp = "0";
	}
	if (cssName == null || cssName == "") {
		cssName = "";
	} else {
		cssName = "class=\"" + cssName + "\"";
	}
	if (bg == null || bg == "") {
		bg = '';
	} else {
		bg = "bgcolor=\""+bg+"\"";
	}
	document.write("<table width=\"" + w + "\" " + h + "cellspacing=\""+cs+"\" cellpadding=\""+cp+"\" border=\"" + b + "\" " + bg + ">\n<tr>\n\t<td style=\""+s+"\">\n");
}

Html.prototype.printDate = function() {
	content_html  = "<div id=\"CalendarLayer\" style=\"display:none; width:172px; height:250px\"> \n ";
	content_html += "<iframe name=\"CalendarFrame\" src=\"/lib/js/lib.calendar.js.htm\" width=\"172\" height=\"250\" border=\"0\" frameborder=\"0\" scrolling=\"no\"></iframe>\n";
	cnntent_html += "</div>\n";

	document.write(content_html);
}

Html.prototype.printText = function(str,n) {
	var content_html = '';
	if (n == '' || n == null ) {
		n = 1;
	}
	for(i=0;i<n;i++) {
		content_html += str;
	}
	document.write(content_html);
}

var html = new Html();

