/*
Deze js bevat functies voor .gif, .png en .jpg.

15-04-2005
*/


/*
Deze functie kijkt naar alle plaatjes die op 0 eindigen zoals: image0.gif en laad dan de 1 versie ervan in, bijv: image1.gif.

Bij onload aanroepen dus: <body onload="preloadImages();">
*/
function preloadImages() {
	documentImages = document.images;
	imagesPreloaded = [];
	for (i=0;i<documentImages.length;i++) {
		curSource = documentImages[i].src;
		if (curSource.match(/0\.(gif|jpg|png)$/i)) {
			newSource = curSource.replace(/(1|0)(\.gif|\.jpg|\.png)$/i, '1$2');
			imagesPreloaded[imagesPreloaded.length] = new Image();
			imagesPreloaded[imagesPreloaded.length-1].src = newSource;
		}
	}
}

/*
Deze functie is geschreven om makkelijker plaatjes op onmouseover te switchen en weer terug bij onmouseout.
image0.gif switched ie naar image1.gif.
Extra feature: Als het plaatje al image1.gif is bij onmouseover dan switch hij hem bij onmouseout niet naar image0.gif.

Gebruik:
 onmouseover="moImage(this, event)" onmouseout="moImage(this, event)
*/
function moImage(obj, objEvent) {
	if(typeof obj.src != 'undefined') {
		curSource = obj.src;
		if (or = curSource.match(/(1|0)\.(gif|jpg|png)$/i)) {
			if (objEvent.type == 'mouseover' && or[1] == 1) {
				selectedType = obj;
			}
			if (objEvent.type == 'mouseover') {
				newSrcState = 1;
			} else if (objEvent.type == 'mouseout') {
				newSrcState = 0;
			}
			newSource = curSource.replace(/(1|0)(\.gif|\.jpg|\.png)$/i, newSrcState+'$2');			
			if (typeof selectedType != 'undefined') {
				if (obj != selectedType) {
					obj.src = newSource;
				}
			} else {
				obj.src = newSource;
			}
		}
	}
	for (i=0;i<obj.childNodes.length;i++) {
		if (typeof obj.childNodes[i].src != 'undefined') {
			curSource = obj.childNodes[i].src;
			if (or = curSource.match(/(1|0)\.(gif|jpg|png)$/i)) {
				if (objEvent.type == 'mouseover' && or[1] == 1) {
					selectedType = obj.childNodes[i];
				}
				if (objEvent.type == 'mouseover') {
					newSrcState = 1;
				} else if (objEvent.type == 'mouseout') {
					newSrcState = 0;
				}
				newSource = curSource.replace(/(1|0)(\.gif|\.jpg|\.png)$/i, newSrcState+'$2');			
				if (typeof selectedType != 'undefined') {
					if (obj.childNodes[i] != selectedType) {
						obj.childNodes[i].src = newSource;
					}
				} else {
					obj.childNodes[i].src = newSource;
				}
			}
		}
	}
}

function moLink(obj, objEvent)
{
	if(typeof obj.childNodes[0].src != 'undefined' ) { 
		imgObj = obj.childNodes[0];
		txtObj = obj.parentNode.parentNode.childNodes[1].childNodes[0];
	} else {
		imgObj = obj.parentNode.parentNode.childNodes[0].childNodes[0].childNodes[0];
		txtObj = obj
	}

	curSource = imgObj.src;
	if (or = curSource.match(/(1|0)\.(gif|jpg|png)$/i)) {
		if (objEvent.type == 'mouseover') {
			newSrcState = 1;
			newClass = "ReadmoreHomeMo";
		} else if (objEvent.type == 'mouseout') {
			newSrcState = 0;
			newClass = "ReadmoreHome";
		}
		newSource = curSource.replace(/(1|0)(\.gif|\.jpg|\.png)$/i, newSrcState+'$2');			
		imgObj.src = newSource;
		txtObj.className = newClass;
	}
	
}