var C_id;

function $(Str) { return document.getElementById(Str); }

function $$(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 login_id = target.value;
	var ascii, i;

	if (login_id == "")
	{
		return true;
	}

	for (i=0;i < login_id.length ;i++)
	{
		ascii = login_id.charCodeAt(i);
		if ((i==0) && ((ascii < 97) || (ascii  > 122)))
		{
			alert("첫 글자는 영문소문자만 가능합니다.");
			target.focus();
			return true;
		}
		else if (   ascii >= 65 && ascii <= 90 )
		{
			alert(" 영문 대문자는 사용할 수 없습니다.");
			target.focus();
			return true;
		}
		else if (ascii > 122)
		{
			alert("한글을 비롯한 특수문자는 사용할 수 없습니다.");
			target.focus();
			return true;
		}
		
	}
	
	for (i = 0; i < login_id.length; i++)
	{
		if (login_id.charAt(i) >= "0" && login_id.charAt(i) <= "9")
		{
			continue;
		}
		else if (login_id.charAt(i) >= "a" && login_id.charAt(i) <= "z")
		{
			continue;
		}
		else if (login_id.charAt(i) >= "A" && login_id.charAt(i) <= "Z")
		{
			continue;
		}
		else if (login_id.charAt(i) == "_")
		{
			continue;
		}
		else if (login_id.charAt(i) == " ")
		{
			alert("회원 아이디(ID)는 띄어쓰기 없이 영문자와 숫자 조합과 '_'만 가능합니다. ");
			target.focus();
			return true;
		}
		else
		{
			alert("회원 아이디(ID)는 띄어쓰기 없이 5~15자리의 영문자와 숫자 조합과 '_'만 가능합니다.");
			target.focus();
			return true;
		}
	}
	 
	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)) 
	{
		
		if(navigator.appVersion.indexOf("MSIE 7.0")>=0) 
		{	
			window.opener='Self';
			window.open('','_parent','');
			window.close();
		}
	
		else 
		{
			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 });
}

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------


// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
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_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)
{
	var obj = $('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 = $('restorationIframe');
	}
	
	obj.src = '/adminnew/design/pop_display_mody.php?fileName='+fileName+'&mode=restoration';
	//window.open('/adminnew/design/pop_display_mody.aspx?fileName='+fileName,'','toolbar=no, width=650, height=370, top=10, left=10, scrollbars=yes, resizable=yes');	
}

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
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 = 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(",","");	 

	 return returnValue;
}

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
String.prototype.replaceAll = function( searchStr, replaceStr )  
{  
	this.temp = this;  
	while( this.temp.indexOf( searchStr ) != -1 )  
	{  
	 	this.temp = this.temp.replace( searchStr, replaceStr );  
	}  
	return this.temp;  
}  
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

function InsertFile(fname, msection)
{    
 	 var URLs='/common/inc/pop_orgAdd.php?fname=' + fname + '&msection=' + msection ;
	 var arr = showModalDialog( URLs ,"","font-family:Verdana; font-size:12; dialogWidth:678px; dialogHeight:487px" );
	 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( arr.idx == "edit")	
		{	
			try{ document.getElementById( '_nowimgdiv_').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){} 
		}
	}

}


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_mody.php?num='+num,'','toolbar=no, width=900, height=700, top=10, left=10, scrollbars=yes, resizable=yes');	
}


function select_box() 
{
	var gsize = parseInt($('gsize').value) ;	

	for(i=0; i<gsize; i++) 
	{
		var goods = eval($('chkitem'+i));
	
		if(goods.checked)
		{
			return true;
		}
	}
	return false;
}

function check_all() 
{
	var gsize = parseInt($('gsize').value) ;	

	var b = false;
	if( $('chkall').checked ) 
	{
		b = true;		
	}

	for(i=0; i<gsize; i++) 
	{			
		var obj = eval($('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);
	}
}

//=======================================================================================================
//=======================================================================================================

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($("chkitem"+i)).checked )
		{	
			paramShop += eval($("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 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 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_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>";
}	


