/*--------------------------------------------------------------------------------*\
 *  W2 JavaScript Framework
 *
 *  Date : 2007. 06. 25.
 *  @author Jeff Yang <k2guest@hotmail.com>
 *  @copyright 1999-2007 DoubleU Two Communications, Inc.
 *  @package common
 *  @license LGPL
 *  @version 0.2
\*--------------------------------------------------------------------------------*/

var W2 = {
	Version: '0.2',
	jsPath:  '/eng/common/js/',
	cssPath: '/eng/common/css/',
	imgPath: '/eng/images/',
	flashPath: '/eng/flash/',
	loadFile: [],
	param: {},
	packages: {
		builder: 'lib/builder.js',
		effect: 'lib/effects.js',
		dragdrop: 'lib/dragdrop.js',
		control: 'lib/controls.js',
		slider: 'lib/slider.js',
		editor: 'editor.js',
		form: 'form.js',
		validation: 'validation.js',
		calendar: 'calendar.js'
	},
	create: function() {
		W2.load(W2.jsPath+'lib/prototype.js', 'js');
		W2.load(W2.jsPath+'extend.js', 'js');
		W2.load(W2.jsPath+'link.js', 'js');
		var common = document.getElementsByTagName('script');
		for(var i = 0; i < common.length; i++) {
			if(common[i].src.match(/common\.js\?(.*)?$/)) {
				var param = common[i].src.replace(/^.+common\.js\?/, '').split('&');
				for(var j = 0; j < param.length; j++) {
					W2.param[param[j].split('=')[0]] =  param[j].split('=')[1];
				}
			}
			break;
		}
	},
	include: function(pkg) {
		if(typeof W2.packages[pkg] != 'undefined') {
			W2.load(W2.jsPath+W2.packages[pkg], 'js');
		}
	},
	load: function(file, type) {
		for(var i = 0; i < W2.loadFile.length; i++) {
			if(file == W2.loadFile[i]) { return; }
		}
		if(type == 'js') {
			document.write('<script type="text/javascript" src="'+file+'"></script>');
			W2.loadFile.push(file);
		} else {
			document.write('<link type="text/css" rel="stylesheet" href="'+W2.cssPath+file+'" />');
		}
	},
	flashLoad: function() {
		var js = document.getElementsByTagName('script');
		js = js[js.length - 1].src.replace(/^.+flash\.js\?name=/, '');
		W2.flash = {};
		for(var property in Flash[js]) {
			W2.flash[property] = Flash[js][property];
		}
	}
};
W2.create();

// HTML Title
document.title = 'World Vision Korea';


// µ¿¿µ»ó
function mediaMovie(playUrl,mw,mh,autoStat)
{
	document.write (" <OBJECT id=objMUSIC hideFocus style='LEFT: 0px; WIDTH: "+mw+"px; TOP: 0px; HEIGHT: "+mh+"px' type=application/x-oleobject standby='Microsoft Windows Media Player ±¸¼º¿ä¼Ò¸¦ ÀÐ´ÂÁßÀÔ´Ï´Ù.' classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 name=objMUSIC VIEWASTEXT AutoStart='1'>");
	document.write (" <PARAM NAME='URL' VALUE='"+playUrl+"'>            ");
	document.write (" <PARAM NAME='rate' VALUE='1'>                     ");
	document.write (" <PARAM NAME='balance' VALUE='0'>                  ");
	document.write('  <param name="autostart" value="'+autoStat+'" />');					//ÆäÀÌÁö°¡ ¿­¸± ¶§ ÀÚµ¿À¸·Î µ¿¿µ»óÀÌ ½ÇÇàµÉÁö¿¡ ´ëÇÑ ¿É¼Ç
	document.write (" <PARAM NAME='currentPosition' VALUE='4.315449'>   ");
	document.write (" <PARAM NAME='defaultFrame' VALUE='0'>             ");
	document.write (" <PARAM NAME='playCount' VALUE='1'>                ");
	document.write (" <PARAM NAME='autoStart' VALUE='1'>                ");
	document.write (" <PARAM NAME='currentMarker' VALUE='0'>            ");
	document.write (" <PARAM NAME='invokeURLs' VALUE='-1'>              ");
	document.write (" <PARAM NAME='baseURL' VALUE=''>                   ");
	document.write (" <PARAM NAME='volume' VALUE='80'>                  ");
	document.write (" <PARAM NAME='uiMode' VALUE='none'>                ");
	document.write (" <PARAM NAME='stretchToFit' VALUE='0'>             ");
	document.write (" <PARAM NAME='transparentatstart' VALUE='false'>   ");
	document.write (" <PARAM NAME='windowlessVideo' VALUE='0'>          ");
	document.write (" <PARAM NAME='enabled' VALUE='-1'>                 ");
	document.write (" <PARAM NAME='enableContextMenu' VALUE='0'>        ");
	document.write (" <PARAM NAME='fullScreen' VALUE='0'>               ");
	document.write (" <PARAM NAME='SAMIStyle' VALUE=''>                 ");
	document.write (" <PARAM NAME='SAMILang' VALUE=''>                  ");
	document.write (" <PARAM NAME='SAMIFilename' VALUE=''>              ");
	document.write (" <PARAM NAME='captioningID' VALUE=''>              ");
	document.write (" <PARAM NAME='enableErrorDialogs' VALUE='0'>       ");
	document.write (" <PARAM NAME='_cx' VALUE='0'>                      ");
	document.write (" <PARAM NAME='_cy' VALUE='0'>                      ");
	document.write (" <PARAM NAME='ShowDisplay' value='true'>           ");
	document.write (" <PARAM NAME='ShowControls' value='true'>          ");
	document.write (" <PARAM NAME='ShowTracker' value='True'>           ");
	document.write('  <param name="animationatstart" value="1">');  //À©µµ¿ì ¹Ìµð¾î ·Î°í¸¦ º¸¿©ÁÙÁö¿¡ ´ëÇÑ ¿É¼Ç. ¹Ø¿¡ ±×¸² 1¹øºÎºÐ
	document.write (" </OBJECT> ");
}


var cur_songInfo = null				// ÇöÀç ÇÃ·¹ÀÌµÇ´Â Á¤º¸
var STOP_IDX = "N";					// Á¤Áö ¹öÆ° Àû¿ë.
var PAUSE_IDX = "N";				// ÀÏ½ÃÁ¤Áö ¼³Á¤

function play(playUrl,playTitle){
	if (PAUSE_IDX=="Y"){		// ÀÏ½ÃÁ¤Áö »óÅÂÀÏ °æ¿ì
		PAUSE_IDX = "N";
	}else{						// ÀÏ½ÃÁ¤Áö »óÅÂ°¡ ¾Æ´Ï¸é
		document.objMUSIC.URL = playUrl;
	}
		document.objMUSIC.AutoStart = 1;
		document.objMUSIC.controls.play();
		if(playTitle != null){
			document.getElementById("playTitle").innerHTML = playTitle;
		}
}

function stop(){
	STOP_IDX="Y";
	document.objMUSIC.URL = "";
	document.objMUSIC.controls.Stop();
}

function pause(){
	PAUSE_IDX = "Y";
	document.objMUSIC.controls.pause();


}

function mute_onoff() {
	if(document.all.m_onf.value == 'mute_on') {
		document.objMUSIC.settings.Volume = 0
		document.all.m_onf.value = 'mute_off';
		document.all.volumeX.src='/images/common/btnmediaoff.gif'
	} else {
		document.all.m_onf.value = 'mute_on';
		document.objMUSIC.settings.Volume = 50
		document.all.volcontrol.style.pixelLeft=390;
		document.all.volumeX.src='/images/common/btnmediaon.gif'
	}
}

var dragapproved=false
var vol_length=75;  //[vol_startpoint + vol_length] = [volcontrolÀÇ ¿ÞÂÊÁÂÇ¥]°¡ µÇ¾î¾ß ÇÑ´Ù
var vol_startpoint=0;//º¼·ý¹ÙÀÇ ¿ÞÂÊ ½ÃÀÛ ºÎºÐ

function initializedragie() {
	iex=event.clientX; //ÇöÀç ¸¶¿ì½ºÀÇ X ÁÂÇ¥
	iey=event.clientY; //ÇöÀç ¸¶¿ì½ºÀÇ Y ÁÂÇ¥
	tempx=volcontrol.style.pixelLeft;  // ÇöÀç º¼·ýÀÌ¹ÌÁöÀÇ left ÁÂÇ¥
	tempy=volcontrol.style.pixelTop; // ÇöÀç º¼·ýÀÌ¹ÌÁöÀÇ top ÁÂÇ¥
	dragapproved=true;
	document.onmousemove=drag_dropie;

	if (document.all)	{
		document.onmouseup=new Function('dragapproved=false');
	}
}

function drag_dropie() {
	if (dragapproved==true) {
		var mov = tempx+event.clientX-iex-vol_length;

		if (mov <= vol_startpoint  && mov > vol_startpoint-vol_length)	{
			document.all.volcontrol.style.pixelLeft = tempx+event.clientX-iex;
			per = ((mov-vol_startpoint)/vol_length);
			new_volume = parseInt(per*100 + 100);

			status = new_volume;
			if(document.all.m_onf.value=='mute_on'){
				document.objMUSIC.settings.Volume = new_volume;
			}

		}
		return false;
	}
}

function initPage(){
	document.objMUSIC.settings.Volume=50;
	vol_startpoint = document.all.volcontrol.offsetLeft
	document.all.volcontrol.style.pixelLeft =  vol_startpoint + 35
	document.all.volcontrol.style.pixelTop = document.all.volcontrol.offsetTop - 14
}


// ÇÁ¸°ÅÍ ¼³Á¤ ½ºÅ©¸³Æ®
// ÇÁ¸°Æ®ÇÒ ºÎºÐ ÁöÁ¤ <SPAN id=d1> </SPAN> ÈÄ ¹öÆ° onclick="printDiv('d1')"
function printDiv() {

	window.open("/html/common/print.html","_print","resizable=no, width=682, height=600, scrollbars=yes");
}
/** ÇÁ¸°ÅÍ ¼³Á¤ ½ºÅ©¸³Æ® ³¡*/



//div layer popup

function quick_helper(){
	$('helperDiv').style.display="block";
}

function quick_helper_close(){
	parent.$('helperDiv').style.display='none';
}

function AllTrim(a)
{
	for (; a.indexOf(" ") != -1 ;)
  {
  	a = a.replace(" ","")
  }
  return a;
}

function upFile(dir,mode,num){
	window.open('/eng/board/popup_file.asp?uploadDir='+dir+'&mode='+mode+'&num='+num,'upFile','width=400, height=250, top=150,left=150, scrollbars=1');
}

// wmode : window, opaque, transparent
var Flash = {
	menu: {
		file: '/eng/flash/mnu.swf?swfAct=' + W2.param.menu,
		id: 'menu',
		width: '320px',
		height: '600px',
		wmode: 'transparent'
	},
	eng_main: {
		file: '/eng/flash/main_mnu.swf',
		id: 'eng_main',
		width: '488px',
		height: '737px',
		wmode: 'transparent'
	},
	main_contents: {
		file: '/eng/flash/main_contents.swf',
		id: 'main_contents',
		width: '285px',
		height: '127px',
		wmode: 'transparent'
	},
	eng_footer: {
		file: '/eng/flash/footer.swf',
		id: 'eng_footer',
		width: '250px',
		height: '30px',
		wmode: 'transparent'
	},
	koreahistorytt: {
		file: '/flash/koreahistorytt.swf',
		id: 'koreahistorytt',
		width: '750',
		height: '560',
		wmode: 'transparent'
	}
};


//sky menu
function skyMenu() {
	var tt = window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop;
	tt = parseInt(tt, 10);
	var element = $('layout-quick');
	var eFrom = parseInt(element.style.top, 10) || 253;
	var eTo = tt + 253;
	var time = 100;
	if(eFrom != eTo) {
		var dist = Math.ceil(Math.abs(eTo - eFrom) / 15);
		if(eTo < eFrom) {
			dist = -dist;
		}
		element.style.top = (eFrom + dist) + 'px';
		time = 10;
	}
	setTimeout('skyMenu()', time);
}
	
	