function preload(img) {
	//Image preload
	var img1 = new Image;
	
	for(i=0; i<img.length; i++) {
		img1.src = img[i];
	}
}


function switch_imgs() {
	//Automatically add roll over image to images
	
	imgs = document.getElementsByTagName('img');
	newsrc = Array();
	newsrc_nid = Array();
	oldsrc = Array();
	
	for(i=0; i<imgs.length; i++) {
		status = imgs[i].src.substr((imgs[i].src.length-7), 3);
		
		if(status=='off') {

			oldsrc[imgs[i].id] = imgs[i].src;
			newsrc[imgs[i].id] = imgs[i].src.replace('_off.', '_on.');
			newsrc_nid[i] = imgs[i].src.replace('_off.', '_on.');
			
			
			imgs[i].onmouseover = function() {
				this.src = newsrc[this.id];	
			}
			
			imgs[i].onmouseout = function() {
				this.src = oldsrc[this.id];	
			}
		}
		
	}
	
	return newsrc_nid;
	
}

function recomienda_labels_switch() {
	
	objects = new Array();
	
	objects[0] = document.getElementById('den');
	objects[1] = document.getElementById('dee');
	objects[2] = document.getElementById('paran');
	objects[3] = document.getElementById('parae');
	objects[4] = document.getElementById('coment');
	
	for(i=0; i<objects.length; i++) {
		
		objects[i].onfocus = function() {
			this.style.zIndex = 3;
			this.style.background = '#06c';	
			this.style.color = '#FFF';
		}
		
		objects[i].onblur = function() {
			if(this.value == '') {
				this.style.zIndex = 1;
			}
			this.style.background = '#379BFF';	
			this.style.color = '#000';
		}
		
	}
}

window.onload = function() {
	preload(switch_imgs());
	recomienda_labels_switch();
}
