
if(typeof com == 'undefined') com = new Object();
if(typeof com.tiso == 'undefined') com.tiso = new Object();
if(typeof com.tiso.classes == 'undefined') com.tiso.classes = new Object();
if(typeof document.loadHooks == 'undefined') document.loadHooks = [];

com.tiso.classes.Discounts = function()
{
	if((this.discounts = document.getElementById('discounts')))
	{
		this.discounts.oldDisplay = this.discounts.style.display;
		
		this.toggleLink = Shine.createHTMLElement('p');
		Shine.setAttribute(this.toggleLink, 'id', 'toggle-discounts');
		Shine.addEventHandler(this.toggleLink, 'click', { host: this, handler: this.toggleDiscounts});
		this.toggleLink.appendChild(document.createTextNode(' '));
		this.toggleDiscounts();
		if((t = document.getElementById('dept-inner')))
		{
			t.appendChild(this.toggleLink);
			t.className = 'with-discounts';
		}
		else
		{
			document.getElementById('main').appendChild(this.toggleLink);
		}
	}
}
com.tiso.classes.Discounts.prototype.setLinkContent = function(value)
{
	if(this.toggleLink.textContent) this.toggleLink.textContent = value;
	else if(this.toggleLink.innerText) this.toggleLink.innerText = value;
}
com.tiso.classes.Discounts.prototype.toggleDiscounts = function()
{
	if(this.discounts.style.display == this.discounts.oldDisplay)
	{
		this.discounts.style.display = 'none';
		this.setLinkContent('Show discounts');
	}
	else
	{
		this.discounts.style.display = this.discounts.oldDisplay;
		this.setLinkContent('Hide discounts');
	}
}

com.tiso.discounts = new com.tiso.classes.Discounts();

