//ÇÑ±Û 2¹ÙÀÌÆ® ¿µ¹® 1¹ÙÀÌÆ®·Î ±æÀÌ¸¦ ¸®ÅÏÇÏ´Â ÇÔ¼ö
function getLength(str)
{
    return(str.length+(escape(str)+"%u").match(/%u/g).length-1);
}

//trim ÇÔ¼ö
String.prototype.trim = function()
{
    a = this;
 
    var search = 0;
    while ( a.charAt(search) == " ")
    {
        search = search + 1;
    }
    
    a = a.substring(search, (a.length));
    search = a.length - 1;
        
    while (a.charAt(search) ==" ") 
    {   
        search = search - 1 ;
    }   
    
    return a.substring(0, search + 1);
} 

//ÀÔ·Â°ª Ã¼Å©(¿µ¹®,¼ýÀÚµî) Ã¼Å© ÇÔ¼ö
function check_input(this_s,type)
{
    /*
    type
    -> 'n' : ¼ýÀÚ¸¸
    -> 'e' : ¿µ¹®¸¸
    -> 'en' : ¿µ¹®°ú ¼ýÀÚ¸¸
    -> 'ens' : ¿µ¹®¼Ò¹®ÀÚ¿Í ¼ýÀÚ¸¸
    -> 'sc' : Æ¯¼ö¹®ÀÚ Á¦¿Ü
    */
 
    var temp_value = this_s.toString();
    var regexp = '';
    switch(type)
    {
        case 'n': regexp = /[^0-9]/g;break;
        case 's': regexp = /[^a-zA-Z]/g;break;
        case 'e': regexp = /[^a-z]/g;break;
        case 'en': regexp = /[^a-zA-Z0-9]/g;break;
        case 'ens': regexp = /[^a-z0-9]/g;break;
        case 'sc': regexp = /[^a-zA-Z0-9°¡-ÆR\s]/g;break;
        default : regexp = /[^a-z0-9]/g;
    }
    if(regexp.test(temp_value))
    {
        return false;
    }else
    {
        return true;
    }
 
}

//ÇÑ±Û ÀÔ·Â Ã¼Å© ÇÔ¼ö 
function check_han(this_s,type)
{
    /*  
    type 
    -> 'c' : ÃÊ¼º Æ÷ÇÔ 
    -> 's' : ÃÊ¼º Æ÷ÇÔ + °ø¹é Æ÷ÇÔ 
    -> '' : ÃÊ¼º, °ø¹é ¹«½Ã  
    */
    var temp_value = this_s.toString(); 
    var regexp = '';
    switch(type)
    {   
        case 'c': regexp = /[^¤¡-¤¾°¡-ÆR]/g;break;
        case 's': regexp = /[^¤¡-¤¾°¡-ÆR\s]/g;break;
        case '': regexp = /[^°¡-ÆR]/g; break;
        default : regexp = /[^¤¡-¤¾°¡-ÆR\s]/g;
    }
    if(regexp.test(temp_value))
    { 
        return false;
    }else
    { 
        return true;
    }
} 

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 initsize(width) 
{
	self.resizeTo(width, document.body.scrollHeight);
}

function ready_msg()
{
	alert("¼­ºñ½º ÁØºñÁß ÀÔ´Ï´Ù.");
	return;
}

//ÆË¾÷Ã¢ »çÀÌÁî Á¶Àý
function winResize(width)
{
    var Dwidth = parseInt(width);
    var Dheight = parseInt(document.body.scrollHeight);
    var divEl = document.createElement("div");
    divEl.style.position = "absolute";
    divEl.style.left = "0px";
    divEl.style.top = "0px";
    divEl.style.width = "100%";
    divEl.style.height = "100%";

    document.body.appendChild(divEl);

    window.resizeBy(Dwidth-divEl.offsetWidth, Dheight-divEl.offsetHeight);
    document.body.removeChild(divEl);
}

		 
function isActiveX(){
	var Installed;

	try	{
		var Installx = new ActiveXObject("ILSWebFunction.ILSWebFunction.1");
		
		if(Installx){

			Installed = true;
		}else{

			Installed = false;
		}
	}catch(ex){
		Installed = false;

	}
	return Installed;
}

function winOpen(src,name,width,height){
	var win = window.open(src,name,"width="+width+", height="+height+",toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no");
	return win;
}

function onFreeCharge(){
	
	if( !login_){
		alert('·Î±×ÀÎÈÄ ÀÌ¿ëÇÏ¼¼¿ä');
		var rtnurl = window.location;
		
		
		location.href="/login/login_page.php?rtn_page="+encodeURIComponent(rtnurl);
		return;
	}

	var url = '/shop/shop_click.php';
	window.open(url,"charge","width=827,scrollbars=yes")
}

function onChanges(){
	window.open("/pay/goods_changepop.php","gift_change_popup","width=400,height=300,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no");
}
function offChanges(sino){
	window.open("/pay/ch_reservation.php?pre_sino="+sino+"","gift_change_popup","width=400,height=148,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no");
}

function onPersonal(){
	window.open("/customer/personalinfo.php","personal","width=480,height=400,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no");
}

function onAgree(){
	window.open("/customer/agree1.php","agree","width=480,height=400,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no");
}

function onAgree2(){
	window.open("/customer/agree2.php","agree","width=480,height=400,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no");
}

function number_format(input){ 
    var input = String(input); 
    var reg = /(\-?\d+)(\d{3})($|\.\d+)/; 
    if(reg.test(input)){ 
        return input.replace(reg, function(str, p1,p2,p3){ 
                return number_format(p1) + "," + p2 + "" + p3; 
            }     
        ); 
    }else{ 
        return input; 
    } 
}


function setPng24(obj)
{
     obj.width = obj.height = "1";
     obj.className = obj.className.replace(/\bpng24\b/i,"");
     obj.style.display = "inline-block";
     obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + obj.src + "', sizingMethod='image')";
     obj.src="";
     return "";
}

function Rolling(canvas,width,height,direction,pixelgap,timegap,idlegap)
{
	this.canvas = canvas;
	this.width = width;
	this.height = height;
	this.direction = direction;	//0: left, 1: right, 2: up, 3: down
	this.pixelgap = pixelgap;
	this.timegap = timegap;
	this.idlegap = idlegap;
	this.box = document.createElement("DIV");
	this.box.style.width = this.width + "px";
	this.box.style.height = this.height + "px";
	this.box.style.overflow = "hidden";
	this.setTimeOut = null;
	this.current = null;
	this.next = null;
}

Rolling.prototype =
{
	Init: function () {
		var This = this;
		this.box.onmouseover = function () { window.clearTimeout(This.setTimeOut); }
		this.box.onmouseout = function () { This.setTimeOut = window.setTimeout(function () { This.Run(); },This.timegap); }
		this.canvas.appendChild(this.box);
		this.box.style.position = "absolute";
		for (var i = 0; i < this.box.childNodes.length; i++) {
			this.box.childNodes[i].style.position = "absolute";
			if (i > 0) {
				if (this.direction == 0 || this.direction == 1) {
					this.box.childNodes[i].style.left = (this.box.childNodes[i - 1].offsetLeft + this.box.childNodes[i - 1].offsetWidth) + "px";
				} else if (this.direction == 2 || this.direction == 3) {
					this.box.childNodes[i].style.top = (this.box.childNodes[i - 1].offsetTop + this.box.childNodes[i - 1].offsetHeight) + "px";
				}
			}
			if (i == this.box.childNodes.length - 1) {
				if (this.direction == 1) {
					this.box.childNodes[i].style.left = -this.box.childNodes[i].offsetWidth + "px";
				} else if (this.direction == 3) {
					this.box.childNodes[i].style.top = -this.box.childNodes[i].offsetHeight + "px";
				}
			}
		}
	},
	Run: function () {
		if (this.box.hasChildNodes() == false) { return; }
		if (this.direction == 0) { this.moveLeft(); }
		if (this.direction == 1) { this.moveRight(); }
		if (this.direction == 2) { this.moveUp(); }
		if (this.direction == 3) { this.moveDown(); }
	},
	moveLeft: function () {
		var This = this;
		if (this.current == null) { this.current = 0; }
		window.clearTimeout(this.setTimeOut);
		for (var i = 0; i < this.box.childNodes.length; i++) {
			this.box.childNodes[i].style.left = (this.box.childNodes[i].offsetLeft - this.pixelgap) + "px";
		}
		this.next = (this.current + 1 >= this.box.childNodes.length) ? 0 : this.current + 1;
		if (this.box.childNodes[this.next].offsetLeft <= 0) {
			var nextPosition = 0;
			for (var i = 1; i < this.box.childNodes.length; i++) { nextPosition += this.box.childNodes[i].offsetWidth; }
			this.box.childNodes[this.current].style.left = nextPosition + "px";
			this.current = (this.current + 1 >= this.box.childNodes.length) ? 0 : this.current + 1;
			this.setTimeOut = window.setTimeout(function () { This.Run(); },this.idlegap);
		} else {
			this.setTimeOut = window.setTimeout(function () { This.Run(); },this.timegap);
		}
	},
	moveRight: function () {
		var This = this;
		if (this.current == null) { this.current = this.box.childNodes.length - 1; }
		window.clearTimeout(this.setTimeOut);
		for (var i = 0; i < this.box.childNodes.length; i++) {
			this.box.childNodes[i].style.left = (this.box.childNodes[i].offsetLeft + this.pixelgap) + "px";
		}
		this.next = (this.current - 1 < 0) ? this.box.childNodes.length - 1 : this.current - 1;
		if (this.box.childNodes[this.current].offsetLeft >= 0) {
			this.box.childNodes[this.next].style.left = -this.box.childNodes[this.next].offsetWidth + "px";
			this.current = (this.current - 1 < 0) ? this.box.childNodes.length - 1 : this.current - 1;
			this.setTimeOut = window.setTimeout(function () { This.Run(); },this.idlegap);
		} else {
			this.setTimeOut = window.setTimeout(function () { This.Run(); },this.timegap);
		}
	},
	moveUp: function () {
		var This = this;
		if (this.current == null) { this.current = 0; }
		window.clearTimeout(this.setTimeOut);
		for (var i = 0; i < this.box.childNodes.length; i++) {
			this.box.childNodes[i].style.top = (this.box.childNodes[i].offsetTop - this.pixelgap) + "px";
		}
		this.next = (this.current + 1 >= this.box.childNodes.length) ? 0 : this.current + 1;
		if (this.box.childNodes[this.next].offsetTop <= 0) {
			var nextPosition = 0;
			for (var i = 1; i < this.box.childNodes.length; i++) { nextPosition += this.box.childNodes[i].offsetHeight; }
			this.box.childNodes[this.current].style.top = nextPosition + "px";
			this.current = (this.current + 1 >= this.box.childNodes.length) ? 0 : this.current + 1;
			this.setTimeOut = window.setTimeout(function () { This.Run(); },this.idlegap);
		} else {
			this.setTimeOut = window.setTimeout(function () { This.Run(); },this.timegap);
		}
	},
	moveDown: function () {
		var This = this;
		if (this.current == null) { this.current = this.box.childNodes.length - 1; }
		window.clearTimeout(this.setTimeOut);
		for (var i = 0; i < this.box.childNodes.length; i++) {
			this.box.childNodes[i].style.top = (this.box.childNodes[i].offsetTop + this.pixelgap) + "px";
		}
		this.next = (this.current - 1 < 0) ? this.box.childNodes.length - 1 : this.current - 1;
		if (this.box.childNodes[this.current].offsetTop >= 0) {
			this.box.childNodes[this.next].style.top = -this.box.childNodes[this.next].offsetHeight + "px";
			this.current = (this.current - 1 < 0) ? this.box.childNodes.length - 1 : this.current - 1;
			this.setTimeOut = window.setTimeout(function () { This.Run(); },this.idlegap);
		} else {
			this.setTimeOut = window.setTimeout(function () { This.Run(); },this.timegap);
		}
	}
}


function main_onclick(name) {
	var action = "/admin/visit_count.php?in_page="+name;
	new Ajax.Request(action, {
		method: 'get',
		asynchronous: true,
		onSuccess: function(rv) {
		eval(rv.responseText);
		}
	});
	
}
