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() {
jQuery(function() {
	//if (/autoaparare-pentru-femei|inscriere/.test(window.location)) {
	//if (/inscriere/.test(window.location) || /locatie/.test(window.location) || /tabara-de-vara/.test(window.location) || window.location == 'http://www.kungfu-wellbeing.com/') {
		var els, foo;
		initHover();
		// els = document.getElementsByTagName("a");
		//for (var i=0, n=els.length; i < n; i++) {
		jQuery("a").each(function(el) {
			var je;

			// el = this;
			//if (/[ \t]*nolink[ \t]*/.test(this.className))
			if ((je = jQuery(this)).hasClass("nolink")) {

				//el.style.color="#999999"
				this.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 if (/harta.*[12]\.jpg$|h0[1234].jpg$/.test(this.href2)) {
						doText('<img src="' + this.href2 + '" />', this);
					} else {
						doText('<img height="200" src="' + this.href2 + '" />', this);
					}
				};
				this.onmouseout = function() {
					doClear();
				};

				// if (!jQuery(this).hasClass("clickable"))
				if (!je.hasClass("clickable")) {
					this.href2 = this.href;
					this.href = '#';
					this.onclick = function() {return false};
				} else {
					//this.href2 = jQuery(this).attr('href2');
					this.href2 = je.attr('href2');
				}
				// Preload it
				foo = new Image();
				foo.src = this.href2;
			}
		});
	//}
});
