/***********************************¹ü¿ëÇÔ¼ö**************************************/

//viewportGPS°´Ã¼ - viewport»óÀÇ ÁÂÇ¥¸¦ ºÒ·¯¿Â´Ù.
viewportGPS = function(){
	if (window.innerWidth)
	{
		this.innerWidth = window.innerWidth;
		this.innerHeight = window.innerHeight;
		this.leftScroll = window.pageXOffset;
		this.topScroll = window.pageYOffset;			
	}else if (document.documentElement && document.documentElement.clientWidth)
	{
		this.innerWidth = document.documentElement.clientWidth;
		this.innerHeight = document.documentElement.clientHeight;
		this.leftScroll = document.documentElement.scrollLeft;
		this.topScroll = document.documentElement.scrollTop;
	}else if(document.body.clientWidth)
	{
		this.innerWidth = document.body.clientWidth;
		this.innerHeight = document.body.clientHeight;
		this.leftScroll = document.body.scrollLeft;
		this.topScroll = document.body.scrollTop;
	}
}

//printAllCharCode(int_startidx, int_endidx) - ¸ðµç ¹®ÀÚ¿­ÀÇ charCode°ªÀ» Ãâ·ÂÇÑ´Ù. (¹üÀ§¸¦ ÀüÃ¼·Î ÇÏ¸é ¹ö¹÷´í´Ù;;)
function printAllCharCode(int_startidx, int_srchqty)
{
	startidx = 1;
	endidx = 65536;
	
	if (int_startidx && (!isNaN(int_startidx)))
		startidx = int_startidx;
	if (int_srchqty && (!isNaN(int_srchqty)))
		endidx = int_startidx + int_srchqty;
	
	document.write("<table border='0'>");
	document.write("<tr><td>charCode</td><td>character</td><td>charCode</td><td>character</td><td>charCode</td><td>character</td><td>charCode</td><td>character</td><td>charCode</td><td>character</td><td>charCode</td><td>character</td><td>charCode</td><td>character</td><td>charCode</td><td>character</td><td>charCode</td><td>character</td><td>charCode</td><td>character</td></tr>");
	for(i=startidx; i<endidx; i++)
	{
		if(i%10==1)
			document.write("<tr>");
			
		document.write("<td style='border:1px;' align='right'>"+i+"</td><td style='border:1px;' align='left'>"+String.fromCharCode(i)+"</td>");
		
		if(i%10==0)
			document.write("</tr>")
	}
	if (i%10==1)
		document.write("</tr>")
	document.write("</table>")
}


/***********************************************************************************/





//************************************** layerSharkSucker *************************************//
// - ÁöÁ¤ÇÑ id°ªÀ» °¡Áö´Â ·¹ÀÌ¾î¸¦ ½ºÅ©·ÑÇÒ¶§¸¶´Ù Ç×»ó °°Àº À§Ä¡·Î ÀÌµ¿ÇÏ°Ô ÇÑ´Ù.
//	layerSharkSucker([str]ÀÌµ¿½ÃÅ³ ·¹ÀÌ¾î id, [int]¸ñÇ¥ÇØ¾ßÇÒ xÁÂÇ¥, [int]¸ñÇ¥ÇØ¾ßÇÒ yÁÂÇ¥, [int]ÀÌµ¿¼Óµµ);

targetObj = function(targetId){
	if (document.getElementById(targetId))
		this.obj = document.getElementById(targetId);
	else
		document.write("<p style='color:red'>ÇÒ´çÇÑ ID°ªÀ» °¡Áö´Â ¿ÀºêÁ§Æ®¸¦ Ã£À» ¼ö ¾ø½À´Ï´Ù. [targetObj]</p>");
}

targetObj.prototype.moveDown = function(int_y){
		if(this.obj && this.obj.style.top)
			return this.obj.style.top = parseInt(this.obj.style.top) + int_y;
		else
			return document.write("<p style='color:red'>style-top¼Ó¼ºÀ» °¡ÁöÁö ¾Ê´Â ¿ÀºêÁ§Æ®ÀÌ°Å³ª ÂüÁ¶°¡ Àß¸øµÇ¾ú½À´Ï´Ù. [targetObj.prototype.moveDown()]</p>");
}
targetObj.prototype.moveUp = function(int_y){
		if(this.obj && this.obj.style.top)
			return this.obj.style.top = parseInt(this.obj.style.top) - int_y;
		else
			return document.write("<p style='color:red'>style-top¼Ó¼ºÀ» °¡ÁöÁö ¾Ê´Â ¿ÀºêÁ§Æ®ÀÌ°Å³ª ÂüÁ¶°¡ Àß¸øµÇ¾ú½À´Ï´Ù. [targetObj.prototype.moveDown()]</p>");
}
targetObj.prototype.moveRight = function(int_x){
		if(this.obj && this.obj.style.left)
			return this.obj.style.left = parseInt(this.obj.style.left) + int_x;
		else
			return document.write("<p style='color:red'>style-top¼Ó¼ºÀ» °¡ÁöÁö ¾Ê´Â ¿ÀºêÁ§Æ®ÀÌ°Å³ª ÂüÁ¶°¡ Àß¸øµÇ¾ú½À´Ï´Ù. [targetObj.prototype.moveDown()]</p>");
}
targetObj.prototype.moveLeft = function(int_x){
		if(this.obj && this.obj.style.left)
			return this.obj.style.left = parseInt(this.obj.style.left) - int_x;
		else
			return document.write("<p style='color:red'>style-top¼Ó¼ºÀ» °¡ÁöÁö ¾Ê´Â ¿ÀºêÁ§Æ®ÀÌ°Å³ª ÂüÁ¶°¡ Àß¸øµÇ¾ú½À´Ï´Ù. [targetObj.prototype.moveDown()]</p>");
}

function slideObj(axis, int_x, int_y, speed, targetId)
{
	if (axis == "down"){
		movinglen = (GPS.topScroll + int_y - parseInt(moveobj.obj.style.top) ) / 10;
		moveobj.moveDown(movinglen);
		recallstr = "fallowScreen('"+targetId+"', "+int_x+", "+int_y+", "+speed+")";
		vertical = setTimeout(recallstr, speed);
	} else 	if (axis == "up"){
		movinglen = (parseInt(moveobj.obj.style.top) - GPS.topScroll - int_y ) / 10;
		moveobj.moveUp(movinglen);
		recallstr = "fallowScreen('"+targetId+"', "+int_x+", "+int_y+", "+speed+")";
		vertical = setTimeout(recallstr, speed);
	}else if (axis == "right"){
		movinglen = (GPS.leftScroll + int_x - parseInt(moveobj.obj.style.left) ) / 10;
		moveobj.moveRight(movinglen);
		recallstr = "fallowScreen('"+targetId+"', "+int_x+", "+int_y+", "+speed+")";
		horizon = setTimeout(recallstr, speed);	
	}else if (axis == "left"){
		movinglen = (parseInt(moveobj.obj.style.left) - GPS.leftScroll - int_x ) / 10;
		moveobj.moveLeft(movinglen);
		recallstr = "fallowScreen('"+targetId+"', "+int_x+", "+int_y+", "+speed+")";
		horizon = setTimeout(recallstr, speed);
	}
}

function fallowScreen(targetId,int_x, int_y,movespeed)
{
	GPS = new viewportGPS();
	moveobj = new targetObj(targetId);

	nowtop = moveobj.obj.style.top;
	nowleft = moveobj.obj.style.left;
	nowtop = parseInt(nowtop);
	nowleft = parseInt(nowleft);

	if(nowtop < GPS.topScroll + int_y)
		slideObj("down", int_x, int_y,movespeed, targetId);
	else if(nowtop > GPS.topScroll+int_y)
		slideObj("up", int_x, int_y,movespeed, targetId);
	else if(nowleft < GPS.leftScroll + int_x)
		slideObj("right", int_x, int_y,movespeed, targetId);
	else if(nowleft > GPS.leftScroll + int_x)
		slideObj("left", int_x, int_y,movespeed, targetId);
}

function layerSharkSucker(targetId, int_x, int_y, movespeed)
{
	vertical = {};
	horizon = {};
	
	window.onscroll = function(){
		window.clearTimeout(vertical);
		window.clearTimeout(horizon);	
		fallowScreen(targetId, int_x, int_y, movespeed);
	}
	
}
/*********************************************************************************************/


/****************************************** layerRevolver *********************************************/
// ÁöÁ¤ÇÑ ¾ÆÀÌµð °ªÀ» °¡Áö´Â ·¹ÀÌ¾îµéÀÌ ÀÏÁ¤ ½Ã°£°£°ÝÀ¸·Î µ¹¾Æ°¡¸ç Ãâ·ÂµÈ´Ù.
//  layerRevolver([str_array]·Ñ¸µ¿¡ Æ÷ÇÔ½ÃÅ³ ·¹ÀÌ¾î id°ªÀ» ','·Î ±¸ºÐ, [int]È¸Àü°£°Ý(¹Ð¸®ÃÊ));

function showObject(str_objid)
{
	showobj = document.getElementById(str_objid);
	if (showobj.style)
		showobj.style.display = "block";
	else
		alert("style¼Ó¼ºÀ» °¡ÁöÁö ¾Ê´Â °³Ã¼¸¦ ÁöÁ¤ÇÏ¿´½À´Ï´Ù. id:"+objid);
}

function hideObject(str_objid)
{
	hideobj = document.getElementById(str_objid);
	if (hideobj.style)
		hideobj.style.display = "none";
	else
		alert("style¼Ó¼ºÀ» °¡ÁöÁö ¾Ê´Â °³Ã¼¸¦ ÁöÁ¤ÇÏ¿´½À´Ï´Ù. id:"+objid);
}

function stopRevolver()
{
	if (revolving)
		window.clearTimeout(revolving);
}

function layerRevolving(str_ids, int_swaptime)
{
	for(i=0; i<str_ids.length; i++)
	{
		if (str_ids.charAt(i) == " ")
		{
			document.write("<p style='color:#FF0000;'>ÀÔ·ÂÇÑ id°ª¿¡ °ø¹é¹®ÀÚ°¡ ÀÖ½À´Ï´Ù.</p>");
			return;
		}
	}
	revolveObj = str_ids.split(",");
	totalObj = revolveObj.length;
	
	for(i=0; i<revolveObj.length; i++)
	{
		hideObject(revolveObj[i]);
	}
	showObject(revolveObj[revolveNum]);
	if(revolveNum == totalObj-1)
		revolveNum = 0;
	else
		revolveNum++;

	revolving = setTimeout("layerRevolving('"+str_ids+"', "+int_swaptime+")", int_swaptime);
}

function layerRevolver(str_ids, int_swaptime)
{
	revolveNum = 0;
	layerRevolving(str_ids, int_swaptime);
}

/*********************************************************************************************/


/************************************************* layerMenuSlider *******************************************************/
// ÁöÁ¤ÇÑ id°ªÀ» °¡Áö´Â ·¹ÀÌ¾îµéÀÌ Æ²ÀÌ µÇ´Â ·¹ÀÌ¾î ¾È¿¡¼­ È¸ÀüÇÑ´Ù.
// layerMenuSlider([str]Æ²ÀÌ µÉ ·¹ÀÌ¾î id, [str_array] È¸Àü½ÃÅ³ ·¹ÀÌ¾î id°ª ','·Î ±¸ºÐÇÏ¿© ³ª¿­, [str]È¸Àü¹æÇâ, [int]ÀÌµ¿¼Óµµ)

function stopMenuSlider()
{
	window.clearTimeout(runSlide);
}

function runMenuSlider(str_axis, int_speed)
{
	if (str_axis == "H")
	{
		var totalWidth = 0;

		for(i=0; i<totalObj; i++)
		{
			totalWidth += parseInt(document.getElementById(movers[i]).style.width);
		}
		for(i=0; i<totalObj; i++)
		{
			moveObj = document.getElementById(movers[i]);
			moveObj.style.left = parseInt(moveObj.style.left) - 10;
			
			if(parseInt(moveObj.style.left) < parseInt(siteobj.style.left) - parseInt(moveObj.style.width) )
			{
				moveObj.style.left = parseInt(moveObj.style.left) + totalWidth;
			}
		}
	}else if (str_axis == "V")
	{
		var totalHeight = 0;
		for(i=0; i<totalObj; i++)
		{
			totalWidth += parseInt(document.getElementById(movers[i]).style.height);
		}
	
		for(i=0; i<totalobj; i++)
		{
			moveObj = document.getElementById(movers[i]);
			
			moveObj.style.top = parseInt(moveObj.style.top) - 1;
			
			if(moveObj.style.top < parseInt(siteobj.style.top) - parseInt(moveObj.style.height) )
				moveObj.style.top = parseInt(moveobj.style.top) + totalHeight;
		}	
	}else
	{
		document.write("<p style='color:#FF0000;'>ÀÌµ¿¹æÇâ°ªÀÌ Àß¸øµÇ¾ú½À´Ï´Ù. - V:¼¼·ÎÀÌµ¿, H:°¡·ÎÀÌµ¿ </p>");
		return;
	}
	
	runSlide = window.setTimeout("runMenuSlider('"+str_axis+"', "+int_speed+")", int_speed);
}

function layerMenuSlider(str_site, str_movers, str_axis, int_speed)
{
	siteobj = document.getElementById(str_site);
	runSlide = {};
	
	for(i=0; i<str_movers.length; i++)
	{
		if (str_movers.charAt(i) == " ")
		{
			document.write("<p style='color:#FF0000;'>ÀÔ·ÂÇÑ id°ª¿¡ °ø¹é¹®ÀÚ°¡ ÀÖ½À´Ï´Ù.</p>");
			return;
		}
	}
		
	movers = str_movers.split(",");
	totalObj = movers.length;
	for(i=0; i<totalObj;i++)
	{
		document.getElementById(movers[i]).onmouseover = function(){
			stopMenuSlider();
		}
		document.getElementById(movers[i]).onmouseout = function(){
			runMenuSlider(str_axis, int_speed);
		}
	}
	
	runMenuSlider(str_axis, int_speed);
}
/***************************************************************************************************************************/








/******************************************************* function list ***********************************************************/
//	layerSharkSucker([str]ÀÌµ¿½ÃÅ³ ·¹ÀÌ¾î id, [int]¸ñÇ¥ÇØ¾ßÇÒ xÁÂÇ¥, [int]¸ñÇ¥ÇØ¾ßÇÒ yÁÂÇ¥, [int]ÀÌµ¿¼Óµµ);
//  layerRevolver([str_array]·Ñ¸µ¿¡ Æ÷ÇÔ½ÃÅ³ ·¹ÀÌ¾î id°ªÀ» ','·Î ±¸ºÐ °ø¹é¹®ÀÚ ±ÝÁö, [int]È¸Àü°£°Ý(¹Ð¸®ÃÊ));
// layerMenuSlider([str]Æ²ÀÌ µÉ ·¹ÀÌ¾î id, [str_array] È¸Àü½ÃÅ³ ·¹ÀÌ¾î id°ª ','·Î ±¸ºÐÇÏ¿© ³ª¿­, [str]È¸Àü¹æÇâ, [int]ÀÌµ¿¼Óµµ);
/********************************************************************************************************************************/