function toggleForm(string) {
	if($(string).style.display=="") {
		$(string).hide();

	} else {
		$(string).show();
		if(string=="loginform") {
			$('lid').focus();
		} else {
			$('rname').focus();
		}
	}
}

function loginProcess() {
	new Ajax.Request("lp.php",{method:'post',parameters:{lid:$('lid').value,lpw:$('lpw').value},onSuccess:function(arg2){
		response=arg2.responseText;
		response.evalScripts();
	}});
}

function registerProcess() {

	if($('rpw').value!=$('rpw2').value) {
		$('rpw').focus();
		alert('두 비밀번호가 일치하지 않습니다!');
		return true;
	} else if($('rname').value && $('rid').value && $('rpw').value && $('rpw2').value && $('rmail').value) {
		
		new Ajax.Request("rp.php",{method:'post',parameters:{rid:$('rid').value,rpw:$('rpw').value,rpw2:$('rpw2').value,rname:$('rname').value,rmail:$('rmail').value},onSuccess:function(arg2){
			response=arg2.responseText;
			response.evalScripts();
		}});	
		
	
	} else {
		alert('모든 항목을 써주세요!');
		
	}
}


function chkId() {

	new Ajax.Request('chkid.php',{method:'post',parameters:{id:$('rid').value},onSuccess:function(arg2) {
		response=arg2.responseText;
		response.evalScripts();
	}});
	
}


function showTerms() {
	stopScroll();
	$('middleWinBg').style.top=document.body.scrollTop;
	$('middleWinBg').style.left=document.body.scrollLeft;
	width=parseInt(document.body.clientWidth);
	height=parseInt(document.body.clientHeight);
	$('middleWinBg').style.width=width;
	$('middleWinBg').style.height=height;
	//new Effect.Appear($('middleWinBg'),{from:0.0,to:0.7,duration:0.3})
	$('middleWinBg').show();
	
	$('termsDiv').style.top=(height-parseInt($('termsDiv').style.height))/2+document.body.scrollTop;
	$('termsDiv').style.left=(width-parseInt($('termsDiv').style.width))/2+document.body.scrollLeft;
	//new Effect.Appear($('termsDiv'),{duration:0.3})
	$('termsDiv').show();
	
}

function closeTerms() {
	startScroll();
	$('middleWinBg').hide();
	$('termsDiv').hide();
	
}

function showLostpass() {
	stopScroll();
	$('middleWinBg').style.top=document.body.scrollTop;
	$('middleWinBg').style.left=document.body.scrollLeft;
	width=parseInt(document.body.clientWidth);
	height=parseInt(document.body.clientHeight);
	$('middleWinBg').style.width=width;
	$('middleWinBg').style.height=height;
	//new Effect.Appear($('middleWinBg'),{from:0.0,to:0.7,duration:0.3})
	$('middleWinBg').show();
	
	$('lostpassDiv').style.top=(height-parseInt($('lostpassDiv').style.height))/2+document.body.scrollTop;
	$('lostpassDiv').style.left=(width-parseInt($('lostpassDiv').style.width))/2+document.body.scrollLeft;
	//new Effect.Appear($('lostpassDiv'),{duration:0.3})
	$('lostpassDiv').show();
	
}
function closeLostpass() {
	startScroll();
	$('middleWinBg').hide();
	$('lostpassDiv').hide();
}


function stopScroll() {
	$('opened').value=1;
	$('nowScrollTop').value=document.body.scrollTop;
	$('nowScrollLeft').value=document.body.scrollLeft;
}

function startScroll() {
	$('opened').value=0;
}
function adjustScroll() {
	/*
	//menu moving
	if (window.pageYOffset){
		scroll_top = window.pageYOffset
		scroll_left = window.pageXOffset
	}else if (document.documentElement && document.documentElement.scrollTop){
		scroll_top = document.documentElement.scrollTop
		scroll_left = document.documentElement.scrollLeft
	}else if (document.body){
		scroll_top = document.body.scrollTop
		scroll_left = document.body.scrollLeft
	}
	var winHeight= document.body.clientHeight;
	$('leftmenu').style.top=(parseInt(winHeight)-454)/2+parseInt(scroll_top);
	
	//
	if($('bigWindow').style.display=="") {
		setBigWindow();
	}
	*/
	if($('opened').value==1) {
		document.body.scrollTop=$('nowScrollTop').value;
		document.body.scrollLeft=$('nowScrollLeft').value;
	}
	$('middleWinBg').style.top=document.body.scrollTop;
	$('middleWinBg').style.left=document.body.scrollLeft;
	width=parseInt(document.body.clientWidth);
	height=parseInt(document.body.clientHeight);
	$('middleWinBg').style.width=width;
	$('middleWinBg').style.height=height;
}

function lostpassProcess() {
	if($('pname').value && $('pmail').value) {
		new Ajax.Request("lpp.php",{method:'post',parameters:{name:$('pname').value,mail:$('pmail').value},onSuccess:function(arg2){
			response=arg2.responseText;
			response.evalScripts();
		}});
	} else {
		alert('모든 항목을 써주셔야 합니다!');
	}
}


//png related
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 and 6.
{
   if ((version >= 5.5) && (document.body.filters) && (version < 7.0)) 
   {
       for(var i=0; i<document.images.length; i++)
       {
	      var img = document.images[i]
	      var imgName = img.src.toUpperCase()
	      if ((imgName.substring(imgName.length-3, imgName.length) == "PNG"))
	      {
		     var imgID = (img.id) ? "id='" + img.id + "' " : ""
		     var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		     var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		     var imgStyle = "display:inline-block;" + img.style.cssText 
		     var imgAttribs = img.attributes;
		     for (var j=0; j<imgAttribs.length; j++)
			 {
			    var imgAttrib = imgAttribs[j];
			    if (imgAttrib.nodeName == "align")
			    {		  
			       if (imgAttrib.nodeValue == "left") imgStyle = "float:left;" + imgStyle
			       if (imgAttrib.nodeValue == "right") imgStyle = "float:right;" + imgStyle
			       break
			    }
             }
		     var strNewHTML = "<span " + imgID + imgClass + imgTitle
		     strNewHTML += " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	         strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		     strNewHTML += "(src='" + img.src + "', sizingMethod='scale');\""
		     strNewHTML += " onmouseover=\"PNGswap('" + img.id + "');\" onmouseout=\"PNGswap('" + img.id +"');\""
		     strNewHTML += "></span>" 
		     img.outerHTML = strNewHTML
		     i = i-1
	      }
       }
   }
   
}
window.attachEvent("onload", correctPNG);

function PNGswap(myID)
{
   var strOver  = "_on"
   var strOff = "_off"
   var oSpan = document.getElementById(myID)
   var currentAlphaImg = oSpan.filters(0).src
   if (currentAlphaImg.indexOf(strOver) != -1)
      oSpan.filters(0).src = currentAlphaImg.replace(strOver,strOff)
   else
      oSpan.filters(0).src = currentAlphaImg.replace(strOff,strOver)
}


function imgSwap(oImg)
{
   var strOver  = "_on"    // image to be used with mouse over
   var strOff = "_off"     // normal image
   var strImg = oImg.src
   if (strImg.indexOf(strOver) != -1) 
      oImg.src = strImg.replace(strOver,strOff)
   else
      oImg.src = strImg.replace(strOff,strOver)
}