
var rsong=
{
	
	sendrequest:function()
	{		
		songname	=	$('r_songname').value;
		
		content		=	$('r_content').value;
		
		rscode		=	$('r_scode').value;
		
		if(songname=="")
		{
			$('r_status').innerHTML	=	"Bạn vui lòng nhập tên bài hát";
			
			$('r_songname').focus();
			
			return false;
		}
		if(rscode=="")
		{
			$('r_status').innerHTML	=	"Bạn vui lòng nhập mã an toàn";
			
			$('r_scode').focus();
			
			return false;
		}
	
		rsong.showLoading('show');
		
		ajpath	=	"";
	
		for(i=0;i<csub.length-5;i++)
		{
			ajpath += "../";
		}
		
		ref	 =	'songrequest.php?action=sendrequest&r_songname=' + songname + '&r_content=' + content + '&r_scode=' + rscode;
		
		ref		=	ajpath	+ref;		
		
		ajax = new ITDAJAX.AJAX();
		
		ajax.onError = this.error;
		
		ajax.callPage(ref,'',this.resultRequest);
		
		return false;
		
	},
	resultRequest:function(response)
	{		
	
		rsong.showLoading();
		
		if(response!='')
		{
			if(response=='notlogin')
			{
				$('r_status').innerHTML	=	"Bạn chưa đăng nhập";
				
				
				return false;
			}
			if(response=="scode")
			{
				$('r_status').innerHTML	=	"Bạn nhập sai mã an toàn";
				
				return false;
			}
			if(response=="ok")
			{
				$('r_status').innerHTML	=	"Đã yêu cầu bài hát thành công";
				
				setTimeout('rsong.closeForm()',3000);
				
				return false;
			}		
			
			
		}
		
		return false;
	},
	closeForm:function()
	{
		ajpath	=	"";
	
		for(i=0;i<csub.length-5;i++)
		{
			ajpath += "../";
		}
		
		//CollapsiblePanel2.close();		
		
		$('r_songname').value="";
		
		$('r_content').value="";
		
		$('r_scode').value="";
		
		$('r_status').innerHTML	=	"";
		
		$('iscode').src			=	ajpath + "securityimage.php?sid=" + rsong.getRandCode();
		
		return false;
	},
	showLoading:function(act)
	{
			
		if(act=="show")
		{
			//window.document.body.style.cursor = 'url(images/dance.ani)';
			
			window.document.body.style.cursor = 'wait';
			
			$('loading_bar').className	=	"loading";
		}
		else
		{
			$('loading_bar').className	=	"stoploading";
			
			window.document.body.style.cursor = 'default';			
			
		}
		

		return false;
	},
	error:function(err)
	{
		//alert(err);
	},
	getRandCode:function()
	{
		
		
		return Math.random();
	}
}