/**
	JavaScript °øÅëÇÔ¼ö Util
	ÆË¾÷ /
*/

var __FRONT_ITEM_IMG = "http://itemimage.cjmall.com/item_images";

/******************************************
* ÄíÅ°¸íÀ»³Ñ°ÜÁÖ¸é ÄíÅ°°ªÀ» ÁØ´Ù
* parameter : ÄíÅ°¸í
*******************************************/
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 setCookie(name, value, expiredays) {
	var endDate = new Date();
	endDate.setDate(endDate.getDate() + expiredays);
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + endDate.toGMTString() + ";"
}

/********************************************************
	ÆË¾÷ ¿ÀÇÂ °øÅëÇÔ¼ö
********************************************************/
function win_pop(path, win_name, width, height, scroll) {
	window.open(path,win_name,'width=' + width + ', height=' + height + ', resizable=no, scrollbars=' + scroll + ', status=no, toolbar=no');
}

/********************************************************
	ÄíÅ°¸¦ Ã¼Å©ÇØ¼­ °ªÀÌ ¾øÀ» °æ¿ì ÆË¾÷ ¿ÀÇÂ
********************************************************/
function win_pop_cookie(p_url, win_name, p_width, p_height, scroll_yn, cookie_name, p_left, p_top) {
	if ( getCookie( cookie_name ) == "" ) {
		window.open(p_url, win_name, 'width=' + p_width + ',height=' + p_height + ',scrollbars=' + scroll_yn + ',left=' + p_left + ',top=' + p_top);
	}
}


/************************************************************
	¸Æ½ºÆ¼ÄÏ ¸µÅ© Ã³¸®
************************************************************/
function goTicketUrl(pUrl, win_type) {

	// ¸Æ½ºÆ¼ÄÏ ¸µÅ© URL ÀÌ ³Ñ¾î¿ÀÁö ¾Ê´Â °æ¿ì..
	// ¸Æ½ºÆ¼ÄÏ ¸ÞÀÎÈ­¸éÀ¸·Î ¿¬°áÇÔ
	if ( pUrl == "" ) {
		pUrl = "http://maxticket.maxmovie.com"
	}

	// HTTP ÇÁ·ÎÅäÄÝÀÌ ¾ø´Â °æ¿ì, http:// ¸¦ ºÙ¿©ÁØ´Ù
	if ( pUrl.indexOf("http://") == -1 ) {
		pUrl = "http://" + pUrl;
	}

	// ¸Æ½ºÆ¼ÄÏ ¸ÞÀÎ ¸µÅ©ÀÏ °æ¿ì, °ø¿¬¸µÅ©·Î °­Á¦º¯°æÇØÁØ´Ù
	// ¸Æ½ºÆ¼ÄÏÀÇ ¸ÞÀÎÀº °ø¿¬ÀÓ
	if ( pUrl == "http://maxticket.maxmovie.com" ) {
		pUrl += "/controls/front/art/ArtMain";
	} else if ( pUrl == "http://maxticket.maxmovie.com/" ) {
		pUrl += "controls/front/art/ArtMain";
	}

	if ( pUrl.indexOf("?") == -1 ) {
		pUrl += "?";
	} else {
		pUrl += "&amp;";
	}

	pUrl += "referer=www.cjmall.com";

	// ¸µÅ©º¯°æ ¿äÃ» [¿äÃ»ÀÚ : ¸Æ½ºÆ¼ÄÏ, iSR : 2009041253]
	pUrl = "http://maxticket.maxmovie.com/controls/front/login/ChannelToTicket?chn_no=001006007&amp;tg_url=" + pUrl;

	if ( win_type  == 'new' ) {
		window.open(pUrl);
	} else {
		document.location = pUrl;
	}
}

function refreshParentPage(url)
{
	parent.location.replace(url);
}


/************************************ ±âÁ¸ °øÅë END *****************************************/


/**
 * ¼±ÅÃµÈ TAB ÀÇ ³»¿ëÀ» º¸¿©ÁÖ´Â °øÅë ÇÔ¼ö (jquery È°¿ë) : Å¬·¡½º ON/OFF
 * °¢ TAB ¹× Target ÀÇ ID °ªÀº 0 ºÎÅÍ ½ÃÀÛÇØ¾ß ÇÑ´Ù
 *
 * @param	 tabSize		TAB Size
 * @param	 tabId			°øÅë TAB ID
 * @param	 idx			¼±ÅÃµÈ TAB ÀÎµ¦½º
 * @param	 targetId		°øÅë Target ID
 *
 * »ç¿ë ¿¹) tabViewList(5, '#thema_planning_1340_tab', 0, '#thema_planning_1340_tab_list')
 *				tabViewList(tabSize, '#TAB ID', 0, '#Target ID')
 */
function tabViewList(tabSize, tabId, idx, targetId) {

	for ( var i = 0; i < tabSize; i++ ) {
		if ( i == idx ) {
			$(tabId + i)[0].className = $(tabId + i)[0].className.replaceAll(" tab_off", " tab_on");

			if ( $(targetId + i) ) {
				$(targetId + i).show();
			}
		} else {
			$(tabId + i)[0].className = $(tabId + i)[0].className.replaceAll(" tab_on", " tab_off");

			if ( $(targetId + i) ) {
				$(targetId + i).hide();
			}
		}
	}
}

/**
 * ¼±ÅÃµÈ TAB ÀÇ ³»¿ëÀ» º¸¿©ÁÖ´Â °øÅë ÇÔ¼ö (jquery È°¿ë) : ÀÌ¹ÌÁö ON/OFF
 * °¢ TAB ¹× Target ÀÇ ID °ªÀº 0 ºÎÅÍ ½ÃÀÛÇØ¾ß ÇÑ´Ù
 *
 * @param	 tabImgSize	TAB Size
 * @param	 tabImgId		°øÅë TAB ID
 * @param	 idx				¼±ÅÃµÈ TAB ÀÎµ¦½º
 * @param	 targetId			°øÅë Target ID
 *
 * »ç¿ë ¿¹) tabImgViewList(4, '#rank_1790_tab', 0, '#rank_1790_tab_list')
 *				tabImgViewList(tabImgSize, '#TAB ID', 0, '#Target ID')
 */
function tabImgViewList(tabImgSize, tabImgId, idx, targetId) {

	for ( var i = 0; i < tabImgSize; i++ ) {
		if ( i == idx ) {
			$(tabImgId + i)[0].src = $(tabImgId + i)[0].src.replace("_off.", "_on.");

			if ( $(targetId + i) ) {
				$(targetId + i).show();
			}
		} else {
			$(tabImgId + i)[0].src = $(tabImgId + i)[0].src.replace("_on.", "_off.");

			if ( $(targetId + i) ) {
				$(targetId + i).hide();
			}
		}
	}
}

/**
 * »óÇ° ÀÌ¹ÌÁö URL À» »ý¼º
 *
 * @param	 itemCd		»óÇ°ÄÚµå
 * @param	 imgType	ÀÌ¹ÌÁöÅ¸ÀÔ (L, M, J, V, K, S µî)
 * @param	 imgExt		ÀÌ¹ÌÁö È®ÀåÀÚ (gif, jpg)
 *
 */
function getItemImagePath(itemCd, imgType, imgExt) {
	var itemImgPath = "";
	var subDir = "";

	subDir = itemCd.substring(itemCd.length - 2);

	// __FRONT_ITEM_IMG ´Â jsCommonUtil.js ÆÄÀÏ¿¡ Àü¿ªº¯¼ö ¼±¾ðµÅ ÀÖÀ½
	itemImgPath = __FRONT_ITEM_IMG.concat("/").concat(subDir).concat("/");
	itemImgPath = itemImgPath.concat(itemCd).concat(imgType).concat(".").concat(imgExt);

	return itemImgPath;
}

/**
 * »óÇ°ÀÌ¹ÌÁö ¸®½ºÆ® Áß, ÀÌ¹ÌÁö¿¡ ¸¶¿ì½º¿À¹öµÆÀ» °æ¿ì
 * ÀÌ¹ÌÁö¿µ¿ª¿¡ ¿øÇÏ´Â Å¸ÀÔÀÇ ÀÌ¹ÌÁö¸¦ º¸¿©ÁØ´Ù
 *
 * @param	 imgId		Display ÀÌ¹ÌÁö¿µ¿ª ID
 * @param	 itemCd		»óÇ°ÄÚµå
 * @param	 imgType	ÀÌ¹ÌÁöÅ¸ÀÔ (L, M, J, V, K, S µî)
 * @param	 imgExt		ÀÌ¹ÌÁö È®ÀåÀÚ (gif, jpg)
 *
 */
function imgPageAnchor(imgId, itemCd, imgType, imgExt) {
	var itemImgPath = "";
	itemImgPath = getItemImagePath(itemCd, imgType, imgExt);

	if ( $(imgId) && itemImgPath != "" ) {
		$(imgId)[0].src = itemImgPath;
	}
}

/**
 * °í°´ÀÌ ¸»ÇÏ´Â ÀÌ·² ¶§ ÀÌ·± »óÇ° 
 * ÅÇ ¸¶¿ì½º ¿À¹ö½Ã µ¿ÀÛÇÏ´Â ½ºÅ©¸³Æ®
 *
 */
function tab1370(tabSize, tabId, idx, targetId) {
	var flashObjId = "#1370flash";

	for ( var i = 0; i < tabSize; i++ ) {
		if ( i == idx ) {
			$(flashObjId + i).show();
		} else {
			$(flashObjId + i).hide();
		}
	}

	tabViewList(tabSize, tabId, idx, targetId);
}

function imageOver(imgEl) {
	imgEl.src = imgEl.src.replaceAll("_off.", "_on.");
}

function imageOut(imgEl) {
	imgEl.src = imgEl.src.replaceAll("_on.", "_off.");
}

/******************************************
* Flash ¿¡¼­ È£ÃâÇÏ´Â ÇÔ¼ö Start
*******************************************/
// Flash »çÀÌÁî Á¶Àý
function setSize(id, h, w) {
	var obj = $("#" + id);

	if ( h ) {
		obj[0].height = h;
	}

	if ( w ) {
		obj[0].width = w;
	}
}


// Layer »çÀÌÁî Á¶Àý
function setLayerSize(id, h, w) {
	var obj = $("#" + id);

	if ( h ) {
		obj.css("height", h.indexOf("px") > -1 ? h : h + "px");
	}

	if ( w ) {
		obj.css("width", w.indexOf("px") > -1 ? w : w + "px");
	}
}

// ·¹ÀÌ¾î Show/Hidden Ã³¸®
function displayLayer(id, disp) {
	$("#" + id).css("display", disp);

	if ( id = "microLayerFlashDiv" ) {
		if ( disp == "none" ) {
			$("#" + id).css("width", "0");
			$("#" + id).css("height", "0");
		} else {
			$("#" + id).css("width", "743px");
			$("#" + id).css("height", "405px");
		}
	}
}

// ´ëºÐ·ù ¸ÅÀå Ä«Å×°í¸®¿¡¼­ »ç¿ë
function setSizeLargeCate(id, p_height_1, p_height_2, p_width)
{
	var objFlashCate	= $("#" + id);
	var objDivMenu		= $("#divMenu");
	
	/************************************************************
		C¿µ¿ªÀÌ ¾ø¾îµµ B¿µ¿ªÀÌ ¿Ã¶ó¿Í Ä«Å×°í¸®¿Í °ãÄ¡Áö ¾Êµµ·Ï 
		·¹ÀÌ¾î ³ôÀÌ°ªÀ» °íÁ¤ÇÑ´Ù.
	************************************************************/
	objDivMenu.css("height", p_height_1 + "px");

	/************************************************************
		ÇÃ·¡½Ã¿¡¼­ »çÀÌÁî º¸³»ÁÖ¸é ÇÃ·¡½Ã ¿µ¿ª »çÀÌÁî º¯°æÇÔ
	************************************************************/
	objFlashCate[0].width	= p_width + "px";
	objFlashCate[0].height	= p_height_2 + "px";
}


/******************************************
* Flash ¿¡¼­ È£ÃâÇÏ´Â ÇÔ¼ö End
*******************************************/

function open_Micro()
{
	window.open( '/oshopping/intro.jsp','oshopping','width=1000,height=700,resizable=yes,scrollbars=yes, status=no,toolbar=no, left=100,  top=150');
}

/**********************************************
	ºê¶ó¿ìÁ® Ã¼Å© (2009-06-05 By RahXephon)
**********************************************/
function checkBrowser()
{
	var userAgent	= navigator.userAgent.toLowerCase();
	var browser		= "";

	if ( userAgent.indexOf("msie 8.0") >= 0 ) 
		browser	= "ie8";
	else if ( userAgent.indexOf("msie 7.0") >= 0 )
		browser	= "ie7";
	else if ( userAgent.indexOf("msie 6.0") >= 0 )
		browser	= "ie6"
	else if ( userAgent.indexOf("firefox") >= 0 )
		browser	= "firefox";
	else if ( userAgent.indexOf("chrome") >= 0 )
		browser	= "chrome";
	else if ( userAgent.indexOf("safari") >= 0 )
		browser	= "safari";
	else if ( userAgent.indexOf("opera") >= 0 )
		browser	= "opera";

	return browser;
}

/**
 * CJmall Áñ°ÜÃ£±â Ã³¸®
 * ÀÌº¥Æ®URL ÀÌ ÀÖÀ» °æ¿ì¿¡´Â ÀÌº¥Æ®ÆäÀÌÁö·Î ¿¬°á
 * ÀÌº¥Æ®URL ÀÌ ¾øÀ» °æ¿ì¿¡´Â Áñ°ÜÃ£±â ´ÙÀÌ¾ó·Î±× Ã¢ º¸¿©ÁÜ
 *
 * @param eventURL			ÀÌº¥Æ®ÆäÀÌÁö URL
 * @param	 bookmarkTitle	Áñ°ÜÃ£±â ÀÌ¸§
 * @param	 bookmarkURL	Áñ°ÜÃ£±â URL
 */
function bookmarkCJmall(eventURL, bookmarkTitle, bookmarkURL) {
	if ( bookmarkTitle == "" ) {
		bookmarkTitle = "LIFESTYLE SHOPPER - CJmall";
	}

	if ( bookmarkURL == "" ) {
		bookmarkURL = "http://www.cjmall.com/";
	}

	if ( eventURL != "" ) {
		top.location.href = eventURL;
	} else {
		if ( $.browser.mozilla ) {
			window.sidebar.addPanel(bookmarkTitle, bookmarkURL, ""); 
		} else if ( $.browser.msie ) {
			window.external.AddFavorite(bookmarkURL, bookmarkTitle);
		}
	}
}

/**
 *	vista ÀÎÁö Ã¼Å©
 *	2007-01-31 By RahXephon
 */
function vistaCheck()
{
	var navi		= navigator.appVersion.split(";");
	var os_version	= navi[2]

	if ( os_version.indexOf("Windows NT 6.0") >= 0 ) 
		return true;
	else 
		return false;
}

//png ÀÌ¹ÌÁö Àû¿ë
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				= '';
	return '';
}

// ·Ñ¿À¹ö
function menuOver(obj) { obj.src = obj.src.replace("_off.gif", "_on.gif");}
function menuOut(obj) { obj.src = obj.src.replace("_on.gif", "_off.gif");}
