var fixDate, fixHour, fixMin, fixSec, strTimeStat, strResourceStat
var fixDate1, fixHour1, fixMin1, fixSec1, strTimeStat1, strResourceStat1
var strResourceName1, strResourceName2, strResourceName3, strResourceNow1,strResourceNow2, strResourceNow3, strResourceReal1, strResourceReal2, getResourceReal3, strNowResourceID, strmaxData



function noneSelectCamp(id, max) {

    for (i = 0; i < max; i++) {
        if (i != id) { gid('campView' + i).style.backgroundColor = '#ccc'; }

        //alert(i);
    }

    gid('campView' + id).style.backgroundColor = '#222';
}


function openWindows(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 timeCheck(setTime1, setTime2, setTime3)
{
	gtime1=setTime1;
	gtime2=setTime2;
	gtime3=setTime3;
	
	timeCheckStatus();
	gintervalid = setInterval("tickCheckTime()",1000);
}

function tickCheckTime()
{
	gtime1--;
	gtime2--;
	gtime3--;
	timeCheckStatus();
}



function timeCheckStatus()
{
	
	strTimeStat1=Math.floor(gtime1/60/60)+":"+Math.floor((gtime1-(Math.floor(gtime1/60/60)*60*60))/60)+":"+Math.floor((gtime1-(Math.floor(gtime1/60/60)*60*60)-(Math.floor((gtime1-(Math.floor(gtime1/60/60)*60*60))/60)*60)));
	strTimeStat2=Math.floor(gtime2/60/60)+":"+Math.floor((gtime2-(Math.floor(gtime2/60/60)*60*60))/60)+":"+Math.floor((gtime2-(Math.floor(gtime2/60/60)*60*60)-(Math.floor((gtime2-(Math.floor(gtime2/60/60)*60*60))/60)*60)));
	strTimeStat3=Math.floor(gtime3/60/60)+":"+Math.floor((gtime3-(Math.floor(gtime3/60/60)*60*60))/60)+":"+Math.floor((gtime3-(Math.floor(gtime3/60/60)*60*60)-(Math.floor((gtime3-(Math.floor(gtime3/60/60)*60*60))/60)*60)));

	if (gtime1>0){		gid('timer1').innerHTML=strTimeStat1;}
	if (gtime2>0){		gid('timer2').innerHTML=strTimeStat2;}
	if (gtime3>0){		gid('timer3').innerHTML=strTimeStat3;}
	
}



function GetTime(setTime, nid, camp, buildNum) {
    gtime = setTime;
    id = nid;
    timeStatus(id);
    gintervalid = setInterval("tickTime('"+id+"', "+camp+", "+buildNum+")", 1000);
}



function timeStatus(id) {
    if (gtime < 0) {
        gtime = 0
    }
    fixHour = Math.floor(gtime / 60 / 60)
    fixMin = Math.floor((gtime - (fixHour * 60 * 60)) / 60)
    fixSec = Math.floor((gtime - (fixHour * 60 * 60) - (fixMin * 60)))

    strTimeStat = fixHour + ":" + fixMin + ":" + fixSec


        if (parent.gid(id)) {
//    alert(id);
        parent.gid(id).innerHTML = strTimeStat;
        //gid(id).innerHTML = strTimeStat;
    }
}

function tickTime(id, camp, buildNum) {
    gtime--;


    if (gtime < 0) {

        if (buildNum > 0) {
            viewParent_tar('index.asp?id=menu&camp=' + camp, 'menuDIV'); viewParent_tar('index.asp?id=build&buildNum=' + buildNum + '&camp=' + camp, 'contentDIV');
        }
        else {
            viewParent_tar('index.asp?id=menu&camp=' + camp, 'menuDIV'); viewParent_tar('index.asp?id=camp&camp=' + camp, 'contentDIV');
        }

        
    }
    timeStatus(id);

}



function GetTime1(setTime, nid)
{
	gtime_1=setTime;
	id=nid;
	timeStatus1(id);
	gintervalid = setInterval("tickTime1(id)",1000);
}

function timeStatus1(id)
{
	fixHour1=Math.floor(gtime_1/60/60)
	fixMin1=Math.floor((gtime_1-(fixHour1*60*60))/60)
	fixSec1=Math.floor((gtime_1-(fixHour1*60*60)-(fixMin1*60)))

	strTimeStat1=fixHour1+":"+fixMin1+":"+fixSec1
	
	gid('viewTime1_1').innerHTML= strTimeStat1;
}

function tickTime1(id)
{
	gtime_1--;
	timeStatus1(id);
	if (gtime_1<0){gid('menu').location.reload();location.reload();}
}

function GetTimeDetail(setTimeDetail)
{
	gtimeDetail=setTimeDetail;
	timeStatusDetail();
	gintervalid = setInterval("tickTimeDetail()",1000);
}


function timeStatusDetail() {
    fixHour = Math.floor(gtimeDetail / 60 / 60)
    fixMin = Math.floor((gtimeDetail - (fixHour * 60 * 60)) / 60)
    fixSec = Math.floor((gtimeDetail - (fixHour * 60 * 60) - (fixMin * 60)))

    strTimeStatDetail = fixHour + ":" + fixMin + ":" + fixSec;

    gid('viewTimeDetail').innerHTML = strTimeStatDetail;
}


function tickTimeDetail()
{
	gtimeDetail--;
	timeStatusDetail();

	if (gtimeDetail<0){gid('menu').location.reload();location.reload();}
}


function fixTime(fixTime)
{
var fixHourF, fixMinF, fixSecF, strTimeStatF
	fixHourF=Math.floor(fixTime/60/60)
	fixMinF=Math.floor((fixTime-(fixHourF*60*60))/60)
	fixSecF=Math.floor((fixTime-(fixHourF*60*60)-(fixMinF*60)))

	strTimeStatF=fixHourF+":"+fixMinF+":"+fixSecF

	//document.write(strTimeStatF);
}

function GetResouceDataNow(resource1, resource2, resource3,ResourceReal1, ResourceReal2, ResourceReal3, maxData)
{

strResourceNow1=resource1;
strResourceNow2=resource2;
strResourceNow3=resource3;

strResourceReal1=ResourceReal1;
strResourceReal2=ResourceReal2;
strResourceReal3=ResourceReal3;
strmaxData=maxData;

	gintervalid = setInterval("GetResourceData()",1000);

}


function timer() {
    timer = setInterval('GetResourceData()', 1);
}





function test() {
    if (flag == "Y") {
        try {
            test2();

            clearInterval(timer);
        }
        catch (e) {

            timer();

        }
    }
}


function GetResourceData()
{

strResourceNow1=strResourceNow1+strResourceReal1;
strResourceNow2=strResourceNow2+strResourceReal2;
strResourceNow3=strResourceNow3+strResourceReal3;


if (parent.gid("nowResource1")) {
    try {
        /*
        if (strmaxData>Math.floor(strResourceNow1)) {gid("nowResource1").innerHTML=Math.floor(strResourceNow1);}
        else {gid("nowResource1").innerHTML='<font color=red>'+strmaxData+'</font>';}

if (strmaxData>Math.floor(strResourceNow2)) {gid("nowResource2").innerHTML=Math.floor(strResourceNow2);}
        else {gid("nowResource2").innerHTML='<font color=red>'+strmaxData+'</font>';}

if (strmaxData>Math.floor(strResourceNow3)) {gid("nowResource3").innerHTML=Math.floor(strResourceNow3);}
        else {gid("nowResource3").innerHTML='<font color=red>'+strmaxData+'</font>';}
        */



        if (strmaxData > Math.floor(strResourceNow1)) { parent.gid("nowResource1").innerHTML = Math.floor(strResourceNow1); }

        else {
            parent.gid("nowResource1").innerHTML = '<font color=red>' + strmaxData + '</font>';
        }

        if (strmaxData > Math.floor(strResourceNow2)) { parent.gid("nowResource2").innerHTML = Math.floor(strResourceNow2); }
        else { parent.gid("nowResource2").innerHTML = '<font color=red>' + strmaxData + '</font>'; }

        if (strmaxData > Math.floor(strResourceNow3)) { parent.gid("nowResource3").innerHTML = Math.floor(strResourceNow3); }
        else { parent.gid("nowResource3").innerHTML = '<font color=red>' + strmaxData + '</font>'; }
    }
    catch (e) {timer();}
}

}

function gid(id) {

        return document.getElementById(id);

}

function insertNumber(input, count) {
	if(input.value != count)
		input.value=count;
	else
		input.value='';}

function doSubmit(){
this.disabled=true;
this.value='Àü¼ÛÁß'; 
}

function moveToLocation(url){

top.location=url;

}

function loadContent(url){

    //    parent.content.location.href = url;
    viewHelpClose();
    view_tar(url, 'contentDIV');


       return false;
}

function loadContentParent(url){

    parent.content.location.href = url;
    //viewParent_tar(url, 'contentDIV');
//    viewHelpClose();
       return false;
}


function CheckMail(strMail) {

    var check1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;

    var check2 = /^[a-zA-Z0-9\-\.\_]+\@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4})$/;

    if (!check1.test(strMail) && check2.test(strMail)) {
        return true;
    } else {
        return false;
    }
}



function getByteLength(input) {
    var byteLength = 0;
    for (var inx = 0; inx < input.value.length; inx++) {
        var oneChar = escape(input.value.charAt(inx));
        if (oneChar.length == 1) {
            byteLength++;
        } else if (oneChar.indexOf("%u") != -1) {
            byteLength += 2;
        } else if (oneChar.indexOf("%") != -1) {
            byteLength += oneChar.length / 3;
        }
    }
    return byteLength;
}

function isAlphaNum(input) {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    return containsCharsOnly(input, chars);

}


function containsCharsOnly(input, chars) {
    for (var inx = 0; inx < input.value.length; inx++) {
        if (chars.indexOf(input.value.charAt(inx)) == -1)
            return true;
    }
    return false;
}


function changMapFrameX(url){
var xmlhttp = getXmlHttpRequest();

     if (url) {

        var originalMessage = parent.gid("xpos").innerHTML;   
        
        xmlhttp.open("GET", url, true);
        xmlhttp.onreadystatechange = function() {
           if (xmlhttp.readyState == 4) {
              if (xmlhttp.status == 200) {
                 
                 replaceParentHtml(parent.gid("xpos"),xmlhttp.responseText );
                 
              } else {
//                 alert("Error while loading " + url + ",("
//                            + xmlhttp.status + " " + xmlhttp.statusText + ")");
                 parent.gid("xpos").innerHTML = originalMessage;

               }
            }
          }
          xmlhttp.send(null);
       }
       return false;
}

function changMapFrameY(url){
var xmlhttp = getXmlHttpRequest();

     if (url) {

        var originalMessage = parent.gid("ypos").innerHTML;   

        xmlhttp.open("GET", url, true);
        xmlhttp.onreadystatechange = function() {
           if (xmlhttp.readyState == 4) {
              if (xmlhttp.status == 200) {
                 
                 replaceParentHtml(parent.gid("ypos"),xmlhttp.responseText );
                 
              } else {
//                 alert("Error while loading " + url + ",("
//                            + xmlhttp.status + " " + xmlhttp.statusText + ")");
                 parent.gid("ypos").innerHTML = originalMessage;

               }
            }
          }
          xmlhttp.send(null);
       }
       return false;
}



function loadContentIframe(url){
var vurl;
vurl=url;
parent.location.href=url;
}

function reLoadMenu(camp) {
    viewParent_tar('index.asp?id=menu&camp=' + camp, 'menuDIV');
    
//gid('menu').location='menu.asp?camp='+camp
}


function hideLoding(){

if(document.all)
	document.all.lodingLayer.style.visibility="hidden";
else if(document.layers)
	document.lodingLayer.style.visibility="hidden";
	lodingLayer.style.display='none';

}

function showObj(id, e){ //°´Ã¼ º¸ÀÌ±â

gid(id).style.left=(e.clientX+10)+'px';
gid(id).style.top=(e.clientY+10)+'px';
gid(id).style.display='block';
} 
 
function hideObj(id){ //°´Ã¼ ¼û±â±â
	gid(id).style.display='none';
}

function showObjClick(id, e){ //°´Ã¼ º¸ÀÌ±â
	gid(id).style.display='none';
	var obj=gid(id);
	var st=document.body.scrollTop;
	var sl=document.body.scrollLeft;
	var ex=e.x+sl;
	var ey=e.y+st;
 
	obj.style.left=ex+5;
	obj.style.top=ey-55;
	obj.style.display='block';
} 

function reNameSubmit(camp){
//resetCampName.doSubmit.disabled=true;
//resetCampName.action="?id=reNameCamp&camp="+camp;
//resetCampName.submit();

//location.href("?id=reNameCamp&camp="+camp);
}

var please_wait = null;

function open_url(url, target) {

    if (window.ActiveXObject) {
          link = new ActiveXObject("Microsoft.XMLHTTP");
    } else if (window.XMLHttpRequest) {
          link = new XMLHttpRequest();
    }

    link.onreadystatechange = function() { response(url, target); }
    link.open("GET, POST", url, true);
    link.send(null);
    
}

function response(url, target) {
    if (link.readyState == 4) {

         gid(target).innerHTML = (link.status == 200) ? link.responseText : "¸µÅ©°¡ Á¤È®ÇÏÁö ¾Ê½À´Ï´Ù. ¿¡·¯ÄÚµå: " + link.status;
    }
}

function set_loading_message(msg) {
    please_wait = msg;
}

function startTimer() {
	var serverTime = getTime(gid("serverTime"));
	timeDiff = serverTime-getLocalTime();
	timeStart = serverTime;

	// Nach span mit der Klasse timer und timer_replace suchen
	var spans = document.getElementsByTagName("span");
	for(var i=0; i<spans.length; i++) {
		var span = spans[i];
		if(span.className == "timer") {
			startTime = getTime(span);
			if(startTime != -1)
				addTimer(span, serverTime+startTime, (span.className == "timer"));
		}
	}

	window.setInterval("tick()", 1000);
}


function tick() {
	tickTimeSet();

	for(timer=0;timer<timers.length;timer++){
		remove = tickTimer(timers[timer]);
		if(remove) {
			timers.splice(timer, 1);
		}
	}
}

 function getXmlHttpRequest() {
     var xmlhttp = false;
     
     if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
     } else {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
     }
     return xmlhttp;
  }

function include(url) {

     var xmlhttp = getXmlHttpRequest();

     if (url) {
        var originalMessage = gid("main").innerHTML;
        gid("main").innerHTML = "Loading";
        xmlhttp.open("GET", url, true);
        xmlhttp.onreadystatechange = function() {
           if (xmlhttp.readyState == 4) {
              if (xmlhttp.status == 200) {
                 //gid("main").innerHTML = xmlhttp.responseText;
                 
                 replaceHtml(gid("main"),xmlhttp.responseText );
              } else {
//                 alert("Error while loading " + url + ",("
//                            + xmlhttp.status + " " + xmlhttp.statusText + ")");
                 gid("main").innerHTML = originalMessage;
               }
            }
          }
          xmlhttp.send(null);
       }
       return false;
    }
 
function include_login(url) {

     var xmlhttp = getXmlHttpRequest();

     if (url) {
        var originalMessage = gid("login").innerHTML;
        gid("login").innerHTML = "Loading";
        xmlhttp.open("GET", url, true);
        xmlhttp.onreadystatechange = function() {
           if (xmlhttp.readyState == 4) {
              if (xmlhttp.status == 200) {
                 //gid("login").innerHTML = xmlhttp.responseText;
                 
                 replaceHtml(gid("login"),xmlhttp.responseText );
              } else {
//                 alert("Error while loading " + url + ",("
//                            + xmlhttp.status + " " + xmlhttp.statusText + ")");
                 gid("login").innerHTML = originalMessage;
               }
            }
          }
          xmlhttp.send(null);
       }
       return false;
    }

function includeMapDetail(x, y, scamp) {

	var url="mapDetail.asp?mapX="+x+"&mapY="+y+"&camp="+scamp
    var xmlhttp = getXmlHttpRequest();

     if (url) {
        var originalMessage = gid("mapDetail").innerHTML;   
        
        //gid("mapDetail").innerHTML = "<tr><td height=494>&nbsp;&nbsp;&nbsp;</td><td width=636 background=images/gras.png>&nbsp;</td></tr><tr><td></td></tr>";
        xmlhttp.open("GET", url, true);
        xmlhttp.onreadystatechange = function() {
           if (xmlhttp.readyState == 4) {
              if (xmlhttp.status == 200) {
                 
                 replaceHtml(gid("mapDetail"),xmlhttp.responseText );
                 
              } else {
//                 alert("Error while loading " + url + ",(" + xmlhttp.status + " " + xmlhttp.statusText + ")");
//                 gid("mapDetail").innerHTML = originalMessage;

               }
            }
          }
          xmlhttp.send(null);
       }

       return false;
    }

function moveMapFrame(e,x,y){
	
	gid("MapFrame").style.left=(e.clientX-555)+'px';
	gid("MapFrame").style.top=(e.clientY-103)+'px';
	gid("MapFrame").style.display='block';
	
	gid('mapX').value=x;
	gid('mapY').value=y;
}

function includeMap(x, y, scamp) {
	var url="map.asp?mapX="+x+"&mapY="+y+"&camp="+scamp;
     var xmlhttp = getXmlHttpRequest();

     if (url) {
        var originalMessage = gid("map").innerHTML;
        //gid("map").innerHTML = "";
        xmlhttp.open("GET", url, true);
        xmlhttp.onreadystatechange = function() {
           if (xmlhttp.readyState == 4) {
              if (xmlhttp.status == 200) {
                 
                 replaceHtml(gid("map"),xmlhttp.responseText );
                 
              } else {

                 gid("map").innerHTML = originalMessage;
               }
            }
          }
          xmlhttp.send(null);
       }
       return false;
    }
    

function moveMapSubmit(){
	gid("smallMap").style.display='none';
	includeMapDetail(gid('mapX').value, gid('mapY').value, gid('camp').value);
}

function viewContent(url){
     var xmlhttp = getXmlHttpRequest();
		
     if (url) {
        var originalMessage = gid("viewContent").innerHTML;
        gid("viewContent").innerHTML = "Loading";
        xmlhttp.open("GET", url, true);
        xmlhttp.onreadystatechange = function() {
           if (xmlhttp.readyState == 4) {
              if (xmlhttp.status == 200) {
                 //gid("viewContent").innerHTML = xmlhttp.responseText;
                 
                 replaceHtml(gid("viewContent"),xmlhttp.responseText );
                 
                 
              } else {
//                 alert("Error while loading " + url + ",("
//                            + xmlhttp.status + " " + xmlhttp.statusText + ")");
                 gid("viewContent").innerHTML = originalMessage;
               }
            }
          }
          xmlhttp.send(null);
       }
       
       return false;
    }

    function view_tar(url, tar) {

        if (document.getElementById(tar)) {


            var xmlhttp = getXmlHttpRequest();
            if (url) {
                var originalMessage = gid(tar).innerHTML;


//                gid(tar).innerHTML = "<table width=680 height=48 align=center valign=middle><tr><td width=680 height=400 align=center valign=middle><h2>Loding...</h2></td></tr></table>";


                xmlhttp.open("GET", url, true);
                xmlhttp.onreadystatechange = function() {
                    if (xmlhttp.readyState == 4) {
                        if (xmlhttp.status == 200) {

                            replaceHtml(gid(tar), xmlhttp.responseText);


                        } else {
//                            alert("Error while loading " + url + ",("
//                            + xmlhttp.status + " " + xmlhttp.statusText + ")");
                            gid(tar).innerHTML = originalMessage;
                        }
                    }
                }
                xmlhttp.send(null);
            }
        }   
       return false;
    }

    function viewChat_tar(url, tar) {

        if (document.getElementById(tar)) {


            var xmlhttp = getXmlHttpRequest();
            if (url) {
                var originalMessage = gid(tar).innerHTML;


                xmlhttp.open("GET", url, true);
                xmlhttp.onreadystatechange = function() {
                    if (xmlhttp.readyState == 4) {
                        if (xmlhttp.status == 200) {

                            replaceHtml(gid(tar), xmlhttp.responseText);


                        } else {
//                            alert("Error while loading " + url + ",("
//                            + xmlhttp.status + " " + xmlhttp.statusText + ")");
                            gid(tar).innerHTML = originalMessage;
                        }
                    }
                }
                xmlhttp.send(null);
            }
        }   
       return false;
    }

    //Post ¹æ½Ä À¥ÆäÀÌÁö È£Ãâ Ã³¸®
    function view_form(url, tar, param) {

        //gid(tar).innerHTML='';
        
        var xmlhttp = getXmlHttpRequest();

        if (url) {
            //alert(gid(tar));
            var originalMessage = gid(tar).innerHTML;
            //gid(tar).innerHTML = "";
            xmlhttp.open("POST", url, true);


            xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xmlhttp.setRequestHeader("Content-length", param.length);
            xmlhttp.setRequestHeader("Connection", "close");
            xmlhttp.send(param);

            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == 4) {
                    if (xmlhttp.status == 200) {

                        replaceHtml(gid(tar), xmlhttp.responseText);
                        //alert(xmlhttp.responseText);
                    } else {
//                        alert("Error while loading " + url + ",("
//                            + xmlhttp.status + " " + xmlhttp.statusText + ")");
                        gid(tar).innerHTML = originalMessage;
                    }
                }
            }

            //xmlhttp.send(null);view_form(this.action, target, SendPOST(this));
        }

        return false;
    }

    // view_form Ã³¸®Àü¿¡ param °ª ¼±¾ð
    function SendPOST(formID) {

        var inputObjs = formID.getElementsByTagName("input");
        var param = "";
        for (var i = 0; i < inputObjs.length; i++) {
            var inputObj = inputObjs[i];
            if (inputObj.name && inputObj.value) {
                if (inputObj.type == "text" || inputObj.type == "hidden" || inputObj.type == "password") {
                    param += inputObj.name + "=" + encodeURIComponent(inputObj.value) + "&";
                }
                else if (inputObj.type == "radio" || inputObj.type == "checkbox") {
                    if (inputObj.checked) param += inputObj.name + "=" + encodeURIComponent(inputObj.value) + "&";
                }
            }
        }

        var selectObjs = formID.getElementsByTagName("select");
        for (var i = 0; i < selectObjs.length; i++) {
            var selectObj = selectObjs[i];
            if (selectObj.name && selectObj.value) {
                param += selectObj.name + "=" + encodeURIComponent(selectObj.value) + "&";
            }
        }

        var textAreaObjs = formID.getElementsByTagName("textarea");

        for (var i = 0; i < textAreaObjs.length; i++) {
            if (textAreaObjs[i].name && textAreaObjs[i].value) {
                param += textAreaObjs[i].name + "=" + encodeURIComponent(textAreaObjs[i].value) + "&";
            }
        } param += "1=1";

        return param;

    }



function viewReportContent(reportSeq, reportType, pageNum, camp, e){

    y = is_ie ? event.clientY : e.clientY; 

     var url="index.asp?id=viewReportContent&reportSeq="+reportSeq+"&reportType="+reportType+"&pageNum="+pageNum+"&camp="+camp;
    
     var xmlhttp = getXmlHttpRequest();
		
     if (url) {
        var originalMessage = gid("viewContent").innerHTML;
        //gid("viewContent").innerHTML = "";
        xmlhttp.open("GET", url, true);
        xmlhttp.onreadystatechange = function() {
           if (xmlhttp.readyState == 4) {
              if (xmlhttp.status == 200) {
                 //gid("viewContent").innerHTML = xmlhttp.responseText;
                 
                 replaceHtml(gid("viewContent"),xmlhttp.responseText );
                 
                 
              } else {
//                 alert("Error while loading " + url + ",("
//                            + xmlhttp.status + " " + xmlhttp.statusText + ")");
                 gid("viewContent").innerHTML = originalMessage;
               }
            }
          }
          xmlhttp.send(null);
       }

       gid("mainFrame").style.display='block';
       return false;
    }


function viewReportContent_N(reportSeq, reportType, pageNum, camp){

     var url="index.asp?id=viewReportContent&reportSeq="+reportSeq+"&reportType="+reportType+"&pageNum="+pageNum+"&camp="+camp;
    
     var xmlhttp = getXmlHttpRequest();
		
     if (url) {
        var originalMessage = gid("viewContent").innerHTML;
        //gid("viewContent").innerHTML = "";
        xmlhttp.open("GET", url, true);
        xmlhttp.onreadystatechange = function() {
           if (xmlhttp.readyState == 4) {
              if (xmlhttp.status == 200) {
                 //gid("viewContent").innerHTML = xmlhttp.responseText;
                 
                 replaceHtml(gid("viewContent"),xmlhttp.responseText );
                 
                 
              } else {
//                 alert("Error while loading " + url + ",("
//                            + xmlhttp.status + " " + xmlhttp.statusText + ")");
                 gid("viewContent").innerHTML = originalMessage;
               }
            }
          }
          xmlhttp.send(null);
       }

       gid("mainFrame").style.display='block';
       return false;
    }

function viewMailContent(mailSeq, ContentSeq, pageNum, camp, e) {

        y = is_ie ? event.clientY : e.clientY;

        var url = "index.asp?id=viewMailContent&camp="+camp+"&mailSeq=" + mailSeq + "&ContentSeq=" + ContentSeq + "&pageNum=" + pageNum;

        var xmlhttp = getXmlHttpRequest();

        if (url) {
            var originalMessage = gid("viewContent").innerHTML;
            //gid("viewContent").innerHTML = "";
            xmlhttp.open("GET", url, true);
            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == 4) {
                    if (xmlhttp.status == 200) {
                        //gid("viewContent").innerHTML = xmlhttp.responseText;

                        replaceHtml(gid("viewContent"), xmlhttp.responseText);


                    } else {
//                        alert("Error while loading " + url + ",("
//                            + xmlhttp.status + " " + xmlhttp.statusText + ")");
                        gid("viewContent").innerHTML = originalMessage;
                    }
                }
            }
            xmlhttp.send(null);
        }

        gid("mainFrame").style.display = 'block';
        return false;
    }
    
function deleteReportContent(reportSeq, nextContent, reportType, pageNum, camp, e){


    view_tar('index.asp?id=deleteReport&reportSeq=' + reportSeq + '&reportType=' + reportType + '&pageNum=' + reportType, 'viewContent');
    loadContent('index.asp?id=viewReport&camp=' + camp + '&pageNum=' + pageNum + '&reportType=' + reportType);
    gid('mainFrame').style.display='none'

    

}


function mapSubmit(x, y, scamp){

	includeMap(x, y, scamp);
	gid('mapX').value=x;
	gid('mapY').value=y;
	
}

 function replaceHtml(el, html) {

        var oldEl = (typeof el === "string" ? gid(el) : el);
        var newEl = document.createElement(oldEl.nodeName);

        newEl.id = oldEl.id;
        newEl.className = oldEl.className;
        // Replace the old with the new

        newEl.innerHTML = html;
        oldEl.parentNode.replaceChild(newEl, oldEl);
        /* Since we just removed the old element from the DOM, return a reference
        to the new element, which can be used to restore variable references. */
        return newEl;
};





function viewParent_tar(url, tar) {
    if (parent.gid(tar)) {


        var xmlhttp = getXmlHttpRequest();
        if (url) {
            var originalMessage = parent.gid(tar).innerHTML;

            
            xmlhttp.open("GET", url, true);
            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == 4) {
                    if (xmlhttp.status == 200) {

                        replaceParentHtml(tar, xmlhttp.responseText);


                    } else {
//                        alert("Error while loading " + url + ",("
//                            + xmlhttp.status + " " + xmlhttp.statusText + ")");

//                        alert(xmlhttp.responseText);
                        parent.gid(tar).innerHTML = originalMessage;
                    }
                }
            }
            xmlhttp.send(null);
        }
    }
    return false;
}

function replaceParentHtml(el, html) {
        
        var oldEl = (typeof el === "string" ? parent.gid(el) : el);
        var newEl = parent.document.createElement(oldEl.nodeName);
        // Preserve the element's id and class (other properties are lost)
        newEl.id = oldEl.id;
        newEl.className = oldEl.className;
        // Replace the old with the new
        newEl.innerHTML = html;
        oldEl.parentNode.replaceChild(newEl, oldEl);
        /* Since we just removed the old element from the DOM, return a reference
        to the new element, which can be used to restore variable references. */
        return newEl;
};



function viewHelp(helpID, e){

var url="help.asp?helpID="+helpID
var xmlhttp = getXmlHttpRequest();

gid("help").style.position = 'absolute';
	gid("help").style.left=(e.clientX+10)+'px';
	gid("help").style.top=(e.clientY-5)+'px';
	gid("help").style.display = 'block';

     if (url) {
        var originalMessage = gid("viewHelp").innerHTML;
        //gid("viewHelp").innerHTML = "";
        xmlhttp.open("GET", url, true);
        xmlhttp.onreadystatechange = function() {
           if (xmlhttp.readyState == 4) {
              if (xmlhttp.status == 200) {
                 replaceHtml(gid("viewHelp"),xmlhttp.responseText );
              } else {
//                 alert("Error while loading " + url + ",(" + xmlhttp.status + " " + xmlhttp.statusText + ")");
                 gid("viewHelp").innerHTML = originalMessage;
               }
            }
          }
          xmlhttp.send(null);
       }
       
       return false;
  }

function viewHelpClose(){
gid("help").style.display='none';
}


function getObject(objectId) { 
// checkW3C DOM, then MSIE 4, then NN 4. 
// 
if(document.getElementById && document.getElementById(objectId)) { 
return document.getElementById(objectId); 
} 
else if (document.all && document.all(objectId)) { 
return document.all(objectId); 
} 
else if (document.layers && document.layers[objectId]) { 
return document.layers[objectId]; 
} else { 
return false; 
} 
} 

function Click_directions(directions_Object, campName)
{
		document.location="makeCamp.asp?directions="+directions_Object+"&campName="+campName;
}

function Span_Show(direction)
{

		//Sapn_Object.style.display='';
		
		if (direction==2) gid('description').innerHTML='¢Ø';
		if (direction==1) gid('description').innerHTML='¢Ö';
		if (direction==3) gid('description').innerHTML='¢×';
		if (direction==4) gid('description').innerHTML='¢Ù';
		
		
}


    function ismaxlength(obj, wordCount) {
        if (obj.value.length > wordCount) {
            //alert("<%=DesMaxWord %>");
            obj.value = obj.value.substring(0, wordCount);
        }
    }



// ¸¶¿ì½º µå·¡±×¿¡ µû¸¥ ÀÌº¥Æ® Ã³¸®

var is_ie=getObject();
var isdrag=false; 
var x,y; 
var dobj; 

function movemouse(e) 
{ 
var name = navigator.appName

  if (isdrag) 
  { 
    dobj.style.left = is_ie ? tx + event.clientX - x + 'px': tx + e.clientX - x + 'px'; 
    dobj.style.top  = is_ie ? ty + event.clientY - y + 'px' : ty + e.clientY - y + 'px'; 

    return false; 
  } 
} 

function selectmouse(e) 
{

    
  var fobj       = is_ie ? event.srcElement : e.target; 

  
  var topelement = is_ie ? 'BODY' : 'HTML';

  if (fobj.className != '') {
      while (fobj.tagName != topelement && fobj.className != 'dragme') {
          fobj = is_ie ? fobj.parentElement : fobj.parentNode;
      }
  }
  if (fobj.className=='dragme') 
  { 
    isdrag = true; 
    dobj = fobj;
    tx = parseInt(dobj.style.left+0); 
    ty = parseInt(dobj.style.top+0); 
    x = is_ie ? event.clientX : e.clientX; 
    y = is_ie ? event.clientY : e.clientY; 

    document.onmousemove=movemouse; 
    
    return false; 
  } 
} 
document.onmousedown=selectmouse; 
document.onmouseup=new Function('isdrag=false');


var startx;
var starty;

var lastx;
var lasty;

var movex;
var movey;

var mapFramex;
var mapFramey;

mapFramex=545;
mapFramey=110;

function setPosition(e)
{
startx=is_ie ? e.clientX : e.clientX;    //setx;
starty=is_ie ? e.clientY : e.clientY;   //sety;
parent.gid("smallMap").style.display='none';

} 

function lastPosition(setX,setY, fieldMax, scamp, e)
{

lastx = is_ie ? e.clientX : e.clientX; 
lasty = is_ie ? e.clientY : e.clientY; 

movex=setY-parseInt((lastx-startx)/53);
movey=setX-parseInt((lasty-starty)/38);

if ((startx==null)||(starty==null)){

}

if ((parseInt((lastx-startx)/53)==0)&&(parseInt((lasty-starty)/38)==0)){

    gid('inMap').style.top=0+'px';
    gid('inMap').style.left=0+'px';
	return;
	}
else{
	
	//changeMapDetail(movey, movex);
	view_tar('innerDetailMap.asp?mapY='+movex+'&mapX='+movey+'&camp='+scamp, 'inMap');
    

		mapFramey=(parseInt((lastx-startx)/53));
		mapFramex=(parseInt((lasty-starty)/38));
		


		mapFramex=(setX-mapFramex);
		mapFramey=(setY-mapFramey);
		
		changMapFrameX('xpos.asp?mapX='+mapFramex+'&mapY='+mapFramey, 'xpos');
		changMapFrameY('ypos.asp?mapX='+mapFramex+'&mapY='+mapFramey, 'ypos');
		
		//alert("<a href='javascript:;' onclick=includeMap(movex,movey);gid('smallMap').style.display='block';return false; ><font color=#dddddd>Ãà¼Ò¸Ê</font></a>");
		parent.gid("setSmallMap").innerHTML="<a href='javascript:;' onclick=includeMap("+movey+","+movex+","+scamp+");gid('smallMap').style.display='block';return false; ><font color=#dddddd>MAP</font></a>";
	}
}








/* Å×ÀÌºí µÕ±Û°Ô Ã³¸® */
function roundTable(objID) {
var obj = document.getElementById(objID);
var Parent, objTmp, Table, TBody, TR, TD;
var bdcolor, bgcolor, Space;
var trIDX, tdIDX, MAX;
var styleWidth, styleHeight;

// get parent node
Parent = obj.parentNode;
objTmp = document.createElement('SPAN');
Parent.insertBefore(objTmp, obj);
Parent.removeChild(obj);

// get attribute
bdcolor = obj.getAttribute('rborder');
bgcolor = obj.getAttribute('rbgcolor');
radius = parseInt(obj.getAttribute('radius'));
if (radius == null || radius < 1) radius = 1;
else if (radius > 6) radius = 6;

MAX = radius * 2 + 1;

/*
create table {{
*/
Table = document.createElement('TABLE');
TBody = document.createElement('TBODY');

Table.cellSpacing = 0;
Table.cellPadding = 0;

for (trIDX=0; trIDX < MAX; trIDX++) {
TR = document.createElement('TR');
Space = Math.abs(trIDX - parseInt(radius));
for (tdIDX=0; tdIDX < MAX; tdIDX++) {
TD = document.createElement('TD');

styleWidth = '1px'; styleHeight = '1px';
if (tdIDX == 0 || tdIDX == MAX - 1) styleHeight = null;
else if (trIDX == 0 || trIDX == MAX - 1) styleWidth = null;
else if (radius > 2) {
if (Math.abs(tdIDX - radius) == 1) styleWidth = '2px';
if (Math.abs(trIDX - radius) == 1) styleHeight = '2px';
}

if (styleWidth != null) TD.style.width = styleWidth;
if (styleHeight != null) TD.style.height = styleHeight;

if (Space == tdIDX || Space == MAX - tdIDX - 1) TD.style.backgroundColor = bdcolor;
else if (tdIDX > Space && Space < MAX - tdIDX - 1) TD.style.backgroundColor = bgcolor;

if (Space == 0 && tdIDX == radius) TD.appendChild(obj);
TR.appendChild(TD);
}
TBody.appendChild(TR);
}

/*
}}
*/

Table.appendChild(TBody);

// insert table and remove original table
Parent.insertBefore(Table, objTmp);
}



function setPng24(obj) { 
var request_os = window.navigator.userAgent; 
var os_array = request_os.split(";"); 

if(os_array[1] != " MSIE 7.0") { 
obj.width=obj.height=1; 
obj.className=obj.className.replace(/png24/i,''); 
obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"; 
obj.src=''; 
} 

return ''; 
}

function CheckStrLen(maxlen) {
    var temp; //µé¾î¿À´Â ¹®ÀÚ°ª... 
    var msglen;
    msglen = maxlen * 2;
    var value = gid("InputMailContent").value;

    l = gid("InputMailContent").value.length;
    tmpstr = "";

    if (l == 0) {
        value = maxlen * 2;
    }
    else {
        for (k = 0; k < l; k++) {
            temp = value.charAt(k);

            if (escape(temp).length > 4)
                msglen -= 2;
            else
                msglen--;

            if (msglen < 0) {
                alert("ÃÑ ¿µ¹® " + (maxlen * 2) + "ÀÚ ÇÑ±Û " + maxlen + "ÀÚ ±îÁö º¸³»½Ç¼ö ÀÖ½À´Ï´Ù.");
                gid("InputMailContent").value = tmpstr;
                break;
            }
            else {
                tmpstr += temp;
            }
        }
    }
}
function _earlyOnload(init_func) {
 /* for IE */
 /*@cc_on @*/
 /*@if (@_win32)
   document.write("<script id=__ie_onload defer src=javascript:void(0)></script>");
   var _script = document.getElementById("__ie_onload");
   _script.onreadystatechange = function() { 
       if(this.readyState == "complete") { eval(init_func); }
   };
    @else @*/
   if(document.addEventListener) { // for Mozilla
        document.addEventListener("DOMContentLoaded", function(){eval(init_func)}, false);
   } else { // for other browsers
        window.onload = function(){eval(init_func)};
   }
 /*@end @*/
}



function resizeFrame(iframeObj) {
    var innerBody = iframeObj.contentWindow.document.body;
    oldEvent = innerBody.onclick;
    innerBody.onclick = function() { resizeFrame(iframeObj, 1); oldEvent; };
    var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
    iframeObj.style.height = innerHeight + 'px';
    var innerWidth = innerBody.scrollWidth + (innerBody.offsetWidth - innerBody.clientWidth);
    iframeObj.style.width = innerWidth + 'px';
    if (!arguments[1])
        this.scrollTo(1, 1);
}

//------------------------------------------------------------------------------------------------------------------------------




var restarea = 16 //1) width of the "neutral" area in the center of the gallery in px
var maxspeed = 17 //2) top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var endofgallerymsg = "" //3) message to show at end of gallery. Enter "" to disable message.

var iedom = document.all || document.getElementById
var scrollspeed = 0
var movestate = ""

var actualheight = ''
var cross_scroll
var loadedyes = 0

function ietruebody() {
    return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
}

function creatediv() {
    statusdiv = document.createElement("div")
    statusdiv.setAttribute("id", "statusdiv")
    document.body.appendChild(statusdiv)
    statusdiv = document.getElementById("statusdiv")
    statusdiv.innerHTML = endofgallerymsg
}

function positiondiv() {
    menuwidth = parseInt(crossmain.offsetWidth)
    mainobjoffsetW = getposOffset(crossmain, "left")
    statusdiv.style.left = mainobjoffsetW + (menuwidth / 2) - (statusdiv.offsetWidth / 2) + "px"
    statusdiv.style.top = menu_height + mainobjoffset + 10 + "px"
}

function showhidediv(what) {
    if (endofgallerymsg != "")
        statusdiv.style.visibility = what
}

function getposOffset(what, offsettype) {
    var totaloffset = (offsettype == "left") ? what.offsetLeft : what.offsetTop;
    var parentEl = what.offsetParent;
    while (parentEl != null) {
        totaloffset = (offsettype == "left") ? totaloffset + parentEl.offsetLeft : totaloffset + parentEl.offsetTop;
        parentEl = parentEl.offsetParent;
    }
    return totaloffset;
}


function moveup() {
    if (loadedyes) {
        movestate = "up"
        if (iedom && parseInt(cross_scroll.style.top) > (menu_height - actualheight)) {
            cross_scroll.style.top = parseInt(cross_scroll.style.top) - scrollspeed + "px"
            showhidediv("hidden")
        }
        else
            showhidediv("visible")
    }
    uptime = setTimeout("moveup()", 10)
}

function movedown() {
    if (loadedyes) {
        movestate = "down"
        if (iedom && parseInt(cross_scroll.style.top) < 0) {
            cross_scroll.style.top = parseInt(cross_scroll.style.top) + scrollspeed + "px"
            showhidediv("hidden")
        }
        else
            showhidediv("visible")
    }
    downtime = setTimeout("movedown()", 10)
}

function motionengine(e) {
    var dsocx = (window.pageXOffset) ? pageXOffset : ietruebody().scrollLeft;
    var dsocy = (window.pageYOffset) ? pageYOffset : ietruebody().scrollTop;
    var curposy = window.event ? event.clientY : e.clientY ? e.clientY : ""
    curposy -= mainobjoffset - dsocy
    var leftbound = (menu_height - restarea) / 2
    var rightbound = (menu_height + restarea) / 2
    if (curposy > rightbound) {
        scrollspeed = (curposy - rightbound) / ((menu_height - restarea) / 2) * maxspeed
        if (window.downtime) clearTimeout(downtime)
        if (movestate != "up") moveup()
    }
    else if (curposy < leftbound) {
        scrollspeed = (leftbound - curposy) / ((menu_height - restarea) / 2) * maxspeed
        if (window.uptime) clearTimeout(uptime)
        if (movestate != "down") movedown()
    }
    else
        scrollspeed = 0
}

function contains_ns6(a, b) {
    while (b.parentNode)
        if ((b = b.parentNode) == a)
        return true;
    return false;
}

function stopmotion(e) {
    if ((window.event && !crossmain.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget != e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))) {
        if (window.downtime) clearTimeout(downtime)
        if (window.uptime) clearTimeout(uptime)
        movestate = ""
    }
}

function fillup() {
    if (iedom) {
        crossmain = document.getElementById ? document.getElementById("motioncontainer") : document.all.motioncontainer
        if (crossmain == null) return;
        else {
            menu_height = parseInt(crossmain.style.height)

            mainobjoffset = getposOffset(crossmain, "top")

            cross_scroll = document.getElementById ? document.getElementById("motiongallery") : document.all.motiongallery
            actualheight = cross_scroll.offsetHeight

            crossmain.onmousemove = function(e) {
                motionengine(e)
            }
        }

        crossmain.onmouseout = function(e) {
            stopmotion(e)
            showhidediv("hidden")
        }
    }
    if (window.opera) {
        cross_scroll.style.top = menu_height - actualheight + 'px'
        setTimeout('cross_scroll.style.top=0', 10)
    }
    loadedyes = 1
    if (endofgallerymsg != "") {
        creatediv()
        positiondiv()
    }
}
//setTimeout(window.onload = fillup, 1000);
//window.onload=fillup





function HideHelp() {

    gid('help1').style.display = 'none';
    gid('help2').style.display = 'none';
    gid('help3').style.display = 'none';
    gid('help4').style.display = 'none';
    gid('help5').style.display = 'none';
    return false;
}

function loadHelp(num) {

    HideHelp();
    gid('help' + num).style.display = 'block';
    return false;
}


function getFname(str)
{
    var len = str.length;
    var last = str.lastIndexOf("\\"); //ÆÄÀÏ¸í ÃßÃâ
    //var dif = len - last;
    //var ext = str.substr(last + 1, dif);  //ÆÄÀÏ¸í ÃßÃâ (\ Á¦¿Ü)
    var ext = str.substring(last + 1, len);  //ÆÄÀÏ¸í ÃßÃâ (\ Á¦¿Ü)
    alert(ext);
    return ext;
}


