/* Copyright (c) 2011 Smileweb co., Ltd.  All rights reserved.  www.smileweb.co.kr */
var C_id;

function _swid(Str) { return document.getElementById(Str); }

function _swnm(Str) { return document.getElementsByName(Str); }

if (window.attachEvent) {
	var addEvent = function (Element,Handle,Action) { return Element.attachEvent(Handle,Action); }
} else if (window.addEventListener) {
	var addEvent = function (Element,Handle,Action) { return Element.addEventListener(Handle.replace(/^on/i,""),Action,false); }
}

var _downFilePath = "/upfile/";

function SetC_id(id)
{
	C_id = id;
}

function isNull( text )
{
	 if( text == null ) return true;

	 var result = text.replace(/(^\s*)|(\s*$)/g, "");

	 if( result )	  return false;
	 else    return true;
}

function CheckNumber(fl) {
	t = fl.value ;
	for(i=0;i<t.length;i++)
	if (t.charAt(i)<'0' || t.charAt(i)>'9') {
		alert("숫자만 입력해주세요.") ;
		fl.value="";
		fl.focus() ;
		return false ;
	}
}

function CheckFloat(fl) {
	t = fl.value ;
	for(i=0;i<t.length;i++)
	if (  t.charAt(i)!='.' && (t.charAt(i)<'0' || t.charAt(i)>'9') ) {
		alert(" 소수점과 숫자만 입력해주세요.") ;
		fl.value="";
		fl.focus() ;
		return false ;
	}
}

function CheckMinus(fl) {
	t = fl.value ;
	for(i=0;i<t.length;i++)
	if (  t.charAt(i)!='-' && (t.charAt(i)<'0' || t.charAt(i)>'9') ) {
		alert(" '-'와 숫자만 입력해주세요.") ;
		fl.value="";
		fl.focus() ;
		return false ;
	}
}

function CheckBar(fl) {
	t = fl.value ;
	for(i=0;i<t.length;i++)
	if (  t.charAt(i)!='|' && (t.charAt(i)<'0' || t.charAt(i)>'9') ) {
		alert(" '|'와 숫자만 입력해주세요.") ;
		fl.value="";
		fl.focus() ;
		return false ;
	}
}

var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var alphaS= 'abcdefghijklmnopqrstuvwxyz';
var numeric = '1234567890';
var dash = '_-';
var special = "`%^&{}|=<>?#'$\\\";:";
var dot = '.';
var email = '@'
var selftextgubun = ',';

function checknorm(target, cmt, astr, lmax,lshort) {
	var i;

	var t = trim(target.value);
	if (t.length == 0) {
		alert(cmt + '(을)를 정확히 기재해 주십시오.');
		target.focus();
		return true ;
	}
	if (lshort != 0 && t.length < lshort) {
		alert(cmt + '는 ' + lshort + '자 이상만 가능합니다.');
		target.focus()
		return true;
	}

	if (lmax != 0 && t.length > lmax) {
		alert(cmt + '는 ' + lmax + '자 이내만 가능합니다.');
		target.focus()
		return true;
	}

	if (astr.length >= 1) {
		for (i = 0; i < t.length; i++)
		if (astr.indexOf(t.substring(i, i+1)) < 0) {
			alert(cmt + '에 정확히 입력해 주십시오.');
			try {
				target.focus();
			}
			catch (ex) {}

			return true;
		}
	}
	return false
}

function checkid(target, cmt)
{
	var ascii, i;

	if (target.value == "")
	{
		alert("아이디를 입력해주세요.");
		return false;
	}

	for (i=0;i < target.value.length ;i++)
	{
		ascii = target.value.charCodeAt(i);
		if ((i==0) && ((ascii < 97) || (ascii  > 122)))
		{
			alert("첫 글자는 영문소문자만 가능합니다.");
			target.focus();
			return false;
		}
		else if (   ascii >= 65 && ascii <= 90 )
		{
			alert(" 영문 대문자는 사용할 수 없습니다.");
			target.focus();
			return false;
		}
		else if (ascii > 122)
		{
			alert("한글을 비롯한 특수문자는 사용할 수 없습니다.");
			target.focus();
			return false;
		}

	}

	for (i = 0; i < target.value.length; i++)
	{
		if (target.value.charAt(i) >= "0" && target.value.charAt(i) <= "9")
		{
			continue;
		}
		else if (target.value.charAt(i) >= "a" && target.value.charAt(i) <= "z")
		{
			continue;
		}
		else if (target.value.charAt(i) >= "A" && target.value.charAt(i) <= "Z")
		{
			continue;
		}
		else if (target.value.charAt(i) == "_")
		{
			continue;
		}
		else if (target.value.charAt(i) == " ")
		{
			alert("회원 아이디(ID)는 띄어쓰기 없이 영문자와 숫자 조합과 '_'만 가능합니다. ");
	  		target.focus();
			return false;
		}
		else
		{
			alert("회원 아이디(ID)는 띄어쓰기 없이 5~15자리의 영문자와 숫자 조합과 '_'만 가능합니다.");
			target.focus();
			return false;
		}
	}

	if (target.value.length < 5)
	{
		alert("ID는 5자 이상이어야 합니다.");
		target.focus();
		return false;
	}
}

function ltrim(str)
{
	var strreturn = "";
	for(i=0; i <= str.length-1 ; i++)
	{
		if (str.charAt(i) != ' ')
		{
			strreturn = str.substring(i,str.length);
			return strreturn;
		}
	}
	return strreturn;
}

function rtrim(str)
{
	var strreturn = "";
	for(i=str.length-1; i >=0  ; i--)
	{
		if (str.charAt(i) != ' ')
		{
			strreturn = str.substring(0,i+1);
			return strreturn;
		}
	}
	return strreturn;
}

function trim(str)
{
	return rtrim(ltrim(str));
}

function checknot(target,cmt,astr)
 {
	var i;
	var t = target.value;

	if (astr.length == 0)	astr = special;

	for (i=0; i<t.length; i++)
	{
		if(astr.indexOf(t.substring(i,i+1)) >= 0)
		{
			alert(cmt + "에 [~()_-*@!'+/]외의 특수문자는 사용불가 합니다. ");
			target.focus()
			return true;
		}
	}
	return false
}

function pop_closed()
{
	if (window.ActiveXObject) {
		try {
			document.close();
		} catch (e) {
			try {
				window.opener = self;
				self.close();
			} catch (e) {
				return null;
			}
		}
	} else if (window.XMLHttpRequest) {
		try {
			window.open('about:blank','_self').close();
		} catch (e) {
			return null;
		}
	}

	if (/MSIE/.test(navigator.userAgent))
	{
		window.opener = self;
		self.close();
	}
}

function ItemPop( mode, tbl, fknum )
{
	param = "mode="+mode+"&tbl="+tbl+"&num="+fknum;
	window.open('/contents/pop_itemAdd.php?'+param,'ITEM_ADD','scrollbars=0, width=750, height=700');
}

function pop_reload_close()
{
	if (window.ActiveXObject) {
		try {
			window.opener.location.reload();
		} catch (e) {
			try {
				opener = self;
				opener.location.reload();
			} catch (e) {
			}
		}
	} else if (window.XMLHttpRequest) {
		try {
			opener.location.reload();
		} catch (e) {
		}
	}

	if (/MSIE/.test(navigator.userAgent)) {
    	if(navigator.appVersion.indexOf('MSIE 7.0')>=0) {
			if (opener && !opener.closed){ opener.location.reload(); }
			}else{
				if (opener && !opener.closed){ opener.location.reload(); }
			}
	}
	pop_closed();
}

function pop_move_close( url )
{
	if (window.ActiveXObject) {
		try {
			window.opener.location.href = url;
		} catch (e) {
			try {
				opener = self;
				opener.location.href = url;
			} catch (e) {
			}
		}
	} else if (window.XMLHttpRequest) {
		try {
			opener.location.href = url;
		} catch (e) {
		}
	}

	if (/MSIE/.test(navigator.userAgent)) {
    	if(navigator.appVersion.indexOf('MSIE 7.0')>=0) {
			if (opener && !opener.closed){ opener.location.href = url;  }
			}else{
				opener = self;
				if (opener && !opener.closed){ opener.location.href = url;  }
			}
	}
	pop_closed();
}

function iframe_reload_close()
{
	if (window.ActiveXObject) {
		try {
			parent.location.reload();
			document.close();
		} catch (e) {
			try {
				parent = self;
				parent.location.reload();
				self.close();
			} catch (e) {
			}
		}
	} else if (window.XMLHttpRequest) {
		try {
			parent.location.reload();
			window.open('about:blank','_self').close();
		} catch (e) {
		}
	}

	if (/MSIE/.test(navigator.userAgent)) {
    	if(navigator.appVersion.indexOf('MSIE 7.0')>=0) {
			if (parent && !parent.closed){ parent.location.reload(); }
	   			window.open('about:blank','_self').close();
			}else{
				parent = self;
				if (parent && !parent.closed){ parent.location.reload(); }
					self.close();
			}
	}
}

if(typeof HTMLElement != "undefined" && typeof HTMLElement.prototype.__defineGetter__ != "undefined") {
	HTMLElement.prototype.__defineGetter__("innerText",
		function() {
			if(this.textContent) { return(this.textContent)	}
			else
			{
				var r = this.ownerDocument.createRange();
				r.selectNodeContents(this);
				return r.toString();
			}
		});

	HTMLElement.prototype.__defineSetter__("innerText",
		function(sText) { this.innerHTML = sText });
}

String.prototype.replaceAll = function(strTarget, strSubString )
{
	var strText = this;
	var intIndexOfMatch = strText.indexOf( strTarget );

	while (intIndexOfMatch != -1)
	{
		strText = strText.replace( strTarget, strSubString )
		intIndexOfMatch = strText.indexOf( strTarget );
	}

	return( strText );
}

var shopTarget;
var shopAdd;
var shopNum;

function shopView( target, shop, add )
{

	if (add =="null" || add == null  ||  add =="" )
	{
		add = '';

	}else{
		add = "&"+add ;
	}
	shopNum    = shop;
	shopTarget = target;
	shopAdd    = add;

	new ajax.xhr.Request("/product/shopview_transaction/move_page.php", "shop="+shop, MoveShopView, 'POST');
}

function MoveShopView( xmlDoc )
{
	var viewUrl = getNodeValue( xmlDoc.getElementsByTagName( 'url' ) );

	if (viewUrl=="")
	{
		document.write("존재 하지 않는 상품입니다.");
	}

	var url = viewUrl + "?shop=" + shopNum + shopAdd ;

	if ( shopTarget =="openwindow" )
	{
		window.open( url ) ;
	}
	else
	{
		document.location.href = url;
	}
}

function pop_emoney( member_id )
{
	window.open('/adminnew/member/pop_emoney_list.php?muid='+member_id,'','toolbar=no, width=800, height=600, top=10, left=10, scrollbars=yes, resizable=yes');
}

function pop_order( code )
{
	window.open('/adminnew/order/pop_order.php?ordercode='+code,'','toolbar=no, width=700, height=740, top=10, left=10, scrollbars=yes, resizable=yes');
}

function pop_display_mody(fileName)
{
	window.open('/adminnew/design/pop_display_mody.php?fileName='+fileName,'','toolbar=no, width=650, height=370, top=10, left=10, scrollbars=yes, resizable=yes');
}

function display_restoration(fileName)
{
	if ( confirm("복구시 최초의 디자인으로 변경됩니다.\n\n정말 복구하시겠습니까?") )
	{
		var obj = _swid('restorationIframe');
		if(obj == null){
			var iframe = document.createElement("IFRAME");
			iframe.setAttribute("id", "restorationIframe");
			iframe.setAttribute("name", "restorationIframe");
			iframe.style.width = "0";
			iframe.style.height = "0";
			document.body.appendChild(iframe);
			obj = _swid('restorationIframe');
		}

		obj.src = '/adminnew/design/pop_display_mody.php?fileName='+fileName+'&mode=restoration';
	}
}

function go_home( )
{
	var url =  "/main/main.php" ;
	document.location.href = url;

}

function pop_member(muid){
	window.open('/adminnew/member/pop_member.php?muid='+muid,'','toolbar=no, width=700, height=600, top=10, left=10, scrollbars=yes, resizable=yes');
}

var initBody
function beforePrint( name ){
	initBody = document.body.innerHTML;
	document.body.innerHTML = document.getElementById(name).innerHTML;
}
function afterPrint(){
	document.body.innerHTML = initBody;
}
function printArea( name ) {
	beforePrint( name );
	window.print();
	afterPrint();
}

function pop_resize()
{
	var Dwidth = parseInt(document.body.scrollWidth);
	var Dheight = parseInt(document.body.scrollHeight);
	var divEl = document.createElement("div");
	divEl.style.position = "absolute";
	divEl.style.left = "0px";
	divEl.style.top = "0px";
	divEl.style.width = "100%";
	divEl.style.height = "100%";

	document.body.appendChild(divEl);

	if (window.DOMParser) {Dheight = Dheight + 75;}

	window.resizeBy(Dwidth-divEl.offsetWidth, Dheight-divEl.offsetHeight);
	document.body.removeChild(divEl);
}


function number_format(val){
	val=parseInt(val)
	ret_val = val.toLocaleString();
	pos = ret_val.indexOf(".");
	if(pos==-1) pos = ret_val.length;
	ret_val = ret_val.substr(0,pos);
	return(ret_val);
}

function renumber_format(val){
	 var returnValue = val.replace(",","");
     returnValue = returnValue.replace(",","");
	 returnValue = returnValue.replace(",","");
	 return returnValue;
}

function InsertFile(fname, msection, fileFilter)
{
 	 var URLs='/common/inc/pop_orgAdd.php?fname=' + fname + '&msection=' + msection + '&imgfname=' + fileFilter;
	 var arr = showModalDialog( URLs ,"","font-family:Verdana; font-size:12; dialogWidth:680px; dialogHeight:540px" );
	  if ( arr == null) return ;
	 if( typeof(arr) == "object" &&  arr.imageUrl != null && arr.imageUrl !='undefined'  )
	 {
		try{ document.getElementById( arr.idx + "view" ).src = arr.imageUrl ;}catch(e){}
		try{ document.getElementById( arr.idx + "viewMain" ).src = arr.imageUrl ; }catch(e){}
		try{ document.getElementById( arr.idx + "view" ).style.background = "url('"+ arr.imageUrl +"')";}catch(e){}

		if( msection == "edit")
		{
			try{ document.getElementById( arr.idx ).innerHTML = "<img src='"+ arr.imageUrl +"' border=0 >"; }catch(e){}
		}
		else
		{
			try{ document.getElementById( arr.idx + '' ).value = arr.imageUrl; }catch(e){}
			try{ document.getElementById( arr.idx + 'name' ).value = arr.imageName; }catch(e){}
			try{ MultiFileAdd(arr);	} catch(e) { }
		}


	}
}

function UserMenuset(BANK,NAME,DATE)
{
	var UserMenu = document.getElementById('UserMenu');

	var text=""
	text+="		<table border='1' cellpadding='1' cellspacing='1' bgcolor='#cccccc'>"
	text+="		  <tr bgcolor='#ffffff'>"
	text+="			  <td width='100px' align='center'>구매인 </td><td width='120px'>"+NAME+"</td>"
	text+="		  </tr>"
	text+="		  <tr bgcolor='#ffffff'>"
	text+="			  <td align='center'>입금예정일 </td><td>"+DATE+"</td>"
	text+="		  </tr>"
	text+="		  <tr bgcolor='#ffffff'>"
	text+="			  <td align='center' colspan='2'>"+BANK+"</td>"
	text+="		  </tr>"
	text+="		</table>"
	UserMenu.innerHTML=text;
}
function UserMenuhide()
{
	var UserMenu = document.getElementById('UserMenu');

	UserMenu.innerHTML=''
}
function OnShowUserMenu(BANK,NAME,DATE,e)
{
	UserMenuCheck();

	var UserMenu = document.getElementById('UserMenu');

	if(e.x)
	{
		UserMenu.style.left = e.clientX + 10 + document.documentElement.scrollLeft+ 'px';
		UserMenu.style.top  = e.clientY - 12 + document.documentElement.scrollTop + 'px';
	}
	else
	{
		UserMenu.style.left = e.pageX + 10 + document.body.scrollLeft + 'px';
		UserMenu.style.top  = e.pageY - 12 + document.body.scrollTop + 'px';
	}

	if(UserMenu.innerHTML == '')
	{
		UserMenuset(BANK,NAME,DATE)
	}
	else UserMenuhide()
}

function UserMenuCheck()
{
	var objDiv = document.getElementById('UserMenu');
	if(objDiv == null)
	{
		var obj = document.createElement("div");
		obj.setAttribute("id", "UserMenu");
		obj.style.width="200px";
		obj.style.position="absolute";
		obj.style.borderStyle="none";
		document.body.appendChild(obj);
	}
}

function OnShowUserMenu2(NOTE,e)
{
	UserMenuCheck();

	var UserMenu = document.getElementById('UserMenu');

	if(e.x)
	{
		UserMenu.style.left = e.clientX + 10 + document.documentElement.scrollLeft+ 'px';
		UserMenu.style.top  = e.clientY - 12 + document.documentElement.scrollTop + 'px';
	}
	else
	{
		UserMenu.style.left = e.pageX + 10 + document.body.scrollLeft + 'px';
		UserMenu.style.top  = e.pageY - 12 + document.body.scrollTop + 'px';
	}

	if(UserMenu.innerHTML == '')
	{
		UserMenuset2(NOTE)
	}
	else UserMenuhide()
}

function UserMenuset2(NOTE)
{
	var UserMenu = document.getElementById('UserMenu');

	var text=""
	text+="		<table border='1' cellpadding='1' cellspacing='1' bgcolor='#cccccc'>"
	text+="		  <tr bgcolor='#ffffff'>"
	text+="			  <td width='100px' align='center'>정산내역 </td><td width='120px'>"+NOTE+"</td>"
	text+="		  </tr>"
	text+="		</table>"
	UserMenu.innerHTML=text;
}

function ShopMody(num)
{
	window.open('/smanage/reg_mody.php?num='+num,'','toolbar=no, width=900, height=700, top=10, left=10, scrollbars=yes, resizable=yes');
}

function ShopReReg(num)
{
	window.open('/smanage/reg_rereg.php?num='+num,'','toolbar=no, width=900, height=700, top=10, left=10, scrollbars=yes, resizable=yes');
}

function select_box()
{
	var gsize = parseInt(_swid('gsize').value) ;

	for(i=0; i<gsize; i++)
	{
		var goods = eval(_swid('chkitem'+i));

		if(goods.checked)
		{
			return true;
		}
	}
	return false;
}

function check_all()
{
	var gsize = parseInt(_swid('gsize').value) ;

	var b = false;
	if( _swid('chkall').checked )
	{
		b = true;
	}

	for(i=0; i<gsize; i++)
	{
		var obj = eval(_swid('chkitem'+i));
		if(b)
		{
			if ( !obj.disabled )
			{
				obj.checked = true;
			}
		}
		else
		{
			obj.checked = false;
		}
	}
}

function Favorite(title) {
	url = location.href;
   if (window.sidebar)
   window.sidebar.addPanel(title, url, "");
   else if(window.opera && window.print)

   {
      var elem = document.createElement('a');
      elem.setAttribute('href',url);
      elem.setAttribute('title',title);
      elem.setAttribute('rel','sidebar');
      elem.click();
   }

   else if(document.all)
   window.external.AddFavorite(url, title);
}

function UrlCopy() {
	if (window.clipboardData)
	{
		window.clipboardData.setData("Text",location.href);
		alert("게시물 내용이 클립보드에 복사되었습니다.");
	}
	else
	{
		prompt("Ctrl+C를 눌러 게시물 내용을 클립보드로 복사하세요", location.href);
	}
}

var shopInfoLayerNumBefor;
function ShopInfoLayerShow(num, e)
{
	var currentElement;


	if (e.target)
	{
		currentElement=e.target;
	}
	else if (e.srcElement)
	{
		currentElement=e.srcElement;
	}

	var oElement = currentElement;
	var curleft = 0;
	var curtop = 0;

	if (oElement.offsetParent)
	{
		while (oElement.offsetParent)
		{
			curleft += ( oElement.offsetLeft - oElement.scrollLeft );
			curtop += ( oElement.offsetTop - oElement.scrollTop );
			oElement = oElement.offsetParent;
		}
	}


	var objDiv = document.getElementById('shipInfo');
	if(objDiv == null)
	{
		var obj = document.createElement("div");
		obj.setAttribute("id", "shipInfo");
		obj.style.width="200px";
		obj.style.height="30px";
		obj.style.position="absolute";
		obj.style.display = "none";
		obj.className = "rollover";
		obj.onmouseover = function() { ShopInfoLayerView(); }
		obj.onmouseout = function() { ShopInfoLayerHidden(); }

		document.body.appendChild(obj);
	}

	var shipInfo = document.getElementById('shipInfo');


	if(shopInfoLayerNumBefor == null || shopInfoLayerNumBefor != num){
		shipInfo.style.display = "none";
		var text = "<div class='p_quick' id='p_quickForm' style='display:none'>"+
			"<a href='javascript:PopPreview("+num+")' class='rollover'><img src='/images/common/btn/quick_img_01.gif' width='15' height='15' alt='미리보기' name='Image1' /><img class='over' width='15' height='15' alt='미리보기' src='/images/common/btn/quick_img_01_ov.gif'/>"+
			"<div class='text'>"+
			"	<img class='over' src='/images/common/btn/quick_text_01.gif' alt='미리보기' />"+
			"</div></a>"+
			"<a href='javascript:wish_in("+num+")'  class='rollover'><img src='/images/common/btn/quick_img_02.gif' width='15' height='15' alt='찜하기' name='Image1' /><img class='over' width='15' height='15' alt='찜하기' src='/images/common/btn/quick_img_02_ov.gif'/>"+
			"<div class='text'>"+
			"	<img class='over' src='/images/common/btn/quick_text_02.gif' alt='찜하기' />"+
			"</div></a></div>";

		shopInfoLayerNumBefor=num;
		shipInfo.innerHTML = text;
		sleep(10);
		document.getElementById('p_quickForm').style.display="";
		shipInfo.style.display = "";
	}
	shipInfo.style.left = (curleft+(currentElement.width/2)-15)+ 'px';
	shipInfo.style.top  = (curtop + currentElement.height - 30) + 'px';
}

function ShopInfoLayerView()
{
	Obj = document.getElementById('shipInfo');
	if(Obj == null) return;
	Obj.style.display = "";
}
function ShopInfoLayerHidden()
{
	Obj = document.getElementById('shipInfo');
	Obj.style.display = "none";
}

function pop_vs()
{
	var paramShop = trim(SelectBoxCheck());
	if(paramShop == "")
	{
		alert(" 대상을 선택해 주세요.");
		return;
	}

	var checkNum = paramShop.split(',');

	if ( checkNum.length < 1 || checkNum.length > 3 )
	{
		alert( " 상품을 3개 이하로 선택해 주세요. " );
		return;
	}

	window.open('/popup/pop_vs.php?shop='+paramShop,'','toolbar=no,width=650, height=480, top=10, left=10, scrollbars=yes, resizable=yes');
}

function wish_in( shop )
{
	if ( C_id=="" )
	{
		alert( "로그인후 이용해 주세요." );
		PopLogin();
		return;
	}

	new ajax.xhr.Request("/popup/popup_transaction/pop_wish_in.php", "shop="+shop, WishOk, 'POST');
}

var checkWishNum = 0;

function pop_wish_in()
{
	var paramShop = trim(SelectBoxCheck());
	if(paramShop == "")
	{
		alert(" 대상을 선택해 주세요.");
		return;
	}

	if ( C_id=="" || C_id==null )
	{
		alert( "로그인후 이용해 주세요." );
		PopLogin();
		return;
	}

	var checkNum = paramShop.split(',');

	checkWishNum = checkNum;

	new ajax.xhr.Request("/popup/popup_transaction/pop_wish_in.php", "shop="+paramShop, WishOk, 'POST');
}

function WishOk( xmlDoc )
{
	var aucShop	     = getNodeValue( xmlDoc.getElementsByTagName( 'aucShop' ) );
	var aucShopCount = eval( getNodeValue( xmlDoc.getElementsByTagName( 'aucShopCount' ) ) );

	if ( aucShopCount > 0 )
	{
		alert( "경매,공구 상품은 찜하기로 등록되지 않습니다." );
		return;

		if ( aucShopCount == 1 )
		{
		 	for (var i=1;i<=gsize;i++ )
			{
				if ( eval(_swid("chkitem"+i)).value == aucShop )
				{
					eval(_swid("chkitem"+i)).checked = false;
				}
			}

			$('#'+shopListKey[shopListViewNum].s_shopListId+' input:checkbox:checked').each(function(e){
				if(aucShop == $(this).val()) $(this).attr("checked", "");
			});
		}
		else
		{
			var aucNumCheck = aucShop.split(',');

			for (var k=0;k<aucShopCount;k++ )
			{
				for (var i=1;i<=gsize;i++ )
				{
					if ( eval(_swid("chkitem"+i)).value == aucNumCheck[k] )
					{
						eval(_swid("chkitem"+i)).checked = false;
					}
				}

				$('#'+shopListKey[shopListViewNum].s_shopListId+' input:checkbox:checked').each(function(e){
					if(aucNumCheck[k] == $(this).val()) $(this).attr("checked", "");
				});
			}
		}

		if ( checkWishNum == aucShopCount )
		{
			return;
		}

	}

	window.open('/popup/pop_wish_in.php','','toolbar=no,width=420, height=250, top=10, left=10, scrollbars=yes, resizable=yes');
}

function cart_in( shop )
{
	if ( C_id=="" || C_id==null )
	{
		alert( "로그인후 이용해 주세요." );
		PopLogin();
		return;
	}

	new ajax.xhr.Request("/popup/popup_transaction/pop_cart_in.php", "shop="+shop, CartOk, 'POST');
}

function pop_buynote( num ){
	if (  _swid("C_id").value=="" ){
		alert( "로그인후 이용해 주세요." );
		PopLogin();
		return;
	}else{
		window.open('/popup/pop_buynote.php?shop='+num,'','toolbar=no, width=580, height=530, top=10, left=10, scrollbars=yes, resizable=yes');
	}
}

function pop_cart_in()
{
	if(!SelectBoxCheck())
	{
		alert(" 대상을 선택해 주세요.");
		return;
	}

	if ( C_id=="" || C_id==null )
	{
		alert( "로그인후 이용해 주세요." );
		PopLogin();
		return;
	}

	var checkNum = 0;
	var paramShop = "";

	for (var i=1;i<=gsize;i++ )
	{
		if ( eval(_swid("chkitem"+i)).checked )
		{
			paramShop += eval(_swid("chkitem"+i)).value + ",";
			checkNum++;
		}
	}

	if ( paramShop.substr(paramShop.length-1,1) == "," )
	{
		parameShop = paramShop.substr(0,paramShop.length-1)
	}

	new ajax.xhr.Request("/popup/popup_transaction/pop_cart_in.php", "shop="+parameShop, CartOk, 'POST');
}

function CartOk( xmlDoc )
{
	var aucShop	     = getNodeValue( xmlDoc.getElementsByTagName( 'aucShop' ) );
	var aucShopCount = eval( getNodeValue( xmlDoc.getElementsByTagName( 'aucShopCount' ) ) );

	if ( aucShopCount > 0 )
	{
		alert( "경매,공구 상품은 장바구니에 등록되지 않습니다." );

		if ( aucShopCount == 1 )
		{
			for (var i=1;i<=gsize;i++ )
			{
				if ( eval(_swid("chkitem"+i)).value == aucShop )
				{
					eval(_swid("chkitem"+i)).checked = false;
				}
			}
		}
		else
		{
			var aucNumCheck = aucShop.split(',');

			for (var k=0;k<aucShopCount;k++ )
			{
				for (var i=1;i<=gsize;i++ )
				{
					if ( eval(_swid("chkitem"+i)).value == aucNumCheck[k] )
					{
						eval(_swid("chkitem"+i)).checked = false;
					}
				}
			}
		}
	}

	window.open('/popup/pop_cart_in.php','','toolbar=no,width=420, height=250, top=10, left=10, scrollbars=yes, resizable=yes');
}

function choiceDel2( tbl,num )
{
	if ( confirm("정말로 삭제하시겠습니까?") )
	{
		new ajax.xhr.Request("/common/inc/choice_del.php", "mode=del&table="+tbl+"&num="+num, CallchoiceDel, 'POST');
	}
}

function choiceDel( tbl )
{
	if(!SelectBoxCheck())
	{
		alert(" 대상을 선택해 주세요.");
		return;
	}

	var checkNum = 0;
	var paramShop = "";

	for (var i=1;i<=gsize;i++ )
	{
		if ( eval(_swid("chkitem"+i)).checked )
		{
			paramShop += eval(_swid("chkitem"+i)).value + ",";
			checkNum++;
		}
	}

	if ( paramShop.substr(paramShop.length-1,1) == "," )
	{
		parameShop = paramShop.substr(0,paramShop.length-1)
	}

	if ( confirm("정말로 삭제하시겠습니까?") )
	{
		new ajax.xhr.Request("/common/inc/choice_del.php", "mode=del&table="+tbl+"&num="+parameShop, CallchoiceDel, 'POST');
	}
}

function CallchoiceDel( xmlDoc )
{
	location.reload();
}

function PopLogin(returnUrl)
{
	window.open('/popup/pop_login.php?returnUrl='+encodeURIComponent(returnUrl),'','toolbar=no, width=460, height=350, top=10, left=10, scrollbars=yes, resizable=yes');
}

function PopBuyLogin()
{
	window.open('/popup/pop_nonorder.php','','toolbar=no, width=460, height=350, top=10, left=10, scrollbars=yes, resizable=yes');
}

function PopPreview(shop)
{
	window.name = "parentMain";
	window.open('/popup/pop_preview.php?shop='+shop,'','toolbar=no, width=750, height=500, top=10, left=10, scrollbars=yes, resizable=yes');
}


function goMiniShop(puid)
{
	document.location.href = "/minishop/myshop_main.php?muid="+puid;
}

function goCallCenter()
{
	pop_closed()
	window.open('/callcenter/callcenter_main.php','','');
}

function View_flash(Url,Width,Height)
{
	document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" + Width + "\" height=\"" + Height + "\">");
	document.writeln("<param name=\"movie\" value=\"" + Url + "\">");
	document.writeln("<param name=\"quality\" value=\"high\" />");
	document.writeln("<param name=\"wmode\" value=\"transparent\">");
	document.writeln("<embed src=\"" + Url + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + Width + "\"  height=\"" + Height + "\" wmode =\"transparent\">");
	document.writeln("</object>");
}

function View_flash2(Url,Width,Height,Param)
{
	document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" + Width + "\" height=\"" + Height + "\">");
	document.writeln("<param name=\"movie\" value=\"" + Url + "\">");
	document.writeln("<param name='FlashVars' value='" + Param + "' />");
	document.writeln("<param name=\"quality\" value=\"high\" />");
	document.writeln("<param name=\"wmode\" value=\"transparent\">");
	document.writeln("<embed src=\"" + Url + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + Width + "\"  height=\"" + Height + "\" wmode =\"transparent\">");
	document.writeln("</object>");
}

function View_flashv2(Url,Width,Height,allowDoamin, objid ,objname )
{
	if(allowDoamin =='') allowDoamin='sameDomain';

	document.writeln("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"" + Width + "\"  height=\"" + Height + "\" id=\"" + objid + "\" align=\"middle\">");
	document.writeln("<param name=\"allowScriptAccess\" value=\"" + allowDoamin + "\" />");
	document.writeln("<param name=\"movie\" value=\"" + Url + "\" />");
	document.writeln("<param name=\"quality\" value=\"high\" />");
	document.writeln("<param name=\"wmode\" value=\"transparent\" />");
	document.writeln("<embed src=\"" + Url + "\" quality=\"high\" width=\"" + Width + "\"  height=\"" + Height + "\" name=\"" + objname + "\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"  wmode =\"transparent\"/>");
	document.writeln("</object>");
}

function View_flv(Url,Width,Height)
{

	document.writeln("<EMBED src=http://www.eosbill.com/movie/flvplayer.swf?autoStart=false&image=http://www.eosbill.com/movie/flvload.jpg&file="+ Url + " width=\"" + Width + "\"  height=\"" + Height + "\" type=application/x-shockwave-flash  wmode =\"transparent\"></embed>");

}


function obj_movie(src, ids, width, height, autostart)
{
	var wh = "";
	if (parseInt(width) && parseInt(height))
		wh = " width='"+width+"' height='"+height+"' ";
	if (!autostart) autostart = false;
	return "<embed src='"+src+"' "+wh+" style='FILTER:xray();'  loop='-1' hidden=''0  autostart='"+autostart+"'  wmode =\"transparent\"></embed>";
}

function check_excel(formname)
{
   	var objDiv = document.getElementById('excelDownForm');
	if(objDiv == null)
	{
		var obj = document.createElement("iframe");
		obj.setAttribute("id", "excelDownForm");
		obj.style.height="0";
		obj.style.width="0";

		document.body.appendChild(obj);
	}
	objDiv = document.getElementById('excelDownForm');

	_swid(formname).action="/adminnew/excel_down.php";
	_swid(formname).target="excelDownForm";
	_swid(formname).method='post';
	_swid(formname).submit();
}

function check_order_excel(formname)
{
   	var objDiv = document.getElementById('excelDownForm');
	if(objDiv == null)
	{
		var obj = document.createElement("iframe");
		obj.setAttribute("id", "excelDownForm");
		obj.style.height="0";
		obj.style.width="0";

		document.body.appendChild(obj);
	}
	objDiv = document.getElementById('excelDownForm');

	_swid(formname).action="/adminnew/order_excel_down.php";
	_swid(formname).target="excelDownForm";
	_swid(formname).method='post';
	_swid(formname).submit();
}

function check_cart_excel(formname)
{
   	var objDiv = document.getElementById('excelDownForm');
	if(objDiv == null)
	{
		var obj = document.createElement("iframe");
		obj.setAttribute("id", "excelDownForm");
		obj.style.height="0";
		obj.style.width="0";

		document.body.appendChild(obj);
	}
	objDiv = document.getElementById('excelDownForm');

	_swid(formname).action="/adminnew/cart_excel_down.php";
	_swid(formname).target="excelDownForm";
	_swid(formname).method='post';
	_swid(formname).submit();
}

function cart_ship_excel(formname)
{
   	var objDiv = document.getElementById('excelDownForm');
	if(objDiv == null)
	{
		var obj = document.createElement("iframe");
		obj.setAttribute("id", "excelDownForm");
		obj.style.height="0";
		obj.style.width="0";

		document.body.appendChild(obj);
	}
	objDiv = document.getElementById('excelDownForm');

	_swid(formname).action="/adminnew/cart_ship_down.php";
	_swid(formname).target="excelDownForm";
	_swid(formname).method='post';
	_swid(formname).submit();
}

function product_list(formname)
{
	if ( _swid("C_id").value == "" )
	{
		alert( "로그인 후 이용해주세요." );
		return;
	}

   	var objDiv = document.getElementById('excelDownForm');

	if(objDiv == null)
	{
		var obj = document.createElement("iframe");
		obj.setAttribute("id", "excelDownForm");
		obj.style.height="0";
		obj.style.width="0";

		document.body.appendChild(obj);
	}
	objDiv = document.getElementById('excelDownForm');

	_swid(formname).action="/smanage/excel_product.php";
	_swid(formname).target="excelDownForm";
	_swid(formname).method='post';
	_swid(formname).submit();
}

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 CallcenterMoreAction(url,stage,type,head)
{
	head = head.replace("&","&amp;");
	document.location.href = url+"?stage="+stage+"&type="+type+"&head="+encodeURIComponent(head);
}

function changeShipCompay(shipType,shipname){
	if ( shipType == "1" ){
		_swid('selectShip').style.display = "";
		_swid('textShip').style.display = "none";
		_swid('select_trans_nm')[0].selected = true;
		_swid(shipname).value = "";
	}else{
		_swid('selectShip').style.display = "none";
		_swid('textShip').style.display = "";
		_swid('select_trans_nm')[0].selected = true;
		_swid(shipname).value = "";
	}
}

function chagneCompanyValue(companyValue, shipname){
	_swid(shipname).value = _swid('select_trans_nm').value;
}


//파라미터 value값 가져오기
function getRequestParam(key){
	if(window.location.href.indexOf('?') > 0)
	{
		var params =  window.location.href.slice(window.location.href.indexOf('?') + 1).split('#');
		var requstParams = decodeURIComponent(params[0]).split('&');

		for(var i = 0; i < requstParams.length; i++){
			var tempArray = requstParams[i].split('=');
			if(tempArray[0] == key) {
				return tempArray[1];
			}
		}
	}
	return '';
}

//파라미터 변경
function getChangeParam(data){
	var paramData = {};
	if(window.location.href.indexOf('?') > 0)
	{
		var params =  window.location.href.slice(window.location.href.indexOf('?') + 1).split('#');
		var requstParams = decodeURIComponent(params[0]).split('&');

		for(var i = 0; i < requstParams.length; i++){
			var tempArray = requstParams[i].split('=');
			paramData[trim(tempArray[0])] = trim(tempArray[1]);
		}
	}
	$.extend(paramData, data);
	return paramData;
}

//파라미터 데이타(맵) 리턴
function getParamData(){
	var paramData = {};
	if(window.location.href.indexOf('?') > 0)
	{
		var params =  window.location.href.slice(window.location.href.indexOf('?') + 1).split('#');
		var requstParams = decodeURIComponent(params[0]).split('&');

		for(var i = 0; i < requstParams.length; i++){
			var tempArray = requstParams[i].split('=');
			paramData[trim(tempArray[0])] = trim(tempArray[1]);
		}
	}
	return paramData;
}
//파라미터 문자열을 데이타(맵) 리턴
function getParamStrToData(str){
	var paramData = {};

	var requstParams = decodeURIComponent(str).split('&');

	for(var i = 0; i < requstParams.length; i++){
		var tempArray = requstParams[i].split('=');
		paramData[trim(tempArray[0])] = trim(tempArray[1]);
	}

	return paramData;
}

//파라미터 데이타를 url형태로 변경
function getParamUrl(paramData){
	var returnParam = '';
	var paramCnt = 0;
	for(key in paramData){
		if(paramCnt > 0) returnParam += '&';
		returnParam += key+'='+encodeURIComponent(paramData[key]);
		paramCnt++;
	}
	return  returnParam;
}

function pollVote(poll){
	var checkPoll="";
	for( var i=0; i<_swnm("pollitem").length; i++){
		if( _swnm("pollitem")[i].checked ){
			checkPoll = _swnm("pollitem")[i].value;
			break;
		}
	}
	if( checkPoll == "" ){
		alert("문항을 선택해주세요.");
		return;
	}
	new ajax.xhr.Request("/main/main_transaction/poll.php", 'poll='+poll+'&checkPoll='+checkPoll, setPollVote, 'POST');	
}

function setPollVote(xmlDoc){
	var code = getNodeValue( xmlDoc.getElementsByTagName( 'code' ) );

	if (code == 'success'){			
		alert("정상적으로 참여되었습니다.");
		return;
	}else if(code == "error1"){
		alert("로그인 후 참여하실 수 있습니다.");
		return;
	}else{
		alert("이미 참여한 Poll입니다.");
		return;
	}
}
