
/*########################### href °æ·Î ###########################
	'ÇÔ¼ö¸í :	fnRef
	'³»¿ë   :	°æ·Î·Î º¸³»ÁØ´Ù.
	'ÆÄ¶ó¹ÌÅÍ :
	'str - ¸µÅ©µÉ °æ·Î
	'AUTH : ¿¬¾çÈì
	'ÀÛ¾÷ÀÏ : 2008.11.14
*/

function fnRef(str){
	location.href = str;
}

//########################### href °æ·Î ###########################


/*########################### href °æ·Î ###########################
	'ÇÔ¼ö¸í :	fnHome
	'³»¿ë   :	°æ·Î·Î º¸³»ÁØ´Ù.
	'ÆÄ¶ó¹ÌÅÍ :
	'str - ¸µÅ©µÉ °æ·Î
	'AUTH : ¿¬¾çÈì
	'ÀÛ¾÷ÀÏ : 2008.11.14
*/

function fnHome(){
	location.href = "/";
}

//########################### href °æ·Î ###########################

/*########################### À©µµ¿ìÃ¢ ¿ÀÇÂ ###########################
	'ÇÔ¼ö¸í :	fnRef
	'³»¿ë   :	°æ·Î·Î º¸³»ÁØ´Ù.
	'ÆÄ¶ó¹ÌÅÍ :
	'str - ¸µÅ©µÉ °æ·Î
	'AUTH : ¿¬¾çÈì
	'ÀÛ¾÷ÀÏ : 2008.11.14
*/

function fnWinOpen(width,height,left,top,name,url,scroll,obj){
	if (left!=''){
		LeftPosition	= left;
	}else{
		LeftPosition	= (screen.width)?(screen.width-width)/2:100;
	}

	if (top!=''){
		TopPosition		= top;
	}else{

		TopPosition		= (screen.height)?(screen.height-height)/2:100;
	}

	winprops		= 'width='+width+', height='+height+', top='+TopPosition+', left='+LeftPosition+' scrollbars='+scroll+', toolbar=no';
	if(obj){
		window.open('',name, winprops);
		obj.target		= name;
		obj.action		= url;
		obj.submit();
		return;
	}else{
		window.open(url,name, winprops);
	}
}

/*########################### ,°¡ ÀÖ´Â ±Ý¾× ¸®ÅÏ ###########################
	'ÇÔ¼ö¸í :	fnMoney
	'³»¿ë   :	,°¡ ÀÖ´Â ±Ý¾× ¸®ÅÏ
	'ÆÄ¶ó¹ÌÅÍ :
	'strNum - ±Ý¾×
	'AUTH : ¿¬¾çÈì
	'ÀÛ¾÷ÀÏ : 2008.11.22
*/

function fnMoney(strNum){
	if(event.keyCode==37||event.keyCode==39) return;

	var strNum = '' + strNum;
	var result = '';

	for(var i=0; i<strNum.length; i++) {
		if(i%3==0 && i!=0) result = ',' + result;
		result = strNum.charAt(strNum.length-(i+1)) + result;
	}

	return result;
}
function fnAllMoney(strNum){/////////////´ÜÀ§ È¯»êÀ» À§ÇØ
	if(event.keyCode==37||event.keyCode==39) return;

	var strNum = '' + strNum;
	var result = '';

	for(var i=0; i<strNum.length; i++) {
		if(i%3==0 && i!=0) result = ',' + result;
		result = strNum.charAt(strNum.length-(i+1)) + result;
	}

	return result;
}


//########################## ,°¡ ÀÖ´Â ±Ý¾× ¸®ÅÏ ###########################

/*########################### ½ÂÀÎÃ¢ ###########################
	'ÇÔ¼ö¸í :	fnConfirm
	'³»¿ë   :	½ÂÀÎÃ¢
	'ÆÄ¶ó¹ÌÅÍ :
	'msg - ¸Þ¼¼Áö
	'AUTH : ¿¬¾çÈì
	'ÀÛ¾÷ÀÏ : 2008.11.22
*/
function fnConfirm(msg){
	ans = confirm('   \n\n    '+msg+'         \n\n');
	if(!ans) return 1;
}
//########################### ½ÂÀÎÃ¢ ###########################



/*########################### Æ÷Ä¿½º ÀÌµ¿ ###########################
	'ÇÔ¼ö¸í :	fnNextFocus
	'³»¿ë   :	Æ÷Ä¿½º ÀÌµ¿
	'ÆÄ¶ó¹ÌÅÍ :
	'obj1 - ¼±ÅÃµÈ ¿ÀºêÁ§Æ®
	'obj2 - ÀÌµ¿ÇÒ ¿ÀºêÁ§Æ®
	'len - ±æÀÌ Ã¼Å©ÈÄ ÀÌµ¿
	'AUTH : ¿¬¾çÈì
	'ÀÛ¾÷ÀÏ : 2008.11.22
*/
function fnNextFocus(obj1,obj2,len){
	if (obj1.value.length==len){
		obj2.focus();
	}
}
//########################### Æ÷Ä¿½º ÀÌµ¿ ###########################


/*########################### ½ºÄÉÁì ÇÁ¸°Æ® ###########################
	'ÇÔ¼ö¸í :	fnSchedulePrint
	'³»¿ë   :	½ºÄÉÁì ÇÁ¸°Æ®
	'ÆÄ¶ó¹ÌÅÍ :
	'obj - ÇÁ¸°Æ®È­¸é
	'AUTH : ¿¬¾çÈì
	'ÀÛ¾÷ÀÏ : 2008.11.22
*/
function fnSchedulePrint(obj){
	var url = "/tour/common/pop_schedule_print.asp";
	fnWinOpen("690","600","","","schedule_print",url,"yes",obj);
}
//########################### ½ºÄÉÁì ÇÁ¸°Æ® ###########################

//########################### À©µµ¿ìÃ¢ ¿ÀÇÂ ###########################

// ÀÌ¹ÌÁö Å¬¸¯ ½Ã Á¡¼± ¾ø¾Ö±â
// 2008-11-14 Çã±¤¸í
function bluring(){
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocus=bluring;


function inicisPopup(){
	window.open('http://www.clubrichtour.co.kr/common/pop_card.asp', 'card_popup', 'width=333, height=430');
}



// ÇÃ·¡½Ã ¸µÅ©
// 2008-11-22 Çã±¤¸í
// »ç¿ë¹æ¹ý
// <script>flash("°¡·ÎÅ©±â","¼¼·ÎÅ©±â","url")</script>

function paran_flash(width,height,flash_name) {
	//alert("asdf");

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'">');
	document.write('<param name="movie" value="'+flash_name+'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');  //Åõ¸íÇÃ·¡½¬°¡ ¾Æ´Ò°æ¿ì ÀÌ ¶óÀÎÀ» »èÁ¦
	//document.write('<param name="bgcolor" value="ffffff" />');
	document.write("<param name='allowScriptAccess' value='always' />");
	document.write('<embed src="'+flash_name+'" quality="high" wmode="transparent" bgcolor="ffffff" width="'+width+'" height="'+height+'"  type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>')

}

function paran_flash_notran(width,height,flash_name) {
	//alert("asdf");

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'">');
	document.write('<param name="movie" value="'+flash_name+'" />');
	document.write('<param name="quality" value="high" />');
	//document.write('<param name="wmode" value="transparent" />');  //Åõ¸íÇÃ·¡½¬°¡ ¾Æ´Ò°æ¿ì ÀÌ ¶óÀÎÀ» »èÁ¦
	//document.write('<param name="bgcolor" value="ffffff" />');
	document.write("<param name='allowScriptAccess' value='always' />");
	document.write('<embed src="'+flash_name+'" quality="high" wmode="transparent" bgcolor="ffffff" width="'+width+'" height="'+height+'"  type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>')

}


// ±¹³»¼÷¹Ú : ±âÈ¹/ÀÌº¥Æ®Àü °øÅë »ç¿ëÇÏ±â
// 2008-12-17 Çã±¤¸í
// À¯ÀÇ»çÇ×
// ½ºÅ©¸³Æ® º¯°æ ½Ã ÆÄ¶õ¿¡µµ º¯°æÇØ¾ß ÇÔ
function goDomHotel(hn){
	//hn : È£ÅÚÄÚµå

	//hostname = window.location.hostname;
	//href = window.location.href;
	//host = window.location.host;
	//port = window.location.port;
	//pathname = window.location.pathname;
	//search = window.location.search;
	//protocoal = window.location.protocol;

	//alert(hostname);
	//alert(href);
	//alert(host);
	//alert(port);
	//alert(pathname);
	//alert(search);
	//alert(protocoal);

	location.href='http://hotel.clubrichtour.co.kr/agent/reservation/main?aid=clubrich&amp;hcode='+hn;

}



//-- Ajax
var ajax_request;
function createRequest()
{
	try {
		ajax_request = new XMLHttpRequest();
	} catch (trymicrosoft) {
		try {
			ajax_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
			try {
				ajax_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
				ajax_request = false;
			}
		}
	}
}


//-- Swap Image
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//-- ÄíÅ°
function setCookie( name, value, expiredays )
{ var todayDate = new Date();
  todayDate.setDate( todayDate.getDate() + expiredays );
  document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
function getCookie( name )
{
	var nameOfCookie = name + "=";
	var x = 0;
	while( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie )
		{	if( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}


//-- ¼ýÀÚ¸¸ ÀÔ·Â¹Þ±â
function OnlyNumber()
{ if( (event.keyCode<48) || (event.keyCode>57) )
  { event.returnValue = false; }
}

//-- ¶óµð¿À ¹öÆ°ÀÇ Ã¼Å©µÈ index ±¸ÇÏ±â
function get_checked_index( obj )
{
	if( obj.length )
	{	for( var i=0; i<obj.length; i++ )
		{ if( obj[i].checked == true )
			{ return i; }
		}
	}
	else
	{ if( obj.checked == true )
		{ return 0; }
	}
	return -1;
}

//-- Ãµ ´ÜÀ§¸¶´Ù ÄÞ¸¶(,) ³Ö±â
function comma( val )
{
	var num = val.toString()
	var len = num.length;
	var cnt = 1;
	var str = "";

	if( len > 3  )
	{ while( len >= cnt )
		{ str = str + num.substr(len-cnt,1);
			if( cnt % 3 == 0 && cnt < len )
			{ str = str + ","; }
			cnt++;
		}
		len = str.length;
		num = "";
		for( var i=1; i<=str.length; i++ )
		{	num = num + str.substr(len-i,1); }
	}

	return num;
}

//-- Re-define trim function.
String.prototype.trim = function() {
  return this.replace(/(^\s*)|(\s*$)/g, "");
}

//-- ÇÑ±ÛÀÔ·Â Á¦¾î
function withHangul(str)
{
	var code;
	var ch;
	var retCode = 0;

	for( i=0; i<str.length; i++ )
	{	code = str.charCodeAt(i);
		ch = str.substr(i,1).toUpperCase();
		code = parseInt(code);
		if( (ch < "0" || ch > "9") && (ch < "A" || ch > "Z") && (code > 255 || code < 0) )
		{ return true; }
	}
	return false;
}


//-- ÁÖ¹Î¹øÈ£ °Ë»ç
function checkPersonalNo(personal_no)
{
	var pattern;
	var i;

	personal_no = personal_no.replace(/[^\d]+/g, '');
	pattern = /^[0-9]{6}[1-8][0-9]{6}$/;

	if(!pattern.test(personal_no)) {
			return false;
	}
	var birth = new Array();
	birth[0] = personal_no.substr(0, 2);
	switch(personal_no.charAt(6)) {
	case '1':
	case '2':
			birth[0] = ('19' + birth[0]) * 1;
			birth[3] = false;
			break;
	case '3':
	case '4':
			birth[0] = ('20' + birth[0]) * 1;
			birth[3] = false;
			break;
	case '5':
	case '6':
			birth[0] = ('19' + birth[0]) * 1;
			birth[3] = true;
			break;
	case '7':
	case '8':
			birth[0] = ('20' + birth[0]) * 1;
			birth[3] = true;
			break;
	/*case '9': // ÀÌ·¸°Ô ´ÄÀº »ç¶÷Àº ÀÖ¾îµµ ¾È¹Þ¾Æ¿ä. À§ÀÇ Á¤±Ô½Ä¿¡¼­ ¾È¹ÞÀ½.
	case '0':
			birth[0] = ('18' + birth[0]) * 1;
			birth[3] = true;
			break;*/
	}

	birth[1] = personal_no.substr(2, 2) * 1;
	birth[2] = personal_no.substr(4, 2) * 1;

	if(birth[1] < 1 || birth[1] > 12) {
			return false;
	}
	if(birth[2] < 1 || birth[2] > 31) {
			return false;
	}
	var check = 0;
	var mul = 2;

	if(birth[3]) {
			if(((personal_no.charAt(7) * 10 + personal_no.charAt(8)) % 2) != 0) {
					return false;
			}
	}
	for(i = 0; i < 12; i ++) {
			check += personal_no.charAt(i) * mul;
			mul ++;
			if(mul > 9) {
					mul = 2;
			}
	}

	check = 11 - (check % 11);

	if(check > 9) {
			check %= 10;
	}
	if(birth[3]) {
			check += 2;
			if(check > 9) {
					check %= 10;
			}
	}
	if(check != personal_no.charAt(12)) {
			return false;
	}
	return birth;
}
function JuminCheck( jumin1, jumin2 )
{
	var birth = checkPersonalNo( jumin1+jumin2 );
	if( birth == false )
	{ return false; }
	else
	{ return true; }
}

//-- ÆË¾÷¿­±â
var open_win;
function popwinOpen( url, iWidth, iHeight )
{
	var wleft = (screen.availWidth-iWidth)/2;
	var wtop = (screen.availHeight-iHeight)/2-40;
	if( open_win != null )
	{ open_win.close(); }
	open_win = window.open(url,"open_pop","toolbar=no,meunbar=no,scrollbars=no,status=no,width="+iWidth+",height="+iHeight+",left="+wleft+",top="+wtop);
	open_win.focus();
}

