function checkContactForm(oForm){
	var oForm = document.forms["contactForm"]
	return checkMail(oForm.Email.value, oForm.Email)
}

function checkShowForm(){
	var oForm = document.forms["showForm"]
	return checkMail(oForm.Email.value, oForm.Email)
}

function checkNextShowForm(){
	var oForm = document.forms["nextShowForm"]
	return checkMail(oForm.Email.value, oForm.Email)
}

function checkTipsForm(){
	var oForm = document.forms["tipsForm"]
	if(checkMail(oForm.receiverEmail.value, oForm.receiverEmail)){
		return checkMail(oForm.senderEmail.value, oForm.senderEmail)
	}
	else return false
}

function showhideRow(iID){
	var cRow = document.getElementById("row"+iID)
	var cSpan = document.getElementById("span"+iID)
	if(cSpan){
		if(cSpan.style.display=="none"){
			cSpan.style.display="block";
			cSpan.style.visibility = "visible";
			cRow.style.paddingBottom = 2;
		}
		else{
			cSpan.style.display="none";
			cSpan.style.visibility = "hidden";
			cRow.style.paddingBottom = 0;
		}
	}
}

function showRow(iID){
	var numargs = arguments.length
	for(i=0;i<numargs;i++){ 
		var cRow = document.getElementById("row"+arguments[i])
		var cSpan = document.getElementById("span"+arguments[i])
		if(cSpan){
			cSpan.style.display="block";
			cSpan.style.visibility = "visible";
			cRow.style.paddingBottom = 2;
		}
	}
}

function checkMaillistForm(sInputValue){
	if(document.forms['maillistForm'].MemberName.value ==""){
		alert(noNameML);
		return false;
	}
	else{
		document.forms['maillistForm'].SubmitMode.value = (document.forms['maillistForm'].Status[0].checked)? "create":"delete"
		var myRe = /[a-z0-9_.=-]+@([a-z0-9-]+\.)+([a-z]{2,3})/i;
		if (!(sInputValue).match(myRe))	{
			alert(emailErrorML)
			return false
		}
		else {
			return true
		}
	}
}		

function checkMail(sInputValue,oFormField){
	var myRe = /[a-z0-9_.=-]+@([a-z0-9-]+\.)+([a-z]{2,3})/i;
	if (!(sInputValue).match(myRe))	{
		alert(emailErrorML)
		oFormField.focus()
		return false
	}
	else {
		return true
	}
}

function validera(){
	if(document.order.kund.value == ""){alert("Du måste fylla i fältet: Kund!");document.order.kund.focus();return false;}
	if(document.order.objekt.value == ""){alert("Du måste fylla i fältet: Objekt!");document.order.objekt.focus();return false;}
	if(document.order.contact.value == ""){alert("Du måste fylla i fältet: Kontaktperson!");document.order.contact.focus();return false;}
	if(document.order.adress.value == ""){alert("Du måste fylla i fältet: Adress!");document.order.adress.focus();return false;}
	if(document.order.postnr.value == ""){alert("Du måste fylla i fältet: Postnummer!");document.order.postnr.focus();return false;}
	if(document.order.ort.value == ""){alert("Du måste fylla i fältet: Ort!");document.order.ort.focus();return false;}
	if(document.order.phone.value == ""){alert("Du måste fylla i fältet: Telefon!");document.order.phone.focus();return false;}
	if(document.order.todo.value == ""){alert("Du måste fylla i fältet: Vad ska göras!");document.order.todo.focus();return false;}
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(order.email.value)){
	return (true)
	}
	alert("Du har angivit en ogiltig epostadress. Kontrollera den angivna adressen!")
	return (false)
}

function showImage(sImgSRC){
	var sUrl = hostPath + "/web/showImage.asp?imgSRC="+sImgSRC;
	window.open(sUrl,null,"height=400,width=280,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=no")
}

function checkRequestForm(){
	var oForm = document.forms["Quotation_request"]
	if(oForm.Name.value==""){
		alert(qRequestNoName);
		oForm.Name.focus();
		return false;
	}
	if(oForm.Efter_namn.value==""){
		alert(qRequestNoLastName);
		oForm.Efter_namn.focus();
		return false;
	}	
	if(oForm.Company.value==""){
		alert(qRequestNoCompany);
		oForm.Company.focus();
		return false;
	}	
	if(oForm.Epost.value==""){
		alert(qRequestNoEmail);
		oForm.Epost.focus();
		return false;
	}
	else{
		var myRe = /[a-z0-9_.=-]+@([a-z0-9-]+\.)+([a-z]{2,3})/i;
		if (!(oForm.Epost.value).match(myRe)){
			alert(qRequestEmailError)
			oForm.Epost.focus()
			return false
		}
	}
	if(!oForm.read_the_authorisation.checked){
		alert(qRequestAuthorisation);
		oForm.Epost.focus();
		return false;
	}	
	oForm.submit()
}
