/*
	JAVASCRIPT DOCUMENT FOR KCL
	COPYRIGHT (C) 2010 SILKROAD COMMUNICATIONS. ALL RIGHTS RESERVED.
*/

/* INITIALIZING FUNCTIONS */
	
	window.onload = initialize;
	window.onresize = controlDivLocation;
	
	function initialize()
	{
		controlDivLocation();
		window.setTimeout("controlHashScroll()", 100);
		check_language();
		return;
	}
	
	function controlDivLocation()
	{
		var scrwh = getScreenWH();
		
		// MENU
		if(scrwh[0] <= 982)
		{
			document.getElementById("menu").style.left = "0px";
			document.getElementById("menu").style.marginLeft = "0px";
		}
		else
		{
			document.getElementById("menu").style.left = "50%";
			document.getElementById("menu").style.marginLeft = "-491px";
		}
		
		// FOOTER
		if(scrwh[1] <= 649)
		{
			if(navigator.appVersion.indexOf("MSIE 6") < 0)
			{
				document.getElementById("footer").style.top = "558px";
			}
		}
		else
		{
			if(navigator.appVersion.indexOf("MSIE 6") < 0)
			{
				document.getElementById("footer").style.top = (parseInt(scrwh[1])-91)+"px";
			}
		}
		
		return;
	}
	
	function controlHashScroll()
	{
		if(location.hash != "")
		{
			document.getElementById("container").scrollTop = document.getElementById("container").scrollTop - 150;
		}
		return;
	}
	
/* FORM CHECKING FUNCTIONS */
	
	function checkLoginForm(theForm)
	{
		if(theForm.mb_id.value == "")
		{
			alert("Please enter the admin ID.");
			theForm.mb_id.focus();
			return false;
		}
		
		if(theForm.mb_pass.value == "")
		{
			alert("Please enter the password.");
			theForm.mb_pass.focus();
			return false;
		}
		
		return true;
	}
	
	function checkWriteForm(theForm)
	{
		if(theForm.cat_num.value == "")
		{
			alert("Please select a category.");
			theForm.cat_num.focus();
			return false;
		}
		
		if(theForm.bd_subject.value == "")
		{
			alert("Please enter a title of the content.");
			theForm.bd_subject.focus();
			return false;
		}
		
		/*if(theForm.bd_content.value == "")
		{
			alert("Please enter the content.");
			theForm.bd_content.focus();
			return false;
		}*/
		
		return true;
	}
	
/* PAGE FUNCTIONS */
	
	function showIndexContent(theLanguage)
	{
		if(theLanguage == "kor")
		{
			document.getElementById("index_welcome_eng").style.display = "none";
			document.getElementById("index_welcome_kor").style.display = "block";
		}
		else if(theLanguage == "eng")
		{
			document.getElementById("index_welcome_kor").style.display = "none";
			document.getElementById("index_welcome_eng").style.display = "block";
		}
		
		return;
	}
	
	function showContentPanel(theLanguage)
	{
		if(theLanguage == "kor")
		{
			document.getElementById("content_panel_eng").style.display = "none";
			document.getElementById("content_panel_kor").style.display = "block";
		}
		else if(theLanguage == "eng")
		{
			document.getElementById("content_panel_kor").style.display = "none";
			document.getElementById("content_panel_eng").style.display = "block";
		}
		
		else if(theLanguage == "spa")
		{
			document.getElementById("content_panel_kor").style.display = "none";
			document.getElementById("content_panel_eng").style.display = "none";
		}
		
		return;
	}
	
/* UTILITY FUNCTIONS */
/*
	JAVASCRIPT FUNCTION FOR USING PNG-24 IMAGE IN IE6
	
	TO USE PNG-24 IMAGE IN <IMG> TAG, USE THIS FUNCTION WITH CLASS STYLE BELOW:
	.png24 {
		tmp:expression(setPng24(this));
	}
	
	TO USE PNG-24 IMAGE AS BACKGROUND, USE CLASS STYLE BELOW:
	.(TARGET CLASSNAME) {
		background:url(PNG24_PATH);
		_background:none;
		_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='PNG24_PATH',sizingMethod='crop');
	}
*/
	
	function setPng24(obj)
	{
		obj.width = obj.height = 1;
		obj.className = obj.className.replace(/\bpng24\b/i,'');
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+obj.src+"',sizingMethod='image');";
		obj.src='';
		return '';
	}
	
	function getScreenWH()
	{
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' )
		{
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		}
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
		{
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		}
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
		{
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		return [ myWidth, myHeight ];
	}
	
	function board_manager()
	{
		if(!chk_checkbox(document.getElementById("list_form"),'chk_nums[]',true)){
			alert('Choose at least one article.');
			return;
		}
		window_open('', "board_manager", 'scrollbars=no,width=355,height=200');
		document.getElementById("list_form").action = '../sr_board/board_manager.php';
		document.getElementById("list_form").target='board_manager';
		document.getElementById("list_form").submit();
	}
	
	function select_language(lang)
	{
		window.name = lang;
		showContentPanel(lang);
	}
	
	function check_language()
	{
		showContentPanel(window.name);
	}
