/*
*	 /include/default.js
*	 »çÀÌÆ® ±âº» ½ºÅ©¸³Æ®
*	 @author echo<echo@commucity.co.kr>
*	 @since 2006-03-21
*/


//ÀÌ¹ÌÁö È¤Àº ¸µÅ© Æ÷Ä¿½º½Ã 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:SPAN");
	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 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;
	}
}

//input ¿À¹öÈ¿°ú(Å¬·¡½ºº¯°æ)
function set_input_tags(tag)
{
	var tags = document.getElementsByTagName(tag);
	for (var i=0; i < tags.length; i++){
		if (tags[i].className == "button" || tags[i].className == "button2"){
			tags[i].onfocus = function(){this.blur();}
			tags[i].onmouseover = function(){if(this.className != "button_r"){if(this.className != "button2_r"){this.className += "_over";}}}
			tags[i].onmouseout = function(){this.className = this.className.replace("_over", "");}
		}else if (tags[i].type == "checkbox" || tags[i].type == "radio"){
			tags[i].onfocus = function(){this.blur();}
		}
	}
}


//ÆäÀÌÁö·ÎµùÀÌ ³¡³­ÈÄ È£Ãâ(°ü¸®ÀÚ °Ô½ÃÆÇ¼³Á¤¿ë)
function onload(){
	set_visual();
}


function set_visual(){
	//¸®½ºÆ® ¸¶¿ì½º¿À¹ö(Å¬·¡½ºº¯°æ)
	var tags = document.getElementsByTagName("tr");
	for (var i=0; i < tags.length; i++){
		if (tags[i].className == "list"){
			tags[i].onmouseover = function(){this.className="list_over";}
			tags[i].onmouseout = function(){this.className="list";}
		}
	}
	set_input_tags("input");
	set_input_tags("textarea");
}


//ÀÌ¹ÌÁö ¹öÆ°
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;
}

/*
*	¼ýÀÚ ÀÚ¸®¼ö ÄÞ¸¶Âï±â
*	Reverse(). Add_Comma()
*/

function Reverse( Str ){
	var ret = "";

	for (var i = 0; i < Str.length; i++)
		ret = Str.substr(i, 1) + ret;

	return ret;
}

//ÄÞ¸¶Âï±â
function Add_Comma( TxtField ){
	var tmp = Reverse(TxtField.value);

	var Acc = "";

	if (tmp.indexOf(",") > -1) {
			return;
	}

	for(var i = 0; i < tmp.length; i = i + 3) {

	 Acc += tmp.substr(i, 3);
	 if (i + 3 < TxtField.value.length)
		Acc += ",";
	}

	TxtField.value = Reverse(Acc);
	return;
}



//·Î±×ÀÎ
function loginView(id)
{
	url = "/sub/member/login.asp?id=" + id;
	window.open(url, 'loginView','resizable=no, scrollbars=no, status=0, width=490, height=250, left=0, top=0');
}

//·Î±×¾Æ¿ô
function logout()
{
	location.href = "/sub/member/logout.asp";
}

//È¸¿ø°¡ÀÔ
function joinView(id)
{
	url = "/sub/member/join.asp?id=" + id;
	window.open(url, 'joinView','resizable=no, scrollbars=yes, status=0, width=520, height=600, left=0, top=0');
}

//È¸¿ø°¡ÀÔ
function joinView2(id)
{
	window.resizeTo(530,600);
	url = "/sub/member/join.asp?id=" + id;
	location.href=url;
}

//È¸¿øÁ¤º¸¼öÁ¤
function modify()
{
	url = "/sub/member/modify.asp";
	window.open(url, 'modify','resizable=no, scrollbars=yes, status=0, width=500, height=590, left=0, top=0');
}

//½Ç¸íÀÎÁõ
function certifyView(id)
{
	url = "/sub/member/certify.asp?id=" + id;
	window.open(url, 'certifyView','resizable=no, scrollbars=no, status=0, width=500, height=250, left=0, top=0');
}


//È¸¿øÁ¤º¸¼öÁ¤
function mmodify(id)
{
	url = "/sub/member/modify.asp?id=" + id;
	window.open(url, 'modifyView','resizable=no, scrollbars=yes, status=0, width=520, height=600, left=0, top=0');
}



function certificate03View(id)
{
	url = "/sub/natural/certificate03.asp?id=" + id;
	window.open(url, 'certificate03View','resizable=no, scrollbars=yes, status=0, width=520, height=696, left=0, top=0');
}

function certificate04View(id)
{
	url = "/sub/natural/certificate04.asp?id=" + id;
	window.open(url, 'certificate04View','resizable=no, scrollbars=no, status=0, width=500, height=696, left=0, top=0');
}

function certificate05View(id)
{
	url = "/sub/natural/certificate05.asp?id=" + id;
	window.open(url, 'certificate05View','resizable=no, scrollbars=no, status=0, width=500, height=696, left=0, top=0');
}

function certificate06View(id)
{
	url = "/sub/natural/certificate06.asp?id=" + id;
	window.open(url, 'certificate06View','resizable=no, scrollbars=no, status=0, width=500, height=696, left=0, top=0');
}

// ¡åÃß°¡ by ÀÌÈ¿Ãá¡å //
//»õÃ¢À¸·Î ÄÁÅÙÃ÷º¸±â
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//map
function view_jejumap()
{
	var iMyWidth;
	var iMyHeight;
	var mywidth=923;
	var myheight=604;

	iMyWidth = parseInt((screen.availWidth-mywidth)/2)
	iMyHeight = parseInt((screen.availHeight-myheight)/2)
	url="http://www.ilovejeju.co.kr/gojejumap_happy.asp"
	
	if (self.child!=null) {
		self.child.moveTo(iMyWidth,iMyHeight);	
		self.child.resizeTo(mywidth,myheight);			
	} else {
		var win_jejumap = window.open(url,"jejumap",'width='+ mywidth +',height='+myheight+',scrollbars=1,resizable=0,toolbar=0,left=' + iMyWidth + ',top=' + iMyHeight);
	}

	win_jejumap.focus();
}
