
R(function() {
	// error message
	formError.each(function(k, i) {
		alert(k[1]);
		//if ($(k[0])) $(k[0]).activate();
	});
});

// event
R(function() {
	// »óÇ° ÀÌ¹ÌÁö
	if ($('goodsViewImage')) $('goodsViewImage').onclick = zoomGoodsImage;
	if ($('goodsZoomImage')) $('goodsZoomImage').onclick = zoomGoodsImage;
	// »óÇ° ÀÌ¹ÌÁö ¾ÆÀÌÄÜ
	if ($$('img.goodsIconImage')) {
		$$('img.goodsIconImage').each(function(el) {
			el.onclick = function() {
				var idx = el.id.replace('goodsIconImage_', '');
				with($('goodsViewImage')) {
					width = goodsImages['view'][idx][0];
					height = goodsImages['view'][idx][1];
					src = goodsImages['view'][idx][2];
				}
				currentViewImage = idx;
			};
		});
	}
	// »óÇ°Æò°¡
	if ($$('p.btnViewContent')) {
		$$('p.btnViewContent').each(function(el) {
			el.onclick = function() {
				var info = el.id.split('_');
				var view = info[0].replace('List', 'View').concat('_'+info[1]);
				$(view).toggle();
			}
		});
	}
});

zoomGoodsImage = function() {
	window.open('image_viewer.php?idx='+currentViewImage, 'imageViewer', 'width=700, height=555');
}
 //º£½ºÆ® ¾Ù¹ü µè±â
 function playbest(param) {
		 
		if(param==""){
			alert('Play ÇÒ °îÀÌ ¾ø½À´Ï´Ù.')
			return;
		}
		pw = window.open('/Nplayer/player.php?param='+param, 'winMusicPlayer', 'width=521, height=511');
		pw.focus();
	}

function encode(param)  {  
		//dum =1;
        str = escape(param); 
        /* end_num = str.length - 1;
        encode_str = '';  
        for(i=0;i<=end_num;i++)   {
           //if(str.charCodeAt(i)==9) i++;
           key =  str.charCodeAt(i) + dum;
           encode_str += String.fromCharCode(key);
           }
		   */
       return  str ;
}

/*
function decode(param)   { 
   dum = 1;
   myObj = document.myform.aaa;
   str = myObj.value;
   //dum = 40000;
   //-- À§¿¡ ´ýÀÌ¶û °°Àº ¼ýÀÚ·Î...^..^
   decode_str = '';
   str_start = getstr('str2 = "') + 'str2 = "'.length;
   str_end = getstr('";eh');
  for(i=str_start;i<str_end;i++)  {
      key = 1*str.charCodeAt(i) - dum;
      decode_str += String.fromCharCode(key);
      }
  document.myform.aaa.value = unescape(decode_str);
}
*/

function ScorePrintView(url, id, goods_id){
	window.open(url+'?id='+id+'&goods_id='+goods_id,'ScorePrintView',"width=450,height=250");
}

function ScorePrint(url, id, goods_id){
	window.open(url+'?id='+id+'&goods_id='+goods_id,'ScorePrintView',"width=720,height=720");
}

function CartUpdate(formname){
	var theform = eval("document."+formname);
	theform.action = "opt_action.php";
	theform.submit();
}

function goDownload(url, goods_id) {
			window.open('/Nmydream/music_popupdown.php?url='+url+"&goods_id="+goods_id, 'downpg', 'width=400, height=238');
 }

 function onlyNumber(fn){

       var str = fn.value;
       var Re = /[^0-9]/g;
       //var ReN = /(-?[0-9]+)([0-9]{3})/;
       str = str.replace(Re,'');              
       //while (ReN.test(str)) { 
       //       str = str.replace(ReN, "$1,$2"); 
       //       }
           if(str==""){
                        str = "";
           }
       fn.value = str;
} 

//Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-24832517-2']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
