/*
function login() {
	<%if session("admin")="ok" or session("member")="ok" then
		%>
		logout();
		<%
		else
		%>
		loginAdmin();
		<%
	end if
	%>
}*/
function loginAdmin() {
  window.open("/login.asp", 'loginAdmin', 'left=0,top=0,width=340,height=200');
}
function logout() {
	location.href = '/logout.asp';
}

String.prototype.trim = function() {
    return this.replace(/(^ *)|( *$)/g, "");
}

function email() {
	document.location.href="mailto:<%=masterMail%>";
}

function newWin(imgsrc) {
	window.open("/newWin.php?imgSrc="+imgsrc,"PictureZoom",'toolbar=0, menubar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, width=407, height=590, top=0, left=0');
}
function openCloseLayer(obj) {
	target = document.all[obj];
	
	if (target.style.display=="") {
		target.style.display="none";
	} else {
		target.style.display="";
	}
	//document.all.toggle_1.style.display="none";
}
function getUrl(url) {
	location.href=url;
}
function menuListMouseOver(obj) {
	obj.style.background = '#ffffff';
	obj.style.border='1px solid #585858';
}
function menuListMouseOut (obj) {
	obj.style.background = '#f2f2f2';
	obj.style.border='1px solid #f2f2f2';
}
function selectedMenuListMouseOut (obj) {
	obj.style.background = '#dfdfdf';
	obj.style.border='1px solid #585858';
}

// ½ºÅ©·Ñ¹Ù
        var stmnLEFT = screen.width/2 + 460; 
        var stmnGAP1 = 240; 
        var stmnGAP2 = 240; 
        var stmnBASE = 85; 
        var stmnActivateSpeed = 0; 
        var stmnScrollSpeed = 0; 

        var stmnTimer;

        // ÄíÅ° ÀÐ±â
        function ReadCookie(name)
        {
                var label = name + "=";
                var labelLen = label.length;
                var cLen = document.cookie.length;
                var i = 0;

                while (i < cLen) {
                        var j = i + labelLen;

                        if (document.cookie.substring(i, j) == label) {
                                var cEnd = document.cookie.indexOf(";", j);
                                if (cEnd == -1) cEnd = document.cookie.length;

                                return unescape(document.cookie.substring(j, cEnd));
                        }
        
                        i++;
                }

                return "";
        }

        // ÄíÅ° ÀúÀå
        function SaveCookie(name, value, expire)
        {
                var eDate = new Date();
                eDate.setDate(eDate.getDate() + expire);
                document.cookie = name + "=" + value + "; expires=" +  eDate.toGMTString()+ "; path=/";
        }

        // ½ºÅ©·Ñ ¸Þ´ºÀÇ À§Ä¡ °»½Å
        function RefreshStaticMenu()
        {
                var stmnStartPoint, stmnEndPoint, stmnRefreshTimer;

                stmnStartPoint = parseInt(STATICMENU.style.top, 10);
                stmnEndPoint = document.body.scrollTop + stmnGAP2;
                if (stmnEndPoint < stmnGAP1) stmnEndPoint = stmnGAP1;

                stmnRefreshTimer = stmnActivateSpeed;

                if ( stmnStartPoint != stmnEndPoint ) {
                        stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint - stmnStartPoint ) / 15 );
                        STATICMENU.style.top = parseInt(STATICMENU.style.top, 10) + ( ( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount );
                        stmnRefreshTimer = stmnScrollSpeed;
                }

                stmnTimer = setTimeout ("RefreshStaticMenu();", stmnRefreshTimer);
        }

        // ¸Þ´º ON/OFF ÇÏ±â
        function ToggleAnimate()
        {
                if (document.all.ANIMATE.checked) { // ÀÌµ¿ÇÏ±â ¹öÆ°ÀÌ Ã¼Å©µÇ¾ú´Ù¸é
                        RefreshStaticMenu(); // ¸Þ´ºÀ§Ä¡¸¦ ´Ù½Ã Á¶Á¤
                        SaveCookie("ANIMATE", "true", 300); // ÀÌµ¿ÀÌ ON »óÅÂ¶ó°í ÄíÅ°¸¦ ¼³Á¤
                }
                else { // ¾Æ´Ï¶ó¸é... (ÀÌµ¿ÇÏ±â ¹öÆ°ÀÌ Ã¼Å©µÇ¾î ÀÖÁö ¾ÊÀ¸¸é)
                        clearTimeout(stmnTimer); // ÀÌµ¿¿ë Å¸ÀÌ¸Ó ÇØÁ¦
                        STATICMENU.style.top = stmnGAP1; // ¸Þ´ºÀÇ À§Ä¡¸¦ »ó´ÜÀ¸·Î ¿Å±ä´Ù.
                        SaveCookie("ANIMATE", "false", 300); // ÀÌµ¿»óÅÂ°¡ "OFF" ÀÓ
                }
        }

        // ¸Þ´º ÃÊ±âÈ­
        function InitializeStaticMenu()
        {
           //     if (ReadCookie("ANIMATE") == "false") { // ÀÌµ¿»óÅÂ°¡ off »óÅÂ¶ó¸é
          //              document.all.ANIMATE.checked = false; // Ã¼Å©Ç¥½Ã¸¦ Áö¿ì°í
          //              STATICMENU.style.top = document.body.scrollTop + stmnGAP1; // ¸Ç À§¿¡ µé·¯ ºÙ´Â´Ù.
          //      }
          //      else { // ÀÌµ¿ on »óÅÂ¶ó¸é
           //             document.all.ANIMATE.checked = true; // Ã¼Å©Ç¥½Ã¸¦ ÇÏ°í
                        STATICMENU.style.top = document.body.scrollTop + stmnBASE; // ±âº»À§Ä¡·Î ÀÌµ¿ÇÑ´Ù.
                        RefreshStaticMenu(); // ½ºÅ©¸³Æ® °¡µ¿
          //      }

                STATICMENU.style.left = stmnLEFT; // ¸Þ´º ¿ÞÂÊ À§Ä¡ ÃÊ±âÈ­. ÇÊ¿ä¾øÀ» °æ¿ì »èÁ¦
        }
        
        //menuEdit¿ë ÇÔ¼öµé
        function addMenu(parentId)
        {
			parent.mainFrame.location.href="add.asp?parentId="+parentId;
        }
        function delMenu(parentId)
        {
			parent.mainFrame.location.href="del.asp?id="+parentId;
        }
        function modMenu(parentId)
        {
			parent.mainFrame.location.href="add.asp?mode=mod&id="+parentId;
        }
        function checkOut(source,target)
        {
		//if source=checked then target=disable
			if (source)
			{
				target.disabled=true;
			} else {
				target.disabled=false;
			}
        }
function disableText (v1,v2,v3) {
	//v1==v2 -> v3=enable
	//v1!=v2 -> v3=disable
	if (v1==v2)
	{
		v3.disabled = false;
	} else {
		v3.disabled = true;
	}
}


function findZip ()
{
	window.open ("/member/zipcode.php","zipcode","width=200, height=200, left=100, top=100, scrollbar=none");
}

//member/zipcode.php
function zipcodeInput (form)
{
	var form = eval("document."+form);
	zipV = form.add.options[form.add.options.selectedIndex].value;
	zipA = zipV.split(",");

	opener.document.join.zip.value=zipA[0];
	opener.document.join.address.value=zipA[1] + form.detail.value;
	window.close();
}

//member/member.php
function checkId() {
	if (document.join.identity.value)
	{
		document.idcheck.location.href="/member/idcheck.php?id="+document.join.identity.value;
	} else {
		alert ("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
		document.join.identity.focus();
	}	
}
function checkPass() {
	p1 = document.join.password.value;
	p2 = document.join.password2.value;
	if (p1&&p2)
	{
		if (p1==p2)
		{
			document.join.checkPassV.value=1;
			checkPassD.innerHTML="È®ÀÎ";
			timer = setInterval("clearPassV();", 2000);
		} else {
			document.join.checkPassV.value=0;
			checkPassD.innerHTML="¹ÌÈ®ÀÎ";
			timer = setInterval("clearPassV();", 2000);
		}
	}
}
function clearPassV() {
	checkPassD.innerHTML="";
}
function joinAc () {
	if (!document.join.identity.value)
	{
		alert ("¾ÆÀÌµð¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
		document.join.identity.focus();
		return false;
	}
	if (document.join.checkIdV.value==2)
	{
		alert ("¾ÆÀÌµð Áßº¹ È®ÀÎ ÇÏ¼¼¿ä");
		return false;
	}
	if (document.join.checkIdV.value!=1)
	{
		alert ("¾ÆÀÌµð°¡ »ç¿ë °¡´ÉÇÏÁö ¾Ê½À´Ï´Ù.");
		return false;
	}
	if (!document.join.password.value)
	{
		alert ("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä");
		document.join.password.focus();
		return false;
	}
	if (document.join.checkPassV.value!=1)
	{
		alert ("ºñ¹Ð ¹øÈ£°¡ ¸ÂÁö ¾Ê½À´Ï´Ù.");
		document.join.password2.focus();
		return false;
	}
}
function del (num) {
	if (confirm("Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		location.href='action.php?mode=del&Id='+num;
	}
}
function getCookie(name) { 
    var from_idx = document.cookie.indexOf(name+'=');
    if (from_idx != -1) { 
       from_idx += name.length + 1 
       to_idx = document.cookie.indexOf(';', from_idx) 
       if (to_idx == -1) { 
           to_idx = document.cookie.length 
       }
       return unescape(document.cookie.substring(from_idx, to_idx)) 
    } 
} 
function setCookie(name,value,expire) {
   var todayDate = new Date(); 
   todayDate.setDate(todayDate.getDate()+expire); 
   todayDate.setHours(0); 
   todayDate.setMinutes(0); 
   todayDate.setSeconds(0); 
   document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
  
} 
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function sendSelect(from,to,target,targetFrom) {
	from = document.all[from];
	to = document.all[to];
	
	if (from.selectedIndex>-1)
	{
		//´ë»ó¿¡ ºÙÀÌ±â
		to.options.length++;
		to.options[to.options.length-1].value=from.options[from.selectedIndex].value;
		to.options[to.options.length-1].text=from.options[from.selectedIndex].text;

		//ÇÏ³ª¾¿ ¶¯±â±â
		from.options[from.selectedIndex]=null;
	}
	logicSelect (target,targetFrom);
}
function moveSelect (from,move,target,targetFrom) {
	from = document.all[from];
	index = from.selectedIndex;

	tempValue = from.options[index].value;
	tempText = from.options[index].text;

	from.options[index].value = from.options[index+move].value;
	from.options[index].text = from.options[index+move].text;

	from.options[index+move].value = tempValue;
	from.options[index+move].text = tempText;

	from.selectedIndex += move;
	logicSelect (target,targetFrom);
}
function logicSelect (target,from) {
	from = document.all[from];
	target = document.all[target];
	i = 0;
	j = "";
	while (i<from.length)
	{
		j = j + from.options[i].value;
		if (i<from.length-1)
		{
			j = j+",";
		}
		i++;
	}
	target.value = j;
}