/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}

	var bImages = document.getElementsByTagName('input');
	for (var i = 0; i < bImages.length; i++) {		
		if (bImages[i].className == 'imgover') {
			var src = bImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			bImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			bImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			bImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
	
	//Boxsystem
		var sBoxSrc;
	var aBox = document.getElementsByTagName('img');

	for (var i = 0; i < aBox.length; i++) {		
		if (aBox[i].className == 'box_sys') {
			var nsrc = aBox[i].getAttribute('src');
			var ftype = nsrc.substring(nsrc.lastIndexOf('.'), nsrc.length);

			var chsrc = nsrc.replace(ftype, '_1'+ftype);
			var osrc = nsrc.replace(ftype, '_2'+ftype);
			var ohsrc= nsrc.replace(ftype, '_3'+ftype);

			aBox[i].setAttribute('chsrc', chsrc);
			aBox[i].setAttribute('osrc', osrc);
			aBox[i].setAttribute('ohsrc', ohsrc);
			var sBoxSrc = aBox[i].getAttribute('src');

			aBox[i].onmouseover = function() {
				var target=document.getElementById(this.getAttribute('name')+'_b').style.display;
				if(target=="none"){
					this.setAttribute('src', this.getAttribute('ohsrc'));
				}else{
					this.setAttribute('src', this.getAttribute('chsrc'));
				}
			}	
			aBox[i].onmouseout = function() {
				var target=document.getElementById(this.getAttribute('name')+'_b').style.display;
				if(target=="none"){
					this.setAttribute('src', this.getAttribute('osrc'));
				}else{	
					this.setAttribute('src',sBoxSrc);
				}
			}
			aBox[i].onmousedown = function() {
				var target=document.getElementById(this.getAttribute('name')+'_b').style.display;
				if(target=="none"){
					document.getElementById(this.getAttribute('name')+'_b').style.display= "block";
					this.setAttribute('src', sBoxSrc);
				}else{
					document.getElementById(this.getAttribute('name')+'_b').style.display="none";
					this.setAttribute('src', this.getAttribute('osrc'));
				}
			}
		}
	}
}
