﻿//<![CDATA[

// Global variant
var _mainFrameCount = 9;
var _defaultThemeCount = 4;
var _contentsWidth = 0;

// Default Theme
var _defaultTheme = new Array(_defaultThemeCount);

_defaultTheme[0] =
	[
		// Main Color, Size : 값을 설정하면 User 설정 값은 무시
		"",	/* body_backgroundColor		*/
		"",	/* body_backgroundImage		*/
		"",	/* frame_backgroundColor	*/
		"",	/* contents_backgroundColor	*/
		0, 0,	/* contents_width, height	*/

		// Main Frame TD
		"", "", "",	/* 1-1 */
		"", "", "",	/* 1-2 */
		"", "", "",	/* 1-3 */
		"", "", "",	/* 2-1 */
		"", "", "",	/* 2-2 */
		"", "", "",	/* 2-3 */
		"", "", "",	/* 3-1 */
		"", "", "",	/* 3-2 */
		"", "", "",	/* 3-3 */

		// TopMenu
		0,	/* topMenuHeightFix	*/
		0,	/* topMenuHeight	*/
		0,	/* topMenuShowMessage	*/
		""	/* topMenuMessage	*/
	];

_defaultTheme[1] =
	[
		// Main Color, Size : 값을 설정하면 User 설정 값은 무시
		"#ffffff",
		"",
		"#e0e0e0",
		"#ffffff",
		0, 0,

		// Main Frame TD
		"", "", "",
		"", "", "",
		"", "", "",
		"", "", "",
		"", "", "",
		"url('" + user_skin_path + "/images/t1_right_under.gif') repeat-y left", "", "url('" + user_skin_path + "/images/t1_right_over.gif') no-repeat top left",
		"", "", "",
		"", "url('" + user_skin_path + "/images/t1_bottom_under.gif') repeat-x top", "url('" + user_skin_path + "/images/t1_bottom_over.gif') no-repeat top left",
		"", "", "url('" + user_skin_path + "/images/t1_corner.gif') no-repeat top left",

		// TopMenu
		0,
		0,
		0,
		""
	];

_defaultTheme[2] =
	[
		// Main Color, Size : 값을 설정하면 User 설정 값은 무시
		"#eaeaea",
		"",
		"#ffffff",
		"#efefef",
		0, 0,

		// Main Frame TD
		"", "url('" + user_skin_path + "/images/t2_left_under.gif') repeat-y right", "",
		"#ffffff", "", "url('" + user_skin_path + "/images/t2_top.gif') no-repeat bottom right",
		"", "url('" + user_skin_path + "/images/t2_right_under.gif') repeat-y left", "",
		"", "url('" + user_skin_path + "/images/t2_left_under.gif') repeat-y right", "",
		"", "", "",
		"", "url('" + user_skin_path + "/images/t2_right_under.gif') repeat-y left", "",
		"", "url('" + user_skin_path + "/images/t2_left_under.gif') repeat-y right", "",
		"#ffffff", "", "",
		"", "url('" + user_skin_path + "/images/t2_right_under.gif') repeat-y left", "",

		// TopMenu
		1,
		200,
		1,
		"<span style='font:11px Verdana'>" +
		"&nbsp; &nbsp; 왜 <font color='#444fe2'>사랑</font>하냐구요?<br /><br />" +
		"&nbsp; &nbsp; <font color='#07aaef'>어린아이</font>에게 왜 태어났느냐고 물어보십시오.<br /><br />" +
		"&nbsp; &nbsp; <font color='#01b784'>꽃</font>에게 왜 피어있는지 물어보십시오.<br /><br />" +
		"&nbsp; &nbsp; <font color='#7ebe44'>태양</font>에게 왜 빛나고 있냐고 물어보십시오.<br /><br />" +
		"&nbsp; &nbsp; 나는 <font color='#f55a0d'>당신</font>을 사랑하지" +
		" 않을 수 없기 때문에 <font color='#cc198f'>사랑</font>하는 겁니다." +
		"</span>"
	];

_defaultTheme[3] =
	[
		// Main Color, Size : 값을 설정하면 User 설정 값은 무시
		"",
		"url('" + user_skin_path + "/images/t3_back.gif') no-repeat top left",
		"",
		"",
		0, 0,

		// Main Frame TD
		"", "", "",	/* 1-1 */
		"", "", "",	/* 1-2 */
		"", "", "",	/* 1-3 */
		"", "", "",	/* 2-1 */
		"", "", "",	/* 2-2 */
		"", "", "",	/* 2-3 */
		"", "", "",	/* 3-1 */
		"", "", "",	/* 3-2 */
		"", "", "",	/* 3-3 */

		// TopMenu
		0,	/* topMenuHeightFix	*/
		0,	/* topMenuHeight	*/
		0,	/* topMenuShowMessage	*/
		""	/* topMenuMessage	*/
	];


// Class
function GCC_ClassTD(bgColor, bgImageUnder, bgImageOver) {
	this.backgroundColor = bgColor;
	this.backgroundImageUnder = bgImageUnder;
	this.backgroundImageOver = bgImageOver;
}

// Class
function GCC_ClassTheme() {
	// member variable
	this.mainFrameTD = new Array(_mainFrameCount);

	// member function
	this.initialize = initialize;
//	this.setContentsPhoto = setContentsPhoto;
	this.drawTable = drawTable;
}

function initialize() {
	var count = 0;
	var styleCount = 0;

	this.body_backgroundColor = _defaultTheme[user_theme][styleCount++];
	this.body_backgroundImage = _defaultTheme[user_theme][styleCount++];
	this.frame_backgroundColor = _defaultTheme[user_theme][styleCount++];
	this.contents_backgroundColor = _defaultTheme[user_theme][styleCount++];
	this.contents_width = _defaultTheme[user_theme][styleCount++];
	this.contents_height = _defaultTheme[user_theme][styleCount++];

	for (count = 0; count < _mainFrameCount; count++) {
		this.mainFrameTD[count] =
			new GCC_ClassTD(_defaultTheme[user_theme][styleCount], _defaultTheme[user_theme][styleCount+1], _defaultTheme[user_theme][styleCount+2]);
		styleCount += 3;
	}

	this.topMenuHeightFix = _defaultTheme[user_theme][styleCount++];
	this.topMenuHeight = _defaultTheme[user_theme][styleCount++];
	this.topMenuShowMessage = _defaultTheme[user_theme][styleCount++];
	this.topMenuMessage = _defaultTheme[user_theme][styleCount++];
}

function drawTable() {
	var count;
	var background_style;

	if (this.body_backgroundColor != "" || this.body_backgroundImage != "") {
		background_style = this.body_backgroundColor + " " + this.body_backgroundImage;
		eval("gcc_mainframe_table.style.background = \"" + background_style + "\"");
	}

	// main frame : background image
	for (count = 0; count < _mainFrameCount; count++) {
		background_style = this.mainFrameTD[count].backgroundColor + " " + this.mainFrameTD[count].backgroundImageUnder;
		eval("gcc_mainframe_td" + (count+1) + ".style.background = \"" + background_style + "\"");
		eval("gcc_mainframe_td" + (count+1) + "_table.style.background = this.mainFrameTD[" + count + "].backgroundImageOver;");
	}

	// main frame : top menu
	if (this.topMenuHeightFix == 1 && this.topMenuHeight > 0) {
		gcc_mainframe_td2.style.height = this.topMenuHeight;
		gcc_mainframe_td2.style.tableLayout = "fixed";
	}
	if (this.topMenuShowMessage == 1 && this.topMenuMessage != "") {
		gcc_mainframe_td2_message.innerHTML = this.topMenuMessage;
	}

	// main frame : contents size
	gcc_mainframe_td5.style.width = (this.contents_width != 0) ? (this.contents_width+30) : (user_contents_width+30);
	gcc_mainframe_td5.style.height = (this.contents_height != 0) ? (this.contents_height+85) : (user_contents_height+85);

	// contents frame
	gcc_mainframe_td5_table.style.backgroundColor = (this.frame_backgroundColor != "") ? this.frame_backgroundColor : user_frame_backgroundColor;

	// contents
	gcc_contents_table.style.backgroundColor = (this.contents_backgroundColor != "") ? this.contents_backgroundColor : user_contents_backgroundColor;
	gcc_contents_table.style.width = (this.contents_width != 0) ? this.contents_width : user_contents_width;
	gcc_contents_table.style.height = (this.contents_height != 0) ? this.contents_height : user_contents_height;
	gcc_contents_table.style.tableLayout = "fixed";

	// contents display type
	if (user_contents_photo_minSize > 0) {
		gcc_contents_all.style.display = "none";
		gcc_contents_photo.style.display = "inline";
	} else {
		gcc_contents_photo.style.display = "none";
		gcc_contents_all.style.display = "inline";
	}

	// contents width
	_contentsWidth = (this.contents_width != 0) ? this.contents_width : user_contents_width;
}

function setContentsPhoto() {
	var i;
	var image_src = "";
	var image_min = user_contents_photo_minSize;
	var temp_image = new Image();

	for(i = 0; i < document.images.length; i++) {
		temp_image.src = document.images[i].src;
		if (temp_image.width > image_min) {
			image_src = temp_image.src;
			break;
		}
	}

	if (image_src != "") {
		if ((user_resize_photo == true) && (image_src.width > _contentsWidth)) {
			gcc_contents_photo_span.innerHTML = "<img src='" + image_src + "' width='" + _contentsWidth + "' />";
		} else {
			gcc_contents_photo_span.innerHTML = "<img src='" + image_src + "' />";
		}
	} else {
		gcc_contents_photo.style.display = "none";
		gcc_contents_all.style.display = "inline";
	}
}

function gcc_resizePhoto() {
	var i;

	for(i = 0; i < document.images.length; i++) {
		if (document.images[i].width > _contentsWidth) {
			document.images[i].height = document.images[i].height / (document.images[i].width / _contentsWidth);
			document.images[i].width = _contentsWidth;
		}
	}
}

function gcc_hasPhoto() {
	var i;

	for(i = 0; i < document.images.length; i++) {
		if (document.images[i].width >= user_contents_photo_minSize) {
			return true;
		}
	}
	return false;
}

function gcc_loadComplete() {
	gcc_load.style.display = "none";
	gcc_body.style.display = "inline";

	setContentsPhoto();

	if ((user_contents_photo_minSize == 0) || !gcc_hasPhoto()) {
		gcc_toggle_text.style.display = "none";
		gcc_toggleShowComments(0);
	} else {
		gcc_toggleShowComments(1);
	}

	if (user_resize_photo == true) {
		gcc_resizePhoto();
	}
}

function gcc_toggleShowContents() {
	if (gcc_contents_photo.style.display == "none") {
		gcc_contents_photo.style.display = "inline";
		gcc_contents_all.style.display = "none";
		gcc_toggleShowComments(1);
	} else {
		gcc_contents_photo.style.display = "none";
		gcc_contents_all.style.display = "inline";
		gcc_toggleShowComments(0);
	}

	if (user_resize_photo == true) {
		gcc_resizePhoto();
	}
}

function gcc_toggleShowComments(flag) {
	if (flag) {
		gcc_comment_link.style.display = "none";
		gcc_comment_nolink.style.display = "inline";
	} else {
		gcc_comment_link.style.display = "inline";
		gcc_comment_nolink.style.display = "none";
	}
}

function gcc_showTooltip(text) {
	if (user_show_tooltip == true) {
		gcc_tooltip.innerText = text;
		gcc_tooltip.style.display = "inline";
		gcc_tooltip.style.pixelTop = event.y + document.body.scrollTop - 30;
		gcc_tooltip.style.pixelLeft = event.x + document.body.scrollLeft + 20;
	}
}

function gcc_hideTooltip() {
	if (user_show_tooltip == true) {
		gcc_tooltip.style.display = "none";
	}
}

function gcc_moveTooltip() {
	if (user_show_tooltip == true) {
		gcc_tooltip.style.pixelTop = event.x + document.body.scrollTop - 30;
		gcc_tooltip.style.pixelLeft = event.x + document.body.scrollLeft + 20;
	}
}

//]]>