/*input clear*/
function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
}
/***************************************************************************
Tab
사용법
var objTab = new content_tab('tab'); //object만들고 content_tab(아이디) 생성
objTab.initialize(); //실행
****************************************************************************/
function content_tab(obj) {
	var objID = document.getElementById(obj);
	var objLI = objID.getElementsByTagName('li');
	var objWrapWidth = 0;
	var currentID = new Array();

	this.initialize = function () {
		for (var i=0; i<objLI.length; i++) {

			setClickEvent(i);

			if (i == 0) {
				objLI[i].className += ' visible';
				if (i != 0) objLI[i - 1].className += ' prev';
				if (i != objLI.length - 1) objLI[i + 1].className += ' next';
				if (objLI[i].getElementsByTagName('img').length > 0)
					objLI[i].getElementsByTagName('img')[0].src = objLI[i].getElementsByTagName('img')[0].src.replace('_off', '_on');
			} else {
				objLI[i].className += ' hidden';
				if (objLI[i].getElementsByTagName('a')[0].href.split('#')[1])
					document.getElementById(objLI[i].getElementsByTagName('a')[0].href.split('#')[1]).style.display = 'none';
			}
			//objWrapWidth += objLI[i].offsetWidth;
		}
		//objID.style.width = objWrapWidth + 'px';
	}

	var setClickEvent = function (num) {
		objLI[num].getElementsByTagName('a')[0].onclick = function () {
			for (var j=0; j<objLI.length; j++) {
				objLI[j].className = objLI[j].className.replace('next', ' ');
				objLI[j].className = objLI[j].className.replace('prev', ' ');
				objLI[j].className = objLI[j].className.replace('visible', 'hidden');
				if (objLI[j].getElementsByTagName('img').length > 0)
					objLI[j].getElementsByTagName('img')[0].src = objLI[j].getElementsByTagName('img')[0].src.replace('_on', '_off');

				if (objLI[j].getElementsByTagName('a')[0].href.split('#')[1])
					document.getElementById(objLI[j].getElementsByTagName('a')[0].href.split('#')[1]).style.display = 'none';
			}

			if (objLI[num].getElementsByTagName('a')[0].href.split('#')[1]) {
				objLI[num].className = objLI[num].className.replace('hidden', 'visible');
				if (num != 0) objLI[num - 1].className += ' prev';
				if (num != objLI.length - 1) objLI[num + 1].className += ' next';

				if (objLI[num].getElementsByTagName('img').length > 0)
					objLI[num].getElementsByTagName('img')[0].src = objLI[num].getElementsByTagName('img')[0].src.replace('_off', '_on');

				document.getElementById(objLI[num].getElementsByTagName('a')[0].href.split('#')[1]).style.display = 'block';
			}
			var objRoundImg = new roundIMG();
			objRoundImg.initialize();
			return false;
		}
	}
}
/*by SUPERCODER*/


function chkform(target, cmt, astr, lmin, lmax)			// 입력글자 검출(target : 해당 폼필드, cmt : 코멘트, astr : 허용문자 지정, lmin : 최소글자수, lmax : 최대 글자수)
{								// 아이디나, 비밀번호 검사시 사용(유효성 검사 스크립트 참조)
    var i;
    var t = target.value;

    if (t.length == 0) {
        alert(cmt + '(을)를 기재하지 않으셨습니다.')
        target.focus()
        return true
    }

    else if (lmax != 0 && t.length < lmin || t.length > lmax) {
        alert(cmt + '는 ' + lmin + ' 이상, ' + lmax + '자 이내만 허용합니다.');
        target.focus()
        return true
    }

    else if (astr.length >= 1) {
        for (i = 0; i < t.length; i++)
            if (astr.indexOf(t.substring(i, i + 1)) < 0) {
            alert(cmt + '에 허용할 수 없는 문자가 입력되었습니다');
            target.focus()
            return true
        }
    }

    return false
}

function ChkLoginData(form) {
    var dight = "0123456789"
    var small = "abcdefghijklmnopqrstuvwxyz@-"
    var large = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    var special = "~!@#$%^&*()_+|"

    if (chkform(form.sLoginID, "아이디", dight + small + large, 4, 20)) { return false; }
    if (chkform(form.sLoginPW, "비밀번호", dight + small + large + special, 4, 20)) { return false; }
    else {
        form.action = "https://www.megazone.co.kr/members/MemberLogin_Ok.asp";
        form.submit();
        return false;
    }

    return false;
}

//2009 0403 서브용 메인 로그인.체크
function ChkLoginDataSub(form) {
    var dight = "0123456789"
    var small = "abcdefghijklmnopqrstuvwxyz@-"
    var large = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    var special = "~!@#$%^&*()_+|"

    if (chkform(form.sLoginID, "아이디", dight + small + large, 4, 20)) { return false; }
    if (chkform(form.sLoginPW, "비밀번호", dight + small + large + special, 4, 20)) { return false; }
    else {
        form.action = "/members/MemberLoginSub_Ok.asp";
        form.submit();
        return false;
    }

    return false;
}

//20080617 현재것만 남기고 숨기기 idname:아이디묶음명,startnum:시작아이디,endnum끝아이디,curnum:현재아이디 이명남 실장
function funcToggleDisplay(idname,startnum,endnum,curnum){
	for(var i=startnum;i<=endnum;i++){
		var obj = document.getElementById(idname+i);
		if(i==curnum) {
			obj.style.display = "";
		}	else	{
			obj.style.display = "none";
		}
	}
}

//20080617 현재것만 남기고 off이미지 idname:아이디묶음명,startnum:시작아이디,endnum끝아이디,curnum:현재아이디 이명남 실장
function funcToggleOff(idname,startnum,endnum,curnum){
	for(var i=startnum;i<=endnum;i++){
		var obj = document.getElementById(idname+i);
		if(i==curnum) {
			obj.src = obj.src.replace("_off.gif", "_on.gif");
		}	else	{
			obj.src = obj.src.replace("_on.gif", "_off.gif");
		}
	}
}




//-------------- Megazone SAT --------------

// Flash publishing with Cross Browsing
function swfprint(furl,fwidth,fheight,transoption)	{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ fwidth +'" height="' + fheight +'" align="middle">');
	document.write('<param name="movie" value="'+ furl +'"/>');
	if (transoption == "t")	{
		document.write('<param name="wmode" value="transparent"/>');
	} else if	(transoption == "o")	{
		document.write('<param name="wmode" value="opaque"/>');
	}
	document.write('<!-- Hixie method -->');
	document.write('<!--[if !IE]> <-->');
	document.write('<object type="application/x-shockwave-flash" data="'+ furl +'" width="'+ fwidth +'" height="' + fheight +'"');
	if (transoption == "t")	{
		document.write(' wmode="transparent"');
	} else if	(transoption == "o")	{
		document.write(' wmode="opaque"');
	}
	document.write('</object>');
	document.write('<!--> <![endif]-->');
	document.write('</object>');
}

function swfprint9(furl,fwidth,fheight,transoption,flashvars)	{
	var type_transoption;
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+ fwidth +'" height="' + fheight +'" id="'+ furl +'" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="allowFullScreen" value="false" />');
	document.write('<param name="movie" value="'+ furl +'"/>');
	document.write('<param name="quality" value="high" />');
	if (transoption == "t")	{
		document.write('<param name="wmode" value="transparent"/>');
		type_transoption = "transparent";
	} else if	(transoption == "o")	{
		document.write('<param name="wmode" value="opaque"/>');
		type_transoption ="opaque";
	}
	document.write('<param name="FlashVars" value="'+ flashvars +'" />');
	document.write('<!-- Hixie method -->');
	document.write('<!--[if !IE]> <-->');
	document.write('<embed src="'+ furl +'" quality="high" wmode="'+type_transoption+'" flashvars="'+ flashvars +' " bgcolor="#ffffff" width="'+ fwidth +'" height="' + fheight +'" id="'+ furl +'" name="'+ furl +'" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
	document.write('<!--> <![endif]-->');
	document.write('</object>');
}

function swfprint9id(furl,fid,fwidth,fheight,transoption,flashvars)	{
	var type_transoption;
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+ fwidth +'" height="' + fheight +'" id="'+ fid +'" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="allowFullScreen" value="false" />');
	document.write('<param name="movie" value="'+ furl +'"/>');
	document.write('<param name="quality" value="high" />');
	if (transoption == "t")	{
		document.write('<param name="wmode" value="transparent"/>');
		type_transoption = "transparent";
	} else if	(transoption == "o")	{
		document.write('<param name="wmode" value="opaque"/>');
		type_transoption ="opaque";
	}
	document.write('<param name="FlashVars" value="'+ flashvars +'" />');
	document.write('<!-- Hixie method -->');
	document.write('<!--[if !IE]> <-->');
	document.write('<embed src="'+ furl +'" quality="high" wmode="'+type_transoption+'" flashvars="'+ flashvars +' " bgcolor="#ffffff" width="'+ fwidth +'" height="' + fheight +'" id="'+ fid +'" name="'+ fid +'" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
	document.write('<!--> <![endif]-->');
	document.write('</object>');
}

//imageOver
function imageOver(objImg) { objImg.src = objImg.src.replace("off.gif", "on.gif");}
function imageOut(objImg) { objImg.src = objImg.src.replace("on.gif", "off.gif");}
function menuOver() { this.src = this.src.replace("off.gif", "on.gif");}
function menuOut() { this.src = this.src.replace("on.gif", "off.gif");}

// Tabbed menu
function initTabMenu(menuElId) {
 var tabMenu = document.getElementById(menuElId).getElementsByTagName("a");
 if(tabMenu.length > 0){
 for(i=0; i<tabMenu.length; i++) {
 thismenu = tabMenu.item(i);
 thismenu.menuContainer = document.getElementById(menuElId);
 thismenu.targetEl = document.getElementById(tabMenu.item(i).href.split("#")[1]);
 thismenu.targetEl.style.display = "none";
 if(thismenu.getElementsByTagName("img").length>0) {
 thismenu.getElementsByTagName("img").item(0).onmouseover = menuOver;
 thismenu.getElementsByTagName("img").item(0).onmouseout = menuOut;
 }
 thismenu.onclick = tabMenuClick;
 }
 initmenu = tabMenu.item(0);
 initmenu.menuContainer = document.getElementById(menuElId);
 initmenu.targetEl = document.getElementById(initmenu.href.split("#")[1]);
 initmenu.targetEl.style.display = "block";
 initmenu.className = "activate";
 if(initmenu.getElementsByTagName("img").length>0) {
 initmenu.getElementsByTagName("img").item(0).onmouseover();
 initmenu.getElementsByTagName("img").item(0).onmouseover = null;
 initmenu.getElementsByTagName("img").item(0).onmouseout = null;
 }
 initmenu.menuContainer.current = initmenu;
 }
}
function tabMenuClick() {
 currentmenu = this.menuContainer.current;
 if (currentmenu != this) {
 currentmenu.targetEl.style.display = "none";
 currentmenu.className = null;
 if(currentmenu.getElementsByTagName("img").length>0) {
 currentmenu.getElementsByTagName("img").item(0).onmouseover = menuOver;
 currentmenu.getElementsByTagName("img").item(0).onmouseout = menuOut;
 currentmenu.getElementsByTagName("img").item(0).onmouseout();
 }
 this.targetEl.style.display = "block";
 this.className = "activate";
 if(this.getElementsByTagName("img").length>0) {
 this.getElementsByTagName("img").item(0).onmouseover = null;
 this.getElementsByTagName("img").item(0).onmouseout = null;
 }
 this.menuContainer.current = this;
 }
 return false;
}
function initRadioMenu(radioElId) { //미완
	var radioMenu = document.getElementById(radioElId).getElementsByTagName("input");
	if(radioMenu.length > 0){
		for(i=0; i<radioMenu.length; i++) {
			thismenu = radioMenu.item(i);
			thismenu.menuContainer = document.getElementById(radioElId);
			thismenu.targetEl = document.getElementById(radioMenu.item(i).getAttribute("value"));
			thismenu.targetEl.style.display = "none";
			thismenu.onclick = radioMenuClick;
		}
		initmenu = radioMenu.item(0);
		initmenu.menuContainer = document.getElementById(radioElId);
		initmenu.targetEl = document.getElementById(initmenu.getAttribute("value"));
		initmenu.checked = true;
		initmenu.targetEl.style.display = "block";
		initmenu.menuContainer.current = initmenu;
	}
}
function radioMenuClick() {
	currentmenu = this.menuContainer.current;
	if (currentmenu != this) {
		currentmenu.targetEl.style.display = "none";
		currentmenu.checked = false;
		this.checked = true;
		this.targetEl.style.display = "block";
		this.menuContainer.current = this;
	}
	return false;
}

// Layer Show-Hide
function showLayer(tgtEl)    {    document.getElementById(tgtEl).style.display = "block";    }
function hideLayer(tgtEl)    {    document.getElementById(tgtEl).style.display = "none";    }

/*function viewExtLink() {
	target = this.href;
	linkEl = document.getElementById(target.split("#")[1]);
	if (linkEl.style.display == "block") {
		linkEl.style.display = "none";
	} else {
		linkEl.style.display = "block";
	}
	return false;
}*/


// Iframe Resize
function calcHeight()
{
  //find the height of the internal page
  var the_height=
    document.getElementById('the_iframe').contentWindow.
      document.body.scrollHeight;

  //change the height of the iframe
  document.getElementById('the_iframe').height=
      the_height;
}

// Select Links
function selectLinks(tgtEl)    {
    var tgtList = document.getElementById(tgtEl);
    if(tgtList.style.display)    {
        hideLayer(tgtEl);
        tgtList.style.display = "";
    } else    {
        showLayer(tgtEl);
    }
}

//Popup
function wopen(url,name,w,h,s)    {
    if(s==1)    {
        sOp = ",scrollbars=yes";
    } else  if(s==0)   {
        sOp = "";
    }
    winOptions = 'width='+w+',height='+h+sOp;
    window.open(url,name,winOptions);
}
//Popup Close
function wclose()     {
    window.close();
}

//png
function setPng24(obj) { 
    obj.width=obj.height=1; 
    obj.className=obj.className.replace(/\bpng24\b/i,''); 
    obj.style.filter = 
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
    obj.src='';  
    return ''; 
}


/* 20071212 Image Over Text - Do Kumho */
function hj_view(obj) {
	var bimgs = new Array();
	var btext = new Array();
	var blinka = new Array();
	var picbox = document.getElementById(obj);
	var picboxli = picbox.getElementsByTagName("li");
	var picboxlitotal = picboxli.length;
	
	for( var i=0; i<picboxlitotal; i++ ) {
		bimgs[i] = picboxli.item(i).getElementsByTagName("a")[0].getElementsByTagName("img")[0].src;
		btext[i] = picboxli.item(i).getElementsByTagName("a")[0].getElementsByTagName("img")[0].alt;
		blinka[i] = picboxli.item(i).getElementsByTagName("a")[0].href;
		if ( i == 0 ) {
			picboxli.item(i).getElementsByTagName("a")[0].className = "over";
		} else {
			picboxli.item(i).getElementsByTagName("a")[0].className = null;
			picboxli.item(i).getElementsByTagName("a")[0].getElementsByTagName("img")[0].style.filter='Alpha(opacity=50)';
		}
	}
	
	var newli = document.createElement("li");
	newli.className = "pic_big";
	picbox.appendChild(newli);
	
	var newlink = document.createElement("a");
	newlink.href = blinka[0];
	newli.appendChild(newlink);
	
	var newPic = document.createElement("img");
	newPic.src = bimgs[0];
	newPic.alt = btext[0];
	newlink.appendChild(newPic);
}
function hj_over(obj,num) {
	var picbox = document.getElementById(obj);
	var picboxli = picbox.getElementsByTagName("li");
	var picboxlitotal = picboxli.length - 1;
	for( var i=0; i<picboxlitotal; i++ ) {
		if ( i == num ) {
			picboxli.item(i).getElementsByTagName("a")[0].className = "over";
			picboxli.item(i).getElementsByTagName("a")[0].getElementsByTagName("img")[0].style.filter='Alpha(opacity=100)';
			picboxli.item(3).getElementsByTagName("img")[0].src = picboxli.item(i).getElementsByTagName("a")[0].getElementsByTagName("img")[0].src;
			picboxli.item(3).getElementsByTagName("img")[0].alt = picboxli.item(i).getElementsByTagName("a")[0].getElementsByTagName("img")[0].alt;
		} else {
			picboxli.item(i).getElementsByTagName("a")[0].className = null;
			picboxli.item(i).getElementsByTagName("a")[0].getElementsByTagName("img")[0].style.filter='Alpha(opacity=50)';
		}
	}
}
function board_view(obj,num,total) {
	for ( var i=0; i<total; i++ ) {
		var objtr = document.getElementById(obj+i);
		if ( i == num ) {
			objtr.className = "valueblockon";
		} else {
			objtr.className = "valueblockoff";
		}
	}
}
function ImagesScroll() {
	this.GoodsSetTime = null;
	this.Speed = 2;
}

ImagesScroll.prototype.GoodsSetting = function() {
	this.DivBox = document.getElementById(this.DivName);
	this.DivBox.style.width = this.DivWidth + "px";
	
	this.LiBox_Left = new Array();							// 각 상품의 위치값을 저장하는 배열
	this.Last_Left = new Array();							// 각 상품의 위치값을 저장하는 배열
	this.MovieWidth = this.ImageWidth+4+this.ImageSpace;
	
	this.tabletd = this.DivBox.getElementsByTagName("table")[0].getElementsByTagName("tr")[0];
	this.tabletd.getElementsByTagName("td")[0].style.width = this.BtnWidth + "px";
	this.tabletd.getElementsByTagName("td")[2].style.width = this.BtnWidth + "px";
	this.tabletd.getElementsByTagName("td")[1].style.width = ( this.DivWidth - this.BtnWidth * 2 ) + "px";
	this.tabletd.getElementsByTagName("td")[0].getElementsByTagName("a")[0].href = "javascript:" + this.ScrollName + "._prevBtn();";
	this.tabletd.getElementsByTagName("td")[2].getElementsByTagName("a")[0].href = "javascript:" + this.ScrollName + "._nextBtn();";
	this.tabletd.getElementsByTagName("td")[2].style.textAlign = "right";
	
	this.SubDivBox = this.tabletd.getElementsByTagName("td")[1].getElementsByTagName("div")[0];
	this.SubDivBox.style.width = ( this.DivWidth - this.BtnWidth * 2 - 12 ) + "px";
	this.PicBox = this.SubDivBox.getElementsByTagName("ul")[0].getElementsByTagName("li");
	
	for ( var i=0; i < this.PicBox.length; i++) {
		this.PicBox.item(i).style.width = ( this.ImageWidth + 4 ) + "px";
		if ( this.Text == 1 ) {
			this.TextBoxHeight =  this.TextLine * 14 + 30;
			this.PicBox.item(i).getElementsByTagName("div")[1].style.height = this.TextBoxHeight + "px";
		} else {
			this.TextBoxHeight = 0;
		}
		this.PicBox.item(i).style.height = ( this.ImageHeight + this.TextBoxHeight + 9 ) + "px";
	}
	this.SubDivBox.style.height = ( this.ImageHeight + this.TextBoxHeight + 9 ) + "px";
	
	this.GoodlsArrange();
	
//	this.GoodsSetTime = setTimeout(this.ScrollName + "._nextFrame()",5000);
}

ImagesScroll.prototype.GoodlsArrange = function() {
	this.Default_left = -4*this.MovieWidth;
	
	for ( var i=0; i < this.PicBox.length; i++ ) {
		this.LiBox_Left[i] = this.Default_left + ( i * this.MovieWidth );
		this.PicBox.item(i).style.left = this.LiBox_Left[i] + "px";
	}
	
	this.Last_Left = this.LiBox_Left[this.PicBox.length-1];
}

ImagesScroll.prototype._nextFrame = function() {
	for ( var i=0; i<this.PicBox.length; i++ ) {
		this.LiBox_Left[i] = this.LiBox_Left[i] - this.Speed;
		if ( this.LiBox_Left[i] == ( this.Default_left - this.MovieWidth ) ) {
			this.LiBox_Left[i] = ( ( this.PicBox.length - 1 ) * this.MovieWidth ) + this.Default_left;
			this.PicBox[i].style.left = this.LiBox_Left[i] + "px"
		} else {
			this.PicBox[i].style.left = this.LiBox_Left[i]+"px";
		}
	}
	if ( Math.abs(this.LiBox_Left[0] % ( this.MovieWidth * this.LiBox_HiddenNum )) <= 1 ) {
//		this.GoodsSetTime = setTimeout(this.ScrollName + "._nextFrame()",5000);
	} else {
		this.GoodsSetTime = setTimeout(this.ScrollName + "._nextFrame()",10);
	}
}


ImagesScroll.prototype._prevFrame = function() {
	for ( var i=0; i<this.PicBox.length; i++ ) {
		this.LiBox_Left[i] = this.LiBox_Left[i] + this.Speed;
		if ( this.LiBox_Left[i] == this.Last_Left + this.MovieWidth ) {
			this.LiBox_Left[i] = this.Default_left;
			this.PicBox[i].style.left = this.LiBox_Left[i] + "px"
		} else {
			this.PicBox[i].style.left = this.LiBox_Left[i]+"px";
		}
	}
	if ( Math.abs(this.LiBox_Left[0] % ( this.MovieWidth * this.LiBox_HiddenNum )) <= 1 ) {
//		this.GoodsSetTime = setTimeout(this.ScrollName + "._nextFrame()",5000);
	} else {
		this.GoodsSetTime = setTimeout(this.ScrollName + "._prevFrame()",10);
	}
}


ImagesScroll.prototype._nextBtn = function() {
	clearTimeout(this.GoodsSetTime);
	this.GoodsSetTime = setTimeout(this.ScrollName + "._nextFrame()",10);
}
ImagesScroll.prototype._prevBtn = function() {
	clearTimeout(this.GoodsSetTime);
	this.GoodsSetTime = setTimeout(this.ScrollName + "._prevFrame()",10);
}

// Select Links
function selectLinks(tgtEl)    {
    var tgtList = document.getElementById(tgtEl);
    if(tgtList.style.display)    {
        hideLayer(tgtEl);
        tgtList.style.display = "";
    } else    {
        showLayer(tgtEl);
    }
}

//image popup
function popimage(imagesrc,winwidth,winheight){
    var look='width='+winwidth+',height='+winheight+','
        popwin=window.open("","",look)
        popwin.document.open()
        popwin.document.write('<title>Image Window</title><body topmargin=0 leftmargin=0><img style=cursor:pointer; onclick="self.close()" src="'+imagesrc+'"></body>')
        popwin.document.close()
}

//Site End mini Pop
function siteEndmPop() {
    var toppos = (screen.height-71)/2 - 100;
	var leftpos = (screen.width-383)/2;
    window.open("/siteEnd.htm", "pop", "width=383, height=0, left="+leftpos+",top="+toppos, "");
}