function Ean(code)
{
	if(code instanceof Isbn)
	{
		// isbn :    2203373873
		// ean  : 9782203373877
		this.code=code.toString().substr(0,9)+"0";
		this.corrected();
	}
	else
		this.code=code;
}

Ean.prototype.toString = function()
{
	return this.code.toString();
}

Ean.prototype.key = function()
{
	var key=0;
	for(var i=0;i<12;i++)
	{
		key+=this.code.charAt(i)* ( (i&1)==0 ? 1:3);
	}
	key%=10;
	key=10-key;
	key%=10;
	return key;
}

Ean.prototype.check = function()
{
	return this.key()==this.code.substr(this.code.length-1,1);
}

Ean.prototype.corrected = function()
{
	this.code=this.code.substr(0,this.code.length-1)+this.key();
	return this;
}

