﻿var select_obj;
function ADWPOP_layerAction(name,status) { 
	var obj=document.all[name];
	var _tmpx,_tmpy, marginx, marginy;
	_tmpx = event.clientX + parseInt(obj.offsetWidth);
	_tmpy = event.clientY + parseInt(obj.offsetHeight);
	_marginx = document.body.clientWidth - _tmpx;
	_marginy = document.body.clientHeight - _tmpy ;
	if(_marginx < 0)
		_tmpx = event.clientX + document.body.scrollLeft + _marginx ;
	else
		_tmpx = event.clientX + document.body.scrollLeft ;
	if(_marginy < 0)
		_tmpy = event.clientY + document.body.scrollTop + _marginy +20;
	else
		_tmpy = event.clientY + document.body.scrollTop ;
	obj.style.posLeft=_tmpx-13;
	obj.style.posTop=_tmpy-12;
	if(status=='visible') {
		if(select_obj) {
			select_obj.style.visibility='hidden';
			select_obj=null;
		}
		select_obj=obj;
	}else{
		select_obj=null;
	}
	obj.style.visibility=status; 
}

function delete_Comment(contentsid, docid, cmtid)
{
	if(confirm('정말로 덧글을 삭제하시겠습니까?'))
	{ 
		window.open('/Common/DeleteComment.aspx?contentsid='+contentsid+'&docid='+docid+'&cmtid='+cmtid,'deleteComment','width=330,height=170,left=100,top=100');
	}
}

function delete_GuestComment(pid,contentsid, id, cmtid)
{
	location.href= '/default.aspx?pid='+pid+'&act=dgcmt&contentsid='+contentsid+'&id='+id+'&cmtid='+cmtid,'deleteComment','width=330,height=170,left=100,top=100';
}

function resizeImage(num)
{
    var oImg = eval("document.getElementById('userImage" + num + "')");

    if (oImg.width > 600) oImg.width = 600;
}

function print_ADWPOPlayer(name, homepage, mail, memberid, publish, writer, pageid, contentsid, docid, isAdmin, isMember) {
	var printHeight = 0;
	var printMain="";

	printMain = "<tr><td><img src=/SysImages/com/pm_title.gif border=0></td></tr>";
	
	if(homepage) {
		printMain = printMain + "<tr onMouseOver=this.style.backgroundColor='#b4d3fe' onMouseOut=this.style.backgroundColor='' onMousedown=window.open('http://"+homepage+"');><td style=font-family:굴림;font-size:9pt height=18 nowrap><img src=/SysImages/com/pm_homepage.gif border=0 align=absmiddle>&nbsp;&nbsp;홈페이지&nbsp;&nbsp;</td></tr>";
		printHeight = printHeight + 16;
	}
	if(mail) {
		printMain = printMain +	"<tr onMouseOver=this.style.backgroundColor='#b4d3fe' onMouseOut=this.style.backgroundColor='' onMousedown=location.href='mailto:" + mail + "';><td style=font-family:굴림;font-size:9pt height=18 nowrap><img src=/SysImages/com/pm_email.gif border=0 align=absmiddle>&nbsp;&nbsp;메일 보내기&nbsp;&nbsp;</td></tr>";
		printHeight = printHeight + 16;
	}
	if(memberid) {
		if(isMember == 1) {
			printMain = printMain +	"<tr onMouseOver=this.style.backgroundColor='#b4d3fe' onMouseOut=this.style.backgroundColor='' onMousedown=window.open('/Messaging/Send.aspx?mid="+memberid+"','send_msg','width=620,height=500,top=100,left=100,toolbar=no,scrollbars=no');><td style=font-family:굴림;font-size:9pt height=18 nowrap><img src=/SysImages/com/pm_msg.gif border=0 align=absmiddle>&nbsp;&nbsp;쪽지 보내기&nbsp;&nbsp;</td></tr>";
			printHeight = printHeight + 16;

			printMain = printMain +	"<tr onMouseOver=this.style.backgroundColor='#b4d3fe' onMouseOut=this.style.backgroundColor='' onMousedown=window.open('/Messaging/AddFriend.aspx?mid="+memberid+"','add_friend','width=620,height=500,top=100,left=100,toolbar=no,scrollbars=no');><td style=font-family:굴림;font-size:9pt height=18 nowrap><img src=/SysImages/com/pm_add_friend.gif border=0 align=absmiddle>&nbsp;&nbsp;내 주소록에 등록&nbsp;&nbsp;</td></tr>";
			printHeight = printHeight + 16;
		}
		
		if(publish == "Y") {
			/* 회원정보보기 */
			printMain = printMain +	"<tr onMouseOver=this.style.backgroundColor='#b4d3fe' onMouseOut=this.style.backgroundColor='' onMousedown=window.open('/Common/ViewMemberInfo.aspx?memberid="+memberid+"','view_info','width=550,height=510,toolbar=no,scrollbars=yes');><td style=font-family:굴림;font-size:9pt height=18 nowrap><img src=/SysImages/com/pm_meminfo.gif border=0 align=absmiddle>&nbsp;&nbsp;회원정보 보기&nbsp;&nbsp;</td></tr>";
			printHeight = printHeight + 16;
		}
		
		/* 아이디로 검색
		printMain = printMain +	"<tr onMouseOver=this.style.backgroundColor='#b4d3fe' onMouseOut=this.style.backgroundColor='' onMousedown=location.href='zboard.php?id="+pageid+"&sid1=on&sn=off&sid=on&ss=off&sc=off&keyword="+memberid+"';><td style=font-family:굴림;font-size:9pt height=18 nowrap><img src=/SysImages/com/pm_idsearch.gif border=0 align=absmiddle>&nbsp;&nbsp;아이디로 검색&nbsp;&nbsp;</td></tr>";
		printHeight = printHeight + 16;
		*/
	}
	else if(writer) {
		/* 이름으로 검색
		printMain = printMain +	"<tr onMouseOver=this.style.backgroundColor='#b4d3fe' onMouseOut=this.style.backgroundColor='' onMousedown=location.href='zboard.php?id="+pageid+"&sn1=on&sn=on&sid=off&ss=off&sc=off&keyword="+writer+"';><td style=font-family:굴림;font-size:9pt height=18 nowrap><img src=/SysImages/com/pm_namesearch.gif border=0 align=absmiddle>&nbsp;&nbsp;이름으로 검색&nbsp;&nbsp;</td></tr>";
		printHeight = printHeight + 16;
		*/
	}
	if(isAdmin==1) {
		/* 불량 게시물 등록 */
		printMain = printMain +	"<tr onMouseOver=this.style.backgroundColor='#b4d3fe' onMouseOut=this.style.backgroundColor='' onMousedown=window.open('/Common/DeactivateContents.aspx?contentsid="+contentsid+"&docid="+docid+"','deactivate','width=330,height=170,left=100,top=100');><td style=font-family:굴림;font-size:9pt height=18 nowrap><img src=/SysImages/com/pm_trashcan.gif border=0 align=absmiddle>&nbsp;&nbsp;불량게시물 등록&nbsp;&nbsp;</td></tr>";
		printHeight = printHeight + 16;
	
	}
	var printHeader = "<div id='"+name+"' style='position:absolute; left:10px; top:25px; width:127; height: "+printHeight+"; z-index:1; visibility: hidden' onMousedown=ADWPOP_layerAction('"+name+"','hidden')><table border=0 cellspacing=0 cellpadding=0><tr><td colspan=3 onMouseover=ADWPOP_layerAction('"+name+"','hidden') height=3></td></tr><tr><td width=5 onMouseover=ADWPOP_layerAction('"+name+"','hidden') rowspan=2>&nbsp;</td><td height=5></td></tr><tr><td><table style=cursor:hand border='0' cellspacing='1' cellpadding='0' bgcolor='black' width=100% height=100%><tr><td valign=top bgcolor=white><table border=0 cellspacing=0 cellpadding=0 width=100% height=100%>";
	var printFooter = "</table></td></tr></table></td><td width=5 rowspan=2 onMouseover=ADWPOP_layerAction('"+name+"','hidden')>&nbsp;</td></tr><tr><td colspan=3 height=10 onMouseover=ADWPOP_layerAction('"+name+"','hidden')></td></tr></table></div>";

	document.writeln(printHeader+printMain+printFooter);
}

function get_cookie(name)
{
	var search = name + "=";
	
	if(document.cookie.length > 0)
	{
		offset = document.cookie.indexOf(search);
		
		if(offset != -1)
		{
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			
			if(end == -1) end = document.cookie.length;
			
			return unescape(document.cookie.substring(offset, end));
		}
	}

	return "";
}

function new_win(filename,p_name,s_width,s_height,s_scrol)
{
	var x = screen.width;
	var y = screen.height;
	var wid = (x / 2) - (s_width / 2);
	var hei = (y / 2) - (s_height / 2);

	window.open(filename, p_name, "toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrollbars=" + 
		s_scrol + ",width=" + s_width + ",height=" + s_height + ",top=" + hei + ",left=" + wid + ",scrolbar=no"); 	
}

function new_win_pos(filename,p_name,s_winpos, s_width,s_height,s_scrol)
{
	var x = screen.width;
	var y = screen.height;
	
	var top = 0;
	var left = 0;

	if(get_cookie(p_name) == "deny") return;
	 
	switch(s_winpos)
	{
		case '01': /* 화면 좌측 상단 */
			top = 0;
			left = 0;
			break;
		case '02': /* 화면 중앙 상단 */
			top = 0;
			left = (x / 2) - (s_width/2);
			break;
		case '03': /* 화면 우측 상단 */
			top = 0;
			left = x - (s_width/2);
			break;
		case '04': /* 화면 좌측 */
			top = (y/2) - (s_height/2);
			left = 0;
			break;
		case '05': /* 화면 중앙 */
			top = (y/2) - (s_height/2);
			left = (x/2) - (s_width/2);
			break;
		case '06': /* 화면 우측 */
			top = (y/2) - (s_height/2);
			left = x - (s_width/2);
			break;
		case '07': /* 화면 좌측 하단 */
			top = y - s_height;
			left = 0;
			break;
		case '08': /* 화면 중앙 하단 */
			top = y - s_height;
			left = (x/2) - (s_width/2);
			break;
		case '09': /* 화면 우측 하단 */
			top = y - s_height;
			left = x - s_width;
			break;
		default:
			top = 0;
			left = 0;
			break;
	}

	window.open(filename, p_name, "toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrollbars=" + 
		s_scrol + ",width=" + s_width + ",height=" + s_height + ",top=" + top + ",left=" + left + ",scrolbar=no"); 	
}

/* 숫자만 입력가능하게*/
function onlyNum()
{
	if(event.keyCode < 48 || event.keyCode > 57)
	{
		event.returnValue = false;
	}
}

/* 전화번호입력용 숫자와 데쉬만 가능하게*/
function onlyTelNum()
{
	if((event.keyCode < 48 && event.keyCode != 45)|| event.keyCode > 57)
	{
		event.returnValue = false;
	}
}

/* 화면 중앙에 이미지 표시 */
function openImageWinCenter(imageRef){
	var x,y,w,h,loadingMsg;
	//팝업될 창의 초기 크기
	w=300;h=100;
	//화면 한가운데로 팝업창 띄우기 위한 좌표 계산
	x=Math.floor( (screen.availWidth-(w+12))/2 );y=Math.floor( (screen.availHeight-(h+30))/2 );

	//이지미가 로딩중에 내보낼 메시지
	loadingMsg="<table width=100% height=100%><tr><td valign=center align=center><font size='2' color='#ff6600' face='termanal'>NOW LODDING...</font></td></tr></table>";

	with( window.open("","",'height='+h+',width='+w+',top='+y+',left='+x+',scrollbars=yes,resizable=yes') )
	{
		document.write(
		"<body topmargin=0 rightmargin=0 bottommargin=0 leftmargin=0>",
		loadingMsg,
		"<img src=\""+imageRef+"\" hspace=0 vspace=0 border=0 onmousedown=\"window.close();\" onload=\"document.title=this.src;document.body.removeChild(document.body.children[0]);window.resizeTo(this.width+12,this.height+30);window.moveTo(Math.floor( (screen.availWidth-(this.width+12))/2),Math.floor( (screen.availHeight-(this.height+30))/2 ));\">",
		"</body>");
		focus();
	}
}

function resizeImgSub(img) {
	var imgTemp = new Image();
	imgTemp.src = img.src; 

	if ( imgTemp.width > img.visibleImgObj.width || imgTemp.height > img.visibleImgObj.height ) {
		if ( (img.width / img.visibleImgObj.width) > (img.height / img.visibleImgObj.height) )
			img.visibleImgObj.height = Math.round(img.height * (img.visibleImgObj.width / img.width));
		else
			img.visibleImgObj.width = Math.round(img.width * (img.visibleImgObj.height / img.height));
	} 
	else {
		img.visibleImgObj.width = imgTemp.width;
		img.visibleImgObj.height = imgTemp.height;
	}
}

function resizeImg(imgObj) {
	var imgOriginal = new Image();
	imgOriginal.visibleImgObj = imgObj;
	imgOriginal.onload = function() { resizeImgSub(this); }  
	imgOriginal.src = imgObj.src;
}



