if (!window.getOffsetTop) {
	function getOffsetTop(object) {
		return object ? object.offsetTop + getOffsetTop(object.offsetParent) : 0;
	}
}

if (!window.addEvent) {
	function addEvent(object, eventName, functionName) {
		var method, option = "";

		if (navigator.appVersion.toUpperCase().indexOf("MSIE") > 0) {
			method = "attachEvent";
		} else {
			method = "addEventListener";
			eventName = eventName.replace("on", "");
			option = ", false";
		}

		eval((object ? "object." : "document.") + method + "(\"" + eventName + "\", functionName " + option + ");");
	}
}

if (!window.removeEvent) {
	function removeEvent(object, eventName, functionName) {
		var method, option = "";

		if (navigator.appVersion.toUpperCase().indexOf("MSIE") > 0) {
			method = "detachEvent";
		} else {
			method = "removeEventListener";
			eventName = eventName.replace("on", "");
			option = ", false";
		}

		eval((object ? "object." : "document.") + method + "(\"" + eventName + "\", functionName " + option + ");");
	}
}

if (!window.Ajax) {
	function Ajax() {
		this.getXMLDocument = function () {
			var xmlDocument = null;

			if (document.implementation && document.implementation.createDocument) {
				xmlDocument = document.implementation.createDocument("", "", null);
			} else if (typeof ActiveXObject != "undefined") {
				try {
					xmlDocument = new ActiveXObject("Msxml2.DOMDocument");
				} catch (e) {
					xmlDocument = new ActiveXObject("Msxml.DOMDocument");
				}
			}

			if (xmlDocument == null || typeof xmlDocument.load == "undefined") return null;

			return xmlDocument;
		}

		this.getXMLHttpRequest = function () {
			var httpRequest = null;

			if (window.ActiveXObject) {
				try {
					httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try {
						httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {
						httpRequest = new XMLHttpRequest();
					}
				}
			} else if (window.XMLHttpRequest) {
				try { httpRequest = new XMLHttpRequest(); } catch (e) {};
			}

			return httpRequest;
		}

		this.submit = function (url, method, variables, callbackFunction) {
			var xmlRequest;

			if (!method) method = "POST";
			if (method) method = method.toUpperCase();

			if (xmlRequest = this.getXMLHttpRequest()) {
				xmlRequest.open(method, (method == "GET" ? (url.indexOf("?") < 0 ? url + "?" : url) + "&dateKey=" + (new Date()).getTime() : url), true);

				if (method == "POST") xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");

				if (navigator.appName.toLowerCase().indexOf("explorer") > 0) {
					xmlRequest.onreadystatechange = function () {
						if (xmlRequest.readyState == 4 && xmlRequest.status == 200) window.ajaxSubmitResult = callbackFunction(xmlRequest, variables);
					}
				} else {
					xmlRequest.onload = function () { window.ajaxSubmitResult = callbackFunction(xmlRequest, variables); }
				}

				xmlRequest.send((variables ? variables : ""));
			}
		}
	}
}

function SkyScrapper() {
	if (window.skyScrapperDisabled) return;

	var optionCompIDs = "D700, H370";
	//var defaultTop = 157, scrollOffset = 10, tempScroll = 0;
	var defaultTop = 205, scrollOffset = 10, tempScroll = 0;

	var mainID = "dnScraper", wrapperID = "scraperWrapper", bodyID = "scraper_body", titleID = "scraper_division_title", divisionID = "scraperDivision", hotItemID = "scrapper_hotitem_area", pageBtnID = "scraper_page_btn", loginInfoID = "scraper_login_info", noItemInfoID = "scraper_no_product";
	var topTabID = "scraper_tab_top", bottomTabID = "scraper_tab_bottom", cartBtnID = "scraper_cart_btn", wishBtnID = "scraper_wish_btn", viewAllBtnLinkID = "scraper_all_btn_link", menuOpenID = "menu_open", menuCloseID = "menu_close";
	var couponCountID = "scraper_my_coupon_count", couponID = "myCoupon_Layer", couponButtonID = "scraper_coupon_btn", couponPopupCntID = "coupon_layer_count", couponNoLoginID = "scrapper_coupon_nologin", couponListID = "scrapper_coupon_list", myCouponCnt = -1;
	var countAreaID = "scraper_count_area", cartCountAreaID = "scraper_cart_count_area", cartCountID = "scraper_cart_count";
	var count1ID = "scraper_product_count", count2ID = "scraper_event_count", optionAlertID = "scraper_option_alert";
	var itemCount = 0, maxItemCount = 3, itemPage = 0, itemPageMax = 20, itemType = "Product", itemHtmlID = "scraper_item_html", itemsID = "scraper_items", itemID = "scraper_item_", pageCountTextID = "scraper_page_count_text";
	var itemNameID = "scraper_item_name_", itemPriceID = "scraper_item_price_", itemCouponPriceID = "scraper_item_couponprice_", itemEventDetailID = "scraper_eventdetail", itemEventDetailNameID = "scraper_eventdetail_name";
	var itemDetailID = "scraper_itemdetail", itemDetailNameID = "scraper_itemdetail_name", itemDetailPriceID = "scraper_itemdetail_price", itemDetailCouponPriceAreaID = "scraper_itemdetail_couponprice_area", itemDetailCouponPriceID = "scraper_itemdetail_couponprice";
	var itemLink1ID = "scraper_item_link1_", itemLink2ID = "scraper_item_link2_", itemImageID = "scraper_item_prodimage_", itemCheckID = "scraper_item_check_", itemDeleteID = "scraper_item_delete_btn_", itemOptionID = "scraper_item_option_";

	var currentCode = "CC|TP", divisionCodes = new Array("HI", "TP"), buttonKeys = new Array("cart", "wish", "all"), divisionNumbers = {"CL":"01", "WL":"02", "HI":"03", "TP":"04"}, countMapping = {"CL":"none", "WL":"", "HI":"none", "TP":""};
	var buttonIDs = {"cart":cartBtnID, "wish":wishBtnID, "all":"scraper_all_btn"}, buttonMapping = {"CL":{"cart":"none", "wish":"", "all":""}, "WL":{"cart":"", "wish":"none", "all":""}, "HI":{"cart":"", "wish":"", "all":"none"}, "TP":{"cart":"", "wish":"", "all":"none"}}, couponMapping = {"CL":"A", "WL":"W", "HI":"I", "TP":"T"};
	var prodRegExp = new RegExp("[A-Z][0-9]{3}_.+"), selectedKeys = "", selectedProducts = new Array(), bannerObjects;

	var sids = new Array(), sidHead = "0020", sidBody = "AQ010000", sidFoot = "04";

	sids["head"] = new Array();
	sids["head"]["shoptop"] = "0002";
	sids["head"]["ptopprodlist"] = "0003";
	sids["head"]["searchtop"] = "0004";
	sids["head"]["communitytop"] = "0005";

	sids["body"] = new Array();
	sids["body"]["banner_AO"] = "AO010000";
	sids["body"]["banner_AP"] = "AP010000";
	sids["body"]["banner_AQ"] = "AR010000";

	sids["foot"] = new Array();
	sids["foot"]["CL"] = "02";
	sids["foot"]["WL"] = "03";
	sids["foot"]["HI"] = "04";
	sids["foot"]["TP"] = "05";

	this.getInstance = function () {
		return document.getElementById(mainID);
	}

	this.getSidHeadKey = function () {
		var uri = location.toString().replace(/^https?:\/\/[0-9a-z_.]+\/?/, ""), key = "";

		uri = uri.substring(0, uri.indexOf("?"));
		key = uri.split(/[\/]+/);
		key = key[key.length -1];

		if (!key || key.indexOf("index.") > -1) key = "shoptop";

		return key;
	}

	this.getSid = function (bodyKey, footKey, no) {
		var head = "", body = "", foot = "", headKey = this.getSidHeadKey();

		if (!headKey || !(head = sids["head"][headKey])) head = sidHead;
		if (!bodyKey || !(body = sids["body"][bodyKey])) body = sidBody;
		if (!footKey || !(foot = sids["foot"][footKey])) foot = sidFoot;
		if (!no) no = "01";
		if (parseInt(no) < 10) no = "0" + no;

		return (head + "_" + body + "_NO_" + foot).replace(/NO/, no);
	}

	this.open = function () {
		var object;

		if (object = document.getElementById(mainID)) object.style.display = "";
	}

	this.close = function () {
		var object;

		if (object = document.getElementById(mainID)) object.style.display = "none";
	}

	this.isLogin = function () {
		var logOffObj = document.getElementById("signoff"), signStatus = getCookie("DCookieChk");

//		if (logOffObj) if (logOffObj.style.display != "none") return true;

		if (signStatus == "101") {
			if (document.domain.toString().indexOf("dnshop.com") > -1) {
				if (isLoginTimeout()) {
					login_setCookie("DCookieChk", "", 0);
					signStatus = "100";
				}
			}
		}

		return signStatus == "101" ? true : false;
	}

	this.login = function () {
		location.href = "/front/Login?rtnUrl=" + location.toString().replace(/\&/gi,"%26");
	}

	this.openDivision = function (divCode, type) {
		if (!divCode) divCode = currentCode;

		var titleBox1, titleBox2, titleImages1, titleImages2, image, button;
		var divisionCode = divisionNumbers[divCode], divisionArea = document.getElementById(divisionID);
		var itemsArea = document.getElementById(itemsID), hotItemArea = document.getElementById(hotItemID);
		var loginInfo = document.getElementById(loginInfoID);

		if (itemsArea) itemsArea.style.display = "none";
		if (hotItemArea) hotItemArea.style.display = "none";

		itemType = (divCode != currentCode) ? (type ? type : "Product") : (type ? type : itemType);
		itemPage = (divCode != currentCode) ? 0 : itemPage;

		if (itemPage < 1) {
			if (divCode.indexOf("HI") > -1) {
				itemPage = (Math.abs(Math.round(Math.random() * 100000)) % 5) + 1;
			} else {
				itemPage = 1;
			}
		}

		if (titleBox1 = document.getElementById(noItemInfoID)) titleBox1.style.display = "none";

		if (divCode == "HI") {
			if (titleBox1 = document.getElementById(topTabID)) titleBox1.style.display = "none";
			if (image = document.getElementById(topTabID + "_HI")) image.style.display = "none";
			if (image = document.getElementById(topTabID + "_TP")) image.style.display = "";
			if (image = document.getElementById(bottomTabID + "_HI")) image.style.display = "none";
			if (image = document.getElementById(bottomTabID + "_TP")) image.style.display = "";
		} else {
			if ((titleBox1 = document.getElementById(topTabID)) && (titleBox2 = titleBox1.getElementsByTagName("IMG"))) {
				titleBox1.style.display = "";
				titleBox2[0].style.display = "";
				titleBox2[1].style.display = "none";
			}
			
			if (image = document.getElementById(topTabID + "_HI")) image.style.display = "";
			if (image = document.getElementById(topTabID + "_TP")) image.style.display = "none";
			if (image = document.getElementById(bottomTabID + "_HI")) image.style.display = "none";
			if (image = document.getElementById(bottomTabID + "_TP")) image.style.display = "none";
		}

		if (button = document.getElementById(viewAllBtnLinkID)) {
			if (divCode == "CL") button.href = "/front/dnshopcart/dnshopCartList?Sid=" + this.getSid(null, currentCode, 97);
			if (divCode == "WL") button.href = "/shoppingDiary/WishList?Sid=" + this.getSid(null, currentCode, 97);
		}

		if (titleBox1 = document.getElementById(titleID)) {
			if (titleImages1 = titleBox1.getElementsByTagName("IMG")) {
				for (var a=0 ; a<titleImages1.length ; a++) {
					if (titleImages1[a].getAttribute("id") == titleID + "_" + divCode) titleImages1[a].style.display = "";
					else titleImages1[a].style.display = "none";
				}
			}
		}

		for (var a=0 ; a<buttonKeys.length ; a++) {
			if (!(button = document.getElementById(buttonIDs[buttonKeys[a]]))) continue;

			button.style.display = buttonMapping[divCode][buttonKeys[a]];
		}

		if (!this.isLogin()) {
			if (button = document.getElementById(cartBtnID)) button.style.display = "none";
			if (button = document.getElementById(wishBtnID)) button.style.display = "none";
		}

//		if (countObj = document.getElementById(couponCountID)) if (!this.isLogin() || parseInt(countObj.innerHTML) > 0) divCode = divCode.replace("CC", "").replace("||", "|");

		if (!this.isLogin() && divCode.indexOf("TP") < 0 && divCode.indexOf("HI") < 0) {
			if (divisionArea) divisionArea.style.display = "none";
			if (loginInfo) loginInfo.style.display = "";
		} else {
			if (loginInfo) loginInfo.style.display = "none";
			if (divisionArea) divisionArea.style.display = "";
			if (titleBox1 = document.getElementById(pageCountTextID)) titleBox1.innerHTML = divCode == "TP" ? "±âÈ¹Àü" : "ÆäÀÌÁö";
			if (titleBox1 = document.getElementById(cartCountAreaID)) titleBox1.style.display = (divCode == "CL" ? "" : "none");

			if (titleBox1 = document.getElementById(countAreaID)) {
				titleBox1.style.display = countMapping[divCode];
				titleBox2 = titleBox1.getElementsByTagName("LI");

				if (image = titleBox2[0]) image.className = itemType.substring(0, 1) == "P" ? image.className.replace(/_(on|off)/, "_on") : image.className.replace(/_(on|off)/, "_off");
				if (image = titleBox2[1]) image.className = itemType.substring(0, 1) != "P" ? image.className.replace(/_(on|off)/, "_on") : image.className.replace(/_(on|off)/, "_off");
			}

//			if (!this.isLogin()) if (button = document.getElementById(couponButtonID)) button.style.display = "none";
			if (button = document.getElementById(couponButtonID)) button.style.display = "none";
			if (this.resetItems(true)) this.loadContents(currentCode = divCode);
		}

		this.isLoad = true;
	}

	this.setListArea = function () {
		var pageBtn = document.getElementById(pageBtnID), noItemInfo = document.getElementById(noItemInfoID);

		if (noItemInfo) {
			if (itemCount > 0) {
				 noItemInfo.style.display = "none";
				 pageBtn.style.display = "";
			} else {
				if (itemPage <= 1) {
					pageBtn.style.display = "none";
					noItemInfo.style.display = "";
				}
			}
		}
	}

	this.loadContents = function (divCode, action, key) {
		var ajax = new Ajax();
		var url = "/front/SkyScrapper?cmd=" + divCode + (bannerObjects ? "" : "|AD") + (myCouponCnt < 0 ? "|CC" : "") + "&page=" + itemPage + "&count=" + (divCode == "HI" ? 1 : maxItemCount);
		var itemsArea = document.getElementById(itemsID), hotItemArea = document.getElementById(hotItemID);

		if (action) url += "&action=" + action;
		if (key) url += "&itemKey=" + key;
		if (itemType) url += "&itemType=" + itemType;

		if (divCode == "HI" && hotItemArea) {
			if (itemsArea) itemsArea.style.display = "none";
			if (hotItemArea) hotItemArea.style.display = "";
		} else {
			if (itemsArea) itemsArea.style.display = "";
			if (hotItemArea) hotItemArea.style.display = "none";
		}

		ajax.submit(url + "&Sid=" + this.getSid(null, divCode), "GET", "mode=" + divCode, loadScrapperContents);
	}

	this.resetItems = function (resetCheckBox) {
		var items = document.getElementById(itemsID), item = document.getElementById(itemHtmlID), itemsHTML = "";

		if (!items || !item) return false;

//		try { if (countObj = document.getElementById(cartCountID)) countObj.innerHTML = "0"; } catch (e) {}
		try { if (countObj = document.getElementById(count1ID)) countObj.innerHTML = "0"; } catch (e) {}
		try { if (countObj = document.getElementById(count2ID)) countObj.innerHTML = "0"; } catch (e) {}

		for (var itemNo=0 ; itemNo<maxItemCount ; itemNo++) {
			itemHTML = item.value.replace(/_\$itemNo/g, "_" + (itemNo+1));
			itemsHTML = itemsHTML + itemHTML;
		}

		items.innerHTML = itemsHTML;
		
		for (var itemNo=1 ; itemNo<=maxItemCount ; itemNo++) {
			if (myObj = document.getElementById(itemID + itemNo)) myObj.style.display = "none";
			if (resetCheckBox) if (myObj = document.getElementById(itemCheckID + itemNo)) myObj.checked = false;
		}

		return true;
	}

	this.setCountInfo = function (object) {
		var countObj;

		try { if (object.couponCount) if (countObj = document.getElementById(couponCountID)) countObj.innerHTML = object.couponCount; myCouponCnt = parseInt(object.couponCount); } catch (e) {}
		try { if (object.couponCount) if (countObj = document.getElementById(couponPopupCntID)) countObj.innerHTML = object.couponCount; } catch (e) {}
		try { if (object.cartCount) if (countObj = document.getElementById(cartCountID)) countObj.innerHTML = object.cartCount; } catch (e) {}
		try { if (object.count1) if (countObj = document.getElementById(count1ID)) countObj.innerHTML = object.count1; } catch (e) {}
		try { if (object.count2) if (countObj = document.getElementById(count2ID)) countObj.innerHTML = object.count2; } catch (e) {}
	}

	this.setItem = function (code, itemNo, object) {
		var myObj, tempObj, hotItemArea, item;
		var imageID, nameID, priceID, couponPriceID, linkID, optionID;
		var itemSid = (itemType.substring(0, 1) == "P" ? 20 : 30) + ((itemPage - 1) * (code == "HI" ? 1 : maxItemCount)) + itemNo;

		if (object) {
			if (object.id) selectedProducts[object.id] = object;
			if (object.url) object.url = (object.url.replace(/Sid=[^&]+/g, "") + "&Sid=" +  this.getSid(null, currentCode, itemSid)).replace(/&&/g, "&");
			if (optionCompIDs.indexOf(object.compid) >= 0) object.option = 1;

			if (item = document.getElementById("scraper_item_" + itemNo)) if (itemNo == 1) item.className = "firstChild";

			imageID = itemImageID + itemNo;
			nameID = itemNameID + itemNo;
			priceID = itemPriceID + itemNo;
			couponPriceID = itemCouponPriceID + itemNo;
			linkID = itemLink1ID + itemNo;
			optionID = itemOptionID + itemNo;

			if (code == "HI") {
				if (myObj = document.getElementById(itemDeleteID + itemNo)) myObj.style.display = "none";

				if (hotItemArea = document.getElementById(hotItemID)) {
					imageID = "scrapper_hotitem_image";
					nameID = "scrapper_hotitem_name";
					priceID = "scrapper_hotitem_price";
					couponPriceID = "scrapper_hotitem_coupon_price";
					linkID = "scrapper_hotitem_link";
					optionID = "scrapper_hotitem_option";

					if (tempObj = document.getElementById("scrapper_hotitem_coupon")) {
						if (object.couponprice && parseInt(object.couponprice.replace(/[^0-9]+/g, "")) > 0) tempObj.style.display = "";
						else tempObj.style.display = "none";
					}

					selectedKeys = "\t" + (object.id ? object.id : object.seq ? object.seq : "") + "\t";
					hotItemArea.style.display = "";
				}
			} else {
				if (myObj = document.getElementById(itemsID)) myObj.style.display = "";
			}

			if (object.image) object.image = object.image.replace(/_[0-9]{2,3}\./, "_80.");

			if (myObj = document.getElementById(nameID)) myObj.innerHTML = object.name ? object.name : "";
			if (myObj = document.getElementById(priceID)) myObj.innerHTML = object.salecost ? this.numberFormat(object.salecost) : "";
			if (myObj = document.getElementById(couponPriceID)) myObj.innerHTML = object.couponprice ? this.numberFormat(object.couponprice) : "";
			if (myObj = document.getElementById(linkID)) myObj.href = "javascript:goDomainUrl('" + object.url + "');";
			if (myObj = document.getElementById(itemLink2ID + itemNo)) myObj.href = "javascript:scrapper.deleteItem('" + (object.seq ? object.seq : object.id ? object.id : "") + "');";
			if (myObj = document.getElementById(optionID)) myObj.style.display = object.option > 0 || object.affiliate > 0 ? "" : "none";

			if (myObj = document.getElementById(imageID)) {
				if (code == "HI" && (hotItemArea = document.getElementById(hotItemID))) {
					if (tempObj = document.getElementById(nameID)) tempObj.href = "javascript:goDomainUrl('" + object.url + "');";
				} else {
					addEvent(myObj, "onmouseover", function () { scrapper.viewItem(itemNo, object.type); });
					addEvent(myObj, "onmouseout", function () { scrapper.hideItem(); });
				}

				myObj.src = object.image;
				myObj.setAttribute("type", object.type ? object.type : "");
			}
			
			if (myObj = document.getElementById(itemCheckID + itemNo)) {
				myObj.value = object.id ? object.id : object.seq ? object.seq : "";

				if (selectedKeys.indexOf("\t" + myObj.value + "\t") > -1) myObj.checked = true;
			}
			
			if (myObj = document.getElementById(itemID + itemNo)) myObj.style.display = "";
		} else {
			if (myObj = document.getElementById(itemID + itemNo)) myObj.style.display = "none";
		}
	}

	this.moveItem = function (direction) {
		if (direction == "up") {
			if (itemPage <= 1) return;
			if (itemPage > 1) itemPage = itemPage - 1;
		} else if (direction == "down") {
			if (currentCode != "HI" && itemCount <= maxItemCount) return;
			if (itemPage < itemPageMax) itemPage = itemPage + 1;
		}

		if (this.resetItems()) this.loadContents(currentCode);
	}

	this.setItemCount = function (itemCnt) {
		itemCount = itemCnt;

//		if (itemCount <= 0 && itemPage > 1) itemPage = itemPage - 1;
	}

	this.viewItem = function (itemNo, type) {
		var myObj, imgObj;

		if (itemNo) {
			if (type.substring(0, 1) == "P") {
				if (myObj = document.getElementById(itemDetailNameID)) myObj.innerHTML = this.removeTags(document.getElementById(itemNameID + itemNo).innerHTML);
				if (myObj = document.getElementById(itemDetailPriceID)) myObj.innerHTML = this.numberFormat(document.getElementById(itemPriceID + itemNo).innerHTML);

				if (myObj = document.getElementById(itemDetailCouponPriceAreaID)) {
					if (parseInt(document.getElementById(itemCouponPriceID + itemNo).innerHTML.replace(/[^0-9]+/g, "")) > 0) {
						myObj.style.display = "";

						if (myObj = document.getElementById(itemDetailCouponPriceID)) myObj.innerHTML = this.numberFormat(document.getElementById(itemCouponPriceID + itemNo).innerHTML);
					} else {
						myObj.style.display = "none";
					}
				}

				if (myObj = document.getElementById(itemDetailID)) {
					if (imgObj = document.getElementById(itemImageID + itemNo)) myObj.style.top = imgObj.offsetParent.offsetTop;

					myObj.style.display = "block";
				}
			} else {
				if (myObj = document.getElementById(itemEventDetailNameID)) myObj.innerHTML = this.removeTags(document.getElementById(itemNameID + itemNo).innerHTML);

				if (myObj = document.getElementById(itemEventDetailID)) {
					if (imgObj = document.getElementById(itemImageID + itemNo)) myObj.style.top = imgObj.offsetParent.offsetParent.offsetTop + imgObj.offsetTop;

					myObj.style.display = "block";
				}
			}
		}
	}

	this.hideItem = function () {
		if (myObj = document.getElementById(itemDetailID)) myObj.style.display = "none";
		if (myObj = document.getElementById(itemEventDetailID)) myObj.style.display = "none";
	}

	this.selectItem = function (checkObj) {
		if (!checkObj) return;

		var itemString = "\t" + checkObj.value + "\t";

		if (checkObj.checked) {
			selectedKeys = selectedKeys + itemString;
		} else {
			selectedKeys = selectedKeys.replace(itemString, "");
		}
	}

	this.deselectItem = function () {
		selectedKeys = "";
//		selectedProducts = new Array();

		for (var itemNo=1 ; itemNo<=maxItemCount ; itemNo++) if (myObj = document.getElementById(itemCheckID + itemNo)) myObj.checked = false;
	}

	this.deleteItem = function (key) {
		this.loadContents(currentCode, "delete", key);
	}

	this.getItemCount = function () {
		return itemCount;
	}

	this.getMaxItemCount = function () {
		return maxItemCount;
	}

	this.addToCart = function () {
		if (!this.isLogin()) return;

		if (!selectedKeys.replace(/[\s\t\r\n]+/g, "")) {
			alert("¼±ÅÃÇÏ½Å »óÇ°ÀÌ ¾ø½À´Ï´Ù");
			return;
		}

		var ajax = new Ajax(), values = selectedKeys.split(/[\s\t\r\n]+/);
		var query = "", prodid = "", PID = "", CID = "", cnt = "", isaffiliate = "", salecost = "", compid = "", stoseq = "";
		var type = " ", optionCount = 0, affilateCount = 0, noProductCount = 0;

		for (var a=0 ; a<values.length ; a++) {
			if (!values[a]) continue;
			if (selectedProducts[values[a]]) type = selectedProducts[values[a]].type;

			if (prodRegExp.test(values[a]) && (type ? type :  " ").substring(0, 1) == "P") {
				if (selectedProducts[values[a]].option > 0) optionCount++;
				if (selectedProducts[values[a]].affiliate > 0) affilateCount++;

				query += "PID=" + selectedProducts[values[a]].id + "&";
				query += "prodid=" + selectedProducts[values[a]].id + "&";
				query += "CID=" + selectedProducts[values[a]].cateid + "&";
				query += "cnt=" + 1 + "&";
				query += "isaffiliate=" + (selectedProducts[values[a]].affiliate ? selectedProducts[values[a]].affiliate : "") + "&";
				query += "salecost=" + selectedProducts[values[a]].salecost + "&";
				query += "compid=" + selectedProducts[values[a]].compid + "&";
				query += "stoseq=" + selectedProducts[values[a]].stoseq + "&";
			} else {
				noProductCount++;
			}
		}

		if (noProductCount > 0) {
			alert("Àå¹Ù±¸´Ï¿¡´Â »óÇ°¸¸ ´ãÀ» ¼ö ÀÖ½À´Ï´Ù");
			return;
		} else if (optionCount > 0 || affilateCount > 0) {
			this.optionAlert();
		} else {
			this.optionAlert("none");

			ajax.submit("/front/dnshopcart/dnshopCartAdd?cmd=cart&rType=A&" + query + "&Sid=" + this.getSid(null, currentCode, 99), "GET", "mode=" + currentCode, function (a, b) { alert("Àå¹Ù±¸´Ï¿¡ ´ã¾Ò½À´Ï´Ù"); scrapper.deselectItem(); });
		}
	}

	this.addToWishList = function () {
		if (!this.isLogin()) return;

		if (!selectedKeys.replace(/[\s\t\r\n]+/g, "")) {
			alert("¼±ÅÃÇÏ½Å Ç×¸ñÀÌ ¾ø½À´Ï´Ù");
			return;
		}

		var ajax = new Ajax(), values = selectedKeys.split(/[\s\t\r\n]+/), query = "action=insert&cmd=WL&";

		for (var a=0 ; a<values.length ; a++) {
			if (!values[a]) continue;

			var item = selectedProducts[values[a]], itemString = "", type = "", id = "", description = "", url = "", image = "";

			if (item) {
				type = item.type ? item.type : "";
				id = item.id ? item.id : "";
				description = item.name ? item.name : "";
				url = item.url ? item.url.replace(/\&/g,"%26") : "";
				image = item.image ? item.image : "";

				itemString = "item=" + type + "@@" + id + "@@" + description + "@@" + url + "@@" + image;
				query = query + "&" + itemString + "&";
			}
		}

		ajax.submit("/front/SkyScrapper?Sid=" + this.getSid(null, currentCode, 98), "POST", query.replace(/&&/g, "&"), function (a, b) { alert("À§½Ã¸®½ºÆ®¿¡ ´ã¾Ò½À´Ï´Ù"); scrapper.deselectItem(); });
	}

	this.myCouponLayer = function (display) {
		var myObj;

		if (display != "none") {
			if (!this.isLogin()) {
				if (myObj = document.getElementById(couponNoLoginID)) myObj.style.display = "";
				if (myObj = document.getElementById(couponListID)) myObj.style.display = "none";
			} else {
				if (myObj = document.getElementById(couponNoLoginID)) myObj.style.display = "none";
				if (myObj = document.getElementById(couponListID)) myObj.style.display = "";

				this.loadContents("coupon", "coupon");
			}
		}

		document.getElementById(couponID).style.display = display ? display : "";
	}

	this.viewCouponList = function (listObj) {
		var item, object;

		if (!listObj) return;

		for (var a=0 ; a<listObj.length ; a++) {
			if (item = listObj[a]) {
				if (object = document.getElementById("coupon_layer_name_" + (a+1))) object.innerHTML = item.name;
				if (object = document.getElementById("coupon_layer_value_" + (a+1))) object.innerHTML = item.value;
				if (object = document.getElementById("coupon_layer_count_" + (a+1))) object.innerHTML = item.count;
			}
		}
	}

	this.setBanner = function (banner) {
		if (!(bannerObjects = banner)) return;

		var bannerID = "", linkURL = "";
		var bannerList = new Array();

		for (var a=0 ; a<bannerObjects.length ; a++) {
			if (!(banner = bannerObjects[a])) continue;

			bannerID = "banner_" + banner.manageid + "_" + banner.zoneid + "_" + banner.areaid;

			banner.link = (banner.linkurl ? banner.linkurl : "#") + (banner.sid ? (linkURL.indexOf("?") < 0 ? "?" : "&") + "Sid=" + banner.sid : "");
			banner.image = (banner.imgurl1 ? banner.imgurl1 : (banner.imgurl2 ? banner.imgurl2 : (banner.imgurl3 ? banner.imgurl3 : "")))
			banner.name = banner.itemnm;

			if (!bannerList[bannerID]) bannerList[bannerID] = new Array();

			bannerList[bannerID][bannerList[bannerID].length] = banner;
		}

		scrapperBanner.setBanner(bannerList);
		scrapperBanner.random("banner_01_G06_AO");
		scrapperBanner.change("banner_01_G07_AP");
		scrapperBanner.random("banner_01_G08_AQ");
	}

	this.hideMenu = function () {
		document.getElementById(menuOpenID).style.display = "";
		document.getElementById(menuCloseID).style.display = "none";
		document.getElementById(wrapperID).style.display = "none";

		return;
	}

	this.showMenu = function () {
		document.getElementById(menuOpenID).style.display = "none";
		document.getElementById(menuCloseID).style.display = "";
		document.getElementById(wrapperID).style.display = "";

		return;
	}

	this.optionAlert = function (display) {
		var optionObj;

		if (optionObj = document.getElementById(optionAlertID)) {
			if (navigator.appVersion.indexOf("MSIE 6")) optionObj.onclick = function () { scrapper.optionAlert("none"); }

			optionObj.style.display = !display ? "" : display;
		}
	}

	this.imageOnOff = function (img) {
		if (!img) return;

		if (img.src.indexOf("_on.") > 0) img.src = img.src.replace(/_on\.([a-z]+)$/, "_off.$1");
		else img.src = img.src.replace(/_off\.([a-z]+)$/, "_on.$1");
	}

	this.removeTags = function (myStr) {
		if (!myStr) return "";

		return myStr.replace(/<[^<>]+>/g, "");
	}

	this.numberFormat = function (numberStr) {
		var str = numberStr.replace(/[^0-9.]+/g, "") + "";

		if (isNaN(str) || str == "") return "";

		var rxSplit = new RegExp("([0-9])([0-9][0-9][0-9][,.])");
		var astr = str.split(".");

		astr[0] += ".";

		do {
			astr[0] = astr[0].replace(rxSplit, "$1,$2");
		} while (rxSplit.test(astr[0]));

		if (astr.length > 1) {
			if (astr[1].length > 2) astr[1] = astr[1].substr(0,2);

			return astr.join("");
		} else {
			return astr[0].split(".")[0];
	    }
	}

	this.slide = function (topPosition, moveUnit, intervalTime) {
		var slideObj = document.getElementById(mainID), intervalPixel = 0;

		if (!topPosition) topPosition = defaultTop;
		if (!moveUnit) moveUnit = 3;
		if (!intervalTime) intervalTime = 10;

		slideObj.style.top = topPosition + "px";

		var slideTime = setInterval(function () {
			if (getScrollTop() <= defaultTop) {
				slideObj.style.top = (topPosition = defaultTop) + "px";
				return;
			} else {
				topPosition = scrollOffset;
			}

			if (parseInt(slideObj.style.top.replace(/[^0-9]+/g, "")) != getScrollTop() + topPosition) {
				if (parseInt(slideObj.style.top.replace(/[^0-9]+/g, "")) > getScrollTop() + topPosition) {
					slideObj.style.top = (parseInt(slideObj.style.top.replace(/[^0-9]+/g, "")) - intervalPixel) + "px";
					intervalPixel = intervalPixel + moveUnit;

					if (parseInt(slideObj.style.top.replace(/[^0-9]+/g, "")) < getScrollTop() + topPosition) slideObj.style.top = (getScrollTop() + topPosition) + "px";
				} else if (parseInt(slideObj.style.top.replace(/[^0-9]+/g, "")) < getScrollTop() + topPosition) {
					slideObj.style.top = (parseInt(slideObj.style.top.replace(/[^0-9]+/g, "")) + intervalPixel) + "px";
					intervalPixel = intervalPixel + moveUnit;

					if (parseInt(slideObj.style.top.replace(/[^0-9]+/g, "")) > getScrollTop() + topPosition) slideObj.style.top = (getScrollTop() + topPosition) + "px";
				}
			} else {
				intervalPixel = 0;
			}
		}, intervalTime);
	}

	this.scroll = function (obj) {
		var object = this.getInstance();

		if (navigator.appVersion.indexOf("MSIE 6") > -1) {
			var returnTop = 0;

			if (getScrollTop() <= defaultTop) {
				returnTop = defaultTop;
			} else {
				returnTop = getScrollTop() + scrollOffset;
			}

			return (tempScroll = returnTop) + "px";
		}

		if (getScrollTop() >= defaultTop) {
			object.style.position = "fixed";
			object.style.top = scrollOffset + "px";
		} else {
			object.style.position = "absolute";
			object.style.top = defaultTop + "px";
		}
	}
}

function loadScrapperContents(xmlRequest, vars) {
	if (!window.scrapper || !xmlRequest) return null;

	var xml = xmlRequest.responseXML, code = vars ? vars.replace(/mode=/, "") : "";
	var xmlObject = new Object(), map;

	if (!xml) return null;

	var xmlDoc = xml.getElementsByTagName("result")[0].childNodes;
	var objName, name, value, count1 = 0, count2 = 0;

	for (var a=0 ; a<xmlDoc.length ; a++) {
		objName = xmlDoc[a].nodeName;
		items = xmlDoc[a].childNodes;
		xmlObject[objName] = new Array();

		if (objName == "CC" || objName == "COUPON") {
			xmlObject[objName]["couponCount"] = xmlDoc[a].firstChild ? xmlDoc[a].firstChild.nodeValue : "0";

			scrapper.setCountInfo(xmlObject[objName]);

			if (objName == "CC") continue;
		}

		try { xmlObject[objName]["cartCount"] = xmlDoc[a].getAttribute("cartCount") ? xmlDoc[a].getAttribute("cartCount") : ""; } catch (e) {}
		try { xmlObject[objName]["count1"] = xmlDoc[a].getAttribute("count1") ? xmlDoc[a].getAttribute("count1") : ""; } catch (e) {}
		try { xmlObject[objName]["count2"] = xmlDoc[a].getAttribute("count2") ? xmlDoc[a].getAttribute("count2") : ""; } catch (e) {}

		for (var i=0 ; i<items.length ; i++) {
			map = new Object();
			nodes = items[i].childNodes;

			for (var b=0 ; b<nodes.length ; b++) {
				name = nodes[b].nodeName;
				value = nodes[b].firstChild ? nodes[b].firstChild.nodeValue : "";

				if (name && value) map[name] = value;
			}

			xmlObject[objName][xmlObject[objName].length] = map;
		}

		if (objName == "AD") if (xmlObject[objName] && xmlObject[objName].length > 0) scrapper.setBanner(xmlObject[objName]);
	}

	if (code == "coupon") {
		scrapper.viewCouponList(xmlObject["COUPON"]);
	} else {
		if (code.indexOf("TP") > -1) {
			if (xmlObject[code]) {
				count1 = xmlObject[code].count1 ? xmlObject[code].count1 : 0;
				count2 = xmlObject[code].count2 ? xmlObject[code].count2 : 0;
			}
			
			if (count1 + count2 <= 0) {
				scrapper.openDivision("HI");
				return;
			}
		}

		scrapper.setCountInfo(xmlObject[code]);
		scrapper.setItemCount(xmlObject[code] ? xmlObject[code].length : 0);
		scrapper.setListArea();

		for (var a=0 ; a<scrapper.getMaxItemCount() ; a++) scrapper.setItem(code, a+1, xmlObject[code] ? xmlObject[code][a] : null);
	}

	return xmlObject;
}

function addToWishList(object) {
	var ajax = new Ajax(), query = "action=insert&cmd=WL&";
	var type = "", id = "", description = "", url = "", image = "";

	if (object) {
		id = object.getAttribute("id");
		url = validateWishURL(object.getAttribute("pageurl"));
		description = validateWishDescription(object.getAttribute("description"));
		description = description ? description.replace(/\&/gi,"%26") : "";
		image = object.getAttribute("iconurl");

		query = query + "item=" + (type ? type : " ") + "@@" + (id ? id : " ") + "@@" + description + "@@" + url + "@@" + (image ?  image : " ") + "@@";

		ajax.submit("/front/SkyScrapper", "POST", query.replace(/[&]+/g, "&"), function (a, b) { alert("À§½Ã¸®½ºÆ®¿¡ ´ã¾Ò½À´Ï´Ù"); });
	}
}

function validateWishURL(url) {
	if (!url) {
		var locationString = location.toString().replace(/http:\/\//i, "");
		var temp = locationString.split("/");

		url = locationString.replace(temp[0], "");
	}

	return url;
}

function validateWishDescription(description) {
	if (!description) {
		var navObj = document.getElementById("pageLocation"), temp;

		if (navObj) {
			if (temp = navObj.getElementsByTagName("LI")) {
				for (var a=0 ; a<temp.length ; a++) {
					if (temp[a].className == "now") {
						description = temp[a].innerHTML;
						break;
					}
				}
			}
		}
	}

	return description;
}

/********************************************************/
/*			Á¦   ¸ñ : png24											  */
/*			ÀÛ¼ºÀÚ : UI °³¹ß ÃÖÁØÈ£									  */
/*			ÀÛ¼ºÀÏ : 2009³â 11¿ù 30ÀÏ								  */
/********************************************************/

function setPng24(obj) {
    obj.width = obj.height = 1;
    obj.className = obj.className.replace(/\bpng24\b/i, "");
    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + obj.src + "', sizingMethod='image');"
    obj.src = 'http://uishopimage.hanmail.net/v4/event/20090910_domino/blank.gif';

    return "";
}

function	getScrollTop()	{
	var scrollTop = document.scrollTop ? document.scrollTop : document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;

	return scrollTop;
}

window.scrapperBanner = new Object();

scrapperBanner.setBanner = function (bannerList) {
	this.banners = bannerList;
}

scrapperBanner.clear = function (bannerID) {
	var bannerObj = document.getElementById(bannerID);

	if (bannerObj) {
		bannerObj.innerHTML = "";
		return bannerObj;
	}
}

scrapperBanner.add = function (bannerID, banner) {
	var bannerObj = document.getElementById(bannerID);
	var divObj, linkObj, imgObj;

	divObj = document.createElement("DIV");
	divObj.style.overflow = "hidden";

	linkObj = document.createElement("A");
	linkObj.target = "_blank";
	linkObj.href = banner.link;

	imgObj = document.createElement("IMG");
	imgObj.src = banner.image
	imgObj.alt = banner.name;

	linkObj.appendChild(imgObj);
	divObj.appendChild(linkObj);
	bannerObj.appendChild(divObj);
}

scrapperBanner.view = function (bannerID, no) {
	var bannerList = this.banners[bannerID], bannerObj = this.clear(bannerID), banner, childs;

	if (!(bannerList && bannerList.length) || !bannerObj) return;
	if (!(banner = bannerList[no % bannerList.length])) return;

	scrapperBanner.add(bannerID, banner);
}

scrapperBanner.random = function (bannerID) {
	var bannerList = this.banners[bannerID], bannerObj = this.clear(bannerID), banner, childs;
	var rand = Math.round(Math.random() * 10000);

	if (!(bannerList && bannerList.length) || !bannerObj) return;
	if (!(banner = bannerList[rand % bannerList.length])) return;

	scrapperBanner.add(bannerID, banner);
}

scrapperBanner.change = function (bannerID, bannerNo, sleepTime) {
	var bannerList = this.banners[bannerID], bannerObj = this.clear(bannerID);

	if (!(bannerList && bannerList.length) || !bannerObj) return;
	if (bannerNo > bannerList.length - 1 || typeof bannerNo == "undefined") bannerNo = 0;

	scrapperBanner.add(bannerID, bannerList[bannerNo]);

	setTimeout(function () {
		scrapperBanner.change(bannerID, ++bannerNo, sleepTime);
	}, sleepTime ? sleepTime : 2000);
}

scrapperBanner.rolling = function (bannerID, offset, runTime, sleepTime) {
	var panel = document.getElementById(bannerID), banner = this.init(bannerID), tempWidth = 0;

	if (!(banner && banner.length)) return;
	if (!this.timeID) this.timeID = new Array();
	if (!this.timeID[bannerID]) this.timeID[bannerID] = new Array();

	for (var a=0 ; a<banner.length ; a++) {
		banner[a].style.display = "";

		if (!banner[a].getAttribute("orgWidth")) banner[a].setAttribute("orgWidth", banner[a].offsetWidth);
	}

	this.timeID[bannerID] = setInterval(function () {
		var parentObj;

		if (banner[0].offsetWidth > 0) {
			tempWidth = banner[0].offsetWidth - (offset ? offset : 10);
			banner[0].style.width = (tempWidth > 0 ? tempWidth : 0) + "px";
		} else {
			clearInterval(scrapperBanner.timeID[bannerID]);

			firstBanner = banner[0].cloneNode(true);
			firstBanner.style.width = parseInt(firstBanner.getAttribute("orgWidth")) + "px";

			panel.removeChild(banner[0]);
			panel.appendChild(firstBanner);

			setTimeout(function () {
				scrapperBanner.rolling(bannerID, offset, runTime, sleepTime);
			}, sleepTime ? sleepTime : 1000);
		}
	}, runTime ? runTime : 100);
}

function setDragnDrop(frameName) {
}

addEvent(window, "onload", function () {
	if (window.skyScrapperDisabled) return;

	if (navigator.appVersion.indexOf("MSIE 6") > 0) {
//		if (window.scrapper) scrapper.getInstance().style.setExpression("top", "scrapper.scroll()");
//		if (window.scrapper) if (scrapper.slide) scrapper.slide();
	} else {
//		if (navigator.appVersion.indexOf("MSIE") > 0 && location.toString().replace(/(http:\/\/)([0-9a-z\-]+\.)?dnshop\.([0-9a-z\-]+\.)?[0-9a-z\-]+/, "").indexOf("/html/event/event") == 0) {
		if (navigator.appVersion.indexOf("MSIE") > 0 && (document.compatMode == "BackCompat" || document.compatMode != "CSS1Compat")) {
			if (window.scrapper) if (scrapper.slide) scrapper.slide();
		} else {
			addEvent(window, "onscroll", function () { scrapper.scroll(); });
		}
	}
});
