///////////////TRIM KEY///////////////////
function trim(Key) {
	while(''+Key.charAt(Key.length-1)==' ')
		{ Key=Key.substring(0,Key.length-1); }
	return Key;
}

/////////////VALIDATE PASS//////////////
function VerifyPassword() {	
	
	a = document.frmChange;
	a.password.value = trim(a.password.value);
	a.password2.value = trim(a.password2.value);
	
	if (a.password.value!=a.password2.value) {
		alert('Parolele nu coincid!');
		a.password.focus();
		return false;
	}
}

/////////////VALIDATE TIP PROPRIETATE//////////////
function VerifyTipProprietate() {	

	a = document.frmAddTipProprietate;
	
	a.tip_proprietate.value = trim(a.tip_proprietate.value);
	if (a.tip_proprietate.value=="") {
		alert('Introduceti Tipul de Proprietate!');
		a.tip_proprietate.focus();
		return false;
	}
}

/////////////VALIDATE ADD USERS//////////////
function VerifyUtilizatori() {	
	
	a = document.frmAddUser;
	
	a.username.value = trim(a.username.value);
	if (a.username.value=="") {
		alert('Va rugam introduceti utilizatorul!');
		a.username.focus();
		return false;
	}	
	
	a.password.value = trim(a.password.value);
	if (a.password.value=="") {
		alert('Va rugam introduceti parola utilizatorului!');
		a.password.focus();
		return false;
	}	
	
	a.password2.value = trim(a.password2.value);
	if (a.password.value!=a.password2.value) {
		alert('Parolele nu coincid!');
		a.password.focus();
		return false;
	}
	
	a.nume.value = trim(a.nume.value);
	if (a.nume.value=="") {
		alert('Va rugam introduceti numele utilizatorului!');
		a.nume.focus();
		return false;
	}

	a.prenume.value = trim(a.prenume.value);
	if (a.prenume.value=="") {
		alert('Va rugam introduceti prenumele utilizatorului!');
		a.prenume.focus();
		return false;
	}

	a.adresa.value = trim(a.adresa.value);
	if (a.adresa.value=="") {
		alert('Va rugam introduceti adresa utilizatorului!');
		a.adresa.focus();
		return false;
	}
	
	a.telefon.value = trim(a.telefon.value);
	if (a.telefon.value=="") {
		alert('Va rugam introduceti telefonul utilizatorului!');
		a.telefon.focus();
		return false;
	}
}

/////////////VALIDATE ADD CARACT//////////////
function VerifyCaract() {	
	
	a = document.frmCaract;
	
	a.caracteristica.value = trim(a.caracteristica.value);
	if (a.caracteristica.value=="") {
		alert('Va rugam introduceti caracteristica!');
		a.caracteristica.focus();
		return false;
	}
}

/////////////VALIDATE ADD ZONA//////////////
function VerifyZona() {	
	
	a = document.frmZona;
	
	a.zona.value = trim(a.zona.value);
	if (a.zona.value=="") {
		alert('Va rugam introduceti zona!');
		a.zona.focus();
		return false;
	}
}

/////////////VALIDATE ADD ZONA//////////////
function VerifyCauta() {	
	
	a = document.frmCauta;
	
	a.keyword.value = trim(a.keyword.value);
	if (a.keyword.value=="") {
		alert('Va rugam introduceti numarul de ordine!');
		//a.frmCauta.focus();
		return false;
	}
}


////////////POPUP RESIZED - OPEN WINDOW//////////////////////
function openWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { 
		win.window.focus(); 
	}
}

/////////////VALIDATE ADD PROPRIETATE//////////////
function VerifyProp() {	
	
	a = document.frmAddProp;
	
	a.pret.value = trim(a.pret.value);
	if (a.pret.value=="") {
		alert('Va rugam introduceti pretul!');
		a.pret.focus();
		return false;
	}
	a.detalii.value = trim(a.detalii.value);
	if (a.detalii.value=="") {
		alert('Va rugam introduceti detaliile!');
		a.detalii.focus();
		return false;
	}
}

/////////////VALIDATE CONTACT//////////////
function VerifyContact() {	
	
	a = document.contact;
	
	a.nume.value = trim(a.nume.value);
	if (a.nume.value=="") {
		alert('Va rugam introduceti numele!');
		a.nume.focus();
		return false;
	}	
	
	a.telefon.value = trim(a.telefon.value);
	if (a.telefon.value=="") {
		alert('Va rugam introduceti numarul de telefon!');
		a.telefon.focus();
		return false;
	}	

	a.email.value = trim(a.email.value);
	if (a.email.value=="") {
		alert('Va rugam introduceti adresa de email!');
		a.email.focus();
		return false;
	}

	a.mesaj.value = trim(a.mesaj.value);
	if (a.mesaj.value=="") {
		alert('Va rugam introduceti mesajul!');
		a.mesaj.focus();
		return false;
	}

}

/////////////VALIDATE NEWSLETTER//////////////
function VerifyNewsletter() {	
	
	a = document.newsletter;
	
	a.nume.value = trim(a.nume.value);
	if (a.nume.value=="") {
		alert('Va rugam introduceti numele!');
		a.nume.focus();
		return false;
	}
	a.telefon.value = trim(a.telefon.value);
	if (a.telefon.value=="") {
		alert('Va rugam introduceti numarul de telefon!');
		a.telefon.focus();
		return false;
	}
}