var APP = false;

var Basket =
{
	addSong : function(SONG_NUM, BUY_TYPE)
	{
		if(!Login.getLogin())
		{
			alert('로그인 후 이용하시기 바랍니다.');
			location.href = '/Login/?DIR='+escape(document.location.href);
			return;
		}
		Basket.Windows = _Window.showPopUp();
		Basket.Windows.style.width    = '606px';
		Basket.Windows.style.height    = '520px';
			
		var Param = {  'MODE' : 'Call'  };
		
		Param["Type"] =  "Page";
		Param['SONG_NUM'] = SONG_NUM;
		Param['BUY_TYPE'] = BUY_TYPE;
		
		Param.onComplete = function ()
		{
			UI.setScreenCenter(this);
		}.bind(Basket.Windows);
	    	  
	    AutoRun.setDocument(Basket.Windows, Param, '/APP/Buy_Song/Content.php');
	},
	addAlbum : function(ALBUM_NUM, BUY_TYPE)
	{
		if(!Login.getLogin())
		{
			alert('로그인 후 이용하시기 바랍니다.');
			location.href = '/Login/?DIR='+escape(document.location.href);
			return;
		}
		Basket.Windows = _Window.showPopUp();
		Basket.Windows.style.width    = '606px';
		Basket.Windows.style.height    = '520px';
			
		var Param = {  'MODE' : 'Call'  };
		
		Param["Type"] =  "Page";
		Param['ALBUM_NUM'] = ALBUM_NUM;
		Param['BUY_TYPE'] = BUY_TYPE;
		
		Param.onComplete = function ()
		{
			UI.setScreenCenter(this);
		}.bind(Basket.Windows);
	    	  
	    AutoRun.setDocument(Basket.Windows, Param, '/APP/Buy_Song/Content.php');
	},
	deleteSong : function(SONG_NUM, BUY_TYPE)
	{
		var Param = {
			'MODE' : 'Call', 
			'Type' : 'Page',
			'MODE' : 'DELETE',
			'SONG_NUM' : SONG_NUM,
			'BUY_TYPE' : BUY_TYPE
		};
		
		AutoRun.setDocument($('BasketLayer'), Param, '/APP/Buy_Song/Basket.php');
	},
	ListLoad : function(BUY_TYPE)
	{
		var Param = {
			'MODE' : 'Call', 
			'Type' : 'Page',
			'BUY_TYPE' : BUY_TYPE
		};

		AutoRun.setDocument($('BasketLayer'), Param, '/APP/Buy_Song/Basket.php');
	},
	Buy : function(BUY_TYPE)
	{
		
		if(!confirm("해당 곡을 구매하시겠습니까?")) return false;
		
		
		var Result = Ajax.exec('/APP/Buy_Song/Buy.php',{'BUY_TYPE' : BUY_TYPE} );
		
		if(!isNaN(Result.text))
		{
			if(APP)
			{
				location.href = '/APP/Buy_Song/End/?BUY_TYPE=MP3&APP=TRUE';
			}
			else
			{
				Basket.Windows.style.height = '300px';
				
				var Param = {
					'MODE': 'Call'
				};
				
				Param["Type"] = "Page";
				Param['ORDER_NUM'] = Result.text;
				Param['BUY_TYPE'] = BUY_TYPE;
				
				Param.onComplete = function(){
					UI.setScreenCenter(this);
				}.bind(Basket.Windows);
				
				AutoRun.setDocument(Basket.Windows, Param, '/APP/Buy_Song/End/Content.php');
			}
		}
		else
			alert(Result.text);
	},
	close : function()
	{
		if(APP)
			self.close();
		else
			Pop.close();
	},
	CashOpen : function()
	{
		if(APP)
		{
			var shape = "left=70,top=10,toolbar=no,location=no,directories=no,status=no,";
				shape += "menubar=no,scrollbars=no,resizable=no";
				shape += ",width=606,height=550";
			window.open('/APP/Cash_Charge', 'CashCharge', shape);
		}
		else
		{
			location.href = '/Store/Cash';
		}
	},
	BuySongOpen : function()
	{
		if(APP)
		{
			window.open('/MyMusicShake/MySong/Buy_Song', '', '');
			self.close();
		}
		else
		{
			location.href = '/MyMusicShake/MySong/Buy_Song';
		}
	},
	CashUseOpen : function()
	{
		if(APP)
		{
			window.open('/MyMusicShake/Cash/Use/', '', '');
			self.close();
		}
		else
		{
			location.href = '/MyMusicShake/Cash/Use/';
		}
	}
}
