// JavaScript Document

function trimAll(strValue){
		var objRegExp = /^(\s*)$/;
    	
		if(objRegExp.test(strValue)) {
       		strValue = strValue.replace(objRegExp, '');
       	if( strValue.length == 0)
          	return strValue;
    	}
		
		objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   		if(objRegExp.test(strValue)) {
       		strValue = strValue.replace(objRegExp, '$2');
    	}
  			return strValue;
	} // regulira space

	function notEmpty(strValue) {
		var strTemp = strValue;
   		strTemp = trimAll(strTemp);
   		
		if(strTemp.length > 0){
     		return true;
   		}
   		return false;
	} // nije prazno
	
	function valEmail(strValue) {
		var objRegExp =/^[^@]+@[^@.]+\.[^@]*\w\w$/;
		return objRegExp.test(strValue);
	} // provjera mail
	
	
	function provjeriFormu(){
		var ime = document.kontaktForma.txtIme.value;
		var email = document.kontaktForma.txtEmail.value;
		var poruka = document.kontaktForma.txtPoruka.value;
		if((notEmpty(ime) != true) || (notEmpty(email) != true) || (notEmpty(poruka) != true)){
			document.getElementById('message').innerHTML = "Sva polja su obvezna!";
		}else if(valEmail(email) != true){
			document.getElementById('message').innerHTML = "E-mail adresa je neispravna!";
		}else{
			document.getElementById('message').innerHTML = "";
			document.kontaktForma.submit();
		}
	}
