// JavaScript Document

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function validateForm(form){
			
				if(form.nev.value.length <= 0){
					alert('Du måste uppge ditt namn!');					
					form.name.focus();
					return false;
				}
				
				if(form.telefon.value.length <= 0){
					alert('Du måste uppge ditt telefonnummer!');					
					form.telephone.focus();
					return false;								
				}
								
				if(!validateEmail(form.email.value)){
					alert('Du måste ange din e-postadress i rätt format ex: john.smith@domain.com!');					
					form.email.focus();
					return false;
				}												
				
				form.submit();
			}

/********************************************************************************
* function		: submitForm()
* args	 		: form => the form to be submitted
* returntype	: boolean 	
* returns		: false
* auth			: Moped AB
* date			: 20050223
* desc			: submits form if validationForm() function returns true.
*				  Else function returns false;
********************************************************************************/			
function submitForm(form){				
	if(validateForm(form))
		form.submit();				
	return false;
}

/********************************************************************************
* function		: checkFilter()
* args 			: [1] instring => the string to be filtered.	
* args 			: [2] regexp => the reg exp to filter with.
* returntype	: boolean 	
* returns		: true or false
* auth			: Moped AB
* date			: 20050223			
* desc			: Returns true if string is filtered good, else it returns false.
********************************************************************************/		
function checkFilter(instring, regexp){
	var newstring = new String(instring);				
	if(newstring.search(regexp) == -1)
		return false;								
	return true;				
}

/********************************************************************************
* function		: validateEmail()
* args 			: [1] email => the email to be validated	
* returntype	: boolean 	
* returns		: true or false
* auth			: Moped AB
* date			: 20050223			
* desc			: Returns true if email validates OK, else it returns false.
********************************************************************************/
function validateEmail(email){
	var regexp = /^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]+\.[A-Za-z0-9_\-\.]+/gi											
	if(!checkFilter(email, regexp))
		return false;
	return true;
}