/**
 * Created on 2006-01-23 by xincub & hana
 * util.js : 전 사이트에 공통으로 쓰이는 유틸 스크립트
 */
 
/**
 * 회원 프로필 팝업을 띄우는 스크립트.
 * @param nickname 회원의 닉네임으로 url encoding된 값이어야 한다.
 */
function viewProfile(nickname) {
    window.open("/bbs/myPage.comm?action=profile&nickname="+nickname,'ProfileViewer','scrollbars=no,status=no,toolbar=no,resizable=no,location=no,menu=no,width=313,height=352');
}

/**
 * 해당 문자열이 빈문자열인지의 여부를 판단한다.
 */
function isEmpty(str) {
	var pattern = /^[\s　]*$/g;
	return pattern.test(str);
}

/**
 * 팝업으로 이미지를 보게 해주는 스크립트.
 * @param path 이미지 경로 
 */
function imageView(path) {
    var imgwin = window.open("",'PFImageViewer','scrollbars=yes,status=yes,toolbar=no,resizable=yes,location=no,menu=no,width=150,height=150');
    imgwin.focus();
    imgwin.document.open();
    imgwin.document.write("<html>\n");
    imgwin.document.write("<html>\n");
    imgwin.document.write("<head>\n");
    imgwin.document.write("<title>PlayForum - ImageViewer</title>\n");
    imgwin.document.write("<sc"+"ript language='javascript'>\n");
    imgwin.document.write("    function resize() {\n");
    imgwin.document.write("        pic = document.image;\n");
    imgwin.document.write("        if (eval(pic).height) {\n");
    imgwin.document.write("            var name = navigator.appName;\n");
    imgwin.document.write("            if (name == 'Microsoft Internet Explorer') {\n");
    imgwin.document.write("                myHeight = eval(pic).height + 40;\n");
    imgwin.document.write("                myWidth = eval(pic).width+ 10;\n");
    imgwin.document.write("            } else {\n");
    imgwin.document.write("                myHeight = eval(pic).height + 9;\n");
    imgwin.document.write("                myWidth = eval(pic).width;\n");
    imgwin.document.write("            }\n");
    imgwin.document.write("            var heightPic = pic.height;\n");
    imgwin.document.write("            var widthPic = pic.width;\n");
    imgwin.document.write("            if (widthPic <= 1024 && heightPic <= 768){\n");
    imgwin.document.write("                self.resizeTo(myWidth, myHeight+20);\n");
    imgwin.document.write("                self.moveTo(80,80);\n");
    imgwin.document.write("                document.body.style.overflow='hidden';\n");
    imgwin.document.write("            } else {\n");
    imgwin.document.write("                if (widthPic > 1024 && heightPic <= 768) {\n");
    imgwin.document.write("                    self.resizeTo(1024, myHeight+20);\n");
    imgwin.document.write("                    self.moveTo(80,80);\n");
    imgwin.document.write("                } else if (widthPic <= 1024 && heightPic > 768) {\n");
    imgwin.document.write("                    self.resizeTo(myWidth+20, 768);\n");
    imgwin.document.write("                    self.moveTo(80,80);\n");
    imgwin.document.write("                } else {\n");
    imgwin.document.write("                    self.resizeTo(1024, 768);\n");
    imgwin.document.write("                    self.moveTo(80,80);\n");
    imgwin.document.write("                }\n");
    imgwin.document.write("            }\n");
    imgwin.document.write("        } else setTimeOut(resize(), 100);\n");
    imgwin.document.write("}\n");
    imgwin.document.write("</sc"+"ript>\n");
    imgwin.document.write("</head>\n");
    imgwin.document.write("<body bgcolor='#FFFFFF' style='margin:0'>\n");
    imgwin.document.write("<div align='center' valign='middle'><a href='javascript:self.close()' onfocus='this.blur()'><img border='0' src='"+path+"' xwidth='10' xheight='9' name='image' onload='resize();'></a></div>\n");
    imgwin.document.write("</body>\n");
    imgwin.document.write("</html>\n");
    imgwin.document.close();
}