/*현재위치 select box 제어 start*/
function locSelView(num,over){
	var listDiv = dEI('locSelLs' + num);
	if(over == 'over')
		{listDiv.style.visibility = 'visible';}
	else
	{listDiv.style.visibility = 'hidden';}
}

function locSelWidth(num){
	var viewDiv = dEI('locSelW' + num)
	var listDiv = dEI('locSelLs' + num)
	var viewDivWidth = viewDiv.clientWidth;
	var listDivWidth = listDiv.clientWidth;	
	if(viewDivWidth > listDivWidth)
	{
		//if(viewDivWidth > 103) viewDivWidth = viewDivWidth-2;
		listDiv.style.width = viewDivWidth-2+"px";
	}
	if(viewDivWidth < listDivWidth)
	{
		//if(listDivWidth > 103) listDivWidth = listDivWidth-2;
		viewDiv.style.width = listDivWidth+2+"px";
	}
}

/*페이지 비활성화*/
function dimLayerView(dim) {
	var oBody = ( document.compatMode && document.compatMode!="BackCompat" ) ? document.documentElement : document.body  ;
	var cheight= ( oBody.scrollHeight > oBody.clientHeight ? oBody.scrollHeight : oBody.clientHeight  ) + 'px';
	if(!dim){
		document.getElementsByTagName("html")[0].style.overflowY="hidden";
		//dEI("shopWrapper").style.paddingRight="16px";
		dEI('dimLay').style.display = "block";
		dEI('dimLay').style.height = cheight;
		chgSelect();
	}
}
function resizeFrame(subWin){
	var guestDoc = subWin.contentWindow.document.getElementById("frameCon");
	var frameHeight = guestDoc.offsetHeight;
	subWin.style.height = frameHeight + 1 + "px";
}


function dimLayerClose() {
	
	if (document.getElementById('ifr_prView') == null) return;
	
	parent.dEI('dimLay').style.display = "none";
	parent.document.getElementsByTagName("html")[0].style.overflowY="auto";
	if (document.getElementById('ifr_prView')){
		thisCon=document.getElementById('ifr_prView');
	} else {
		thisCon=document.getElementById('ifrPre').contentWindow.document.getElementById("ifr_prView");
	}
	if(thisCon) {
		thisCon.className += " offView";
	}
	//parent.dEI("shopWrapper").style.paddingRight="0px";
		if(parent.dEI('layQuickView')){
			parent.dEI('layQuickView').style.display="none";
		}
		parent.chgSelectDefaut();
}

//CENTER POSITION check
var ObjTemp = {};
function viewLayer(the_id, the_width, the_height, dim) 
{
	var lfrm = dEI(the_id); 
	if(!dim) {
	dimLayerView(null);
	//document.getElementsByTagName("html")[0].style.overflowY="hidden";
	//dEI("shopWapper").style.paddingRight="16px";
	getviewpoint();
	showLayer(the_id);

	lfrm.style.left = ObjTemp.scroll_left + ((ObjTemp.docwidth-lfrm.offsetWidth) / 2) + "px";
	lfrm.style.top = ObjTemp.scroll_top + ((ObjTemp.docheight-lfrm.offsetHeight) / 2) + "px";
	lfrm.width = the_width + "px";
	lfrm.height = the_height + "px";
	}

}

window.onresize = function()
{

var laySizeQuick = dEI('layQuickView'); 
	getviewpoint();
	if(laySizeQuick){laySizeQuick.style.top = ObjTemp.scroll_top + ((ObjTemp.docheight-laySizeQuick.offsetHeight) / 2) + "px";}
	if(laySizeQuick){laySizeQuick.style.left = ObjTemp.scroll_left + ((ObjTemp.docwidth-laySizeQuick.offsetWidth) / 2) + "px";}
}
function getviewpoint()
{
    var ie=document.all && !window.opera;
   var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000; //Preliminary doc width in non IE browsers
    ObjTemp.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body; //create reference to common "body" across doctypes
    ObjTemp.scroll_top=(ie)? ObjTemp.standardbody.scrollTop : window.pageYOffset;
   ObjTemp.scroll_left=(ie)? ObjTemp.standardbody.scrollLeft : window.pageXOffset;
  ObjTemp.docwidth=(ie)? ObjTemp.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16);
    ObjTemp.docheight=(ie)? ObjTemp.standardbody.clientHeight: window.innerHeight;
}


//카테고리
function categorymovie(over){
	if(over=='over')
	{
		dEI('sub_category').style.width='992px';
		chgSelect();
	}
	else
	{
		setTimeout("dEI('sub_category').style.width='194px'",1000);
		setTimeout("dEI('sub_category').style.height='30px'",1000);
		chgSelectDefaut();
	}
}

function icoView(obj){
	dEI(obj).className="icoLayer icoOn";
}
function icoHide(obj){
	dEI(obj).className="icoLayer";
}


//검색레이어
function over_select(idx) {
	var tmpObj = dEI(idx);
	tmpObj.style.display = "";
}

function out_select(idx) {
	var tmpObj = dEI(idx);
	tmpObj.style.display = "none";
}


function toggleLs(obj, num, total) {
	for(i = 1; i <= total; i++){
		if (dEI(obj+'_'+i).style.display == "block") {
			dEI(obj+'_'+i).style.display="none";
			dEI(obj+'Q_'+i).className="replyList";
		}else {
		dEI(obj+'_'+i).style.display= (num==i)?"block":"none";
		dEI(obj+'Q_'+i).className= (num==i)?"replyList click":"replyList";
		}
	}
}

function addClass(element,value) {
  if (!element.className) {
    element.className = value;
  } else {
    newClassName = element.className;
    newClassName+= " ";
    newClassName+= value;
    element.className = newClassName;
  }
}


function showLp(num){
	
	var obj=dEI('secMenuIn'+num);
	var obj1=dEI('secMenu'+num);
	//if(obj==null || obj1==null) return;
	obj1.className="on";
	var onImg = obj1.getElementsByTagName("img").item(0);
	var onImgO = obj1.getElementsByTagName("img").item(1);
	//onImg.src=onImg.src.replace("_off.gif", "_on.gif");
	if(onImgO){
		//onImg.style.display='none';
		//onImgO.style.display='';
	}
}
function hideLp(num){
	var obj=dEI('secMenuIn'+num);
	var obj1=dEI('secMenu'+num);
	//if(obj==null || obj1==null) return;
	obj1.className="off";
	var onImg = obj1.getElementsByTagName("img").item(0);
	var onImgO = obj1.getElementsByTagName("img").item(1);
	//onImg.src=onImg.src.replace("_on.gif", "_off.gif");
	if(onImgO){
		//onImg.style.display='';
		//onImgO.style.display='none';
	}
}

function selHide() {
	var selectObj = document.getElementsByTagName("select");
	if(appname=="IE" && IE55 || IE6) {
		for (var i=0; i<selectObj.length; i++) {
			if (selectObj.item(i).className == "selHide") selectObj.item(i).style.visibility="hidden";
		}
	}
}
function selShow() {
	var selectObj = document.getElementsByTagName("select");
	if(appname=="IE" && IE55 || IE6) {
		for (var i=0; i<selectObj.length; i++) {
			if (selectObj.item(i).className == "selHide") selectObj.item(i).style.visibility="visible";
		}
	}
}

function selHideIn(target) {
	var selectObj = document.getElementsByTagName("select");
	if(appname=="IE" && IE55 || IE6) {
		for (var i=0; i<selectObj.length; i++) {
			if (selectObj.item(i).className == target) selectObj.item(i).style.visibility="hidden";
		}
	}
}
function selShowIn(target) {
	var selectObj = document.getElementsByTagName("select");
	if(appname=="IE" && IE55 || IE6) {
		for (var i=0; i<selectObj.length; i++) {
			if (selectObj.item(i).className == target) selectObj.item(i).style.visibility="visible";
		}
	}
}


function initToggleList(ulEl, que, ans) {
	currentListNum = false;
	queEl = ulEl.getElementsByTagName(que);
	ansEl = ulEl.getElementsByTagName(ans);

	for (i=0;i<queEl.length;i++) {
		ansEl.item(i).listNum = i;
		queEl.item(i).listNum = i;
		ansEl.item(i).className = "off";
		queEl.item(i).onclick = toggleList;
	}
}
function toggleList () {
	if (currentListNum != false && this.listNum != currentListNum-1 ) {
		queEl.item(currentListNum-1).className = null;
		ansEl.item(currentListNum-1).className = "off";
	}
	if (this.className == "on") {
		queEl.item(this.listNum).className = null;
		ansEl.item(this.listNum).className = "off";
		currentListNum = false;
	} else {
		this.className = "on";
		ansEl.item(this.listNum).className = "on";
		currentListNum = this.listNum + 1;
	}
}

function cateView(num){
	if(num=="max"){
		dEI('cateView').style.width='900px';
		dEI('cateView').style.height='411px';
	}else if(num=="min"){
		dEI('cateView').style.width='154px';
		dEI('cateView').style.height='43px';
	}
}


function sizeControl(num){
	if(num=="max"){
		//alert(num);
		dEI('mateIframe').style.height='266px';
		dEI('widgetWrap').style.height='266px';
	}else if(num=="min"){
		//alert(num);
		dEI('mateIframe').style.height="31px";
		setTimeout("dEI('widgetWrap').style.height='31px'",500);
		//dEI('widgetWrap').style.height="31px";
	}
}
function openMate(){
	if(navigator.appName.indexOf("Microsoft") != -1) 
		{
			dEI('mateIframe').style.height='266px';
			dEI('widgetWrap').style.height='266px';
			window['externalInterfaceExample'].menuOpen();
			
		}
	else 
		{
		dEI('mateIframe').style.height='266px';
		dEI('widgetWrap').style.height='266px';
		document['externalInterfaceExample'].menuOpen();
		}
	
}

function callExternalInterface(num) {
	dEI('mateIframe').style.height='266px';
	dEI('widgetWrap').style.height='266px';
	getMovieName("shoppingMate").menuOpen(num); 
}
function callDelete(num) {
	getMovieName("shoppingMate").mateControl(num); 
}
function getMovieName(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
   }
   else {
       return document[movieName]
   }
}













//★★ 개발팀 추가 ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
//★★  START        ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

function goU_R_L( url ){
	location.replace( url );
}

var onloads = new Array();
function bodyOnLoad() {
    for ( var i = 0 ; i < onloads.length ; i++ )
    onloads[i]();
}



function ltrim(s){
	var im = "";
	for(var i=0; i<s.length; i++){
		im = s.substring(i,i+1);
		if (im != " ")
		{
			return  s.substring(i,s.length);
		}
	}
	return "";
}

function rtrim(s){
	var im = "";
	for(var i=s.length-1; i>=0; i--){
		im = s.substring(i,i+1);
		if (im != " ")
		{
			return  s.substring(0,i+1);
		}
	}
	return "";
}

function isInteger (s){   
		var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}

//공백 체크
function IsEmpty(source,comment)
{
	if(source.value.length == 0)
	{
		source.focus();
		alert(comment);
		return false;

	}
	return true;
}

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

//*********************************************************************
//Method	: String.trim
//Purpose	: Removing leading and trailing space.
//Inputs	: None
//Returns	: String
//*********************************************************************
String.prototype.trim = function (){
	var thisStr = ""+this;
 if(thisStr=="undefined")
     thisStr = "";
 var objRegExp = /^(\s*[　]*[ ]*)$/;
 if(objRegExp.test(thisStr))
 {
     var strValue = thisStr.replace(objRegExp,'');
     if( strValue.length == 0 ) return strValue;
 }

 objRegExp = /^(\s*[　]*[ ]*)([\w\W]*)(\b\s*[　]*[ ]*$)/;
 if(objRegExp.test(thisStr))
 {
     return thisStr.replace(objRegExp,'$2');
 }

 return thisStr;
}


 //-----------------------------------------------------------------------------
 // 숫자에 3자리마다 , 를 찍어서 반환
 // @return : String
 //-----------------------------------------------------------------------------
 String.prototype.money = function() {
     var num = this.trim();
     while((/(-?[0-9]+)([0-9]{3})/).test(num)) {
         num = num.replace((/(-?[0-9]+)([0-9]{3})/), "$1,$2");
     }
     return num;
 }

//*********************************************************************
//Method	: String.toFloat
//Purpose	: String to Float
//Inputs	: None
//Returns	: Float
//*********************************************************************
String.prototype.nullchk = function ()
{
 if(this==null||this==undefined||this=="undefined" || this=="---N/A---")
     return "";
 else
     return this;
}

String.prototype.null2zero = function ()
{
 if(this==null||this==undefined||this=="undefined" || this=="---N/A---")
     return "0";
 else
     return this;
}

String.prototype.zero2null = function ()
{
 if(this==null||this==undefined||this=="undefined" || this=="---N/A---" || this=="0")
     return "";
 else
     return this;
}

//*********************************************************************
//Method : var String = new StringBuffer();
//Purpose : String to StringBuffer
//Inputs : None
//Returns : StringBuffer
//*********************************************************************
var StringBuffer = function() {
this.buffer = new Array();
}
//*********************************************************************
//Method : String.append("text");
//Purpose : add to StringBuffer
//Inputs : Text
//Returns : StringBuffer
//*********************************************************************

StringBuffer.prototype.append = function(obj) {
this.buffer.push(obj);
}
//*********************************************************************
//Method : StringBuffer.toString()
//Purpose : StringBuffer to String
//Inputs : None
//Returns : String
//*********************************************************************
StringBuffer.prototype.toString = function() {
return this.buffer.join("");
}


//*********************************************************************
//Method	: numOnly
//Purpose	: number only check
//Inputs	: None (Key Event)
//Returns	: None (Key Event Control)
//*********************************************************************

//숫자, 엔터, 탭 키만 입력가능
function numOnly(obj){
	var val = obj.value;

	re = /[^0-9]/gi;
	obj.value = "";
	obj.value = val.replace(re, "");
	
}


String.prototype.nl2br = function ()
{
 var retStr = this;
if(this==null||this==undefined||this=="undefined")
     return "";
     
 var objRegExp1 = /\n/g;
 var objRegExp2 = /\r/g;

 if(objRegExp1.test(this)){
     retStr = this.replace(/\n/g,'<br />');
 }else if(objRegExp2.test(this)){
  retStr = this.replace(/\r/g,'<br />');
 }

 return retStr;
}


function Upper(obj){
	obj.value = obj.value.toUpperCase();
}

function SetNum(obj){  //숫자만 체크
	 val=obj.value;
	 re=/[^0-9]/gi;
	 if(isNaN(val))alert("Input number only");
	 obj.value=val.replace(re,"");
}

function SetDotNum(obj){  //숫자만 체크
	 val=obj.value;
	 re=/[^0-9].[^0-9]/gi;
	 if(isNaN(val))alert("Input number only ");
	 obj.value=val.replace(re,"");
}

function AutoNum(obj){  //숫자만 체크(Alert 없이)
	 val=obj.value;
	 re=/[^0-9]/gi;
	 obj.value=val.replace(re,"");
}

function AutoDotNum(obj){  //숫자만 체크(Alert 없이)
	 val=obj.value;
	 re=/[^0-9].[^0-9]/gi;
	 obj.value=val.replace(re,"");
}


function SetNum2(obj,max){  //숫자만 체크
	 val=obj.value;
	 re=/[^0-9]/gi;
	 if(isNaN(val)){
		 alert("Input number only.");
		 obj.value=val.replace(re,"0");
	 }else{
		 if( +val > max ){
			alert("can not be more than "+max+".");
			obj.value=val.replace(re,"0");
		 }
	 }
}

function Left(str, n){
	if (n <= 0)
	 return "";
	else if (n > String(str).length)
	 return str;
	else
	 return String(str).substring(0,n);
}

function Right(str, n){
 if (n <= 0)
    return "";
 else if (n > String(str).length)
    return str;
 else {
    var iLen = String(str).length;
    return String(str).substring(iLen, iLen - n);
 }
}

//한글,영문이 섞여있는 경우, 총 byte수를 리턴한다.
function getByteLength(s){
   var len = 0;
   if ( s == null ) return 0;
   for(var i=0;i<s.length;i++){
      var c = escape(s.charAt(i));
      if ( c.length == 1 ) len ++;
      else if ( c.indexOf("%u") != -1 ) len += 2;
      else if ( c.indexOf("%") != -1 ) len += c.length/3;
   }
   return len;
}

function __SetAll(){
	var resultSelect = $('frm').getElementsByTagName('input');

	for(var i=0; i<resultSelect.length; i++){
		if( resultSelect[i].name != "" ){
			$(resultSelect[i].name).value = "1";
		}
	}
}






//★★페이지 이동함수 

function goPageMove(mapUrl,rtnPage,_target){
	var frmPageMove = document.forms["formPageMove"];

	if(rtnPage != undefined) frmPageMove.page.value = rtnPage;
	
	frmPageMove.target = "_self";
	if(_target!=undefined) frmPageMove.target = _target;

	frmPageMove.action = mapUrl;
	frmPageMove.submit();
}



//★★Load시 키를 호출 페이지로 넘기기위한 쿠키함수 
function __setKeyVal(key, value) { 
	document.cookie = key + "=" + value +";" 
	
}

function __getKeyVal(key){
	cookies = document.cookie+";";
	if((pos = cookies.indexOf( key + "=" ))== -1) {
		return false;
	}else{
		spos = cookies.indexOf( "=" , pos );
		epos = cookies.indexOf( ";" , spos );
		rtn = cookies.substring( spos+1 , epos );
		//setKeyVal(key);
		
		return rtn;
	}
}


//★★Load시 키를 호출 페이지로 넘기기위한 Session 함수
function setKeyVal(key, value) { 
	var frmSession = document.forms["FormSession"];
	frmSession.ss_key.value = key;
	frmSession.ss_value.value = value;

	frmSession.target = "iFrameAction";
	frmSession.action = "/static_root/comm_jsp/setKeySession.jsp";
	frmSession.submit();
}

//★★ 리스트체크박스 
function allCheck() { 
	var frm = document.forms["frm"];
	if(frm.allcheck.checked){
		for(var i=1; i<frm.check.length; i++){
			frm.check[i].checked = true;
		}
	}else{
		for(var i=1; i<frm.check.length; i++){
			frm.check[i].checked = false;
		}
	}
}



//★★ 상품 및 브랜드이미지 생성하는 자바스크립트함수 START ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
//상품이미지경로
ImageUtils = {
	// 상품이미지 사이즈별로 읽어오기 (사용안함)
	getURL: function(productId, imgNo, size, element) {
		var imgRoot = "http://image.i-mom.co.kr/product_img";
		var dir = productId.substring(0,7);
		
		//return imgRoot + "/" +dir+ "/" +productId + "_" + imgNo + "_" + size+".jpg";
		return imgRoot + "/" +dir+ "/" +productId + "_" + size+".jpg";
	},
	// 상품이미지 사이즈별로 읽어오기 (신버전)
	getProductURL: function(imgRoot, productId, imgNo, size, element) {
		var imgRoot = "http://image.i-mom.co.kr/product_img";
		var dir = productId.substring(0,7);
		
		return imgRoot + "/" +dir+ "/" +productId + "_" + size+".jpg";
	},
	//브렌드이미지경로
	getBrandURL: function(brandId, imgNo, size, element) {
		var imgRoot = "http://image.i-mom.co.kr/brand_img";
		var dir = brandId.substring(0,7);
		
		return imgRoot + "/" +dir+ "/" +brandId + "_" + imgNo + "_" + size+".jpg";
	},
	//중분류 제목(카테고리)명 이미지
	getCateTitle: function(categoryId, element) {
		var imgRoot = "/static_root/image/shop/catetitle";
		var dir = "";
		
		return imgRoot + "/" +categoryId+".jpg";
	},
	//이미지 없을경우
	getNoImgUrl: function(mode, size, element) {
		var imgRoot = "/static_root/image/shop/common";
		var imgName = "";
		if(mode==1){
			imgName = "noprd_"+size+".gif";
		}else if(mode==2){
			imgName = "nobrand_"+size+".gif";
		}else if(mode==3){
			imgName = "nobanner_"+size+".gif";
		}else if(mode==4){
			imgName = "nocatetitle_"+size+".gif";
		}
			
		return imgRoot+"/"+imgName;	
	},
	//이미지 아이콘
	InsertImageIcon: function(product_id, category_id, item_id, order_qyt, mode, element){
		var HTML = new StringBuffer();
		var ShopImgRootPath = "http://image.i-mom.co.kr/static_root/image/shop";
		
		//미리보기
		HTML.append("<img src='"+ShopImgRootPath+"/common/ico/preview.gif' alt='미리보기' onclick=\"viewLayer('layQuickView');ImgMagnifier('"+product_id+"'); return false;\" class=\"cPointer\" /></a>");
		
		//장바구니
		HTML.append("<img src='"+ShopImgRootPath+"/common/ico/cart.gif' alt='장바구니' class='cPointer' onclick=\"optView(this, '"+category_id+"','"+product_id+"','"+ShopImgRootPath+"');\" /></a>");
		
		//찜
		HTML.append("<a href=\"javascript:insertZzim('"+product_id+"','"+item_id+"')\"><img src='"+ShopImgRootPath+"/common/ico/zzim.gif' alt='찜' /></a>");
		
		//if(mode==0){
		//비교
		HTML.append("<a href=\"javascript:insertComp('"+product_id+"','"+item_id+"')\"><img src='"+ShopImgRootPath+"/common/ico/comp.gif' alt='비교' /></a>");
		//}
		
		return HTML.toString();
	},
	//무이자, 쿠폰, 댓글 아이콘으로 보여주기
	Icon3Value: function(NoInstallYn, NoInstallMm, DcCouponInfo, ReplyCnt, element){
		var HTML = new StringBuffer();
		var ShopImgRootPath = "http://image.i-mom.co.kr/static_root/image/shop";

		if(NoInstallYn == "Y"){
			HTML.append("<img src='"+ShopImgRootPath+"/common/ico/interest.gif' alt='무이자' /><strong>"+NoInstallMm+"</strong>&nbsp;");
		}
		if(DcCouponInfo.trim() != null && DcCouponInfo.trim() != ""){
			HTML.append("<img src='"+ShopImgRootPath+"/common/ico/coupon2.gif' alt='쿠폰' /><strong>"+DcCouponInfo+"%</strong>&nbsp;");
		}
		if(ReplyCnt > 0){
			HTML.append("<img src='"+ShopImgRootPath+"/common/ico/reply.gif' alt='댓글' /><strong>"+ReplyCnt+"</strong>&nbsp;");
		}
		
		return HTML.toString();
	},
	//무이자, 쿠폰, 댓글 아이콘으로 보여주기 
	ImagePrice: function(num, path, element){
		var HTML = new StringBuffer();
		var ShopImgRootPath = "http://image.i-mom.co.kr/static_root/image/shop";

		var numComma = num.money();
		var strLen = numComma.length;
		var sNum = "";
		for(var i=0; i<strLen; i++){
			sNum = numComma.substring(0+i, 1+i);
			if(sNum == ","){
				sNum = "comma";
			}
			HTML.append("<img src='"+ShopImgRootPath+"/"+path+"_"+sNum+".gif' />");
		}
		HTML.append("<i></i>");
		return HTML.toString();
	}

};

//★★ JAVA FormatUtil 을 JavaScript로 변환  ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
FormatUtil = {
	// JavaScript 단품페이지이동
	productUrl: function(product_id, category_id) {
		var ProdUrl = "/shop/PrdDetail.do?method=ProductDetail&product_id=";
		ProdUrl += product_id;
			if ( category_id != "" ) {
				ProdUrl += "&category_id=" + category_id;
			}
		
		return ProdUrl;
	}
};

// 이미지 돋보기 클릭 (퀵뷰)
function ImgMagnifier(product_id) {
	document.getElementById('ifrPre').contentWindow.location.href = "/shop/PrdDetail.do?method=QuickView&product_id="+product_id;
}

//투데이세일 이미지 돋보기 클릭 (퀵뷰)
function ImgMagnifierTodaySale(product_id) {
	document.getElementById('ifrPre').contentWindow.location.href = "/shop/PrdDetail.do?method=QuickView&todaySale=Y&product_id="+product_id;
}

//★★ 상품 및 브랜드이미지 생성하는 자바스크립트함수 END ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★




//주소검색창 
function ZipCodePop(){
	var v_width = 500;
	var v_height = 440;
	var v_left = screen.width / 2 - (v_width/2);
	var v_top = screen.height / 2 - (v_height/2);
	window.open("/unitypage/Common.do?page=/unitypage/member/join/pop_postcode","pop_postcode","width="+v_width+",height="+v_height+",top="+v_top+",left="+v_left+",menubar=no,scrollbars=no,status=yes");					
}


function opencal(obj) {
	window.showModalDialog("/shop/common.do?method=Calendar", obj,	"dialogWidth=245px;dialogHeight=240px;resizable=no;status=no");
}

function callMateControl(num) {
	getMovieName("shoppingMate").mateControl(num); 
} 

function optView2( obj, categoryId, prdId, shopImgRootPath ){  // 2009-08-08 현재 사용안하고 있음.
	var $jq = jQuery.noConflict();	
	$jq( ".selLay" ).hide();	
	
	dEI('ifrZZ'+prdId).style.height='266px';
	
	var optDiv = $jq( obj ).parent().parent().find(".selChg:first");
	var isFirst = true;

	$jq(optDiv).each(function(){
		if( $jq(this).html() != "" ){
			isFirst = false;
		}
	});
	
	if( isFirst ){ // 한 번 만든 것은 재사용(DB를 다시 타지 않기 위해서)
		
		var HTML = new StringBuffer();
		HTML.append('<div class="selLay">');
			HTML.append('<div class="innerT fixBox">');
				HTML.append('<h5><img src="'+ shopImgRootPath +'/category/tit_lay_seloption2.gif" alt="옵션선택" /></h5>')
				HTML.append('<p class="btnClose"><img src="'+ shopImgRootPath +'/common/btn/i_lay_close.gif" class="cPointer" alt="CLOSE" onclick="optClose(this);selShow();" /></p>');
			HTML.append('</div>');
			HTML.append('<div class="inner">');
			HTML.append('<div class="optListBox">');		
				HTML.append('<table class="optList" summary="옵션선택">');
					HTML.append('<colgroup><col width="30%" /><col /></colgroup>');
					HTML.append('<tbody>');
	
					// Ajax로 DB에서 가져온 옵션 값으로 HTML을 동적생성 
					var url = "/shop/common.do";
					var data = "method=list&procedureid=Basket.getVariation&PRODUCT_ID="+prdId+"&ID1=1";
					var dataList = getDataList( url, data ); // Ajax 
					if( dataList != null ){
						HTML.append('<tr>');
						HTML.append('<th>옵션1</th>');
						HTML.append('<td><select name="opt1" style="width:140px">');
						var size = dataList.length;
						for( var i=0; i<size; i++ ){
							HTML.append('<option value="'+dataList[i].variation_seq+'">'+dataList[i].variation_value+'</option>');
						}
						HTML.append('</select></td>');
						HTML.append('</tr>');
					}
				
					data = "method=list&procedureid=Basket.getVariation&PRODUCT_ID="+prdId+"&ID2=1";
					var dataList2 = getDataList( url, data ); // Ajax 
					if( dataList2 != null ){
						HTML.append('<tr>');
						HTML.append('<th>옵션2</th>');
						HTML.append('<td><select name="opt2" style="width:140px">');
						var size = dataList2.length;
						for( var i=0; i<size; i++ ){
							HTML.append('<option value="'+dataList2[i].variation_seq+'">'+dataList2[i].variation_value+'</option>');
						}
						HTML.append('</select></td>');
						HTML.append('</tr>');
					}
	
					if( dataList == null && dataList2 == null ){
						HTML.append('<tr><td height="30px" colspan="2" align="center">변경 가능한 옵션이 없습니다.</td></tr>');
					}
	
					dataList = null;
					dataList2 = null;
					
					HTML.append('<tr>');
						HTML.append('<th>구매수량</th>');
						HTML.append('<td>');
							HTML.append('<div class="selEa">');
							HTML.append('<input type="text" class="txt" name="odQty" style="ime-mode:disabled" value="1" maxlength="6" />');
							HTML.append('<img src="'+ shopImgRootPath +'/common/btn/i_up.gif" class="up cPointer" alt="더하기" onclick="optAddQty(this)" />');
							HTML.append('<img src="'+ shopImgRootPath +'/common/btn/i_down.gif" class="down cPointer" alt="빼기" onclick="optSubQty(this)" />');
							HTML.append('</div>');
						HTML.append('</td>');
					HTML.append('</tr>');
				HTML.append('</tbody>');
			HTML.append('</table>');
		HTML.append('</div>');
		HTML.append('<p class="btn">');
		HTML.append('<img src="'+ shopImgRootPath +'/common/btn/a_cart.gif" alt="장바구니" class="cPointer" onclick="optBasket(this,\''+ categoryId +'\',\''+ prdId +'\')" />');
		HTML.append('</p>');
		HTML.append('</div>');
		HTML.append('</div>');

		$jq( optDiv ).html( HTML.toString() );	
	}
	
	$jq( optDiv ).find( ".selLay:first" ).show();
}

function optView( obj, categoryId, prdId, shopImgRootPath ){
	var $jq = jQuery.noConflict();	

	var HTML = new StringBuffer();
	HTML.append('<div id="floatingDiv" style="position:absolute;left:0px;top:0px;">');
	HTML.append('<div class="selLay">');
		HTML.append('<div class="innerT fixBox">');
			HTML.append('<h5><img src="'+ shopImgRootPath +'/category/tit_lay_seloption2.gif" alt="옵션선택" /></h5>')
			HTML.append('<p class="btnClose"><img src="'+ shopImgRootPath +'/common/btn/i_lay_close.gif" class="cPointer" alt="CLOSE" onclick="optClose(this);selShow();" /></p>');
		HTML.append('</div>');
		HTML.append('<div class="inner">');
		HTML.append('<div class="optListBox">');		
			HTML.append('<table class="optList" summary="옵션선택">');
				HTML.append('<colgroup><col width="30%" /><col /></colgroup>');
				HTML.append('<tbody>');

				// Ajax로 DB에서 가져온 옵션 값으로 HTML을 동적생성 
				var url = "/shop/common.do";
				var data = "method=list&procedureid=Basket.getVariation&PRODUCT_ID="+prdId+"&ID1=1";
				var dataList = getDataList( url, data ); // Ajax 
				if( dataList != null ){
					HTML.append('<tr>');
					HTML.append('<th>옵션1</th>');
					HTML.append('<td><select name="opt1" style="width:140px">');
					var size = dataList.length;
					for( var i=0; i<size; i++ ){
						HTML.append('<option value="'+dataList[i].variation_seq+'">'+dataList[i].variation_value+'</option>');
					}
					HTML.append('</select><input type="hidden" name="singleItemGbn" value="N"></td>');
					HTML.append('</tr>');
				}
			
				data = "method=list&procedureid=Basket.getVariation&PRODUCT_ID="+prdId+"&ID2=1";
				var dataList2 = getDataList( url, data ); // Ajax 
				if( dataList2 != null ){
					HTML.append('<tr>');
					HTML.append('<th>옵션2</th>');
					HTML.append('<td><select name="opt2" style="width:140px">');
					var size = dataList2.length;
					for( var i=0; i<size; i++ ){
						HTML.append('<option value="'+dataList2[i].variation_seq+'">'+dataList2[i].variation_value+'</option>');
					}
					HTML.append('</select></td>');
					HTML.append('</tr>');
				}

				if( dataList == null && dataList2 == null ){
					HTML.append('<tr><td class="oneprd" colspan="2">단일상품<input type="hidden" name="singleItemGbn" value="Y"></td></tr>');
				}

				dataList = null;
				dataList2 = null;
				
				HTML.append('<tr>');
					HTML.append('<th>구매수량</th>');
					HTML.append('<td>');
						HTML.append('<div class="selEa">');
						HTML.append('<input type="text" class="txt" name="odQty" style="ime-mode:disabled" value="1" maxlength="6" />');
						HTML.append('<img src="'+ shopImgRootPath +'/common/btn/i_up.gif" class="up cPointer" alt="더하기" onclick="optAddQty(this)" />');
						HTML.append('<img src="'+ shopImgRootPath +'/common/btn/i_down.gif" class="down cPointer" alt="빼기" onclick="optSubQty(this)" />');
						HTML.append('</div>');
					HTML.append('</td>');
				HTML.append('</tr>');
			HTML.append('</tbody>');
		HTML.append('</table>');
	HTML.append('</div>');
	HTML.append('<p class="btn">');
	HTML.append('<img src="'+ shopImgRootPath +'/common/btn/a_cart.gif" alt="장바구니" class="cPointer" onclick="optBasket(this,\''+ categoryId +'\',\''+ prdId +'\')" />');
	HTML.append('</p>');
	HTML.append('</div>');			
	HTML.append('</div>');
	HTML.append('</div>');

	$jq( "#floatingOption" ).html( HTML.toString() );	
	
	// 아이프레임 밑에 깔기...
	//fnLayerShow(); 
	
	$jq( "#floatingOption" ).find( ".selLay:first" ).show();
	
	//사용법 new Floating(적용할개체 , X축여백 , Y축여백 , 미끄러지는속도:작을수록빠름..기본20 , 빠르기:작을수록부드러움..기본10); 
	new Floating(document.getElementById("floatingDiv"),380,150,1,1); 	
}

function fnLayerShow(){
	var objLayer = document.getElementById("floatingDiv");
	objLayer.style.display = "block";

	//ie6에서 셀렉트 박스 위로 보이기
	if(navigator.userAgent.indexOf("MSIE 6")>-1 && navigator.userAgent.indexOf("MSIE 7")<0){
		if (!document.getElementById("IE6Iframe")){
			var ie6_ifm = document.createElement("iframe");
			ie6_ifm.setAttribute("id","IE6Iframe");
			ie6_ifm.style.position = "absolute";
			ie6_ifm.style.opacity = "0";
			ie6_ifm.style.filter = "alpha(opacity=0)";
			ie6_ifm.style.zindex = "-1";
			ie6_ifm.style.left = "0";
			ie6_ifm.style.top = "0";
			ie6_ifm.style.width = "270";
			ie6_ifm.style.height = "190";
			objLayer.appendChild(ie6_ifm);
		}
	}
}

function optClose( obj ){
	var $jq = jQuery.noConflict();		
	$jq(obj).parent().parent().parent().parent().find( ".selLay:first" ).hide();
}

function optAddQty(obj){
	var $jq = jQuery.noConflict();		
	var qty = Number($jq(obj).prev().val());
	$jq(obj).prev().val( qty + 1 );
}

function optSubQty(obj){
	var $jq = jQuery.noConflict();		
	var qty = Number($jq(obj).prev().prev().val());
	if( qty > 1 ){
		$jq(obj).prev().prev().val( qty - 1 );
	}
}

function optBasket( obj, categoryId, prdId ){
	var $jq = jQuery.noConflict();	
	if( ! loginPopCheck_Basket("","1") ){return;}

	var opt1 = $jq(obj).parent().prev().find(":select[name='opt1']").val();
	var opt2 = $jq(obj).parent().prev().find(":select[name='opt2']").val();
	var odQty;
	var singleItemGbn;
	$jq(obj).parent().prev().find(":input[name='odQty']").each(function(){
		odQty = this;
	});
	$jq(obj).parent().prev().find(":input[name='singleItemGbn']").each(function(){
		singleItemGbn = this;
	});
	var Msg = "죄송합니다 고객님! 해당 옵션은 장바구니에 담을 수 없습니다.";
	var data = "";
	
	if( isNaN( odQty.value ) ){
		alert("구매수량을 숫자로 입력해주세요!");
		odQty.focus();
		return;
	}

	if( Number(odQty.value) == 0 ){
		alert("구매수량을 입력해주세요!");
		odQty.focus();
		return;
	}
	//alert(singleItemGbn.value);
	//if( typeof(opt1) == "undefined" ){
	//	alert(Msg);
	//	return;
	//}
	if ( singleItemGbn.value == "N" ) {		// 베리에이션 선택이 있는 경우
		if( typeof(opt1) != "undefined" && typeof(opt2) != "undefined" ){
	
			data = "method=list&PRODUCT_ID="+prdId+"&OPT1="+opt1+"&OPT2="+opt2+"&procedureid=Basket.getItemIdIconV2";
			
		}else if( typeof(opt1) != "undefined" && typeof(opt2) == "undefined" ){
			
			data = "method=list&PRODUCT_ID="+prdId+"&OPT1="+opt1+"&procedureid=Basket.getItemIdIconV1";
		}
	
		var dataList = getDataList("/shop/common.do",data);
		var itemId = "";
		if(dataList != null){
			itemId = dataList[0].item_id+"";
		}else{
			alert(Msg);
			return;		
		}
	
		if( itemId == "" || itemId == null ){
			alert(Msg);
			return;
		}
	}
	else {		// 단일 상품의 경우
		itemId = "001";
	}
	//AceCounter 장바구니등록
	//AEC_F_D(prdId,'i',odQty.value);

	var queryData = "product_id="+prdId+"&item_id="+itemId+"&category_id="+categoryId+"&order_qty="+odQty.value;

	$jq.ajax({
		type: "GET",
		async: false,
		url: "/shop/Prd.do?method=InsertBasketIcon",
		data: queryData ,
		dataType: "text",
		success: function(obj){
			var dataList = eval("("+obj+")");
			if( dataList[0].success == "true" ){
				
				// 회원/비회원 - 1,	 오늘 본 상품 - 2,	 장바구니 - 3, 찜보관함 - 4, 비교함 - 5, 나의 할인헤택 - 6 
				callMateControl(1); //쇼핑메이트에 각종 카운트 수 새로고침 
				callMateControl(3); //쇼핑메이트에 장바구니 리스트 새로고침 
				callExternalInterface(2); // 쇼핑메이트에 장바구니 스스륵 올라오는 기능(1:오늘본상품,2:장바구니
				
				// 장바구니 팝업 레이어창 숨기기 처리
				$jq( "#floatingDiv" ).hide();
				
				if( confirm("상품이 장바구니에 등록되었습니다.\n\n지금 확인하시겠습니까?") ){
					location.href = "/shop/Basket.do?method=CartMainList";
				}
			}
		}
	});
}


//----------------------------------------------
//Floating v1.1 Source By Bermann
//dobermann75@gmail.com
//----------------------------------------------

//new Floating(적용할개체 , X축여백 , Y축여백 , 미끄러지는속도:작을수록빠름..기본20 , 빠르기:작을수록부드러움..기본10);

function Floating(FloatingObj,MarginX,MarginY,Percentage,setTime) {
	this.FloatingObj = FloatingObj;
	this.MarginX = (MarginX) ? MarginX : 0;
	this.MarginY = (MarginY) ? MarginY : 0;
	this.Percentage = (Percentage) ? Percentage : 20;
	this.setTime = (setTime) ? setTime : 10;
	this.FloatingObj.style.position = "absolute";
	this.Body = null;
	this.setTimeOut = null;
	this.Run();
}

Floating.prototype.Run = function () {
	if ((document.documentElement.scrollLeft + document.documentElement.scrollTop) > (document.body.scrollLeft + document.body.scrollTop)) {
		this.Body = document.documentElement;
	} else {
		this.Body = document.body;
	}

	var This = this;
	var FloatingObjLeft = (this.FloatingObj.style.left) ? parseInt(this.FloatingObj.style.left,10) : this.FloatingObj.offsetLeft;
	var FloatingObjTop = (this.FloatingObj.style.top) ? parseInt(this.FloatingObj.style.top,10) : this.FloatingObj.offsetTop;
	var DocLeft = this.Body.scrollLeft + this.MarginX;
	var DocTop = this.Body.scrollTop + this.MarginY;

	var MoveX = Math.abs(FloatingObjLeft - DocLeft);
	MoveX = Math.ceil(MoveX / this.Percentage);
	var MoveY = Math.abs(FloatingObjTop - DocTop);
	MoveY = Math.ceil(MoveY / this.Percentage);

	if (FloatingObjLeft < DocLeft) {
		this.FloatingObj.style.left = FloatingObjLeft + MoveX + "px";
	} else {
		this.FloatingObj.style.left = FloatingObjLeft - MoveX + "px";
	}

	if (FloatingObjTop < DocTop) {
		this.FloatingObj.style.top = FloatingObjTop + MoveY + "px";
	} else {
		this.FloatingObj.style.top = FloatingObjTop - MoveY + "px";
	}

	window.clearTimeout(this.setTimeOut);
	this.setTimeOut = window.setTimeout(function () { This.Run(); },this.setTime);
}

function goOrderDetail( orderId ){
	window.open("/shop/Order.do?method=OrderDetail&order_id="+orderId,"pop1","width=850,height=675,scrollbars=yes");
}

function goOrderDetailOptChange( orderId ){
	window.open("/shop/Order.do?method=OrderDetail&optChng=Y&order_id="+orderId,"pop1","width=850,height=675,scrollbars=yes");
}

function goDetail( prdId ){
	location.href = "/shop/PrdDetail.do?method=ProductDetail&product_id="+prdId;
}

function popupCompare(strCode) {
	var productArray = "";
	var prodData = strCode.split("$");
	var idx = 0;
	
	for(var i=0; i<prodData.length; i++){
		var prduct_id = prodData[i].split(":")[0];
		
		if(prduct_id.trim() != ""){
			++idx;
			if(i>0) productArray += ",";
			productArray += "'"+prduct_id+"'";
		}
	}
	
	var widthPx = 0 ;
	if ( idx == 2 ) {
		widthPx = parseInt(150 + idx*270, 10);
	}
	else {
		widthPx = parseInt(100 + idx*270, 10);
	}
	window.open('/shop/Prd.do?method=ComparePopup&product_id='+productArray+"&idx="+idx,'compare_pop','width='+widthPx+',height=650,scrollbars=yes');
}

function popupSizeInfo(productId,brandId) {	
	window.open('/shop/PrdDetail.do?method=SizeInfoPopup&product_id='+productId+"&brand_id="+brandId,'sizeinfo_pop','width=680,height=650,scrollbars=yes');
}

//메인팝업사용쿠키
function setCommonCookie( name, value, expiredays )
{
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + expiredays );
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function getCommonCookie( 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 getInternetExplorerVersion() {    
	var rv = -1; // Return value assumes failure.    
	if (navigator.appName == 'Microsoft Internet Explorer') {        
		var ua = navigator.userAgent;        
		var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");        
		
		if (re.exec(ua) != null)  
			rv = parseFloat(RegExp.$1);    
		
	}    
	
	return rv;
	
}
/** 이미지 오류(이미지없음..) 발생시 기본 처리 함수 **/
function defaultImageErrorHandler(oImg,w,h) {
	if (oImg == null || oImg.src == null) return;
	
	oImg.src = '/static_root/image/portal/temp/noimg.gif';
	if (typeof w != 'undefined') oImg.style.width 	= w + 'px';
	if (typeof h != 'undefined') oImg.style.height 	= h + 'px';
	oImg.onerror = null;
}

function chkStrLength(obj) {
	// 바이트체크
	var str = obj.value;
	var len = getByteLength(str);
	if ( len > 400 ) {
		var i=0;
		var tmplen = 0;
		for (; i < str.length; i++) {
	        if (str.charCodeAt(i) > 127) {
	            tmplen += 2;
	            if ( tmplen > 400 ) {
					i--;
		            break;
	            }
	        }
	        else {
	            tmplen++;
	            if ( tmplen > 400 ) {
					i--;
		            break;
	            }
	        }             
	    }
		alert("400 Byte까지만 입력이 가능합니다.");
		obj.value = str.substring(0, i+1);
	}
	len = getByteLength(obj.value);
	document.getElementById("str_len").innerHTML = len;
}


function goBeforeMileage(loginId, userNo) {
	if ( loginId == "" || userNo == "" ) return;	
	window.open("http://test.i-mom.co.kr//myhome/opensite_mileage_gift_read.jsp?login_id="+loginId+"&cust_id=" + userNo,"","resizable=no , scrollbars=yes,width=700,height=781");
	
}

function goBeforeOrderList(loginId, userNo) {	
	if ( loginId == "" || userNo == "" ) return;
	window.open("http://test.i-mom.co.kr//myhome/opensite_order_deliver_list.jsp?login_id="+loginId+"&cust_id="+userNo,"","resizable=no , scrollbars=yes,width=700,height=781");
}
	
