function showDetails(el) {
	el.addClass("hover");
	var det = el.find(".details");
	$("#main").append('<div id="line"></div>');
	$("#line").css("height",el.height()); 
	$("#line").css("top",el.position().top); 
	det.appendTo("#leftcol");
	
	var newY = el.position().top-det.height()/2+el.height();
	newY > $("table.grid").position().top+$("table.grid").outerHeight()-det.outerHeight() ? newY=$("table.grid").position().top+$("table.grid").outerHeight()-det.outerHeight() : newY;
	newY < $("table.grid").position().top ? newY=$("table.grid").position().top : newY;
	det.css("top",(newY+"px"));
}

function hideDetails(el) {
	el.removeClass("hover");
	$("#leftcol > .details").appendTo(el.find("td.hide"));
	$("#line").remove();
}

$(function() {
	$("table.grid tbody tr").hover(
		function () {
			showDetails($(this));
		}, 
		function () {
			hideDetails($(this));
		}
	);
});

function load() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		var center = new GLatLng(47.5606296, 19.1070954);
		map.setCenter(center, 15);
		var marker = new GMarker(center);
		map.addOverlay(marker);
	}
}

function showDialog() {
	$(function() {
		$("#dialog").dialog({
			bgiframe: true,
			height: 140,
			modal: true,
			overlay: {
				backgroundColor: '#000',
				opacity: 0.5
			}
		});
	});
}

function MM_validateForm() {
  if (document.getElementById){
		var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
		for (i=0; i<(args.length-2); i+=3) {
			test=args[i+2];
			nm=args[i+1];
			val=document.getElementById(args[i]);
			if (val) {
				nm=args[i+1];
				if ((val=val.value)!="") {
					if (test.indexOf('isEmail')!=-1) { 
						p=val.indexOf('@');
						if (p<1 || p==(val.length-1)) errors+='- '+nm+' mező tartalma nem e-mail\n';
					}
				} else if (test.charAt(0) == 'R') errors += '- '+nm+' mező kitöltése kötelező\n'; 
			}
		}
		if (errors) alert('A kitöltés során a következő hiba/hibák történtek:\n'+errors);
		return (errors == '');
	}
}
