function showAlert(tekst) {
  alert(tekst);
}

function ConfirmLink(question,redirect) {
if (confirm(question)) {
  document.location.href(redirect);
  }
}

function sendForm(question, v) { 
if (confirm(question)) {
  document.vismailsformular.strfunction.value = (v); 
  document.vismailsformular.submit(); 
  }
} 

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
  field.value = field.value.substring(0, maxlimit);
else 
  countfield.value = maxlimit - field.value.length;
}

function ValidateEmail(strEmail) {
	if ((strEmail!="") && (VECharPos(strEmail)) && (VECountAts(strEmail)) && (VEIligalChars(strEmail))) {
	 	return true;
	 }
	 else {
	 	return false;
	 }
}

function VECharPos(strEmail) {
	if ((strEmail.indexOf("@",0) > 0) && (strEmail.indexOf(".",strEmail.indexOf("@",1) + 2) != "-1") && (strEmail.indexOf(".",0) >= 1) && (strEmail.charAt(strEmail.length-1) != "@") && (strEmail.charAt(strEmail.length-1) != ".")) {
		return true;
	} else {
		return false;
	}
}

function VECountAts(strEmail) {
	if (strEmail.indexOf("@",(strEmail.indexOf("@",0)+1)) == "-1") {
		return true;
	}
	else {
		return false;
	}
}

var VELegalChars = "abcdefghijklmnopqrstuvwxyz0123456789.@-_";
function VEIligalChars(strEmail) {
	for (i=0;i<strEmail.length;i++) {
		if (VELegalChars.indexOf((strEmail.toLowerCase()).charAt(i),0) == "-1") {
			return false;
		}
	}
	return true;
}

function trim(strText) { 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);
   return strText;
}
