var rotateCount = 2;



function initPage()

{

	initActive();

	initRotate();

}



function initActive()

{

	var links = $$('#categoties a');

	links.each(function(item,index){

		if (item.getParent().getParent().getProperty('id') == 'categoties'){

			item.addEvent('click',function(e){

				if (this.getParent().hasClass('active')){

					this.getParent().removeClass('active');

				} else {

					this.getParent().addClass('active');

				}

				

				var event = new Event(e);

				event.stop();

			});

		}

	});

}



function initRotate()

{

	var destImg = $('rotate');

	var lastShownImage = Cookie.get('LastShownImage');

	if (lastShownImage == false) lastShownImage = 0;

	if (destImg){

		Cookie.set('LastShownImage',getNextNumber(lastShownImage));

		destImg.src = 'img/rotate/' + Cookie.get('LastShownImage') + '.gif';

	}

}



function getNextNumber(currentNumber)

{

	currentNumber = currentNumber.toInt();

	if (currentNumber + 1 <= rotateCount){

		return currentNumber + 1;

	}

	return 1;

}



if (window.addEventListener){

	window.addEventListener("load", initPage, false);

}

else if (window.attachEvent){

	window.attachEvent("onload", initPage);

}
