var Materials = new Object();

Materials.init = function(){
	this.element = $('materials');
	this.curObject = 0;
	this.materials = new Array();
	if(this.element != undefined){
		this.getObjects();
	}
}

Materials.getObjects = function(){
	childs = this.element.children;
	for(i = 0; i<childs.length; i++)
		this.materials[i] = childs[i];
}

Materials.nextMaterial = function() {
	
	if(this.curObject+1 <= this.materials.length-1){
		var curMaterial = this.curObject;
		this.materials[curMaterial].style.display = 'none';
		this.curObject++;
		this.materials[this.curObject].style.display = '';
		
		if(this.curObject > 0){
			$('materials_prev').setAttribute('src','/img/poprzednie_aktywny.png');
			$('materials_prev').style.cursor = 'pointer';
		}
			
		if(this.curObject == this.materials.length-1){
			$('materials_next').style.display = 'none';
			//$('materials_next').setAttribute('src','/img/nastepne_nieaktywny.png');
			//$('materials_next').style.cursor = '';
		}
	}
	
}

Materials.prevMaterial = function() {
	
	if(this.curObject-1 >= 0){
		var curMaterial = this.curObject;
		this.materials[curMaterial].style.display = 'none';
		this.curObject--;
		this.materials[this.curObject].style.display = '';
		
		if(this.curObject < this.materials.length-1){
			$('materials_next').setAttribute('src','/img/nastepne_aktywny.png');
			$('materials_next').style.cursor = 'pointer';
			$('materials_next').style.display = 'block';
		}
			
		if(this.curObject == 0){
			$('materials_prev').setAttribute('src','/img/poprzednie_nieaktywny.png');
			$('materials_prev').style.cursor = '';
		}
	}
	
}
