
/*start:EMAIL FORM FUNCTIONS*/	
	function reset_form(){
		var fields     = document.getElementById('mailforma');
		var arrayInput = fields.getElementsByTagName('input');
		for(var i=0; i < arrayInput.length; i++){
			var myID = '';
			myID     = arrayInput[i].id;
			document.getElementById(myID).value='';
		}
		document.getElementById('sporocilo').value='';
	}


	function check_form()
	{
		intMin = 3;
		document.getElementById('gumbi').style.visibility='hidden';
		document.getElementById('sender').style.visibility='visible';
		var error     = '';
		var emailID   = document.getElementById('email');
		var ime       = document.getElementById('name').value;
		var sporocilo = document.getElementById('sporocilo').value;
		
	
		if ((emailID.value==null)||(emailID.value=="")){
			error_show("<br><br>izpolnite obvezna polja označena z *");
			emailID.focus()
			return false;
		}
		else
		if (email_check(emailID.value)==false){
			error_show("<br><br>email ni pravilen");
			emailID.focus();
			return false;
		}
		else
		if(sporocilo.length < intMin){
			document.getElementById('sporocilo').focus();
			error_show("<br><br>Vpišite sporočilo");
			return false;
		}

		document.mailforma.submit();

	}

			
	
	



	function close_sender(){
		document.getElementById('sender').style.visibility="hidden";
	}



	function error_show(val){
		window.scrollBy(0,550);		
		document.getElementById('error').style.visibility="visible";
		document.getElementById('error').innerHTML=val;
		document.getElementById('errorClose').style.visibility="visible";
	}
	
	function error_close(){
		document.getElementById('error').style.visibility="hidden";
		document.getElementById('errorClose').style.visibility="hidden";
		document.getElementById('sender').style.visibility='hidden';
		document.getElementById('gumbi').style.visibility='visible';
	}

//email validation
	function email_check(str) 
	{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}

/*end:EMAIL FORM FUNCTIONS*/	

	function addLoadEvent(func) {//call function when everithing is loaded (body on load LIKE)
	  var oldonload = window.onload;
	  if (typeof window.onload != 'function') {
		window.onload = func;
	  } else {
		window.onload = function() {
		  if (oldonload) {
			oldonload();
		  }
		  eval(func);
		}
	  }
	}




	
