/*========================================
// js_layer_move.js
// ·¹ÀÌ¾î(¶Ç´Â ´Ù¸¥ °´Ã¼)°¡ ¸¶¿ì½º·Î ÀÌµ¿ÇÒ ¼ö ÀÖµµ·Ï ÇØÁØ´Ù.
//
// ex> js_layer_move(document.getElementById('test1'),document.getElementById('test2'));
// ex> js_layer_move(document.getElementById('test2'));
// ex> js_layer_move([ÀÌµ¿À» Á¦¾îÇÒ ´ë»ó], [ÀÌµ¿ÇÒ ´ë»ó]);
// [ÀÌµ¿ÇÒ ´ë»ó] : Á¤ÇØÁöÁö ¾ÊÀ¸¸é [ÀÌµ¿À» Á¦¾îÇÒ ´ë»ó]ÀÌ [ÀÌµ¿ÇÒ ´ë»ó] ´ë»óÀ¸·Î Á¤ÇØÁø´Ù.
// Àú ÄÚµå¸¦ ½ÇÇà ÈÄ ¸¶¿ì½º·Î ÀÌµ¿½ÃÅ³ ¼ö ÀÖ°Ô µÈ´Ù.
//
// ÁÖÀÇ : ÇØ´ç °³Ã¼ÀÇ onmousedown,onmouseup,onmousemove ÀÌº¥Æ®¿¡ µî·ÏµÇ¾îÀÖ´ø ÇÔ¼ö´Â »ç¿ëÇÒ ¼ö ¾ø°ÔµÈ´Ù.
// ÀÌº¥Æ®¸¦ Áßº¹µÇ°Ô ÇÒ ¼ö ÀÖÁö¸¸, ´ë»óÀ» ÀÌµ¿ÇÏ´Âµ¥ ¹æÇØ°¡ µÇ±â ¶§¹®¿¡ ±×³É Á¦°ÅÇÔ.
//
¿¬°è
js_event_anti.js ¿¡¼­ js_event_anti_stop_event() ¸¦ »ç¿ëÇÑ´Ù.

// mins01,mins,°ø´ë¿©ÀÚ
// MSN,NateOn : mins01(at)lycos.co.kr
// 2007-01-30
// 2007-03-31 : ÀÌµ¿´ë»ó µû·Î ÁöÁ¤ÇÒ ¼ö ÀÖµµ·Ï ¹Ù²ñ
// "°ø´ë¿©ÀÚ´Â ¿¹»Ú´Ù."¸¦ ³ªÅ¸³»¾ß¸¸ ¾µ ¼ö ÀÖ½À´Ï´Ù.
//========================================*/
//ÇØ´ç °³Ã¼°¡ ÀÌµ¿ÀÌ °¡´ÉÇÏµµ·Ï ÀÚµ¿ ¼³Á¤µîÀ» ¹Ù²ãÁØ´Ù.
function js_layer_move(this_s1,this_s2) {
	//this_s1 : ÀÌº¥Æ®¸¦ ¹ÞÀ» ´ë»ó
	//this_s2 : ÀÌµ¿À» ÇÒ ´ë»ó : ¾øÀ¸¸é this_s1 °ú °°°Ô Ã³¸®
	// this_s1 ÀÌ ÀÌµ¿Ã³¸®µÇ¸é this_s2 °¡ ÀÌµ¿ÇÏ´Â Çü½Ä
	if (!this_s2) {
		this_s2=this_s1;
	}

//	this_s1.style.position='relative';
	this_s2.style.position='absolute';
	//this_s1.style.zIndex='9000';
	//this_s2.style.zIndex='9000';
	try {
		//this_s2.style.left='0px';
		//this_s2.style.top='0px';
	} catch(e) {}
	this_s1.style.cursor = 'move';
	this_s1.onmousedown= function (event) {
		js_layer_move_down(this_s2,event);
	}
	this_s1.onmouseup= js_layer_move_up;
	this_s1.onmouseout= js_layer_move_up;
	this_s1.onmousemove= js_layer_move_move;
}
///------------ ¸¶¿ì½º·Î °´Ã¼ µå·¡±×
var bdown = false;
var x, y;
var js_layer_move_element = null;//ÀÌµ¿µÇ´Â ´ë»óÁöÁ¤
//------------------------------------- ¼ýÀÚ NaNÃ¼Ä¿
function changeInt(num){ //¼öÆò¼± ´Ô Ãß°¡
	var temp = parseInt(num);
	if (isNaN(temp)){
		temp = 0;
	}
	return temp;
} 
//------------------------------------ IE/FF °ø¿ëÃ³¸®
function js_layer_move_down(this_s2,e) {
	var evt = e || window.event;
	js_layer_stop_bubble(evt);
	//js_layer_move_element = evt.target || evt.srcElement ;
	var this_s1 = evt.target || evt.srcElement;
	js_layer_move_element = this_s2;
	if (this_s1.style.cursor == 'move') {
		bdown = true;
		x = evt.clientX;
		y = evt.clientY;
	}
}
function js_layer_move_up() {
	bdown = false;
}
function js_layer_move_move(e) {
	if (bdown) {
		var evt = e || window.event;
		js_layer_stop_bubble(evt);
		var distX = changeInt(evt.clientX) - x;
		var distY = changeInt(evt.clientY) - y;
		js_layer_move_element.style.left = (changeInt(js_layer_move_element.style.left) + distX) + 'px';
		js_layer_move_element.style.top = (changeInt(js_layer_move_element.style.top) + distY) + 'px';
		x = changeInt(evt.clientX);
		y = changeInt(evt.clientY);
		return false;
	}
}
function js_layer_stop_bubble(evt){
	if (typeof(js_event_anti_stop_event) != 'function') {
		return;
	}
	try {
		js_event_anti_stop_event(evt);
	} catch (e) {
	}
}