/**
 * 앞, 뒤 공백 제거
 */
String.prototype.trim = function(str)
{ 
	str = this != window ? this : str; 
	return str.replace(/^\s*|\s*$/g,"");
}

/**
 * ,를 삽입
 */
String.prototype.numberFormat = function(str)
{ 
	str = this != window ? this : str; 
	str+="";
	var objRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');
	while(objRegExp.test(str))
		str = str.replace(objRegExp, '$1,$2');
	return str;
}

/**
 * 실제 문자열 길이
 */
String.prototype.bytes = function(str)
{
	str = this != window ? this : str;
	for(j=0; j<str.length; j++) {
		var chr = str.charAt(j);
		len += (chr.charCodeAt() > 128) ? 2 : 1
	}
	return len;
}

/**
 * NIDA 퀵돔 점검
 */
function quickdomPopup(domain, ctfyno)
{
	var thistime= new Date()
	var h=thistime.getHours()
	var m=thistime.getMinutes()
	var s=thistime.getSeconds()
	var path = 'https://domain.nida.or.kr/quickDom/krApplySearchResult.jsp?domain=' + domain + '&comNum=' + ctfyno + '&time=' + h + m + s;

	var result = window.open(path, 'nida', 'width=630px, height=310px, scrollbars=no, status=no');
	result.focus();
}

/**
 *  도메인 정보 검색 창
 */
function domainSearchPopup(domain)
{
	var thistime= new Date()
	var h=thistime.getHours()
	var m=thistime.getMinutes()
	var s=thistime.getSeconds()
	var path = '/domain2/library/html/domainsearch/?domain=' + domain + '&time=' + h + m + s;

	window.showModalDialog(path, window,'dialogWidth:530px; dialogHeight:500px; scroll:yes; status:no; help:no; center:yes');	
}

function domainInfoPopup(url, domain, pro_code)
{
	var thistime= new Date()
	var h=thistime.getHours()
	var m=thistime.getMinutes()
	var s=thistime.getSeconds()
	var path = url + '?domain=' + domain + '&time=' + h + m + s;

	// pro_code를 넘겨서 한인주, 키워드, 윙크를 구별한다.
	if (pro_code)
	{
		path = path + '&pro_code=' + pro_code;
	}

	// 새창이 항상 앞으로 나오도록 by param 2005.12.15
	var result = window.open(path, 'whois', 'width=530px, height=500px, scrollbars=yes, status0=yes');
	result.focus();
//	window.showModalDialog(path, window,'dialogWidth:530px; dialogHeight:500px; scroll:yes; status:no; help:no; center:yes');
}

function designInfoPopup(url, order_no, oitem_no){
	var thistime= new Date()
	var h=thistime.getHours()
	var m=thistime.getMinutes()
	var s=thistime.getSeconds()
	var path = url + '?order_no=' + order_no + '&oitem_no=' + oitem_no + '&time=' + h + m + s;
	
	var result = window.open(path, 'Design', 'width=600px, height=130px, scrollbars=no, status:no; help:no;');
	//result.focus();
}

function modalPopup(url,width,height)
{
	var thistime= new Date()
	var h=thistime.getHours()
	var m=thistime.getMinutes()
	var s=thistime.getSeconds()
	var path = url + '&time=' + h + m + s;

	window.showModalDialog(path, window,'dialogWidth:'+width+'px; dialogHeight:'+height+'px; scroll:yes; status:no; help:no; center:yes');	
}

function modalPopupFix(url,width,height)
{
	var thistime= new Date()
	var h=thistime.getHours()
	var m=thistime.getMinutes()
	var s=thistime.getSeconds()
	var path = url + '&time=' + h + m + s;

	window.showModalDialog(path, window,'dialogWidth:'+width+'px; dialogHeight:'+height+'px; scroll:no; status:no; help:no; center:yes');	
}

/**
 * 텍스트를 클립보드로 복사
 */
function copyText(obj)
{
	var txtSelect = obj.createTextRange();
	obj.select();
	txtSelect.execCommand('copy');

	alert('복사하였습니다.\n\n사용할 곳에 붙여넣기(Ctrl + v)하시면 됩니다.');
}

/**
 * 문자열 길이 계산(한글 2byte)
 */
function checkByte(tmp)
{
	var tmpStr;
	var temp=0;
	var onechar;
	var tcount;
	tcount = 0;

	tmpStr = new String(tmp);
	temp = tmpStr.length;

	for (k=0;k<temp;k++)
	{
		onechar = tmpStr.charAt(k);

		if (escape(onechar).length > 4)
		{
			tcount += 2;
		}
		else if (onechar!='\r')
		{
			tcount++;
		}
	}
	return tcount;
}


function checkOctect(tmp) 
{
	var counter = 0;
	for(var i=0;i<tmp.length;i++) 
	{
		if(tmp.charAt(i) == '.') 
		{
			++counter
		}
		if(tmp.charAt(i) == '.' && tmp.charAt(i+1) == '.') {	return 0;	}
	}
	return counter;
}

/**
 * object를 화면에 출력(flash, activex..)

	<script>
		printObject('<object></object>')
	</script>

 */
function printObject(data)
{
	document.write (data);
}

/**
 * 플래시를 출력
 *
 */
function printFlash(src, width, height)
{
	if(!src || !width || !height)
	{
		return null;
	}

	var classid  = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000";
	var codebase = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0";
	var wmode    = "transparent";
	var quality  = "high";
	var plugin   = "http://www.macromedia.com/go/getflashplayer";
	var type     = "application/x-shockwave-flash";

	var html = "<object classid='" + classid + "' "
			 + "codebase='" + codebase + "' "
			 + "width='" + width + "' height='" + height + "'> "
			 + "<param name='wmode' value='" + wmode + "'>"
			 + "<param name='movie' value='" + src + "'>"
			 + "<param name='quality' value='" + quality + "'>"
			 + "<embed src='" + src + "' "
			 + "quality='" + quality + "' pluginspage='" + plugin + "' type='" + type + "' "
			 + "width='" + width + "' height='" + height + "' wmode='transparent'></embed></object>";

	printObject(html);
}

/**
 * object를 화면에 출력(flash, activex..)

	<textarea id=flash1 style="display:none;" rows="0" cols="0">
		<object>
		</object>
	<textarea>
	<script>
		PrintEmbed('flash1')
	</script>
 */
function PrintEmbed(EmbID) 
{ 
    document.write(document.getElementById(EmbID).value); 
} 

/**
** 본문에 이메일, 전화번호 체크하기
**/
function EmailTelCheck(text)
{
	var TelNum = new Array( '02-','031-','032-','033-','041-','042-','043-','051-','052-','053-','054-','055-','061-','062-','063-','064-','02 -','031 -','032 -','033 -','041 -','042 -','043 -','051 -','052 -','053 -','054 -','055 -','061 -','062 -','063 -','064 -','02 - ','031 - ','032 - ','033 - ','041 - ','042 - ','043 - ','051 - ','052 - ','053 - ','054 -' ,'055 - ','061 - ','062 - ','063 - ','064 - ', '010-', '011-',  '016-', '017-', '018-', '019', '010 -', '011 -', '016 -', '017 -', '018 -', '019 -', '010 - ', '011 - ', '016 - ', '017 - ', '018 - ', '019 - ', '@');
	var str = new String(text);
	var check, textval	

	for(j=0; j < TelNum.length; j++){		
		textval = TelNum[j];				
		if(str.match(textval)){				
			check = 1;		
		}		
	}	
	if(check == 1){
		return false;
	}else{
		return true;
	}
}

function modal_open(url)
{
	var array = url.split("&");
	var array2 = array[1].split("=");
	var mode = array2[1];
	if(!mode){
		alert("商品の情報はありません"); 
		return;
	}
	if  (window.showModelessDialog) {
		var status	= "help: no; scroll: yes; status: no; dialogWidth: 1050px; dialogHeight: 850px; center: yes";
		window.showModelessDialog(url, window, status);
	} else {
		var win = window.open(url, '_preView', 'height=850,width=1050,toolbar=no,directories=no,status=no,linemenubar=no,scrollbars=no,resizable=no,modal=yes,dependent=yes');
	}
}



function modal_open2(url)
{
	var modal_view= null; 

	if(!modal_view || modal_view.closed){ 
		modal_view = window.open(url,"modal_view","left=0, top=0, resizable=no, width=800, height=850, scrollbars=yes"); 
		
	}else{ 		
		modal_view.location = url; 
		modal_view.focus(); 
	} 
	//return window.open(url,"modal_view","left=0, top=0, resizable=no, width=800, height=850, scrollbars=yes, alwaysRaised=yes");
}

function AsaChangeSelectPage(key, value)
{
	var url			= location.href;
	var regExp		= '/?/';
	var addStr		= '?';

	if (url.match(regExp))
	{
		addStr		= '&';
	}

	location.href	= url + addStr + key + '=' + value;
}

function hideDegugInfo() {
	objDivDebug = document.getElementById('div_debug');	
	
	if(objDivDebug) {
		objDivDebug.style.display='none';
	}
}

function showDegugInfo(msg) {
	try 
	{
		objDivDebug = document.getElementById('div_debug');	
	
		if(!objDivDebug) {	
			document.write("<body><div id='div_debug' style='position: absolute; Z-INDEX: 1'><hr><b>debug info</b>&nbsp;&nbsp;<input type='button' onclick='hideDegugInfo();' value='닫기'><hr></div></body>");
			objDivDebug = document.getElementById('div_debug');
			objDivDebug.style.left = 0;
			objDivDebug.style.top = 0;
			objDivDebug.style.width = 180;
			objDivDebug.style.height = 100;
			objDivDebug.style.textAlign = 'left';
			objDivDebug.style.paddingLeft = 5;
			objDivDebug.style.paddingRight = 5;
			objDivDebug.style.fontSize = 12;
			objDivDebug.style.backgroundColor = '#D4D4D4';
			objDivDebug.style.filter = 'alpha(opacity:75)';			
		}

		objDivDebug.innerHTML = objDivDebug.innerHTML+msg;

	}	catch (e) {}
	
}
