function BxDlzProductView () {}

BxDlzProductView.prototype.getUserLicense = function (iProductId) {	
	if(!iProductId) return false;
		
	var oRequest = null;	
	var loadComplete = function(oResult)
	{			
		var oRequest = new BxXmlRequest('','','');
		vResult = oRequest.getRetNodeValue(oResult, 'result');						
		switch(vResult)
		{
			case '0':				
				alert('Error occured. Please report.');				
				break;		
			default:
				prompt('You license number is:', vResult);
				break;
		}				
	}	
	oRequest = new BxXmlRequest(aBxConfig['urlRoot'] + "xcontent/downloadz/xml_getUserLicense/" + iProductId, loadComplete, true);			
}
//--- Comments ---//
BxDlzProductView.prototype.addComment = function (iProductId)
{	
	if(!iProductId) return false;
		
	var oRequest = null;	
	var loadComplete = function(oResult)
	{			
		var oRequest = new BxXmlRequest('','','');
		iResultCode = oRequest.getRetNodeValue(oResult, 'result');						
		switch(iResultCode)
		{
			case '0':				
				document.location = aBxConfig['urlRoot'] + "Downloadz/comment/" + iProductId;		
				break;
			case '1':
				alert('Unknown error occured. Please report.');
				break;
			case '2':
				alert('You cannot comment this product because you have no license for it.');
				break;				
			case '3':
				alert('You already commented this product.');
				break;
			case '4':
				alert('You cannot comment your own product.');
				break;
		}				
	}	
	oRequest = new BxXmlRequest(aBxConfig['urlRoot'] + "xcontent/Downloadz/cmt_checkLicense/" + iProductId, loadComplete, true);			
}
BxDlzProductView.prototype.reportComment = function(iId)
{
	if(!iId) return false;
	
	var oRequest = null;
	var loadComplete = function(oResult)
	{			
		alert('Comment has been reported');
	}	
	oRequest = new BxXmlRequest(aBxConfig['urlRoot'] + "xcontent/Downloadz/cmt_report/" + iId, loadComplete, true);	
}

BxDlzProductView.prototype.delProduct = function (iProductId)
{	
	if(!iProductId) return false;
		
	var oRequest = null;	
	var loadComplete = function(oResult){
		alert('Product was successfully removed');
		window.parent.document.location = aBxConfig['urlRoot'] + 'Downloadz/home/';		
	}	
	oRequest = new BxXmlRequest(aBxConfig['urlRoot'] + "xcontent/Downloadz/delete/" + iProductId, loadComplete, true);			
}

BxDlzProductView.prototype.stopProduct = function (iProductId)
{
	if(!iProductId) return false;
		
	var oRequest = null;	
	var loadComplete = function(oResult) {		
		alert('Product was successfully removed from selling area');
		var oAnchor = $('dlzSelling');
		oAnchor.innerHTML = 'resume selling';
		oAnchor.onclick = function() {
			gBxDlzProductView.startProduct(iProductId);
		}
	}	
	oRequest = new BxXmlRequest(aBxConfig['urlRoot'] + "xcontent/Downloadz/stop/" + iProductId, loadComplete, true);				
}
BxDlzProductView.prototype.startProduct = function (iProductId)
{
	if(!iProductId) return false;
		
	var oRequest = null;	
	var loadComplete = function(oResult) {
		alert('Product was successfully resumed to selling area');
		var oAnchor = $('dlzSelling');
		oAnchor.innerHTML = 'stop selling';
		oAnchor.onclick = function() {
			gBxDlzProductView.stopProduct(iProductId);
		}
	}	
	oRequest = new BxXmlRequest(aBxConfig['urlRoot'] + "xcontent/Downloadz/start/" + iProductId, loadComplete, true);				
}

gScriptLoader.scriptLoaded();