/***********************************************************
*
*<��  ��> : ���� ��ü ��
*		 �̹� ��� ��ü�� ��� ��: �ؽ���8�� ��Ÿ�� ��d
*<���ϰ�> : ��=
*<�ۼ���> : ��âȣ
*<�ۼ���> : 2007.10.09
*<��  ��> : 
*	parentObject : ���ų ��ü�� ���Ե� �θ� ��ü		
*	id : ��� ��ü�� ID
*	nodeTagName : ��� ��ü�� �±׸�
*	h : ��Ÿ���� �ؽ���
*<usage> : 
*	var h = $H({ position : 'absolute',top : '0px',left : '0px',zIndex : '2',overflow : 'hidden',display : 'none' });
*	makeDomElement(document.getElementsByTagName("body")[0],'DetailZoomView','div',h);
*
************************************************************/
function makeDomElement(parentObject,id,nodeTagName,h)
{
	// �θ� ��ü�� ���ڷ� ��: ��ü�� ID �� ��
	if ( !document.getElementById(id) )
	{
		var tbody = parentObject;
		var tnode = document.createElement(nodeTagName);

		// JSON ���·� ��� ��: �Ӽ���� ��; �̿��� ��ü�� ��Ÿ��; ��d�Ѵ�.
		// ��� ��ü�� �θ� ��ü�� append �Ѵ�.
		h.each(function(pair) {
			eval("tnode.style." + pair.key + "='" + pair.value + "'");			
		});
		tnode.id = id;
		tbody.appendChild(tnode);
	}
	else
	{
		var tnode = document.getElementById(id);
		// JSON ���·� ��� ��: �Ӽ���� ��; �̿��� ��ü�� ��Ÿ��; ��d�Ѵ�.
		h.each(function(pair) {
			eval("tnode.style." + pair.key + "='" + pair.value + "'");			
		});
	}
}
/***********************************************************
*
*<��  ��> : ȭ��; ����� ���̾�� ������.
*<���ϰ�> : ��=
*<�ۼ���> : http://www.hunlock.com/blogs/Snippets:_Howto_Grey-Out_The_Screen
*<�ۼ���> : 2007.10.09
*<��  ��> : 
*	vis : ���ȭ ��ų��� => true,���; ��f�� ��� => false
*	options : ��Ÿ���� d�ǵ� JSON ������ �ؽ���
*<��  ó> : http://www.hunlock.com/blogs/Snippets:_Howto_Grey-Out_The_Screen
*<usage> : 
*	var options = {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
*	grayOut(true,options);
************************************************************/

function grayOut(vis, options) {
	// Pass true to gray out screen, false to ungray
	// options are optional.  This is a JSON object with the following (optional) properties
	// opacity:0-100         // Lower number = less grayout higher = more of a blackout 
	// zindex: #             // HTML elements with a higher zindex appear on top of the gray out
	// bgcolor: (#xxxxxx)    // Standard RGB Hex color code
	// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
	// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
	// in any order.  Pass only the properties you need to set.
	var options		= options || {}; 
	var zindex		= options.zindex || 50;
	var opacity		= options.opacity || 25;
	var opaque		= (opacity / 100);
	var bgcolor		= options.bgcolor || '#000000';
	var dark		= document.getElementById('darkenScreenObject');
	if (!dark) {
		// The dark layer doesn't exist, it's never been created.  So we'll
		// create it here and apply some basic styles.
		// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
		var tbody = document.getElementsByTagName("body")[0];
		var tnode = document.createElement('div');           // Create the layer.
			tnode.style.position='absolute';                 // Position absolutely
			tnode.style.top='0px';                           // In the top
			tnode.style.left='0px';                          // Left corner of the page
			tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
			tnode.style.display='none';                      // Start out Hidden
			tnode.id='darkenScreenObject';                   // Name it so we can find it later
			tbody.appendChild(tnode);                            // Add it to the web page
		dark=document.getElementById('darkenScreenObject');  // Get the object.
	}
	if (vis) {
		// Calculate the page width and height 
		if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
			var pageWidth = document.body.scrollWidth+'px';
			var pageHeight = document.body.scrollHeight+'px';
		} else if( document.body.offsetWidth ) {
			var pageWidth = document.body.offsetWidth+'px';
			var pageHeight = document.body.offsetHeight+'px';
		} else {
			var pageWidth='100%';
			var pageHeight='100%';
		}   
		//set the shader to cover the entire page and make it visible.
		dark.style.opacity=opaque;                      
		dark.style.MozOpacity=opaque;                   
		dark.style.filter='alpha(opacity='+opacity+')'; 
		dark.style.zIndex=zindex;        
		dark.style.backgroundColor=bgcolor;  
		dark.style.width= pageWidth;
		dark.style.height= pageHeight;
		dark.style.display='block';                          
	} else {
		dark.style.display='none';
	}
}
/***********************************************************
*
*<��  ��> : object �� ��� ��ǥ(absolute) �� �迭���·� ����
*<���ϰ�> : array
*<�ۼ���> : http://www.quirksmode.org/js/findpos.html
*<�ۼ���> : 2007.10.09
*<��  ��> : 
*	obj : ��ǥ��; ã�Ƴ� ��ü
*<��  ó> : http://www.quirksmode.org/js/findpos.html
*<usage>  : 
*	var obj = document.getElementById('SizeView');
*	findPos(obj)
*<Path>   :
*	IE �� ��� 5px �� ���̰� �߻��Ͽ� 5px; ���Ͽ� �����ϵ��� ��d
************************************************************/

// obj�� ���� ��ǥ�� ã�Ƴ���
// http://www.quirksmode.org/js/findpos.html
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	
	/*
	patched by ��âȣ
	*/
	/*
	if ( document.all )
	{
		curtop += 5;
		curleft += 5;
	}
	*/

	var pos =new Array();
	pos[0] = curtop;
	pos[1] = curleft;

	//return [curleft,curtop];
	return pos;
}

function getScrollWidth()
{
   var w = window.pageXOffset ||  document.body.scrollLeft || document.documentElement.scrollLeft;
           
   return w ? w : 0;
} 

function getScrollHeight()
{
   var h = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
           
   return h ? h : 0;
}

/******************************************************************
title : mEmbed v1.1
contents : IE��ġ�� ���� embed �±׸� js�� ����Ѵ�.
�� �ҽ��� ���� JS����: �ݵ�� src�� �ܺο��� ȣ��Ǿ���ϰ�
<script>mEmbed("src=source.swf","width=100","height=100", "wmode=Tranpsarent");</script>
�� ��: ���8�� �÷��� �±׸� ����ؼ� �־��ش�.
mGET �Լ�� �ι迭; �̿��� Ű���� Data �� ��n�4� �Լ�.(mEmbed�� �ʿ�)
ex) srcdata = mGET(key,value,'src'); -> php�� $srcdata = $array['src'];
by : http://blog.daum.net/battlej
******************************************************************/

function mGET(arrayKey, arrayValue, Value) {
	count = arrayKey.length;
	for(i=0;i<count;i++) {
		if(arrayKey[i]==Value) {
			return arrayValue[i];
			break;
		}
	}
}

function mEmbed() 
{
	var key = new Array();
	var value = new Array();
	var contents;
	var embed_type;
	var error_check=0;
	var i, j;
	var count;
	var data;
	var temp;
	if(mEmbed.arguments.length==1) 
	{
		contents = mEmbed.arguments[0];
	} else 
	{
		for(i=0;i<mEmbed.arguments.length;i++) 
		{
			temp = mEmbed.arguments[i].replace(/"|'/g,"");
			data = temp.split('=');
			key[i] = data[0];
			value[i] = data[1];
			count = data.length;

			for(j=2;j<count;j++) 
			{
				value[i] += '=' + data[j];
			}
		}

		contents='';
		srcdata = mGET(key,value,'src');

		if(/\.(swf)$/.test(srcdata)) 
		{
			embed_type = 1;
		} 
		else if(/\.(mov|avi|wma|wmv)$/.test(srcdata)) 
		{
			embed_type = 2;
		}

		var classid = mGET(key,value,'classid');
		var codebase = mGET(key,value,'codebase'); 
		if(embed_type==1) 
		{
			classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
			codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0';
		} else if(embed_type==2)
		{
			classid = 'clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95';
			codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715';
		}

		if(classid && codebase) 
		{
			contents += '<object';
			if(classid) 
			{
				contents += ' classid="' + classid + '"';
			}
			if(codebase) 
			{
				contents += ' codebase="' + codebase + '"';
			} 
			count = key.length;
			for(i=0;i<count;i++) 
			{
				if(value[i]!='') 
				{
					if(key[i]!='src') 
					{
						contents += ' ' + key[i] + '="' + value[i] + '"';
					}
				}
			}
			contents += '>';
			for(i=0;i<count;i++) 
			{
				if(value[i]!='') 
				{
					if(embed_type==1 && key[i]=='src') 
					{
						contents += '<param name="movie" value="' + value[i] + '" />';
					} 
					else 
					{
					  if(key[i]!='onmousedown')
						contents += '<param name="' + key[i] + '" value="' + value[i] + '" />';
					}
				}
			}
		}
		count = key.length;
		contents += '<embed';
		for(i=0;i<count;i++) 
		{
			if(value[i]!='') 
			{
				contents += ' ' + key[i] + '="' + value[i] + '"';
			}
		}
		contents += '>';
		contents += '</embed>';
		if(classid && codebase) 
		{
			contents += '</object>';
		}
	} 
	//alert(contents);
	document.write(contents);	
}

/***********************************************************
*
*<��  ��> : Ưd��ǰ�� ������� ����Ʈ(�ɼ�)�� ����Ѵ�.
*<���ϰ�> : ��=
*<�ۼ���> : ��âȣ
*<�ۼ���> : 2007.10.09
*<��  ��> : 
*	button_obj : �̺�Ʈ�� �߻��ϴ�(Ŭ���Ǵ�) ��ü
*	goods_no : ��ǰ�ڵ�1
*	goods_sub : ��ǰ�ڵ�2
*<usage> : 
*	getStockList(object,'goods_no','goods_sub');
************************************************************/

function getStockList(button_obj,goods_no,goods_sub)
{
	var obj_pos		= Position.cumulativeOffset(button_obj);
	var obj_height	= button_obj.offsetHeight;
	
	if ( $('SizeView') != null ) { $('SizeView').remove(); }
	var URL = '/v3/share/svc/svc_stock_list.php?goods_no=' + goods_no + '&goods_sub=' + goods_sub;
	new Ajax.Request(URL, {
		method: 'get',
		onSuccess: function(transport) {
			var result = transport.responseText;
			new Insertion.Top($$("body")[0], result);

			// SizeView div�� �̺�Ʈ ó��
			Event.observe($('SizeView'), 'mousemove', function(event) { $('SizeView').style.display = 'block'; });
			Event.observe($('SizeView'), 'mouseout', function(event) { $('SizeView').style.display = 'none'; });
			Event.observe(button_obj, 'mouseout', function(event) { $('SizeView').style.display = 'none'; });	
			$('SizeView').style.top = obj_pos[1] + obj_height + "px";
			$('SizeView').style.left = obj_pos[0] + "px";
			$('SizeView').style.display = "block";	
		}
	});
}
/***********************************************************
*
*<��  ��> : ��ǰd���� Ȯ���Ͽ� ����
*<���ϰ�> : ��=
*<�ۼ���> : ��âȣ
*<�ۼ���> : 2007.10.09
*<��  ��> : 
*	button_obj : �̺�Ʈ�� �߻��ϴ�(Ŭ���Ǵ�) ��ü
*	goods_no : ��ǰ�ڵ�1
*	goods_sub : ��ǰ�ڵ�2
*<usage> : 
*	viewPrdZoom('goods_no','goods_sub');
************************************************************/
function viewPrdZoom(goods_no,goods_sub)
{
	var URL = '/v3/share/svc/svc_zoom_view.php?goods_no=' + goods_no + '&goods_sub=' + goods_sub;
	
	if ( $('DetailZoomView') != null ) { $('DetailZoomView').remove(); }
	new Ajax.Request(URL,{
		method: 'get',
		onSuccess: function(transport) 
		{
			var result = transport.responseText;
			// IE7 and IE6 ���� After / Bottom / Before �� �ȵ� ��/�� �𸣰�= ??
			// dom element v�� �޼��� �� After �� �� �ϱ�?
			new Insertion.Top($$("body")[0], result);

			// DetailZoomView �� ũ��
			var dimensions = $('DetailZoomView').getDimensions();
			var xposition = (screen.width - dimensions.width) / 2;
			var yposition = Math.max(document.documentElement.scrollTop, document.body.scrollTop); 
			
			$('DetailZoomView').style.top = yposition + "px";
			$('DetailZoomView').style.left = xposition + "px";
			$('DetailZoomView').style.zIndex = '99';
			$('DetailZoomView').style.display = "block";
		}
	});	
}

function pop_Window(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
	if(window.screen)if(isCenter)if(isCenter=="true"){
		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop;
	}
	popWindow = window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
	popWindow.focus();
	return false;
}

/***********************************************************
*
*<��  ��> : ��Ű �����ϱ�
*<���ϰ�> : ��=
*<�ۼ���> : http://www.bluesider.com/18
*<�ۼ���> : 
*<��  ��> : 
*	strName : ��Ű��
*	strVaue : ��Ű��
*	secondes : ��Ű/ȿ�ð�(��':��)
************************************************************/
function setCookie(strName,strValue,seconds)
{
	var d = new Date();
	d.setTime( d.getTime() + (seconds * 1000) );
	document.cookie = strName+ "=" + escape(strValue) + "; path=/; expires=" + d.toGMTString() + ";";
}
/***********************************************************
*
*<��  ��> : ��Ű ��f�ϱ�
*<���ϰ�> : ��=
*<�ۼ���> : http://www.bluesider.com/18
*<�ۼ���> : 
*<��  ��> : 
*	strName : ��Ű��
************************************************************/
function delCookie(strName)
{
	var objExpireDate = new Date();
	objExpireDate.setDate(objExpireDate.getDate() - 1);
	document.cookie = strName + "=;expires=" + objExpireDate.toGMTString();
}
/***********************************************************
*
*<��  ��> : ��Ű��n �1�
*<���ϰ�> : ��Ű��
*<�ۼ���> : http://www.bluesider.com/18
*<�ۼ���> : 
*<��  ��> : 
*	strName : ��Ű��
************************************************************/
function getCookieValue(strName)
{
	var strCookieName = strName + "=";
	var objCookie = document.cookie;
    
    if (objCookie.length > 0) 
    {
        var nBegin = objCookie.indexOf(strCookieName);
        
        if (nBegin < 0) 
        {
            return;
        }
 
        nBegin += strCookieName.length;
        var nEnd = objCookie.indexOf(";", nBegin);
                
        if (nEnd == -1) 
        {
            nEnd = objCookie.length;
        }
    }
            
    return unescape(objCookie.substring(nBegin, nEnd)); 
}

//
// Sub ID		: getRadioValue
// Description	: üũ�� ���9�ư ��
// Param		: obj	- RadioButton object
// Return		: üũ�� ���9�ư ��
//
function getRadioValue(obj){
	if(obj){
		if(obj.length){
			for(i=0;i<obj.length;i++){
				if(obj[i].checked == true){ 
					return obj[i].value;
				}
			}

		}else{
			return obj.value;
		}
	} else { return false; }
}


function Comma(numstr) {
  var numstr = String(numstr);
  var re0 = /(\d+)(\d{3})($|\..*)/;
  if (re0.test(numstr))
    return numstr.replace(re0, function(str,p1,p2,p3) { return Comma(p1) + "," + p2 + p3; });
  else
    return numstr;
}

///////////////////////////////////////////////////////////////////////
// ��  ��  �� : unComma
// �Է� �ʵ�
//		input : Comma�� ���Ե� ����
// ��      �� :  ���ڿ��� Comma f��
function unComma(input) { 
   var inputString = new String; 
   var outputString = new String; 
   var outputNumber = new Number; 
   var counter = 0; 
   inputString=input; 
   outputString=''; 
   for (counter=0;counter <inputString.length; counter++)  
   { 
      outputString += (inputString.charAt(counter) != ',' ?inputString.charAt(counter) : ''); 
   } 
   outputNumber = parseFloat(outputString); 
   return (outputNumber);  
} 