/*hanmail.js*/
/* IE 5.0에서 지원되지 않아 추가 했으나, for....in 구문에서 prototype을 property인양 넘겨주는 문제가 있어 제외시킴.
if ( ! Array.prototype.push ) {
	Array.prototype.push = function () {
		var l = this.length;
		for ( var i = 0; i < arguments.length; i++ ) {
			this[l+i] = arguments[i];
		}
		return this.length;
	}
}
*/
String.prototype.addslashes = function(){
	return this.replace(/(["\\\.\|\[\]\^\*\+\?\$\(\)])/g, '\\$1');
}
String.prototype.trim = function () {
	return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
}
String.prototype.ltrim = function(){
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function(){
	return this.replace(/\s+$/,"");
}
String.prototype.replaceAll = function(findStr, newStr){
	return this.replace(new RegExp(findStr, "gi"), newStr);
}
var $A = function(iterable){
    if (!iterable) return [];
    if (iterable.toArray) {
        return iterable.toArray();
    }else{
        var results = [];
        for(var i = 0; i < iterable.length; i++){
            results.push(iterable[i]);
        }
        
        return results;
    }
}
if(!Function.prototype.apply){
	Function.prototype.apply = function() {
		if(!arguments[0]){
			this();
			return;
		}
		var baseObj = arguments[0];
		var d = new Date();
		var tempFuncName = "f" + d.getTime();
		var args = new Array();
		
		baseObj[tempFuncName] = this;
		if(arguments[1]){
			for (var i=0; i<arguments[1].length; i++){
				args[i] = "arguments[1][" + i + "]";
			}
		}
		eval("baseObj[tempFuncName](" + args.join(",") + ")");
		delete baseObj[tempFuncName];
	}
}
Function.prototype.bind = function(){
	var __method = this, args = $A(arguments), object = args.shift();	
	
	return function(){
    	return __method.apply(object, args.concat($A(arguments)));
	}
}
Function.prototype.bindAsEventListener = function(object){
	var __method = this;
	return function(e){
		return __method.call(object, e || window.event);
	}
}
var Hanmail = {
	//docHeight : window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
	ieBug : (navigator.userAgent.toLowerCase().indexOf("msie") != -1) ? true : false, 
	exceptHeight : 0,
	resetSize : function(){
		try{
			this.docWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
			this.docHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
		}catch(ignored){}
	},
	
	setExceptWrap : function(){
		if(!this.exceptWrap){
			this.exceptWrap = document.getElementById("totalSearchWrap") || null;
			if(document.getElementById("totalSearchWrap")){
				this.exceptHeight = this.exceptWrap.offsetHeight || 0;
			}
		}
	},
	
	setScroller : function(){
		this.resetSize();		
		if(document.getElementById("hanmailWrap")){
			if(!this.scroller){
				this.scroller = document.getElementById("hanmailWrap");				
				this.scroller.style.overflowY = "scroll";
				this.scroller.style.overflowX = "auto";				
				//this.scroller.style.position = "relative";
				//this.scroller.style.zIndex = "1";
				this.scroller.style.paddingRight = "15px";
				this.setExceptWrap();										
			}			
		}else{
			return false;
		}
		
		try{					
			this.scroller.style.height = this.docHeight - this.exceptHeight + "px";
		}catch(ignored){}
		/*		
		this.resetSize();
		if(document.getElementById("hanmailWrap")){
			if(!this.scroller){
				this.scroller = document.getElementById("hanmailWrap");				
				this.scroller.style.overflowY = "scroll";
				this.scroller.style.position = "relative";
				this.scroller.style.zIndex = "1";
				this.scroller.style.paddingRight = "15px";
				this.exceptWrap = document.getElementById("totalSearchWrap") || null;				
				this.exceptHeight = (this.exceptWrap) ? this.exceptWrap.offsetHeight : 0;		
			}			
		}else{
			return false;
		}
		
		try{
			this.scroller.style.height = this.docHeight - this.exceptHeight + "px";
		}catch(ignored){}
		*/
	},
	getCoords : function(element){
		var _element = (typeof(element) == "string") ? document.getElementById(element) : element;		
		
		var coords = {
			left: 0,
			top: 0,
			right: 0,
			bottom: 0,
			width: _element.offsetWidth,
			height:	_element.offsetHeight
		};
		
		while(_element){
			coords.left += _element.offsetLeft;
			coords.top += _element.offsetTop;			
			_element = _element.offsetParent;			
		}
		if(document.getElementById("hanmailWrap")){
			coords.top = coords.top - document.getElementById("hanmailWrap").scrollTop;
		}
		
		coords.right = coords.left + coords.width;
		coords.bottom = coords.top + coords.height;
	
		return coords;
	},
	eventModel : (document.addEventListener) ? "w3c" : "bubble",
	
	addEvent : function(targetObject, eventType, eventHandler, isCapture){
		if(isCapture == null) var isCapture = false;	

		if(this.eventModel == "w3c"){
			targetObject.addEventListener(eventType.replace(/on/,""), eventHandler, isCapture);
		}else if(this.eventModel == "bubble"){
			targetObject.attachEvent(eventType, eventHandler);
		}	
	},
	
	removeEvent : function(targetObject, eventType, eventHandler, isCapture){ 
		if(isCapture == null) var isCapture = false;
		
		if(this.eventModel == "w3c"){ 
			targetObject.removeEventListener(eventType.replace(/on/,"") , eventHandler, isCapture);
		}else if(this.eventModel == "bubble"){
			targetObject.detachEvent(eventType, eventHandler);
		} 
	},
	
	stopEvent : function(e){
		if(!e) var e = window.event;

		e.cancelBubble = true;

		if(e.stopPropagation) e.stopPropagation();
	}
}

var DocumentTitleChanger = function(){	
	if((window.top.document.title != document.title) && (window.name == "right" || window.name == "showen")){
		window.top.document.title = document.title;
	}
}
try{ DocumentTitleChanger(); } catch(ignored){}
function SearchBoxFocus(box){
	if(!box.searchFlag){
		box.value = "";
		box.searchFlag = true;
	}	
}
function SearchBoxBlur(box){
	if(box.value.trim().length == 0){
		box.value = "메일을 검색하세요~";
		box.searchFlag = false;
	}
}

var Daum= {
	default_path : null,
	strDummy : new Date().getTime(),
	setPath: function(url){
		this.default_path = url;
	},
	setDummy: function(dummy){
		this.strDummy = dummy;
	},
	include: function(){
		var jsList = this.include.arguments;
		for ( var i=0; i<jsList.length; i++ ){
			var tag = "<script language=\"javascript\" ";			
			tag+= "src=\"" + this.default_path + jsList[i] + ".js?dummy="+ this.strDummy +"\"></script>";
			document.write(tag);
		}
	},
	includeEntity: function(strType){
		var jsList = this.include.arguments;
		for ( var i=1; i<jsList.length; i++ ){
			var tag = "<script type=\""+strType+"\" ";			
			tag+= "src=\"" + jsList[i] + "\"></script>";
			document.write(tag);
		}	
	}
}

function rotateAd(){	
	if(window.top.left.document.getElementById("adWrap")){			
		window.top.left.commonAd.document.location.reload();				
	}		
}
//광고 숨김
function hideAd(){
	return; 
	//Dead Codes
	var objAd = null;	
	if(window.top.left.document.getElementById("commonAdArea")){
		objAd = window.top.left.document.getElementById("commonAdArea");	}
	
	var objMg = window.top.left.document.getElementById("lMarginL");
	
	if(objAd != null || objAd != undefined ){
		objAd.style.display = "none";
		objMg.style.display = "block";
	}
	
	if(document.getElementById("adIcons")){
		document.getElementById("adIcons").style.display = "block";
	}
}

function IsIE() {
	if( navigator.userAgent.indexOf("MSIE") == -1 ) {
		return false;
	}
	return true;
}

function toggleHover(obj){
	if(obj.style.textDecoration == "underline"){
		obj.style.textDecoration = "none";
	}else{
		obj.style.textDecoration = "underline";
	}
}

//편지목록 - mouseOver시 tr에 보더주기
function list_over(t1, bool)
{
	var oTD = eval("document.all.m" + t1);
	var len = oTD.length;
	var borderStyle = "1 solid #b8d659";
	var borderStyle2 = "1 solid #ffffff";

	if (bool){
		for(var i =0; i < len ; i++){
			oTD[i].style.borderTop = borderStyle;
			oTD[i].style.borderBottom = borderStyle;
			oTD[i].style.cursor = "default";
		}
		oTD[0].style.borderLeft = borderStyle;
		oTD[len-1].style.borderRight = borderStyle;
	}else{
		for(var i =0; i < len ; i++){
			oTD[i].style.borderTop = borderStyle2;
			oTD[i].style.borderBottom = borderStyle2;
			oTD[i].style.cursor = "default";
		}
		oTD[0].style.borderLeft = borderStyle2;
		oTD[len-1].style.borderRight = borderStyle2;
	}
}

function change_check_box_status(obj,status) {
	if( obj.checked != null ) {
		obj.checked = status;
	} else {
		if( obj.length ){
			for( var i = 0; i< obj.length; i++ ){
				obj[i].checked = status;
				chk_selected(obj[i]);
			}	
		}
	}
}

function SpamKeywordcheckall(formname,checkname,thestate){
	var el_collection=eval("document.forms."+formname+"."+checkname);
	if(el_collection != null)
	{
		if(el_collection.length){
			for (c=0;c<el_collection.length;c++)
				if(el_collection[c].disabled==false)
				el_collection[c].checked=thestate;
		}
		else{
			el_collection.checked=thestate;
		}
	}
}

//view 메일에서 사용.
//Tip 기능
flag=true;
function Display_tip(index , view, flag) {

	if(view == 'show'){
		if(flag) {
			if (navigator.userAgent.indexOf("MSIE") != -1) {
				document.getElementById('Tip' + index).style.display='';
				flag = false;
			}else {
				location.href = "";
			}
		} else {
			document.getElementById('Tip' + index).style.display='none';
			flag = true;
		}
	} else if(view == 'hide'){
		if (flag){
			document.getElementById('Tip' + index).style.display ='';
		}else{
			document.getElementById('Tip' + index).style.display = "none";
		}
	}
}

function showBoardList(index,bool){
	if (bool){
		document.getElementById('Tip' + index).style.display ='';
	}else{
		document.getElementById('Tip' + index).style.display = "none";
	}
}

function getUserFeature(){
	var strOs = "";
	var strOsver = "";
	var browser = "";
	var browserVer = "";
	
	var userAgent = navigator.userAgent.toLowerCase();

	// OS
	if(userAgent.indexOf ( "win" ) >= 0 || userAgent.indexOf ( "16bit" ) >= 0 ){
		strOs = "Windows";		

		// OS ver
		if(userAgent.indexOf("nt 6.0") != -1){
			strOsver = "Vista";
		}else if(userAgent.indexOf("nt 5.1") != -1){
			strOsver = "XP";
		}else if(userAgent.indexOf("nt 5.0") != -1){
			strOsver = "2000";
		}else if(userAgent.indexOf("windows 98") != -1){
			strOsver = "98";
		}else if(userAgent.indexOf("windows 95") != -1){
			strOsver = "95";
		}else if(userAgent.indexOf("windows ce") != -1){
			strOsver = "ce";
		}else{
			strOsver = "";
		}
	}else if(userAgent.indexOf ("mac" )>= 0 ){
		strOs = "Mac";
	}else if ( userAgent.indexOf ( "unix" ) >= 0
		 || userAgent.indexOf ( "x11" ) >= 0
		 || userAgent.indexOf ( "linux" ) >= 0
		 || userAgent.indexOf ( "bsd" ) >= 0
		 || userAgent.indexOf ( "sunos" ) >= 0
		 || userAgent.indexOf ( "irix" ) >= 0
		 || userAgent.indexOf ( "lynx" ) >= 0
		 || userAgent.indexOf ( "hp-ux" ) >= 0
		 || userAgent.indexOf ( "aix" ) >= 0
		 || userAgent.indexOf ( "sco" ) >= 0
		 || userAgent.indexOf ( "ncr" ) >= 0
		 || userAgent.indexOf ( "dec" ) >= 0
		 || userAgent.indexOf ( "osf1" ) >= 0
		 || userAgent.indexOf ( "ultrix" ) >= 0
		 || userAgent.indexOf ( "sinix" ) >= 0 ){
		strOs = "Unix";
	}else{
		strOs = "anonymous system";
	}
	
	// browser
	if(userAgent.indexOf("sv1") >= 0){
		browser = "ie6";		
	}else if(userAgent.indexOf("msie 7") >= 0){
		browser = "ie7";
	}else if(userAgent.indexOf("firefox/2") >= 0){
		browser = "firefox2";
	}else if(userAgent.indexOf("firefox/3") >= 0){
		browser = "firefox3";
	}else if(userAgent.indexOf("gecko") >= 0){
		browser = "gecko";
	}else if(userAgent.indexOf("netscape") >= 0){
		browser = "netscape";
	}else{
		browser = "anonymous browser"
	}
	
	return {
		osType: strOs,
		osVer: strOsver,		
		browser: browser,
		userFull: (strOsver != "") ? strOs + " " + strOsver + " " + browser : strOs + " " + browser
	};
}

function getAdvHeight(){
    var h=0;
    var userFeatures = getUserFeature();
    switch(userFeatures.browser){
    	case "ie6" :
    		h = 14;
    		break;
    	case "ie7" :
    		h = 45;
    		break;
       	case "gecko" :
    		h = 11;
    		break;
       	case "firefox2" :
    		h = 18;
    		break;
    	case "firefox3" :
    		h = 38;
    		break;     		
		case "netscape" :
    		h = -2;
    		break;
    }    

	if(userFeatures.browser == "ie7" && userFeatures.osVer == "Vista"){
		h = h + 20;
	}

    return h;
}

function OpenWindow(p_sURL, p_sName, p_iTopMargin, p_iLefMargin, p_bScrollBars, p_bResizable, p_iWidth, p_iHeight) {
	//IE7 출시관계로 높이 재조정해서 띠움	
	p_iHeight = parseInt(p_iHeight);
	p_iHeight += parseInt(getAdvHeight());
	
	l_sSpecialty = 'topmargin=' + p_iTopMargin;
	l_sSpecialty = l_sSpecialty + ', leftmargin=' + p_iLefMargin;
	l_sSpecialty = l_sSpecialty + ', scrollbars=' + p_bScrollBars;
	l_sSpecialty = l_sSpecialty + ', resizable=' + p_bResizable;
	l_sSpecialty = l_sSpecialty + ', width=' + p_iWidth;
	l_sSpecialty = l_sSpecialty + ', height=' + p_iHeight;

	return window.open(p_sURL, p_sName, l_sSpecialty);
}

function OpenWindowWithoutReturn(p_sURL, p_sName, p_iTopMargin, p_iLefMargin, p_bScrollBars, p_bResizable, p_iWidth, p_iHeight) {
	//IE7 출시관계로 높이 재조정해서 띠움
	p_iHeight = parseInt(p_iHeight);	
	p_iHeight += parseInt(getAdvHeight());
	
	l_sSpecialty = 'topmargin=' + p_iTopMargin;
	l_sSpecialty = l_sSpecialty + ', leftmargin=' + p_iLefMargin;
	l_sSpecialty = l_sSpecialty + ', scrollbars=' + p_bScrollBars;
	l_sSpecialty = l_sSpecialty + ', resizable=' + p_bResizable;
	l_sSpecialty = l_sSpecialty + ', width=' + p_iWidth;
	l_sSpecialty = l_sSpecialty + ', height=' + p_iHeight;

	window.open(p_sURL, p_sName, l_sSpecialty);
}

function OpenWindowWithoutReturn2(p_sURL, p_sName, p_iTopMargin, p_iLefMargin, p_bScrollBars, p_statusbar, p_bResizable, p_iWidth, p_iHeight) {
	//IE7 출시관계로 높이 재조정해서 띠움	
	p_iHeight = parseInt(p_iHeight);
	p_iHeight += parseInt(getAdvHeight());	
	
	l_sSpecialty = 'topmargin=' + p_iTopMargin;
	l_sSpecialty = l_sSpecialty + ', leftmargin=' + p_iLefMargin;
	l_sSpecialty = l_sSpecialty + ', scrollbars=' + p_bScrollBars;
	l_sSpecialty = l_sSpecialty + ', status='	  + p_statusbar;
	l_sSpecialty = l_sSpecialty + ', resizable=' + p_bResizable;
	l_sSpecialty = l_sSpecialty + ', width=' + p_iWidth;
	l_sSpecialty = l_sSpecialty + ', height=' + p_iHeight;

	window.open(p_sURL, p_sName, l_sSpecialty);
}

function GetStringLength(p_str)
{
	var c;
	var l_sLength = 0;

	for(k = 0;k < p_str.length; k++) {
		c = p_str.charAt(k);
		//내장함수 escape를 통해 그 글자의 길이가 4보다 크면 한글이므로 2를 더한다.
		if(escape(c).length > 4)
			l_sLength += 2;
		else
			l_sLength++;
	}
	return l_sLength;
}

function CheckFormValidation(p_sFormVar, p_sFormName, p_iMaxLength, p_iFormType, p_bEssential, p_bMessage) {
	var l_iStringLength = GetStringLength(p_sFormVar.value)

	if ( p_bEssential ) {
		if( l_iStringLength == 0 ) {
			if (p_bMessage) {
				AlertPrompt( p_sFormVar, "입력하지 않은 항목(" + p_sFormName + ")이 있습니다.");
			}
			return( false );
		}
		spacecount = 0;
		for( var i = 0; i < l_iStringLength; i++ ) {
			thisChar = p_sFormVar.value.charAt( i );
			if( thisChar == ' ' ) spacecount++;
		}
		if( spacecount == l_iStringLength ) {
			if (p_bMessage) {
				AlertPrompt( p_sFormVar, "입력하지 않은 항목(" + p_sFormName + ")이 있습니다.");
			}
			return( false );
		}
	}

	if ( p_iMaxLength > 0 ) {
		if( l_iStringLength > p_iMaxLength ) {
			if (p_bMessage) {
				AlertPrompt( p_sFormVar, "입력하신 항목(" + p_sFormName + ")의 길이가 초과하였습니다. " + (l_iStringLength-p_iMaxLength) + " 자 이상을 지우시기 바랍니다.")
			}
			return( false );
		}
	}

	switch (p_iFormType) {
		case 1 : // 영문만 입력
			var regEx = new RegExp("^[a-z]+$", "i");

			if ( regEx.test(p_sFormVar.value) )
			{
				return true;
			}
			else
			{
				if ( p_bMessage )
				{
					window.alert("영문자만 입력 가능합니다" + "\n\n" + "\"" + p_sFormVar.value + "\"");
				}
				p_sFormVar.focus();
				return false;
			}
			break;
		case 2 : // 숫자만 입력
			var regEx = new RegExp("^[0-9]+$", "i");

			if ( regEx.test(p_sFormVar.value) )
			{
				return true;
			}
			else
			{
				if ( p_bMessage )
				{
					window.alert("숫자만 입력 가능합니다" + "\n\n" + "\"" + p_sFormVar.value + "\"");
				}
				p_sFormVar.focus();
				return false;
			}
			break;
		case 3 : // Email입력
			if ( l_iStringLength > 0 ) {
				ret = checkEmailAddress(p_sFormVar.value, p_bMessage);
				if ( ! ret ) {
					p_sFormVar.focus();
					return false;
				}
			}
			break;
		case 4 : // 영문&숫자만 입력
			var regEx = new RegExp("^[a-z0-9]+$", "i");

			if ( regEx.test(p_sFormVar.value) )
			{
				return true;
			}
			else
			{
				if ( p_bMessage )
				{
					window.alert("영문자와 숫자만 입력 가능합니다" + "\n\n" + "\"" + p_sFormVar.value + "\"");
				}
				p_sFormVar.focus();
				return false;
			}
			break;
		case 5 : // 영문&숫자&_ 회원 아이디 확인시
			var regEx = new RegExp("^[a-z][a-z0-9_]*$", "i");

			if ( regEx.test(p_sFormVar.value) )
			{
				return true;
			}
			else
			{
				if ( p_bMessage )
				{
					window.alert("영문자와 숫자, 언더바만 입력 가능합니다" + "\n\n" + "\"" + p_sFormVar.value + "\"");
				}
				p_sFormVar.focus();
				return false;
			}
			break;
		default : // 제한 없음
			break;
	}
	return( true );
}

function AlertPrompt(p_Ctrl, p_sAlertMessage) {
    alert(p_sAlertMessage);
    p_Ctrl.focus();
    return;
}

function checkEmailAddress(p_sMailAddress, p_bMessage)
{
	var regEx = new RegExp("^([a-z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-z0-9_\\-]+\\.)+))([a-z]{2,4}|[0-9]{1,3})(\\]?)$", "i");

	if ( regEx.test(p_sMailAddress) )
	{
		return true;
	}
	else
	{
		if ( p_bMessage )
		{
			window.alert("아래 이메일 주소가 잘못 되었습니다" + "\n\n" + "\"" + p_sMailAddress + "\"");
		}
		return false;
	}
}

function ResponseConfirm(p_sConfirmMessage, p_sURL) {
	if ( confirm(p_sConfirmMessage) ) {
		location.href = p_sURL;
	}
}

function noaction() {}

function getCookie(Name) {
	var search = Name + "="
	if (document.cookie.length > 0) { // if there are any cookies
		offset = document.cookie.indexOf(search)
		if (offset != -1) { // if cookie exists
			offset += search.length
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset)
			// set index of end of cookie value
			if (end == -1)
				end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		}
	}
}
function getCookie2(Name1, Name2) {
	var l_sStr = getCookie(Name1);
	var search = Name2 + "="
	offset = l_sStr.indexOf(search)
	if (offset != -1) { // if exists
		offset += search.length
		// set index of beginning of value
		end = l_sStr.indexOf("&", offset)
		// set index of end of cookie value
		if (end == -1)
			end = l_sStr.length
		return unescape(l_sStr.substring(offset, end))
	}
}

function setCookie(name, value, expire) {
	document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}

function delCookie(name)	{
	document.cookie = name + "=;expires=Fri, 31 Dec 1987 23:59:59 GMT;";
}
function CheckNull(elementName,message)
{
	if(IsNullString(elementName.value))
	{
		alert(message+"를(을) 입력하시기 바랍니다.");
		elementName.focus();
		return false;
	}
	else return true;
}

function IsNullString(string)
{
        for(var i=0; i<string.length; i++)
                if(string.charAt(i)!=' ' && string.charAt(i)!='\r' && string.charAt(i)!='\n'
			&& string.charAt(i)!='\t' && string.charAt(i)!='\b') return false;

        return true;
}

function IsPositiveInt(string)
{
	if(string=="") return false;
	else for(var i=0; i<string.length; i++) if(isNaN(parseInt(string.charAt(i)))) return false;

	return true;
}

function checkEmailAddressWithCheckbox (p_oCheckbox,p_oEmailBox)
{
  var l_sEmail

  l_sEmail =  p_oEmailBox.value;


  if (p_oCheckbox.checked) {
   	 if (checkEmailAddress(l_sEmail, true))
     {
		 return true;
  	 }
	 else
	 {
		 p_oEmailBox.focus();
  	  	 return false;
	 }
  }

  else
  {
	return true;
  }
}

function IsValidObject(p_oVal)
{
	if(  p_oVal == null || typeof(p_oVal) == "undefined" )
        return false;

    return true;
}

function IsValidString(p_sVal)
{
	if( IsValidObject(p_sVal) == false || p_sVal == "" )
		return false;

	return true;
}

function MakeOptionTag( p_sPrev, p_sText, p_sValue, p_sSelValue)
{
	var l_sResult = "";
	if( IsValidString(p_sValue) == false )
		p_sValue = "";

	if( IsValidString(p_sSelValue) == false )
		p_sSelValue = "";

	if( String(p_sValue) == String(p_sSelValue) )
		l_sResult = p_sPrev + "<option value=\"" + p_sValue + "\" selected>" + p_sText + "</option>";
	else
		l_sResult = p_sPrev + "<option value=\"" + p_sValue + "\">" + p_sText + "</option>";

	return l_sResult;
}

// 스트링 값에 있는 모든 공백을 제거해준다. chon2
function Space_All(str)
{
	var index, len
	while(true)
	{
		index = str.indexOf(" ")
		if (index == -1) break
		len = str.length
		str = str.substring(0, index) + str.substring((index+1),len);
	}
	return str;
}

// 스트링의 앞 뒤 여백 제거한다. hwon
function Space_FrontBack(str)
{
	str = str.replace(/(^\s*)|(\s*$)/g, "");
	return str;
}


function Trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function LeftTrim(str)
{
	return str.replace(/^\s+/,"");
}

function RightTrim(str)
{
	return str.replace(/\s+$/,"");
}

function IsIncludeKoreanChar(str)
{
    var flag = false;
    for (i=0; i<str.length; i++) {
    	if( str.charCodeAt(i) >= 12593 )
        	return true;
    }
}

function checkMaxCharLangth(oInput, nMaxLength, bAlert)
{
	var nLength = 0;
	var sResult = "";
	var sTemp;
	nLength = GetStringLength(oInput.value);
	if( nMaxLength < nLength ) {
		if(bAlert) {
			alert("입력 가능한 범위를 넘었습니다.");
		}
		sTemp = oInput.value.substring(0,nMaxLength);
		var step = 0;
		while(GetStringLength(sTemp) > nMaxLength){
			sTemp = sTemp.substring(0, (nMaxLength - step));
			step += 2; 
		}
		
		oInput.value = sTemp;
	}
}

function encodeURI(strVal)
{
	if(encodeURIComponent){
	    return encodeURIComponent(strVal);
	}
	if(escape){
	    return escape(strVal);
	}
}

function insertAddrbook(name, email){
	OpenWindowWithoutReturn('http://addrbook.daum.net/aplus/api/insertAddrList.do?name='+encodeURIComponent(name)+'&email='+encodeURIComponent(email), 'spam_ip_block', 0, 0, 'no', 'no', 600, 680);
}

function insertAddrbook2(){

	OpenWindowWithoutReturn2('about:blank', 'addr_list', 0, 0, 'no', 'yes','no', 600, 20);
	document.startForm.target = "addr_list";
	document.startForm.submit();

    return true;

}

function insertAddrbook3(email,w,h){

	OpenWindowWithoutReturn2('/hanmail/mail/AddAddrBookList.daum?addrlist='+encodeURIComponent(email)+'&_top_hm=v_add_addrlist', 'addr_list', 0, 0, 'no', 'yes','no', w, h);
    return true;

}

function add_exceptlist(url){
	OpenWindowWithoutReturn(url, 'spamexcept', 0, 0, false, false, 750, 685);
}


function underconstruction() {
		alert('준비중인 서비스입니다.');
}

function getUTF8(src_str) {
  var c, s;
  var enc = "";
  var i = 0;
  while(i<src_str.length) {
    c= src_str.charCodeAt(i++);
    // handle UTF-16 surrogates
    if (c>=0xDC00 && c<0xE000) continue;
    if (c>=0xD800 && c<0xDC00) {
      if (i>=src_str.length) continue;
      s= src_str.charCodeAt(i++);
      if (s<0xDC00 || c>=0xDE00) continue;
      c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
    }
    // output value
    if (c<0x80) enc += String.fromCharCode(c);
    else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
    else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
    else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
  }
  return enc;
}

var hexchars = "0123456789ABCDEF";

function toHex(n) {
  return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";

function encodeURIComponent2(inpram) {
  var s = getUTF8(inpram);
  var c;
  var enc = "";
  for (var i= 0; i<s.length; i++) {
    if (okURIchars.indexOf(s.charAt(i))==-1)
      enc += "%"+toHex(s.charCodeAt(i));
    else
      enc += s.charAt(i);
  }
  return enc;
}
function paramEncode( inparam){
	if(typeof encodeURIComponent == "function" ){
	    return encodeURIComponent(inparam);
	} else{
          // 내부에 UTF8 인코딩 함수가 없는 old 버전 브라우저를 지원함
          return encodeURIComponent2(inparam);
    }
}

function isWindowsXP() {
    if (navigator.userAgent.indexOf("Windows NT 5.1")  > 0)
        return true;
    else
        return false;
}


function spamZeroSave(add_type) {
	if(add_type=='mail') {
		self.location.href = "/hanmail/spam/SpamUseCheck.daum" ;
	}
	else {
		if(confirm("스팸제로2.0을 설정하시면, 유사 스팸 메일이 자동 차단됩니다.\n \n스팸제로2.0을 설정하시겠습니까?") ) {
 			if(add_type=='list')
				self.location.href = "/hanmail/spam/SpamEnvSave.daum?spamfolder_use=1&spamfolder_type=d&spamfolder_except_addrbook=1&spamfolder_except_list=1&spamfolder_clrday=15&spamfolder_viewimg=0&add_type=list" ;
			else if(add_type=='ad')
				self.location.href = "/hanmail/spam/SpamEnvSave.daum?spamfolder_use=1&spamfolder_type=d&spamfolder_except_addrbook=1&spamfolder_except_list=1&spamfolder_clrday=15&spamfolder_viewimg=0&add_type=ad" ;
		}
	}
}
/* 내게메일보내기 */
function Tome(){	
	var uid = daumIdForCheck;
	var mailTo = document.getElementById('S_TO');
	var txt = mailTo.value.trim();	
	var hanmailid = uid + '@hanmail.net';	

	if(document.getElementById('me').checked){
		if(txt == ""){
			mailTo.value = uid + ", ";
		}else{
			if(txt.trim().substring(txt.lastIndexOf(",")) == ","){
				mailTo.value = txt + " " + uid + ", ";				
			}else{
				mailTo.value = txt + ', ' + uid + ", ";
			}
		}
	}else {
		if(txt.lastIndexOf(", "+uid) != -1){
			var sample = ", "+uid+",";
			var tmp_txt = txt.substring(0,txt.lastIndexOf(sample));
			mailTo.value = tmp_txt + ", " + txt.substring(txt.lastIndexOf(sample) + sample.length);
		}else if(txt.lastIndexOf(uid) != -1){
			txt = txt.substring(0,txt.lastIndexOf(uid));
			mailTo.value = txt;
		}
		/*
		var txtsp = txt.split(',');
		for(i=0; i<txtsp.length ; i++){
			txtsp[i] = Space_All(txtsp[i].replace(new RegExp(/^\s+/),""));

			if(txtsp[i] == uid ){
				txtsp[i] = txtsp[i].replace(uid,'');
			}
			else if(txtsp[i] == hanmailid ) {
				txtsp[i] = txtsp[i].replace(hanmailid,'');
			}
		}
		document.getElementById('S_TO').value = '';
		for(i=0; i<txtsp.length ; i++){
			if(i==0 && txtsp[i]!=''){
				document.getElementById('S_TO').value = txtsp[i];
			}else if(txtsp[i] == ''){
				document.getElementById('S_TO').value = document.getElementById('S_TO').value + txtsp[i];
			}else {
				document.getElementById('S_TO').value = document.getElementById('S_TO').value + ', ' + txtsp[i];
			}
		}
		*/
	}
	
	document.getElementById("S_SUBJECT").focus();
	
	if(h_suggest){
		h_suggest.tome = true;
	}	
}

function check_myid() {	
	var userid = daumIdForCheck;
	var txt = document.getElementById('S_TO').value;
	var hanmailid = userid + '@hanmail.net';
	var p_email = txt.split(',');
	var email = '';
	var check = 0;
	for(i=0; i < p_email.length; i++) {
		email = Trim(p_email[i])
		if(userid == email || hanmailid == email) {
				document.getElementById('me').checked = true;
				check = 1;
		}
	}
	
	if(check == 0)
		document.getElementById('me').checked = false;	
}

var g_objInterval = "";
function refresh_cookie() {
	 g_objInterval = window.setInterval("fnUpdateCookie()", 1000 * 60 * 30  );
}

function fnUpdateCookie(){
	var objBottom = top.bottom;
	objBottom.location.href = "http://go.daum.net/bin/daumtrans.gif";

}

function flagUserAgent()
{
    if (navigator.appVersion.indexOf("NT") !=-1) {
        if((navigator.userAgent.indexOf('5.1') != -1) && (navigator.userAgent.indexOf('SV1') != -1))
            {   var rVal=0; }
        else {  var rVal= -1;   }
    }
    return rVal;
}

function ResizeWin(w,h){
    var osKind = flagUserAgent();
    if (osKind != -1) { h+=25; }
    window.resizeTo(w,h);
}

function move_page(page, param, action){
	if(action) 
		var gotoPage = action + "?mpage="+page+"&"+param +"&_top_hm=li_page_go";
	else
		var gotoPage = g_MailListURL+"?mpage="+page+"&"+param +"&_top_hm=li_page_go";
	location.href = gotoPage;

}
function forMacSubject(){
	if(window.navigator.appVersion.toLowerCase().indexOf("msie 5.0") != -1 && window.navigator.appVersion.toLowerCase().indexOf("mac") != -1){
	 // 맥으로 간주..
		var objTable = document.all.tblMac;
		var objTd = document.all.tdMac;

		for(var i=0; i < objTable.length; i++){
			objTable[i].setAttribute("width","100%");
			objTable[i].style.width = "100%";
			objTd[i].setAttribute("width","100%");
			objTd[i].style.width = "100%";
		}
	}
}

function change_id(list) {
	var tmp = list.options[list.selectedIndex].value;
	document.changeID.no.value = tmp;

	OpenWindowWithoutReturn2('about:blank', 'change_id_list', 0, 0, 'no', 'yes','no', 500, 200);
	document.changeID.target = "change_id_list";
	document.changeID.submit();
}

function toggleBoxClick(obj){
	var element = document.getElementById(obj);

	if(element.style.display == "none" || element.className == "hide"){
		element.style.display = "inline";
	}else if(element.style.display == "block" || element.style.display == "inline" || element.style.display == "" || element.className == "show"){
		element.style.display = "none";
	}else{
		element.style.display = "none";
	}
}

function toggleButton(obj){
	if(obj.style.border == "" || obj.style.border == null || obj.style.border == "none"){
		obj.style.border = "solid 1px #cacaca";
	}else{
		obj.style.border = "none";
	}
}

/*
function toggleItem(obj){
	if(obj.className == "toolItem"){
		obj.className = "toolItemOn";
	}else{
		obj.className = "toolItem";
	}
}
*/
