/**
 * @(#)page_util.js
 *
 * Copyright (C) 2007 D.TRIBE, Inc. All rights reserved.
 *
 * THIS SOFTWARE IS THE PROPRIETARY INFORMATION OF D.TRIBE, INC.
 * USE IS SUBJECT TO LICENSE TERMS.
 *
 * @author	Barney Kim
 * @version	1.0, 2007/02/07 ÆÄÀÏ ÀÛ¼º
 *					1.1, 2007/03/02 ÇÔ¼öÃß°¡  ¼öÁ¤ : Triple_H
 */

// ÆäÀÌÁö ¿Â·Îµå ÀÌº¥Æ®½Ã ½ÇÇàÇÒ °´Ã¼
function PageLoad() {
	this.todo = new Array();

	// ÇÔ¼ö Ãß°¡
	this.add = function(func) {
		this.todo[this.todo.length] = func;
	}

	// ÇÔ¼ö ½ÇÇà
	this.process = function() {
		for (var i = 0; i < this.todo.length; i++) {
			try {
				eval(this.todo[i]);
			} catch(e) {
				//
			}
		}
	}
}

// µ¿¿µ»ó ÇÃ·¡ÀÌ¾î ·Îµå
//
// @param id Object ¾ÆÀÌµð
// @param url ÇÃ·¡½Ã URL
// @param w ³ÐÀÌ
// @param h ³ôÀÌ
//
function create_player(id, url, w, h) {
	var strObj = '\
	<object id="' + id + '" \
			classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" \
			codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" \
			standby="Loading Microsoft Windows Media Player components..." \
			type="application/x-oleobject" \
			bgcolor="DarkBlue" width="' + w + '" Height="' + h + '" VIEWASTEXT> \
			<param name="FileName" value="' + url + '"> \
			<param name="AutoStart" value="1"> \
			<param name="AutoSize" value="1"> \
			<param name="AnimationAtStart" value="0"> \
			<param name="DisplayMode" value="4"> \
			<param name="Enabled" value="1"> \
			<param name="ShowControls" value="0"> \
			<param name="ShowAudioControls" value="0"> \
			<param name="ShowDisplay" value="0"> \
			<param name="ShowGotoBar" value="0"> \
			<param name="ShowPositionControls" value="0"> \
			<param name="ShowStatusBar" value="0"> \
			<param name="Volume" value="100"> \
			<param name="ShowCaptioning" value="0"> \
			<param name="TransparentAtStart" value="0"> \
			<embed name="' + id + '" Name="MediaPlayer" invokeURLs="false" \
				type="application/x-mpPlayerOnPlayBtn_div" \
				pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" \
				AutoStart="1" \
				AutoSize="1" \
				AnimationAtStart="0" \
				DisplayMode="4" \
				Enabled="1" \
				ShowControls="0" \
				ShowAudioControls="0" \
				ShowDisplay="0" \
				ShowGotoBar="0" \
				ShowPositionControls="0" \
				ShowStatusBar="0" \
				Volume="0" \
				ShowCaptioning="0" \
				TransparentAtStart="1"></embed> \
		</object>';

	document.write(strObj);
}

function create_player1(id, url) {
	var strObj = '\
	<object id="' + id + '" \
			classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" \
			codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" \
			standby="Loading Microsoft Windows Media Player components..." \
			type="application/x-oleobject" \
			bgcolor="DarkBlue" VIEWASTEXT> \
			<param name="FileName" value="' + url + '"> \
			<param name="AutoStart" value="1"> \
			<param name="AutoSize" value="1"> \
			<param name="AnimationAtStart" value="0"> \
			<param name="DisplayMode" value="4"> \
			<param name="Enabled" value="1"> \
			<param name="ShowControls" value="1"> \
			<param name="ShowAudioControls" value="1"> \
			<param name="ShowDisplay" value="0"> \
			<param name="ShowGotoBar" value="0"> \
			<param name="ShowPositionControls" value="0"> \
			<param name="ShowStatusBar" value="0"> \
			<param name="Volume" value="100"> \
			<param name="ShowCaptioning" value="0"> \
			<param name="TransparentAtStart" value="0"> \
			<embed name="' + id + '" Name="MediaPlayer" invokeURLs="false" \
				type="application/x-mpPlayerOnPlayBtn_div" \
				pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" \
				AutoStart="1" \
				AutoSize="1" \
				AnimationAtStart="0" \
				DisplayMode="4" \
				Enabled="1" \
				ShowControls="0" \
				ShowAudioControls="0" \
				ShowDisplay="0" \
				ShowGotoBar="0" \
				ShowPositionControls="0" \
				ShowStatusBar="0" \
				Volume="0" \
				ShowCaptioning="0" \
				TransparentAtStart="1"></embed> \
		</object>';

	document.write(strObj);
}
// ÇÃ·¡½Ã ·Îµå
//
// @param id Object ¾ÆÀÌµð
// @param url ÇÃ·¡½Ã URL
// @param width ³ÐÀÌ
// @param height ³ôÀÌ
//
function write_flash(id, url, w, h) {
	var strObj = '\
	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" \
		codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" \
		width="' + w + '" height="' + h + '" id="' + id + '"> \
		<param name="allowScriptAccess" value="sameDomain" /> \
		<param name="movie" value="' + url + '" /> \
		<param name="quality" value="high" /> \
		<param name=wmode value=transparent  /> \
		<embed src="' + url + '" quality="high" width="' + w + '" height="' + h + '" name="' + id + '" \
			bgcolor="#000000" \
			allowScriptAccess="sameDomain" \
			type="application/x-shockwave-flash" \
			pluginspage="http://www.macromedia.com/go/getflashplayer" /> \
	</object>';
	document.write(strObj);
}

// ÆË¾÷ Ã¢ Áß¾ÓÀ¸·Î ¶ç¿ì±â
// º¸Á¤°ªÀº ÇöÀç 20
//
// @param url URL
// @param wname Ã¢ ÀÌ¸§
// @param w Ã¢ ³Êºñ
// @param h Ã¢ ³ôÀÌ
//
function popupCenterWindow(url, wname, w, h) {
	var gab = 20;
	var wx = (window.screen.width-w)/2;
	var wy = (window.screen.height-h)/2;
	if(wy > gab) {
		wy -= gab;
	}
	var p=window.open(url, wname, "width="+w+",height="+h+",left="+wx+",top="+wy);
	p.focus();
}

// ÆË¾÷ Ã¢ ºê¶ó¿ìÁ® Á¶Àý 
// º¸Á¤°ª gab
//
// @param url URL
// @param wname Ã¢ÀÌ¸§
// @param w Ã¢ ³Êºñ
// @param h Ã¢ ³ôÀÌ
// @param f
function popupWindow(url, wname, w, h, f) {
	var gab = 0;
	if(f != undefined && f == true) {
		var agent = navigator.userAgent.toLowerCase();
		if (agent.indexOf("msie") != -1 ) {
			gab += 50;
		}
		if (agent.indexOf("firefox") != -1 ) {
			gab += 20;
		}
		h += gab;
	}
	var p=window.open(url, wname, "width="+w+",height="+h);
	p.focus();
}

// ÀÌ¹ÌÁö»çÀÌÁî Á¶Àý
// ÃÖ´ë °ªÀ» ³Ñ±âÁö ¸øÇÏ°Ô ÇÑ´Ù
// 
// @param ÀÌ¹ÌÁö °´Ã¼
// @param imgWidth ÃÖ´ë³ÐÀÌ
// @param imgHeight ÃÖ´ë³ôÀÌ
//
function changeSize(img, maxWidth, maxheight) {
	var imgWidth = img.width;
	var imgHeight = img.height;
	if (imgWidth >= maxWidth) {
		imgHeight = imgHeight / (imgWidth / maxWidth);			
		imgWidth = maxWidth;
	}
	if ( imgHeight >= maxheight) {
		imgWidth = imgWidth / (imgHeight / maxheight);
		imgHeight = maxheight;			
	}
	img.width = imgWidth;
	img.height = imgHeight;
}
// EOF