// JavaScript Document

/*
** Functions
** - no expressions below this line...
*/

function openIntresseWindow() {
	window.open('../intresse.htm', 'intresseWin', 'width=600, height=420');
}

Function.prototype.method = function(name, func) {
	this.prototype[name] = func;
	return this;
}

function ImageDeck(hostImg, arImages) {
	var pointer = 0;
	this.length = arImages.length;
	if(this.length == 0)
		return this;
	/* Init */
	(function() {
		var tmp;
		for(var i = 0; i < arImages.length; i++) {
			tmp = new Image();
			tmp.src = arImages[i];
			arImages[i] = tmp;
		}
		hostImg.src = arImages[0].src;
	})();
	
	function update() {
		while(pointer < 0)
			pointer += arImages.length;
		pointer %= arImages.length;
		hostImg.src = arImages[pointer].src;
	}
	
	/* Public */
	ImageDeck.method('next', function() {
		pointer++;
		update();
	});
	ImageDeck.method('prev', function() {
		pointer--;
		update();
	});
}

function Checkbox(divId, fieldId) {
	fieldId = fieldId || (divId + 'Field');
	var cbDiv = document.getElementById(divId);
	var cbField = document.getElementById(fieldId);
	var state = false;
	
	this.toggle = function() {
		state = !state;
		cbDiv.style.backgroundPosition = state ? 'right' : 'left';
		cbField.value = state ? '1' : '0';
	}
	this.getValue = function() {
		return state;
	}
	cbDiv.onclick = this.toggle;
}

function loadImage(src, text) {
	document.getElementById('image').src = src;
	if(text) {
		document.getElementById('imagefooter').innerHTML = text;
	}
}
		  
