﻿var script = {
	version : "On jQuery v1.4.2, jQueryUi v1.8.5",
	lib : {}
};


script.browser = {
	isMobile : (navigator.userAgent.toUpperCase().indexOf("MOBILE")==-1)?false:true,
	isIPad : (navigator.userAgent.toUpperCase().indexOf("IPAD")==-1)?false:true,
	isGalaxyTab : (navigator.userAgent.toUpperCase().indexOf("SHW-M180")==-1)?false:true,
	isIE : ($.browser.msie)?true:false,
	isIE6 : ($.browser.msie&&$.browser.version=="6.0")?true:false,
	isStrict : function() {
		var docRoot = document.documentElement;
		return (docRoot!=undefined);
	},
	screenW : function() {
		var w = window.innerWidth ||
			(this.isStrict() && document.documentElement.clientWidth) ||
			document.body.clientWidth || 0;
		if (!this.isIE&&!this.isMobile) {w-=20;}
		return w;
	},
	screenH : function() {
		return window.innerHeight ||
			(this.isStrict() && document.documentElement.clientHeight) ||
			document.body.clientHeight || 0;
	},
	scrollW : function() {
		return (this.isStrict() && document.documentElement.scrollWidth) ||
			document.body.scrollWidth || 0;
	},
	scrollH : function() {
		return (this.isStrict() && document.documentElement.scrollHeight) ||
			document.body.scrollHeight || 0;
	},
	bodyW : function() {
		return document.body.scrollWidth || 0;
	},
	bodyH : function() {
		return document.body.scrollHeight || 0;
	},
	scrollX : function() {
		return window.pageXOffset ||
			(this.isStrict() && document.documentElement.scrollLeft) ||
			document.body.scrollLeft || 0;
	},
	scrollY : function() {
		return window.pageYOffset ||
			(this.isStrict() && document.documentElement.scrollTop) ||
			document.body.scrollTop || 0;
	},
	maxW : function() {
		return Math.max(this.screenW(), this.scrollW());
	},
	maxH : function() {
		return Math.max(this.screenH(), this.scrollH());
	}
};

/* String Methods (Public) */
$.extend(String.prototype, {
	trim : function () {
		return $.trim(this);
	},
	escapeXml : function() {
		return this
		.replace(/&/g,"&amp;")
		.replace(/\'/g,"&#039;")
		.replace(/\"/g,"&#34;")
		.replace(/</g,"&lt;")
		.replace(/>/g,"&gt;")
		.replace(/\n/g,"&#10;")
		.replace(/\r/g,"&#13;")
		.replace(/\t/g,"&#9;");
	},
	escapeJS : function() {
		return this
		.replace(/\\/g,"\\\\")
		.replace(/\//g,"\\/")
		.replace(/\n/g,"\\n")
		.replace(/\r/g,"\\r")
		.replace(/\t/g,"\\t")
		.replace(/\"/g,"\\\"")
		.replace(/\'/g,"\\'");
	},
	escapeCss : function() {
		return this
		.replace(/\'/g,"\\\'")
		.replace(/\"/g,"\\\"")
		.replace(/\,/g,"\\,")
		.replace(/\(/g,"\\(")
		.replace(/\)/g,"\\)");
	},
	appendParameter : function(_param) {
		return this+((_param!=undefined&&_param!="")?
			((this.indexOf("?")>-1) ? "&":"?")+_param : "" );
	},
	toCamelize : function() {
		var s = this;
		if (s.indexOf("-")>-1) {
			var a = s.split("-");
			s = a[0];
			for (var i=1; i<a.length; i++) {
				if (a[i].length>0) {
					s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
				}
			}
		}
		return s;
	},
	toBold : function() {
		return "<strong>"+this+"</strong>";
	},
	toCssBgPng24 : function() {
		return (($.browser.msie&&$.browser.version=="6.0")
		? ' filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+this+' ,sizingMethod=scale ); '
		: ' background:url('+this+') transparent; ');
	},
	toDomNodes : function() {
		var s = this, nodes = [];
		var box = document.createElement("DIV");
		box.innerHTML = s;
		for (var i=0; i<box.childNodes.length; i++) {
			nodes.push(box.childNodes[i]);
		}
		box = null;
		return nodes;
	}
});



/* Math Methods (Static) */
$.extend(Math, {
	isInt : function(_n, _base) {
		var base = (_base==undefined) ? 10 : _base;
		return (""+parseInt(_n, base)!="NaN");
	},
	isFloat : function(_n) {
		return (""+parseFloat(_n)!="NaN");
	},
	toInt : function(_n, _def, _base) {
		var def = (_def==undefined) ? 0 : _def;
		var base = (_base==undefined) ? 10 : _base;
		return this.isInt(_n, base) ? parseInt(_n, base) : def;
	},
	toFloat : function(_n, _def) {
		var def = (_def==undefined) ? 0 : _def;
		return this.isFloat(_n) ? parseFloat(_n) : def;
	}
});


/* Array Methods (Public) */
$.extend(Array.prototype, {
	remove : function(_obj) {
		for (var i=0; i<this.length; i++) {
			if (this[i]===_obj) {
				this[i] = null;
				delete this[i];
			}
		}
	},
	compact : function() {
		var temp = [];
		for (var i=0; i<this.length; i++) {
			if (this[i]!==null&&this[i]!==undefined) {
				temp.push(this[i]);
			}
		}
		return temp;
	}
});


/* Date Methods (Public) */
$.extend(Date.prototype, {
	toFormatted : function(_s) {
		var s = (_s==undefined) ? "YYYYMMDD" : _s;
		var YYYY = this.getYear();
		var MM = this.getMonth()+1;
		var DD = this.getDate();
		var HH = this.getHours();
		var MI = this.getMinutes();
		var SS = this.getSeconds();
		if (YYYY<1000) {
			YYYY += 1900;
		}
		if (MM<10) MM = "0"+MM;
		if (DD<10) DD = "0"+DD;
		if (HH<10) HH = "0"+HH;
		if (MI<10) MI = "0"+MI;
		if (SS<10) SS = "0"+SS;
		return s.replace(/YYYY/gi,YYYY)
			.replace(/MM/gi,MM)
			.replace(/DD/gi,DD)
			.replace(/HH/gi,HH)
			.replace(/MI/gi,MI)
			.replace(/SS/gi,SS);
	},
	addYear : function(_n) {
		this.setYear(this.getYear()+_n);
		return this;
	},
	addMonth : function(_n) {
		this.setMonth(this.getMonth()+_n);
		return this;
	},
	addDate : function(_n) {
		this.setDate(this.getDate()+_n);
		return this;
	},
	addHours : function(_n) {
		this.setHours(this.getHours()+_n);
		return this;
	},
	addMinutes : function(_n) {
		this.setMinutes(this.getMinutes()+_n);
		return this;
	},
	addSeconds : function(_n) {
		this.setSeconds(this.getSeconds()+_n);
		return this;
	}
});


/**
 * Object Event Class
*****************************/
script.lib.ObjectEvent = function() {
	this.actions;
	this.returnValue = true;
};
$.extend(script.lib.ObjectEvent.prototype, {
	push : function(_type, _group, _func, _count) {
		if (this.actions==undefined) {
			this.actions = [];
		}
		var type = (""+_type).trim().toLowerCase(),
			group = (""+_group).trim().toLowerCase()
		this.actions.push({
			  type	: type
			, group	: group
			, func	: _func
		});
	},
	on : function(_type, _func, _count) {
		if (_type!=undefined&&_func!=undefined) {
			var group = "", type = (""+_type).toLowerCase();
			var dot = type.indexOf(".");
			if (dot>-1) {
				group = type.substring(dot+1);
				type = type.substring(0,dot);
			}
			this.push(type.trim(), group.trim(), _func, _count);
		}
		return this;
	},
	off : function(_type) {
		if (_type==undefined) {
			_type = "";
		}
		var group = "", type = (""+_type).toLowerCase();
		var dot = type.indexOf(".");
		if (dot>-1) {
			group = type.substring(dot+1);
			type = type.substring(0,dot);
		}
		group = group.trim();
		type = type.trim();
		if (this.actions) {
			for (var i=0; i<this.actions.length; i++) {
				if ((group==""||this.actions[i].group==group)&&(type==""||this.actions[i].type==type)) {
					this.actions[i].func = null;
					this.actions[i] = null;
				}
			}
			this.actions = this.actions.compact();
		}
		return this;
	},
	stopDefault : function() {
		this.returnValue = false;
	},
	stop : function() {
		this.stopDefault();
	},
	onEvent : function() {
		var type = (""+arguments[1]).trim().toLowerCase();
		var removed = false;
		if (this.actions) {
			for (var i=0; i<this.actions.length; i++) {
				if (this.actions[i]&&this.actions[i].type==type) {
					if (typeof(this.actions[i].func)=="function") {
						this.actions[i].func.apply(arguments[0], Array.prototype.slice.apply(arguments, [2]));
					} else {
						eval(this.actions[i].func);
					}
					if (this.actions[i]&&Math.isInt(this.actions[i].count)) {
						this.actions[i].count--;
						if (this.actions[i].count<=0) {
							this.actions[i].func = null;
							this.actions[i] = null;
							removed = true;
						}
					}
				}
			}
			if (removed) {
				this.actions = this.actions.compact();
			}
		}
		var returnValue = this.returnValue;
		this.returnValue = true;
		return returnValue;
	}
});


/* Define Request Class */
script.lib.Request = function(_query) {
	var search = (_query!=undefined)?""+_query:"";
	this.search = "";
	this.key = {};
	this.keys = [];
	this.values = [];
	this.host = window.location.host;
	this.port = window.location.port;
	this.pathname = window.location.pathname;
	
	if (search.length>1&&search.indexOf("?")==0) search = search.substring(1,search.length);
	var param = search.split("&");
	var paramValue = "";
	for (var i=0; i<param.length; i++) {
		var index = param[i].indexOf("=");
		if (index>-1) {
			var name = param[i].split("=")[0];
			var value = param[i].substring(index+1, param[i].length).trim();
			if (this.key[name]==undefined) {
				this.set(name, value);
			}
		}
	}
};
$.extend(script.lib.Request.prototype, {
	size : function() {
		return this.values.length;
	},
	set : function(_name, _value) {
		if (this.key[_name]==undefined) {
			var index = this.values.length;
			this.key[_name] = index;
			this.keys.push(_name);
			this.values.push(_value);
		}
		this.search = this.search.appendParameter(_name+"="+_value);
	},
	get : function(_name) {
		var value = this.values[this.key[_name]];
		if (value==undefined) value = "";
		return value;
	},
	getKey : function(_index) {
		return this.keys[_index];
	}
});

/* Initialize Default Request */
script.request = new script.lib.Request(window.location.search);

/* Define Cookies Util */
script.cookie = {
	get : function(_name) {
		var list = document.cookie.split(";");
		var value = "";
		for (i = 0; i < list.length; i++) {
			if (list[i].indexOf(_name+"=") > -1) {
				if (list[i].split("=")[0].replace(/\s/g,"") == _name) {
					value = decodeURIComponent(list[i].split("=")[1]);
					break;
				}
			}
		}
		return value;
	},
	set : function(_name, _value, _days, _path, _domain) {
		if (_name!=undefined&&_name.trim()!="") {
			if (_value==undefined) _value = "";
			if (_days==undefined) _days = 365;
			if (_path==undefined) _path = "/";
			/* try { if (_domain==undefined) _domain = location.hostname; } catch(e) { } */
			var d = new Date();
			d.setDate(d.getDate()+_days);
			var s = "";
			s += _name+"="+encodeURIComponent(_value) + ";";
			s += "expires=" + d.toGMTString() + ";";
			s += "path=" + _path + ";";
			if (_domain!=undefined) {
				s += "domain=" + _domain + ";";
			}
			document.cookie = s;
		}
	}
};

/* Printer Object */
var out = {
	print : function(_s) {
		document.write(_s);
	},
	println : function(_s) {
		document.writeln(_s);
	},
	printBr : function(_s) {
		document.writeln(_s+"<br/>");
	}
};

var $js = script;


/**
 Use BackgroundImageCache For IE
*****************************/
try {
	document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}






//::::::::::::::::::::::::::::::::::::::::::: 딤드 처리:::::::::::::::::::::::::::::::::::::::::::/
alpha = new Object
alpha = {
	clear  : function() {
				alpha.create().style.display = "none"
				document.getElementsByTagName('HTML')[0].style.overflow = "";
				
		},
	apply  : function(co,op) {
				var Alpha = alpha.create()
				var alphacolor = co ? co : "#000000"
				var opacity = op ? op : "60"
				document.getElementsByTagName('HTML')[0].style.overflow = "";
				with (Alpha.style) {
					width      = "990px";
					height     = "620px";
					background = alphacolor;
					filter     = "alpha(opacity=50)";
					opacity    = op / 100;
					display    = "block";
				}
		},
	create : function() {
				if (!document.getElementById('alpha')) {
					var alphaDiv = document.createElement('div');
					alphaDiv.setAttribute('id', 'alpha');
					with(alphaDiv.style) {
						display  = "none";
						position = "absolute";
						top      = "0";
						left     = "0";
						right    = "0px";
						zIndex   = "9";
					}
					document.body.appendChild(alphaDiv)
					window.onresize = alpha.resize
				}
				return document.getElementById('alpha')
		},
	resize : function() {
				var Alpha = alpha.create()
				with (Alpha.style) {
					width      = document.body.scrollWidth + "px";
					height     = document.body.scrollHeight + "px";
				}
		}
}

function Dimact(){
	/* 딤드 처리 */
	alpha.apply('#000000','50');
}

function Dimdel(){
	/* 딤드 없애기 */
	alpha.clear();
}
//::::::::::::::::::::::::::::::::::::::::::: 딤드 처리:::::::::::::::::::::::::::::::::::::::::::






var ContentsMain = {
	instanceName : "ContentsMain",
	data : [],
	isFirst : true,
	current : {
		index : -1
	},
	before : {
		index : -1
	},
	bannerPositionLeft : [30,310,590],
	vars : {
		autoMotionWaitTime : 3000
		, autoMotionTimer : null
	},
	
	push : function(_data) {
		this.data.push(_data);
	},
	
	openDetail : function(_index) {
		var url = this.data[_index].url;
		location.href = url;
	},
	
	getPrevIndex : function(_index) {
		var index = Math.toInt(_index);
		return ((index>0) ? index-1 : this.data.length-1);
	},
	
	getNextIndex : function(_index) {
		var index = Math.toInt(_index);
		return ((index<this.data.length-1) ? index+1 : 0);
	},
	
	prev : function() {
		var index = this.current.index;
		if (--index<0) {
			index = this.data.length-1;
		}
		this.focus(index);
	},
	
	next : function() {
		var index = this.current.index;
		if (++index>=this.data.length) {
			index = 0;
		}
		this.focus(index);
	},
	
	blur : function(_index) {
		$("#main-visual-link-button-"+_index).stop().animate({top:-60});
		$("#main-visual-paging-"+_index).removeClass("selected");
	},
	
	focus : function(_index) {
		this.stopAutoMotion();
		if (this.current.index!=_index) {
			if (this.current.index!=-1) {
				this.blur(this.current.index);
				this.before.index = this.current.index;
			}
			this.current.index = _index;
			if (!this.isFirst) {
				this.scroll();
			} else {
				this.isFirst = false;
				$("#main-visual-body").css({left:(-1)*990*this.current.index});
				var ui = this.instanceName;
				setTimeout(function() {
					var index = window[ui].current.index;
					var prevIndex = window[ui].getPrevIndex(index);
					var nextIndex = window[ui].getNextIndex(index);
					$("#main-visual-banner-bg").animate({top:392}, function() {
						$("#main-visual-banner-"+prevIndex).animate({left:window[ui].bannerPositionLeft[0]}, "slow", function() {
							$("#main-visual-link-button-"+index).animate({top:225}, 1400, "easeOutExpo");
							$("#main-visual-paging-"+index).addClass("selected");
							$("#main-visual-banner-focus").animate({top:392}, function() {
								window[ui].activeEvent();
								window[ui].runAutoMotion();
							});
						});
						$("#main-visual-banner-"+index).animate({left:window[ui].bannerPositionLeft[1]});
						$("#main-visual-banner-"+nextIndex).animate({left:window[ui].bannerPositionLeft[2]}, "fast");
					});
				}, 1000);
			}
		}
	},
	
	scroll : function() {
		onLocationView();	//지도 숨기기
		onViewer();			//설명 숨기기
		$("#main-visual-paging-1").children("img").attr("src",$("#main-visual-paging-1").children("img").attr("src").replace("_on","_off"));
		$("#main-visual-paging-2").children("img").attr("src",$("#main-visual-paging-2").children("img").attr("src").replace("_on","_off"));
		if (this.current.index == 1){
			$("#main-visual-paging-1").children("img").attr("src",$("#main-visual-paging-1").children("img").attr("src").replace("_off","_on"));
		}
		if (this.current.index == 2){
			$("#main-visual-paging-2").children("img").attr("src",$("#main-visual-paging-2").children("img").attr("src").replace("_off","_on"));
		}
		var ui = this.instanceName;
		var index = this.current.index;
		var prevIndex = this.getPrevIndex(index);
		var nextIndex = this.getNextIndex(index);
		$("#main-visual-paging-"+index).addClass("selected");
		$("#main-visual-body").stop().animate({left:(-1)*990*index}, 1400, "easeInExpo", function() {
			$("#main-visual-link-button-"+index).animate({top:225}, 1400, "easeOutExpo", function() {
				window[ui].runAutoMotion();
			});
		});
		if (index>this.before.index) {
			$(".main-visual-banner").css({left:900});
		} else {
			$(".main-visual-banner").css({left:-260});
		}
		if (this.before.index==this.data.length-1&&index==0) {
			$(".main-visual-banner").css({left:900});
		}
		if (this.before.index==0&&index==this.data.length-1) {
			$(".main-visual-banner").css({left:-260});
		}
		
		$("#main-visual-banner-"+prevIndex).stop().animate({left:this.bannerPositionLeft[0]}, (index>this.before.index)?"fast":"slow");
		$("#main-visual-banner-"+index).stop().animate({left:this.bannerPositionLeft[1]});
		$("#main-visual-banner-"+nextIndex).stop().animate({left:this.bannerPositionLeft[2]}, (index>this.before.index)?"slow":"fast");
	},
	
	/* ## */
	runAutoMotion : function() {
	//	this.stopAutoMotion();
	//	var ui = this.instanceName;
	//	this.vars.autoMotionTimer = setTimeout(function() {
	//		window[ui].next();
	//	}, this.vars.autoMotionWaitTime);
	},
	
	stopAutoMotion : function() {
	//	clearTimeout(this.vars.autoMotionTimer);
	},
	
	getHTML : function() {
		var s = '';
		s += '<div id="main-visual-root">\n';
		s += '	<div id="main-visual-body">\n';
		s += '		<table cellpadding="0" cellspacing="0" border="0">\n';
		s += '			<tr>\n';
		for (var i=0; i<this.data.length; i++) {
			s += '<td><div style="background-image:url('+this.data[i].visual+');"></div></td>\n';
		}
		s += '			</tr>\n';
		s += '		</table>\n';
		s += '	</div>\n';
		s += '	<div id="main-visual-slogan"></div>\n';
		s += '	<div id="main-visual-banner-bg" style="display:none;"></div>\n';
		s += '	<div id="main-visual-banner-focus" style="display:none;"></div>\n';
		

		for (var i=0; i<this.data.length; i++) {
			if (this.data[i].detail != "")	{
				s += '<a href="javascript:;"  onfocus="this.blur()" ';
				s += ' index="'+i+'"';
				s += ' id="main-visual-link-button-'+i+'"';
				s += ' class="main-visual-link-button"';
				s += ' style="';
				if (!$js.browser.isIE6) {
					s += 'background-image:url('+this.data[i].detail+');';
				} else {
					s += 'background-image:url(blank.gif);';
					s += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+this.data[i].detail+', sizingMethod=scale);';
				}
				s += '"></a>\n';
			}
		}

		for (var i=0; i<this.data.length; i++) {
			s += '<a href="javascript:;"  onfocus="this.blur()" ';
			s += ' index="'+i+'"';
			s += ' id="main-visual-banner-'+i+'"';
			s += ' class="main-visual-banner"';
			s += ' style="display:none; ';
			if (!$js.browser.isIE6) {
				s += 'background-image:url('+this.data[i].banner+');';
			} else {
				s += 'background-image:url(blank.gif);';
				s += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+this.data[i].banner+', sizingMethod=scale);';
			}
			s += '"></a>\n';
		}
		s += '<a href="javascript:;" onfocus="this.blur()" class="main-visual-prev-button" title="Prev"></a>\n';
		s += '<a href="javascript:;" onfocus="this.blur()" class="main-visual-next-button" title="Next"></a>\n';
		s += '</div>\n';
		
		s += '<table cellpadding="0" cellspacing="0" border="0" width="990">\n';
		s += '	<tr>\n';
		s += '		<td align="center">\n';
		s += '			<div id="main-visual-paging">\n';
		s += '				<p class="fl"><a href="#" onfocus="this.blur()"><img src="/images/intro/introBTN001.gif" border="0"></a></p>\n';
		for (var i=1; i<this.data.length; i++) {
			s += '<p class="fl"><a href="javascript:;" onClick="'+this.data[i].url.escapeXml()+'" onfocus="this.blur()" index="'+i+'" title="'+this.data[i].title.escapeXml()+'" id="main-visual-paging-'+i+'"><img src="/images/intro/introBTN00'+ (i+1) +'.gif" border="0"></a></p>\n';
		}

		// 2011-11-21 : 롯데호텔 바로가기 안보이도록 수정 : 고객요청
		//s += '<p class="fl"><a href="javascript:;" onClick="onLangSite(\'hotel\');" onfocus="this.blur()"><img src="/images/intro/introBTN004.gif" border="0"></a></p>\n';

		s += '<p class="cb"></p>\n';
		s += '			</div>\n';
		s += '		</td>\n';
		s += '	</tr>\n';
		s += '</table>\n';
		return s;
	},
	
	print : function() {
		document.write(this.getHTML());
	},
	
	activeEvent : function() {
		var ui = this.instanceName;
		
		$(".main-visual-prev-button").click(function(e) {
			e.preventDefault();
			window[ui].prev();
		});
		$(".main-visual-next-button").click(function(e) {
			e.preventDefault();
			window[ui].next();
		});
		
		$("#main-visual-paging a").click(function(e) {
			e.preventDefault();
			var index = Math.toInt($(this).attr("index"));
			window[ui].focus(index);
		});
		
		$(".main-visual-banner").click(function(e) {
			e.preventDefault();
			var index = Math.toInt($(this).attr("index"));
			if (index!=window[ui].current.index) {
				window[ui].focus(index);
			} else {
				window[ui].openDetail(index);
			}
		});
		
		$(".main-visual-link-button").click(function(e) {
			e.preventDefault();
			var index = Math.toInt($(this).attr("index"));
			window[ui].openDetail(index);
		});
		
	},
	
	initialize : function() {
		this.ids = {
			
		};
		this.print();
		this.focus(Math.floor(0));
	}
};



function onViewer(idx){
	//alert("idx : " + idx);
	document.getElementById('layerView001').style.display = "none";
	document.getElementById('layerView002').style.display = "none";

	document.getElementById('main-visual-link-button-1').style.display = "block";
	document.getElementById('main-visual-link-button-2').style.display = "block";
	
	if (idx) {
		eval("document.getElementById('main-visual-link-button-"+idx+"')").style.display = "none";
		eval("document.getElementById('layerView00"+idx+"')").style.display = "block";	
	}
}

function onLocationView(idx){
	//alert("idx : " + idx);
	document.getElementById('location_01').style.display = "none";
	document.getElementById('location_02').style.display = "none";	

	if (idx) {
		Dimact();
		eval("document.getElementById('location_0"+idx+"')").style.display = "block";
	}else{
		Dimdel();
	}
}
		





