
function checkFieldFor(e,c) {
	if(!e.value) {
		tip.hide();
	} else {
		switch (c) {
			case "mail": // proverka dali e (element) e popylnen s korekten mail
				if(!isEmail(e.value)) {
					tip.show(e,"left","You have entered a non-valid e-mail","error")
				} else tip.hide();
			break;
			case "pass":
				if(typeof checkPassStrength == "function" && checkPassStrength(e.value)<15) {
					tip.show(e,"left","This couldn't be your password. It's very weak!","error")
				} else tip.hide();
			break;
		}
	}
}

/* ----------------------------------------------------------------------------
Class: Tip Window
Version: 1.0
Status: Stable
----------------------------------------------------------------------------  */

var tip = {
	created:false,
	show:function(e,position,text,clas) {
		if(!this.created) {
			this.create(e);
		}
		var p = this.findElementPosition(e)
		$("tipTable").className = (clas)?clas:"notice";
		$("tipTd").innerHTML = text;
		
		switch(position) {
			case "left":
				$("tipDiv").style.left = parseInt(p.left + e.offsetWidth + 2) + "px";
				$("tipDiv").style.top = parseInt(p.top - 3) + "px";
			break;
		}
		$("tipDiv").style.visibility = "visible";
	},
	create:function(e) {
		var d = newElement({
			tag:'div',
			className:'tipDiv',
			id:'tipDiv',
			children:{
				tag:'table',
				id:'tipTable',
				cellSpacing:'0',
				cellPadding:'0',
				children:[{
					tag:'tbody',
					children:[{
						tag:'tr',
						children:[{
							tag:'td',
							className:'left'
						},{
							tag:'td',
							id:'tipTd',
							className:'center',
							children:["test"]
						},{
							tag:'td',
							className:'right'
						}]
					}]
				}]
			}
		});
		document.body.appendChild(d);
		if($("tipDiv")) this.created = true;
		else this.created = false;
	},
	hide:function() {
		if($("tipDiv")) $("tipDiv").style.visibility = "hidden";
	},
	findElementPosition:function(e){
		var Left = e.offsetLeft;
		var Top = e.offsetTop;
		while (e.offsetParent) {
			e = e.offsetParent;
			Left = Left + e.offsetLeft;
			Top = Top + e.offsetTop;
		}
		return {left:Left,top:Top};
	}
}
// SpeedButton class v1.0
function SpeedButton(settings) {
	this.settings = settings;
	this.object = {};
	
	this.generate = generate;
	this.init = init;
	this.pressed = pressed;
	
	this.init();
	
	function init(image) {
		var image1 = new Image();
		image1.src = this.settings.normalImage;
		var image2 = new Image();
		image2.src = this.settings.activeImage;
		this.generate()
	}
	function generate() {
		this.object = newElement({
			tag:"div",
			className:"speedButton",
			children:[{
				tag:"img",
				src:FOLDERS.images+"/"+this.settings.normalImage,
				settings:this.settings,
				title:this.settings.altText,
				onclick:pressed
			},{
				tag:"input",
				type:"hidden",
				name:this.settings.name,
				id:this.settings.name,
				value:""
			}]
		});
//		alert(this.object.innerHTML)
		if(typeof this.settings.writeTo == "string" && $(this.settings.writeTo)) {
			$(this.settings.writeTo).appendChild(this.object);
		}
	}
	function pressed(e) {
		this.blur();
		if($(this.settings.name).value == "") {
			this.src = FOLDERS.images+"/"+this.settings.activeImage;
			$(this.settings.name).value = "active";
		} else {
			this.src = FOLDERS.images+"/"+this.settings.normalImage;
			$(this.settings.name).value = "";
		}
	}
}
// to disable the next td use this:
function disableNext(e) {
	try {
		disabled = e.checked;
		var next = document.all?e.offsetParent.nextSibling.childNodes:e.offsetParent.nextSibling.nextSibling.childNodes;
		for(var i=0;i<next.length;i++) {
			next[i].disabled = disabled;
			if(isset(next[i].style)) next[i].style.visibility=disabled?"hidden":"visible";
		}
	} catch(e) {}
}
