/* 
	Escolha seus numeros
*/

function FormatDoubleNumber(number)
{
	var prefix = '0';
	if (number >= 10)
	{
		prefix = '';
	}
	return prefix + '' + number;
}

function importJS(jsURL)
{
	var tag = document.createElement("script");
    tag.type="text/javascript";
	tag.src = jsURL;
	document.body.appendChild(tag);
}

/* ------------------------------------------------------------------------------------------------------------------------------------------------------------ */

function FactoryChangeNumbers(areaName, objName, divSelectNumbers, divSelectedNumbers, divSelectedCount, divValor, divTotal)
{
	
	this.areaID = areaName;
	this.ObjArea = null;
	
	switch (this.areaID)
	{
		case "MEGASENA":
			this.ObjArea = new ChangeMegaSena(objName);
		break;
	}
	
	if (this.ObjArea == null)
	{
		alert('Invalid Type of Change');
	}
	
	this.OutputChange = document.getElementById(divSelectNumbers);
	if (this.OutputChange == null || typeof divSelectNumbers == 'undefined')
	{
		alert('Invalid divSelectNumbers for id "' + divSelectNumbers + '"');
	}

	this.OutputSelected = document.getElementById(divSelectedNumbers);
	if (this.OutputSelected == null || typeof divSelectedNumbers == 'undefined')
	{
		alert('Invalid divSelectedNumbers for id "' + divSelectedNumbers + '"');
	}

	this.OutputSelectedCount = document.getElementById(divSelectedCount);
	if (this.OutputSelectedCount == null || typeof divSelectedCount == 'undefined')
	{
		alert('Invalid divSelectedCount for id "' + divSelectedCount + '"');
	}
	
	this.OutputValor = document.getElementById(divValor);
	if (this.OutputValor == null || typeof divValor == 'undefined')
	{
		this.OutputValor = null;
	}
	
	this.OutputTotalValor = document.getElementById(divTotal);
	if (this.OutputTotalValor == null || typeof divValor == 'undefined')
	{
		this.OutputTotalValor = null;
	}
}

FactoryChangeNumbers.prototype.GetNumbers = function ()
{
	this.OutputChange.innerHTML = this.ObjArea.GetNumbers();
}
FactoryChangeNumbers.prototype.GetSelectedNumbers = function ()
{
	this.OutputSelected.innerHTML = this.ObjArea.GetSelectedNumbers();
}
FactoryChangeNumbers.prototype.SetNumber = function (number)
{
	this.ObjArea.SetNumber(number);
	this.GetNumbers();
	this.GetSelectedNumbers();
	this.GetSelectedCount();
	this.GetCurrency();
}
FactoryChangeNumbers.prototype.GetExport = function ()
{
	return this.ObjArea.GetExport();
}
FactoryChangeNumbers.prototype.GetSelectedCount = function ()
{
	this.OutputSelectedCount.innerHTML = FormatDoubleNumber(this.ObjArea.Count());
}
FactoryChangeNumbers.prototype.GetCurrency = function ()
{
	if (this.OutputValor != null)
	{
		this.OutputValor.innerHTML = this.ObjArea.GetCurrency();
	}
}
FactoryChangeNumbers.prototype.Clear = function()
{
	this.ObjArea.Clear();
	this.GetNumbers();
	this.GetSelectedNumbers();
	this.GetSelectedCount();
	this.GetCurrency();
}