function confirmation() {
	var answer = confirm("Are you sure?")
	if (answer){
		return true;
	}
	else{
		return true;
	}
}


function f_trimmer(thisstring)
{
	while(thisstring.charAt(0)==" ")
	{
		thisstring=thisstring.substring(1,thisstring.length);
	}
	return thisstring;
}

function isValidEmail($email){
    return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
}

function checkme_search_form(search_form){
	var ss = document.forms[search_form].search_for.value;
	if (ss.length<4){	
		 alert("Cuvantul cautat trebuie sa aiba cel putin 4 caractere!");
		 document.forms[search_form].search_for.focus();
		 return false;
	}
}

function checkme_search_form(search_form2){
	var ss = document.forms[search_form2].search_for.value;
	if (ss.length<4){	
		 alert("Cuvantul cautat trebuie sa aiba cel putin 4 caractere!");
		 document.forms[search_form2].search_for.focus();
		 return false;
	}
}

function checkme_cont_form(cont_form){

	if (document.cont_form.mail){
		if (f_trimmer(document.cont_form.mail.value)==""){
			alert("E-mail camp obligatoriu !");
			document.cont_form.mail.focus();
			return false;
		} else {
			var s = new String(document.cont_form.mail.value);
			if ((s.indexOf(".")==-1 || s.indexOf("@")==-1)){       
		       alert ("E-mail invalid!");
				document.cont_form.mail.focus();
				return false;
			}
		}
	}
	
	if (document.cont_form.name){
		if (f_trimmer(document.cont_form.name.value)==""){
			 alert("Nume si prenume camp obligatoriu!");
			 document.cont_form.name.focus();
			 return false;
		}
	}
	
}

function checkme_messagesend_form(messagesend_form){
	
	if (document.messagesend_form.mailsubject){
		if (f_trimmer(document.messagesend_form.mailsubject.value)==""){
			 alert("Subiect camp obligatoriu!");
			 document.messagesend_form.mailsubject.focus();
			 return false;
		}
	}
	
	if (document.messagesend_form.message){
		if (f_trimmer(document.messagesend_form.message.value)==""){
			 alert("Mesaj gol!");
			 document.messagesend_form.message.focus();
			 return false;
		}
	}
}

function checkme_passwordchange_form(passwordchange_form){
	
	if (document.passwordchange_form.password){
		if (f_trimmer(document.passwordchange_form.password.value)==""){
			 alert("Parola noua camp obligatoriu!");
			 document.passwordchange_form.password.focus();
			 return false;
		}
	}
	
	if (document.passwordchange_form.password1){
		if (f_trimmer(document.passwordchange_form.password1.value)==""){
			 alert("Parola veche camp obligatoriu!");
			 document.passwordchange_form.password1.focus();
			 return false;
		}
	}
	
	if (document.passwordchange_form.password2){
		if (f_trimmer(document.passwordchange_form.password2.value)==""){
			 alert("Confirmare parola camp obligatoriu!");
			 document.passwordchange_form.password2.focus();
			 return false;
		}
	}
	
}

function checkme_comment_form(comment_form){

	if (document.comment_form.comment){
		if (f_trimmer(document.comment_form.comment.value)==""){
			 alert("NU se poate trimite comentariu gol!");
			 document.comment_form.comment.focus();
			 return false;
		}
	}
}

function checkme_register_form(register_form){

	if (document.register_form.name){
		if (f_trimmer(document.register_form.name.value)==""){
			 alert("Nume si prenume camp obligatoriu!");
			 document.register_form.name.focus();
			 return false;
		}
	}
	
	if (document.register_form.username){
		if (f_trimmer(document.register_form.username.value)==""){
			 alert("Nume de utilizator camp obligatoriu!");
			 document.register_form.username.focus();
			 return false;
		}
	}
	
	if (document.register_form.password){
		if (f_trimmer(document.register_form.password.value)==""){
			 alert("Parola camp obligatoriu!");
			 document.register_form.password.focus();
			 return false;
		}
	}
	
	if (document.register_form.password_conf){
		if (f_trimmer(document.register_form.password_conf.value)==""){
			 alert("Confirmare parola camp obligatoriu!");
			 document.register_form.password_conf.focus();
			 return false;
		}
	}
	
	if (document.register_form.mail){
		if (f_trimmer(document.register_form.mail.value)==""){
			alert("E-mail camp obligatoriu !");
			document.register_form.mail.focus();
			return false;
		} else {
			var s = new String(document.register_form.mail.value);
			if ((s.indexOf(".")==-1 || s.indexOf("@")==-1)){       
		       alert ("E-mail invalid!");
				document.register_form.mail.focus();
				return false;
			}
		}
	}
	
	
	if (document.register_form.cod_conf){
		if (f_trimmer(document.register_form.cod_conf.value)==""){
			 alert("Confirmare code de securitate camp obligatoriu!");
			 document.register_form.cod_conf.focus();
			 return false;
		}
	}

}


function checkme_login_form(login_form){

	if (document.login_form.username){
		if (f_trimmer(document.login_form.username.value)==""){
			 alert("Nume de utilizator camp obligatoriu!");
			 document.login_form.username.focus();
			 return false;
		}
	}
	
	if (document.login_form.password){
		if (f_trimmer(document.login_form.password.value)==""){
			 alert("Parola camp obligatoriu!");
			 document.login_form.password.focus();
			 return false;
		}
	}
}

function checkme_recover_form(recover_form){

	if (document.recover_form.mail){
		if (f_trimmer(document.recover_form.mail.value)==""){
			alert("E-mail camp obligatoriu !");
			document.recover_form.mail.focus();
			return false;
		} else {
			var s = new String(document.recover_form.mail.value);
			if ((s.indexOf(".")==-1 || s.indexOf("@")==-1)){       
		       alert ("E-mail invalid!");
				document.recover_form.mail.focus();
				return false;
			}
		}
	}
}

function checkme_recomend_form(recomend_form){

	if (document.recomend_form.email1){
		if (f_trimmer(document.recomend_form.email1.value)!=""){
			var s = new String(document.recomend_form.email1.value);
			if ((s.indexOf(".")==-1 || s.indexOf("@")==-1)){       
			   alert ("E-mail1 invalid!");
				document.recomend_form.email1.focus();
				return false;
			}
		}
	}
	
	if (document.recomend_form.email2){
		if (f_trimmer(document.recomend_form.email2.value)!=""){
			var s = new String(document.recomend_form.email2.value);
			if ((s.indexOf(".")==-1 || s.indexOf("@")==-1)){       
			   alert ("E-mail2 invalid!");
				document.recomend_form.email2.focus();
				return false;
			}
		}
	}
	
	if (document.recomend_form.email3){
		if (f_trimmer(document.recomend_form.email3.value)!=""){
			var s = new String(document.recomend_form.email3.value);
			if ((s.indexOf(".")==-1 || s.indexOf("@")==-1)){       
			   alert ("E-mail3 invalid!");
				document.recomend_form.email3.focus();
				return false;
			}
		}
	}
	
	if (document.recomend_form.email4){
		if (f_trimmer(document.recomend_form.email4.value)!=""){
			var s = new String(document.recomend_form.email4.value);
			if ((s.indexOf(".")==-1 || s.indexOf("@")==-1)){       
			   alert ("E-mail4 invalid!");
				document.recomend_form.email4.focus();
				return false;
			}
		}
	}
	
	if (document.recomend_form.email5){
		if (f_trimmer(document.recomend_form.email5.value)!=""){
			var s = new String(document.recomend_form.email5.value);
			if ((s.indexOf(".")==-1 || s.indexOf("@")==-1)){       
			   alert ("E-mail5 invalid!");
				document.recomend_form.email5.focus();
				return false;
			}
		}
	}
}

function checkme_upload_form(upload_form){

	if (document.upload_form.author){
		if (f_trimmer(document.upload_form.author.value)==""){
			 alert("Autor camp obligatoriu!");
			 document.upload_form.author.focus();
			 return false;
		}
	}
	
	if (document.upload_form.title){
		if (f_trimmer(document.upload_form.title.value)==""){
			 alert("Titlu camp obligatoriu!");
			 document.upload_form.title.focus();
			 return false;
		}
	}
	
	if (document.upload_form.embeded){
		if (f_trimmer(document.upload_form.embeded.value)==""){
			 alert("Embeded camp obligatoriu!");
			 document.upload_form.embeded.focus();
			 return false;
		}
	}
	
	if (document.upload_form.categ){
		if (document.upload_form.categ.value==0){
			 alert("Categoria camp obligatoriu!");
			 document.upload_form.categ.focus();
			 return false;
		}
	}
	
	if (document.upload_form.tags){
		if (f_trimmer(document.upload_form.tags.value)==""){
			 alert("Embeded camp obligatoriu!");
			 document.upload_form.tags.focus();
			 return false;
		}
	}
}
