function repopulate_input(el, txt) {
	el = document.getElementById(el);
	if (!el)
		return;

	if (/^[ \t]*$/.test(el.value)) {
		el.value = txt;
	}
}

function clear_input(el, txt) {
	el = document.getElementById(el);
	if (!el)
		return;
	if (el.value == txt) {
		el.value = '';
	}
}

// ** Popup box hover thingy (c)2005 by Ralph Capper
// ** Free for you to use - but please credit me - www.ralpharama.co.uk
// Start trapping mouse

if (document.layers)
	document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=mtrack;
var ent; // Our floating div
var posx=0; // Our mouseX
var posy=0; // Our mouseY
var offsetX=16; // Offset X away from mouse
var offsetY=16; // Offset Y
var popUp = false; // Is it showing right now??!

// Run upon load
function initHover() {
	// Set up div we will use to hover our text
	ent = document.createElement("div");
	// Change these to customise your popup
	ent.style.color = "#000000";
	ent.style.font = "normal xx-small verdana";
	ent.style.padding = "1px 1px 1px 1px";
	ent.style.background = "#fff588";
	ent.style.border = "1px solid black";
	// Don't, however, change these
	ent.style.left = -100;
	ent.style.top = -100;
	ent.style.position = 'absolute';
	ent.innerHTML = '';
	ent.style.zIndex = 10;
	document.getElementsByTagName("body")[0].appendChild(ent);
}
// Keeps mouse x and y in posx and posy

function mtrack(e) {
	if (popUp) {
		if (!e) var e = window.event;
		if (e.pageX || e.pageY) {
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY) {
			posx = e.clientX + document.body.scrollLeft;
			posy = e.clientY + document.body.scrollTop;
		}
		ent.style.left = (posx + offsetX ) + "px";
		ent.style.top = (posy + offsetY - 240) + "px";
	}
}
// Change floating div to correct text on mouseover

function doText(t, e) {
	popUp = true;
	ent.innerHTML = t;
	ent.style.display='';
}
// Change back to nothing

function doClear() {
	popUp = false;
	ent.style.left = -100;
	ent.style.top = -100;
	ent.innerHTML = "";
	ent.style.display='none';
}

window.onload = function() {
	//if (/autoaparare-pentru-femei|inscriere/.test(window.location)) {
	if (/inscriere/.test(window.location) || /locatie/.test(window.location) || /sali/.test(window.location) || /program/.test(window.location)) {
	
		var els, foo;
		initHover();
		els = document.getElementsByTagName("a");
		for (var i=0, n=els.length; i < n; i++) {
			if (/[ \t]*nolink[ \t]*/.test(els[i].className)) {
				var el;

				el = els[i];
				//el.style.color="#999999";
				el.onmouseover = function() {
					if (/locatie\.jpg$/.test(this.href2)) {
						doText('<img height="350" src="' + this.href2 + '" />', this);
					} else if (/tabara/.test(this.href2)) {
						doText('<img height="230" src="' + this.href2 + '" />', this);
					} else {
						doText('<img src="' + this.href2 + '" />', this);
					}
				};
				el.onmouseout = function() {
					doClear();
				};
				// els[i].href = '#';
				el.onclick = function() {return false};
				el.href2 = el.href;
				el.href = '#';
				// Preload it
				foo = new Image();
				foo.src = el.href2;
			}
		}
	}
};
