/*
*	 /include/default.js
*	 »çÀÌÆ® ±âº» ½ºÅ©¸³Æ®
*	 @author echo<echo@commucity.co.kr>
* @since 2006-03-21
*/

//Æ÷ÆÃÀü ±¸¸Å ½ºÅ©¸³Æ® ¿À·ù ¿¹¿ÜÃ³¸® ÀÓ½Ã ½ºÅ©¸³Æ®
function goSaleContent(id){
	alert("[" + id + "] À¯ÅëÄÜÅÙÃ÷ ±¸¸ÅÇÏ±â\nÆ÷ÆÃÀü±îÁö ÀÓ½Ã alert");
}

//¿ë¾î»çÀü °Ë»öÃ¢ ÆË¾÷
function dic(key, ch){
	if (ch = "CP6") url="../help/dictionary.asp";
	else url = "help/dictionary.asp";

	if (key) url = url + "?dckeyword=" + key
	window.open(url, 'dictionary','resizable=no, scrollbars=yes, status=0, width=517, height=621, top=0, left=0');
}

//ÀÌ¹ÌÁö È¤Àº ¸µÅ© Æ÷Ä¿½º½Ã blur();
document.onfocusin=function(){if(event.srcelement && (event.srcelement.tagname=="a"||event.srcelement.tagname=="img")) event.srcelement.blur();}

// ÆäÀÌÁö ·ÎµùÈÄ
function after_load()
{
	new Tooltip("A:IMG:TR:TD");
	new ImageButton();
}

//°Ë»ö Å°¿öµå Ã¼Å©
function chkKey(field)
{
	var hangul_eng_num  = /[°¡-ÆRa-zA-Z0-9]/;
	patten = eval(hangul_eng_num);

	if(!patten.test(field.value)){ 
		alert("°Ë»ö¾î´Â ¿µ¹® È¤Àº ÇÑ±Û ÇÑ±ÛÀÚ ÀÌ»ó ÀÔ·ÂÇÏ¼Å¾ß ÇÕ´Ï´Ù."); 
		field.focus();
		field.select();
		return false; 
	} 
}

//Å¾À¸·Î °¡±â
function goTop()
{
	window.scrollTo(0,0);
}

//¼­ºêÆäÀÌÁö ÀÌµ¿
function gotopage(cid,nid){
	if (nid == "CP6"){
		document.location.href = "../sub.asp?cid=" + cid;
	}else{
		document.location.href = "sub.asp?cid=" + cid;
	}
}

//5´Ü°èÆäÀÌÁö ÀÌµ¿
function goto5page(cid){
		document.location.href = "sub.asp?cid=" + cid;
}

//ÄÜÅÙÃ÷¸ôÆäÀÌÁö ÀÌµ¿
function gotocpage(cid,url){
	if (url){
		document.location.href = "contentsmall/contents.asp?cid=" + cid + url ;
	}else{
		document.location.href = "contentsmall/contents.asp?cid=" + cid;
	}
}

//ÄÜÅÙÃ÷¸ô ÀÌµ¿(ÄÜÅÙÃ÷¸ô ¸Þ´º)
function gotocmpage(cid,url){
	if (url){
		document.location.href = "contents.asp?cid=" + cid + url ;
	}else{
		document.location.href = "contents.asp?cid=" + cid;
	}
}

//HELP>»çÀÌÆ®¸Ê»óÀÇ ÀÌµ¿
function gotohpage(cid, site){
	if (site == "con"){
		document.location.href = "../contentsmall/contents.asp?cid=" + cid;
	}else{
		document.location.href = "../sub.asp?cid=" + cid;
	}
}

//ÄÜÅÙÃ÷ »ó¼¼º¸±â ÆäÀÌÁö
function gotodetail(cid, coid, urlquery, gotopage){
	document.location.href = "contents_detail.asp?cid=" + cid + "&id=" + coid + urlquery + "&gotopage=" + gotopage;
}

//°ü·Ã ÄÜÅÙÃ÷ »ó¼¼º¸±â ÆË¾÷
function detail(id){
	url = "contentsmall/detail.asp?id=" + id;
	window.open(url, 'detail','resizable=no, scrollbars=auto, status=0, width=663, height=475');
}


//ÄÜÅÙÃ÷ ÅëÇÕ°Ë»ö »ó¼¼º¸±â ÆË¾÷
function pDetail(id){
	url = "../../contentsmall/detail.asp?id=" + id;
	window.open(url, 'detail','resizable=no, scrollbars=auto, status=0, width=663, height=475');
}

//ÄÜÅÙÃ÷ »ó¼¼º¸±â ÀÌ¹ÌÁö Å©°Ôº¸±â ÆË¾÷
function zoom(coid, coname){
	url="zoom.asp?coid=" + coid + "&coName=" + coname;
	window.open(url, 'zoom','resizable=no, scrollbars=auto, status=0, width=500');
}

//ÄÜÅÙÃ÷ ¹Ì¸®º¸±â
function freeView(coid, coname, t){
	url="view.asp?coid=" + coid + "&coName=" + coname + "&styleFile=" + t;
	window.open(url, 'freeview','resizable=no, scrollbars=auto, status=0, width=500');
}

//Å¾¸Þ´º ·¹ÀÌ¾î show
function divVisible(id){
	document.getElementById(id).style.visibility='visible';
}

//Å¾¸Þ´º ·¹ÀÌ¾î hidden
function divHidden(){
	document.getElementById('m1').style.visibility='hidden';
	document.getElementById('m2').style.visibility='hidden';
	document.getElementById('m3').style.visibility='hidden';
	document.getElementById('m4').style.visibility='hidden';
	document.getElementById('m5').style.visibility='hidden';
}

//ÀÎ¹°¼Ò°³ ÆäÀÌÁö ÆË¾÷
function popPerson(person){
	window.open('/page/person/person_info.asp?person=' + person, 'person','resizable=no, scrollbars=auto, status=0, width= 850, height=630');
}

//ÇÃ·¡½¬ ¸¸È­ º¸±â ÆË¾÷
function goCartoon(id)
{	
	if (id != ""){
		if (id > 248)	url = 'cartoon.asp?cartoonID=b';
		else url = 'cartoon.asp?cartoonID=a';
	}else{
		url = 'contentsmall/cartoon.asp?cartoonID=a';
	}	
	window.open(url,'cartoon','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=700,height=650,top=0,left=0');
}

//ÇÃ·¡½¬ ¾Ö´Ï º¸±â ÆË¾÷
function goAni(id)
{	
	if (id != "")  url = 'ani.asp?aniID=a';
	else url = 'contentsmall/ani.asp?aniID=c';
	window.open(url,'ani','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=767,height=501,top=0,left=0');
}

//E book º¸±â ÆË¾÷
function goEbook(id)
{	
	if(id != "") url = "ebook.asp";
	else url = "contentsmall/ebook.asp";

	window.open(url,'ebook','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=960,height=700,top=0,left=0');
}
function goVr(){
	window.open('../page/img/03_defense/01_hangpa/VR/CP311000_2.html','cp311000','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=720,height=448');
}


//ÄÜÅÙÃ÷ ÅëÇÕ°Ë»ö
function search(f){
	//°ø¹éÃ³¸®
	String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,'') };
	var keys = f.tkeyword.value;
	var str = keys.trim();
	
	if (str != "")	{
		//°Ë»ö Å°¿öµå Ã¼Å©	
		var field = f.tkeyword;
		var hangul_eng_num  = /[°¡-ÆRa-zA-Z0-9!-}]/;
		patten = eval(hangul_eng_num);

		if(!patten.test(field.value)){ 
			alert("°Ë»ö¾î´Â ¿µ¹® È¤Àº ÇÑ±Û ÇÑ±ÛÀÚ ÀÌ»ó ÀÔ·ÂÇÏ¼Å¾ß ÇÕ´Ï´Ù."); 
			field.focus();
			return false; 
		}else{
			f.submit();
			return true;
		}
	}else{
		alert("ÃÖ¼Ò ¿µ¹®,ÇÑ±Û ÇÑ±ÛÀÚ ÀÌ»ó ÀÔ·ÂÇÏ¼Å¾ß µË´Ï´Ù.");
		f.tkeyword.focus();
		f.tkeyword.value="";
		return false;
	}
}

//ÄÜÅÙÃ÷ ÅëÇÕ°Ë»ö(°Ë»öÆäÀÌÁö)
function fsearch(f){

	String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,'') };
	var keys = f.ffkeyword.value;
	var str = keys.trim();

	if (str != "")	{
		//°Ë»ö Å°¿öµå Ã¼Å©	
		var field = f.ffkeyword;
		var hangul_eng_num  = /[°¡-ÆRa-zA-Z0-9!-}]/;
		patten = eval(hangul_eng_num);

		if(!patten.test(field.value)){ 
			alert("°Ë»ö¾î´Â ¿µ¹® È¤Àº ÇÑ±Û ÇÑ±ÛÀÚ ÀÌ»ó ÀÔ·ÂÇÏ¼Å¾ß ÇÕ´Ï´Ù."); 
			field.focus();
			return false; 
		}else{
			f.submit();
			return true;
		}
	}else{
		alert("ÃÖ¼Ò ¿µ¹®,ÇÑ±Û ÇÑ±ÛÀÚ ÀÌ»ó ÀÔ·ÂÇÏ¼Å¾ß µË´Ï´Ù.");
		f.ffkeyword.focus();
		f.ffkeyword.value="";
		return false;
	}
}

//ÄÜÅÙÃ÷ ºÐ·ù³» °Ë»ö(°Ë»öÆäÀÌÁö)
function csearch(f){

	String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,'') };
	var keys = f.keyword.value;
	var str = keys.trim();
	
	if (str != "")	{
		//°Ë»ö Å°¿öµå Ã¼Å©	
		var field = f.keyword;
		var hangul_eng_num  = /[°¡-ÆRa-zA-Z0-9!-}]/;
		patten = eval(hangul_eng_num);

		if(!patten.test(field.value)){ 
			alert("°Ë»ö¾î´Â ¿µ¹® È¤Àº ÇÑ±Û ÇÑ±ÛÀÚ ÀÌ»ó ÀÔ·ÂÇÏ¼Å¾ß ÇÕ´Ï´Ù."); 
			field.focus();
			return false; 
		}else{
			f.submit();
			return true;
		}
	}else{
		alert("ÃÖ¼Ò ¿µ¹®,ÇÑ±Û ÇÑ±ÛÀÚ ÀÌ»ó ÀÔ·ÂÇÏ¼Å¾ß µË´Ï´Ù.");
		f.keyword.focus();
		f.keyword.value="";
		return false;
	}
}

//ÄÜÅÙÃ÷ »ó¼¼°Ë»ö(°Ë»öÆäÀÌÁö->¸Þ´ºº° °Ë»öÃ¢À¸·Î)
function dsearch(ct){
	document.frmfSearch.action = "contents.asp?cid=" + ct;
	frmfSearch.submit();	
}

//ÀÌ¹ÌÁö ¹öÆ°
ImageButton = function(overSuffix)
{
	if (!document.body.getAttribute) return false;
	this.overSuffix = (overSuffix==null) ? '_r' : overSuffix;

	this.num = 0;
	this.srcList = new Array();
	this.oversrcList = new Array();
	
	this.selectedLayer = new Array();
	this.selectedImage = new Array();
	this.defaultImage = new Array();

	var imgtags = document.getElementsByTagName("img");
	for (var i=0; i<imgtags.length; i++)
	{
		if (imgtags[i].getAttribute("png")!=null) this.forPNG(imgtags[i]);
		if (imgtags[i].getAttribute("button")!=null) this.createButton(imgtags[i]);
	}
}
ImageButton.prototype.createButton = function(img)
{
	ImageButton.object = this;
	img.style.borderWidth = 0;
	img.setAttribute("button", this.num);
	this.srcList[this.num] = new Image;
	this.srcList[this.num].src = img.src;
	this.oversrcList[this.num] = new Image;

	var group = (img.getAttribute("group") != null) ? img.getAttribute("group") : 'default';
	img.group = group;

	if (img.getAttribute("oversrc")!=null) this.oversrcList[this.num].src = img.getAttribute("oversrc");
	else this.oversrcList[this.num].src = img.src.replace(RegExp("(\.[^\.]+)$"), this.overSuffix + "$1");
	
	if (img.getAttribute("selected")!=null) 
	{
		img.src = this.oversrcList[this.num].src;
		img.style.cursor = 'hand';
	}
	else img.style.cursor = 'hand';

	if (img.getAttribute("defaultbutton")!=null)
	{
		img.src = this.oversrcList[this.num].src;
		this.defaultImage[group] = img;
	}

	if (img.getAttribute("show")!=null)
	{
		var layer = document.getElementById(img.getAttribute("show"));
		//if (img.getAttribute("selected")==null) layer.style.display = 'none';
		if (img.getAttribute("selected")==null && img.getAttribute("defaultbutton")==null) layer.style.display = 'none';
		else this.selectedLayer[group] = layer;
	}

	if (document.all)
	{
		if (img.getAttribute("selected") == null)
		{
			// mouse over action
			if (img.onmouseover)
			{
				eval("img._onmouseover=function()" + img.onmouseover.toString().replace(/^[^)]+\)/,''));
				img.onmouseover = function()
				{ 
					this._onmouseover(); 
					ImageButton.object.over_action(this); 
				}
			}
			else
			{
				img.onmouseover = function(){ImageButton.object.over_action(this);}
			}
			// mouse out action
			if (img.getAttribute("noout") == null)
			{
				if (img.onmouseout)
				{
					eval("img._onmouseout=function()" + img.onmouseout.toString().replace(/^[^)]+\)/,''));
					img.onmouseout = function()
					{ 
						this._onmouseout(); 
						ImageButton.object.out_action(this); 
					} 
				}
				else
				{
					img.onmouseout = function(){ImageButton.object.out_action(this);}
				}
			}
		}

		if (img.getAttribute("url")!=null || img.getAttribute("java")!=null)
		{
			// mouse click action
			if (img.onclick)
			{
				eval("img._onclick=function()" + img.onclick.toString().replace(/^[^)]+\)/,''));
				img.onclick = function()
				{ 
					this._onclick(); 
					ImageButton.object.click_action(this); 
				} 
			}
			else
			{
				img.onclick = function(){ImageButton.object.click_action(this);}
			}
		}
	}
	else if (img.addEventListener)
	{
		if (img.getAttribute("selected") == null)
		{
			img.addEventListener('mouseover', function(){ImageButton.object.over_action(this)}, true); 
			if (img.getAttribute("noout") == null) img.addEventListener('mouseout',  function(){ImageButton.object.out_action (this)}, true);
		}
		if (img.getAttribute("url")!=null || img.getAttribute("java")!=null) img.addEventListener('click',  function(){ImageButton.object.click_action (this)}, true);
	}
	this.num++;
}

/*
* onMouseOver
*/

ImageButton.prototype.over_action = function(img)
{
	if (this.defaultImage[img.group] != null)
	{
		if (this.defaultImage[img.group] != img) this.defaultImage[img.group].src = this.srcList[this.defaultImage[img.group].getAttribute("button")].src;
		this.defaultImage[img.group] = null;
	}

	img.src = this.oversrcList[img.getAttribute("button")].src;
	if (img.getAttribute("show"))
	{
		var layer = document.getElementById(img.getAttribute("show"));
		if (layer==this.selectedLayer[img.group]) return;
		if (this.selectedLayer[img.group]!=null) this.selectedLayer[img.group].style.display = 'none';
		layer.style.display = 'inline';
		this.selectedLayer[img.group] = layer;
	}

	if (img != this.selectedImage[img.group])
	{
		if (this.selectedImage[img.group] != null) this.out_action(this.selectedImage[img.group]);
		this.selectedImage[img.group] = img;
	}
}
/*
* onMouseOut
*/
ImageButton.prototype.out_action = function(img)
{
	img.src = this.srcList[img.getAttribute("button")].src;
}



//¼ýÀÚ¸¸
function onlyNumber()
{
   if((event.keyCode<48)||(event.keyCode>57))
      event.returnValue=false;
}