function copyAddr() {
	if (document.getElementById('bill_inst')) {
		fieldlist=new Array('inst','zip','city','street');
		for(a=0;a<fieldlist.length;a++) {
			document.getElementById('post_'+fieldlist[a]).value=document.getElementById('bill_'+fieldlist[a]).value;
			}
	}
}

function searchsubmit(form) {
	q=form.q.value;
	if (q.length<3) {
		alert('Kérem, hogy legalább 3 karakterből álljon a keresendő kifejezés!');
		return false;
	}
	return true;
}
function loginsubmit(form) {
	user=trim(form.u.value);
	pass=trim(form.p.value);
	if (user.length<3 || user=='e-mail cím') {
		alert('Kérem, hogy az e-mail cím mezőbe az e-mail címét írja, ezt használja azonosítóként!');
		return false;
	}
	if (pass.length<3 || pass=='*****') {
		alert('Kérem, hogy adja meg a jelszavát!');
		return false;
	}
	
	return true;
}

function email(user,domain) {
	full=user+'@'+domain;
	document.write('<a href="mailto:'+full+'">'+full+'</a>');
}

function fp() { 
	if (window.innerWidth) {
		wiw=true;
	} else {
		wiw=false;
	}
	w = (wiw)?window.innerWidth:document.body.clientWidth;
	h = (wiw)?window.innerHeight:document.body.clientHeight;
		
	w = document.images[0].width - w;
	h = document.images[0].height - h;
	
	l = (screen.width) ? (screen.width-document.images[0].width)/2 : 0;
	t = (screen.height) ? (screen.height-document.images[0].height)/2 : 0;
	l = (l<0) ? 0 : l;
	t = (t<0) ? 0 : t;
	
	window.resizeBy(w, h);
	window.moveTo(l,t);
	self.focus();
};



function pic(id) {
	a=window.open('/gal.php?id='+id,'G','width=400,height=400');
	a.focus();
}

// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

// vajon ures az atadott string?
function isEmpty(s)
{
return ((s == null) || (s.length == 0))
}

// vajon eleri a minimalis hosszt az atadott string?
function minLength(s,minlen)
{
	return s.length>=minlen ? true : false;;
}

// email ellenorzes
function isEmail(who) {
	var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
	return(email.test(who));
}

function addError(err) {
	idx=errors.length;
	errors[idx]=err;
}

function displayErrorMsgs() {
	var es='Kérem, hogy javítsa a következő hibákat!' + "\n";
	for(a=0;a<errors.length;a++) {
		es=es+"- "+eMsgs[errors[a]]+"\n";
	}
	alert(es);
}
