/*
	shop_public.js

	쇼핑몰 관련 페이지 출력시 본 자바스크립트 파일은  기본적으로 로딩된다.
	사용자가 직접,  필요한 자바스크립트 코드를 여기에 작성해 넣고 사용하면 된다.
	새 function 을 넣을때는 기존 function 네임과 중복되지 않도록 항상 고유 단어를 앞에 붙여 네이밍 할것.
	-------------------------
	정식버전에 기본 제공되는 쇼핑몰 스킨에서는 작업 편의를 고려해 각각의 php 파일에
	자바스크립트 코드가 분산되어 있는데, 필요하다면 본 파일 하나에 모두 통합해 넣어 줘도 된다.
	단, php 변수가 포함된 자바스크립트 코드는 원래의 php 파일에 그대로 위치 되어야 한다.

*/




function public_js_test(){
	alert('테스트입니다.');
}

/*
	[Discuz!] (C)2001-2007 Comsenz Inc.
	This is NOT a freeware, use is subject to license terms

	$RCSfile: msn.js,v $
	$Revision: 1.4 $
	$Date: 2007/03/21 15:57:53 $
*/

function msnoperate(action, msn) {
	var actionArray = new Array();
	actionArray = {
		'reghotmail' : 'http://go.discuz.com/?app=msn&linkid=1',
		'reglivemail' : 'http://go.discuz.com/?app=msn&linkid=2',
		'regliveid' : 'http://go.discuz.com/?app=msn&linkid=3',
		'download' : 'http://go.discuz.com/?app=msn&linkid=4',
		'add' : 'http://go.discuz.com/?app=msn&linkid=5&msn=' + msn,
		'chat' : 'http://go.discuz.com/?app=msn&linkid=6&msn=' + msn
	}

	if(messengerInstalled()) {
		window.open(actionArray[action]);
	} else {
		window.open('http://go.discuz.com/msn/msn.html','_blank','width=571, height=498');
	}
}

function messengerInstalled() {
      try {
            new ActiveXObject("MSNMessenger.P4QuickLaunch");
            return true;
      }
      catch (e) {
            return false;
      }
}




//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


 /******************************************************************************
 * 공지사항 스크롤 수정 by hanxj
 *****************************************************************************/
	var toScroll = new Array();
	var ie = document.all;
	var dom = document.getElementById;
	var firstNews_obj;
	var secondNews_obj;

	function newsScroll(name) {
		var c = this;
		c.name = name;
		c.mc = 0;
		c.i = 2;
		return this;
	}

	newsScroll.prototype.addItem = function(text) {
		var c = this;
		toScroll[c.mc] = text;
		c.mc++;
	}

	newsScroll.prototype.construct = function() {
		var c = this;
		theWidth = c.scrollerwidth;
		theHeight = c.scrollerheight;
		thebgColor = c.scrollerbgcolor;
		theBackground = c.scrollerbackground;
		theDelay = c.scrollerdelay;
		scroll_obj = eval(c.name);
		
		if(ie||dom) {
			document.writeln('<div id="main2" style="position:relative;width:'+theWidth+';height:'+theHeight+';overflow:hidden;background-color:'+thebgColor+' ;background-image:url('+theBackground+')">')
			document.writeln('<div style="position:absolute;width:'+theWidth+';height:'+theHeight+';clip:rect(0 '+theWidth+' '+theHeight+' 0);left:0;top:0">')
			document.writeln('<div id="firstNews" style="position:absolute;width:'+theWidth+';left:0;top:1">')
			document.write(toScroll[0])
			document.writeln('</div>')
			document.writeln('<div id="secondNews" style="position:absolute;width:'+theWidth+';left:0;top:0;visibility:hidden">')
			document.write(toScroll[dyndetermine=(toScroll.length==1)? 0 : 1])
			document.writeln('</div>')
			document.writeln('</div>')
			document.writeln('</div>')
		}
	}

	newsScroll.prototype.move = function(whichdiv) {
		var c = this;
		theDelay = c.scrollerdelay;
		theHeight = c.scrollerheight; 
		scroll_obj = eval(c.name);
		tdiv = eval(whichdiv);

		if(parseInt(tdiv.style.top)>0 && parseInt(tdiv.style.top)<=5) {
			tdiv.style.top = 0+"px";
			setTimeout("scroll_obj.move(tdiv)",theDelay);
			setTimeout("scroll_obj.move2(secondNews_obj)",theDelay);
			return;
		}
		if(parseInt(tdiv.style.top)>=tdiv.offsetHeight*-1) {
			tdiv.style.top=parseInt(tdiv.style.top)-5+"px";
			setTimeout("scroll_obj.move(tdiv)",50);
		} else {
			tdiv.style.top=parseInt(theHeight)+"px";
			tdiv.innerHTML=toScroll[c.i];
			if(c.i==toScroll.length-1) c.i = 0;
			else c.i++;
		}
	}

	newsScroll.prototype.move2 = function(whichdiv) {
		var c = this;
		theDelay = c.scrollerdelay;
		theHeight = c.scrollerheight;
		scroll_obj = eval(c.name);
		tdiv2 = eval(whichdiv);

		if(parseInt(tdiv2.style.top)>0 && parseInt(tdiv2.style.top)<=5) {
			tdiv2.style.top=0+"px";
			setTimeout("scroll_obj.move2(tdiv2)",theDelay);
			setTimeout("scroll_obj.move(firstNews_obj)",theDelay);
			return;
		}
		if(parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1) {
			tdiv2.style.top=parseInt(tdiv2.style.top)-5+"px";
			setTimeout("scroll_obj.move2(secondNews_obj)",50);
		} else {
			tdiv2.style.top=parseInt(theHeight)+"px";
			tdiv2.innerHTML=toScroll[c.i];
			if(c.i==toScroll.length-1) c.i=0;
			else c.i++;
		}
	}

	newsScroll.prototype.startScroll = function() {
		var c = this;
		scroll_obj = eval(c.name);        
	  
		if(toScroll.length >2) c.i = 2;
		else c.i = 0;
	  
		firstNews_obj=ie? firstNews : document.getElementById("firstNews")
		secondNews_obj=ie? secondNews : document.getElementById("secondNews")
		setTimeout("scroll_obj.move(firstNews_obj)",c.scrollerDelay);
		secondNews_obj.style.top=theHeight;
		secondNews_obj.style.visibility='visible'
	}



//
function swf_tm(src, w, h)
{
	html = '';
	html += '<embed src="'+src+'" quality="high" wmode="transparent" width="'+w+'"  height="'+h+'"><\/embed>';
	document.write(html);
}


function copyUrl(url){
var content='';
window.clipboardData.setData("Text",url);
alert("성공적으로 복사되였습니다, 마우스 오른쪽버튼 누르고 붙여넣기 혹은 Ctrl+V를 누르면 됩니다.");
}

//
function scroll(n)   
{a=n;   
document.getElementById("scroller").scrollTop=document.getElementById("scroller").scrollTop+a;   
if (a==0) return;   
setTimeout("scroll(a)",80);   
}   
function scrollw(n)   
{b=n;   
document.getElementById("scroller").scrollLeft=document.getElementById("scroller").scrollLeft+b;   
if (b==0) return;   
setTimeout("scrollw(b)",80);   
}   



// 상품타이틀 스크롤
	var mqId	= null;
	var mqObj	= null;
	var mqOn	= false;
	var mqCls	= new mqClass();

	function mqStart (Obj) {
		if (mqOn) return;
		if (!Obj) return;
		if (!Obj.style) return;
		if (!Obj.style.width) return;

		if (Obj.scrollWidth > parseInt(Obj.style.width)) {
			mqCls.set(Obj);
			mqId = setInterval('mqCls.scroll()',15);
		}
	}

	function mqEnd (Obj) {
		clearInterval(mqId);
		mqCls.init();
	}

	function mqClass() {
	}

	mqClass.prototype.set = function(Obj) {
		mqOn = true;
		mqObj = Obj;
		mqObj.style.overflow = "visible";
		mqObj.style.position = "relative";
		mqObj.style.paddingLeft = parseInt(mqObj.style.width);
		mqObj.style.paddingRight = parseInt(mqObj.style.width);
		mqObj.style.left = 0;
	}

	mqClass.prototype.init = function() {
		mqOn = false;
		if (!mqObj) return;
		mqObj.style.overflow = "hidden";
		mqObj.style.paddingLeft = 0;
		mqObj.style.paddingRight = 0;
		mqObj.style.left = 0;
	}

	mqClass.prototype.scroll = function() {
		if (!mqObj) return;

		if (mqObj.scrollWidth + parseInt(mqObj.style.left) < parseInt(mqObj.style.width)) {
			mqObj.style.left = 0;
		} else {
			mqObj.style.left = parseInt(mqObj.style.left) - 1;
		}
	}




// top banner by hanxj
/*
var is_home_tx_show = false;
var div_home_tx = document.getElementById("home_tx");
var div_home_tx_in = document.getElementById("home_tx_in");
var stepms = 10;

function home_tx_show(){
	home_tx_stepshow();
}
function home_tx_stepshow(){
	var curHeight = parseInt(div_home_tx.offsetHeight);
	if(curHeight>=37){
		is_home_tx_show = true;
	}else{
		div_home_tx.style.height = (curHeight + 4) + "px";
		div_home_tx_in.style.top = (parseInt(div_home_tx_in.style.top)+4)+"px";
		window.setTimeout(home_tx_stepshow,30);
	}
}
function home_tx_hide(){
	if(is_home_tx_show){
		home_tx_stephide()
	}else{
		window.setTimeout(home_tx_stephide,1200);
	}
}

function home_tx_stephide(){
	var curHeight = parseInt(div_home_tx.style.height);
	if(curHeight<=0){
		is_home_tx_show = false;
	}else{
		try{
			div_home_tx.style.height = (curHeight - 4) + "px";
    		div_home_tx_in.style.top = (parseInt(div_home_tx_in.style.top)-4)+"px";
    		window.setTimeout(home_tx_stephide,30);
		} catch(e) {}
	}
}
if(window.addEventListener){
	window.addEventListener("load",home_tx_show,false);
}else{
	window.attachEvent("onload",home_tx_show);
}
*/

/*
 * sinaBG
 */
 
if(typeof(sina)!="object"){var sina={}}
sina.$=function(i){if(!i){return null}
return document.getElementById(i)};var sinaFlash=function(V,x,X,Z,v,z,i,c,I,l,o){var w=this;if(!document.createElement||!document.getElementById){return}
w.id=x?x:'';var O=function(I,i){for(var l=0;l<I.length;l++){if(I[l]==i){return l}}
return-1},C='8.0.42.0';if(O(['eladies.sina.com.cn','ent.sina.com.cn'],document.domain)>-1){w.ver=C}else{w.ver=v?v:C}
w.ver=w.ver.replace(/\./g,',');w.__classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";w.__codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+w.ver;w.width=X;w.height=Z;w.movie=V;w.src=w.movie;w.bgcolor=z?z:'';w.quality=c?c:"high";w.__pluginspage="http://www.macromedia.com/go/getflashplayer";w.__type="application/x-shockwave-flash";w.useExpressInstall=(typeof(i)=="boolean")?i:false;w.xir=I?I:window.location;w.redirectUrl=l?l:window.location;w.detectKey=(typeof(o)=="boolean")?o:true;w.escapeIs=false;w.__objAttrs={};w.__params={};w.__embedAttrs={};w.__flashVars=[];w.__flashVarsStr="";w.__forSetAttribute("id",w.id);w.__objAttrs["classid"]=w.__classid;w.__forSetAttribute("codebase",w.__codebase);w.__forSetAttribute("width",w.width);w.__forSetAttribute("height",w.height);w.__forSetAttribute("movie",w.movie);w.__forSetAttribute("quality",w.quality);w.__forSetAttribute("pluginspage",w.__pluginspage);w.__forSetAttribute("type",w.__type);w.__forSetAttribute("bgcolor",w.bgcolor)}
sinaFlash.prototype={getFlashHtml:function(){var I=this,i='<object ';for(var l in I.__objAttrs){i+=l+'="'+I.__objAttrs[l]+'"'+' '}
i+='>\n';for(var l in I.__params){i+='	<param name="'+l+'" value="'+I.__params[l]+'" \/>\n'}
if(I.__flashVarsStr!=""){i+='	<param name="flashvars" value="'+I.__flashVarsStr+'" \/>\n'}
i+='	<embed ';for(var l in I.__embedAttrs){i+=l+'="'+I.__embedAttrs[l]+'"'+' '}
i+='><\/embed>\n<\/object>';return i},__forSetAttribute:function(I,i){var l=this;if(typeof(I)=="undefined"||I==''||typeof(i)=="undefined"||i==''){return}
I=I.toLowerCase();switch(I){case "classid":break;case "pluginspage":l.__embedAttrs[I]=i;break;case "onafterupdate":case "onbeforeupdate":case "onblur":case "oncellchange":case "onclick":case "ondblClick":case "ondrag":case "ondragend":case "ondragenter":case "ondragleave":case "ondragover":case "ondrop":case "onfinish":case "onfocus":case "onhelp":case "onmousedown":case "onmouseup":case "onmouseover":case "onmousemove":case "onmouseout":case "onkeypress":case "onkeydown":case "onkeyup":case "onload":case "onlosecapture":case "onpropertychange":case "onreadystatechange":case "onrowsdelete":case "onrowenter":case "onrowexit":case "onrowsinserted":case "onstart":case "onscroll":case "onbeforeeditfocus":case "onactivate":case "onbeforedeactivate":case "ondeactivate":case "codebase":l.__objAttrs[I]=i;break;case "src":case "movie":l.__embedAttrs["src"]=i;l.__params["movie"]=i;break;case "width":case "height":case "align":case "vspace":case "hspace":case "title":case "class":case "name":case "id":case "accesskey":case "tabindex":case "type":l.__objAttrs[I]=l.__embedAttrs[I]=i;break;default:l.__params[I]=l.__embedAttrs[I]=i}},__forGetAttribute:function(i){var I=this;i=i.toLowerCase();if(typeof I.__objAttrs[i]!="undefined"){return I.__objAttrs[i]}else if(typeof I.__params[i]!="undefined"){return I.__params[i]}else if(typeof I.__embedAttrs[i]!="undefined"){return I.__embedAttrs[i]}else{return null}},setAttribute:function(I,i){this.__forSetAttribute(I,i)},getAttribute:function(i){return this.__forGetAttribute(i)},addVariable:function(I,i){var l=this;if(l.escapeIs){I=escape(I);i=escape(i)}
if(l.__flashVarsStr==""){l.__flashVarsStr=I+"="+i}else{l.__flashVarsStr+="&"+I+"="+i}
l.__embedAttrs["FlashVars"]=l.__flashVarsStr},getVariable:function(I){var o=this,i=o.__flashVarsStr;if(o.escapeIs){I=escape(I)}
var l=new RegExp(I+"=([^\\&]*)(\\&?)","i").exec(i);if(o.escapeIs){return unescape(RegExp.$1)}
return RegExp.$1},addParam:function(I,i){this.__forSetAttribute(I,i)},getParam:function(i){return this.__forGetAttribute(i)},write:function(i){var I=this;if(typeof i=="string"){document.getElementById(i).innerHTML=I.getFlashHtml()}else if(typeof i=="object"){i.innerHTML=I.getFlashHtml()}}}
