var contextPath="";

function openMenu(menuId){
    if(menuId == "ROOT"){
        document.location = contextPath+"/";
    }else{
        document.location = contextPath+"/content.jsp?menuId="+menuId;
    }
}

function login(menuId){
    if(menuId!=null){
        document.location = contextPath+"/session/login.jsp?returnMenu="+menuId;
    }else{
        document.location = contextPath+"/session/login.jsp";
    }
}
function join(){
    document.location = contextPath+"/session/join.jsp";
}
function joinout(){
    document.location = contextPath+"/session/joinout.jsp";
}
function logout(){
    document.location = contextPath+"/session/logout.jsp";
}
function findId(){
    document.location = contextPath+"/session/findId.jsp";
}
function modifyMember(){
    document.location = contextPath+"/session/modifyMember.jsp";
}
function siteMap(){
    document.location = contextPath+"/contents/siteMap.jsp";
}
function siteInfo(){
    document.location = contextPath+"/contents/siteInfo.jsp";
}
function siteInfo1(){
    document.location = contextPath+"/contents/siteInfo1.jsp";
}

function openLinkSite(url){
    if(startsWith(url,"http://")){
        window.open(url,"","");
    }else{
        documnet.location = url;
    }
}

function searchFormUser(){
    window.open(contextPath+"/include/findFormUser.jsp","findIdWindow","width=300, height=200, scrollbars=yes, resizable=yes");
}
function searchForm(){
    window.open(contextPath+"/include/findForm.jsp","findIdWindow","width=300, height=200, scrollbars=yes, resizable=yes");
}

function pageout(){
    //alert("session_out");
    window.open(contextPath+"/session/logout.jsp", "pageoutframe");
}
function downloadFile(contentId, idx, number){
    var frame = document.createElement("IFRAME");
    frame.width = 0;
    frame.height = 0;
    document.body.insertBefore(frame);
    frame.src = contextPath+"/include/downloadAttachFile.jsp?contentId="+contentId+"&idx="+idx+"&fileIndex="+number;
}
function otherDownload(url){
    var frame = document.createElement("IFRAME");
    frame.width = 0;
    frame.height = 0;
    document.body.insertBefore(frame);
    frame.src = contextPath+"/include/otherDown.jsp?url="+url;
}

function openPopup(idx, width, height, isCenterAlign, positionX, positionY, option){
    var popup;

    if(!isCenterAlign){
        if(option.length>0){
            popup = window.open(contextPath+'/include/popup.jsp?idx='+idx,"popupWin"+idx,option+", width="+width+", height="+(eval(height)+30)
                + ",left="+positionX+",top="+positionY);
        }else{
            popup = window.open(contextPath+'/include/popup.jsp?idx='+idx,"popupWin"+idx,"width="+width+", height="+(eval(height)+30)
                + ",left="+positionX+",top="+positionY);
        }
    }else{
        if(option.length>0){
            popup = window.open(contextPath+'/include/popup.jsp?idx='+idx,"popupWin"+idx,
            option+", width="+width+", height="+(eval(height)+30) +",left="+(screen.width - eval(width))/2+",top="
                +(screen.height - eval(height)+30)/2);
        }else{
            popup = window.open(contextPath+'/include/popup.jsp?idx='+idx,"popupWin"+idx,"width="+width+", height="+(eval(height)+30) +",left="+(screen.width - eval(width))/2+",top="
                +(screen.height - eval(height)+30)/2);
        }
    }
    popup.focus()
}

function findPasswd(){
    window.open(contextPath+"/session/findPasswd.jsp","findAddress","width=350, height=340");
}

function printContent(){
    window.open(contextPath+"/print.jsp"+(location.href.substring(location.href.indexOf("?"))),"print","width=668, height=600, scrollbars=yes");
}
function emailContent(){
    window.open(contextPath+"/email.jsp"+(location.href.substring(location.href.indexOf("?"))),"email","width=700, height=600");
}
function getContent(name){
    return document.getElementById(name).innerHTML;
}

function ecatalog(docu, kd, dir){
	if(screen.width < 800){
		alert("The screen resolution should be over 800*600");
		return;
	}

	if(kd == "fixed"){ x = 1024; y = 768; wname = "fixed_ecatalog"; }
	else if(screen.width > 1280 || screen.height > 1024){ x = 1280; y = 1024; wname = "ecatalog"; }
	else{ x = screen.width; y = screen.height; wname = "ecatalog"; }

	x = x - 10;
	y = y - 58;

	property = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no,copyhistory=no,";
	property += "width=" + x + ",height=" + y + ",left=" + 0 + ",top=" + 0;
	docu = docu + "/ecatalog.php?Dir=" + dir;

	ecawin = window.open(docu, wname, property);
}