function disableIt(obj)
{
	obj.disabled = true;
}

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;
}

//var menu; 
//function showMenu (evt) { 
//  if (document.all) { 
//    document.all.contextMenu.style.pixelLeft = event.clientX; 
//    document.all.contextMenu.style.pixelTop = event.clientY; 
//    document.all.contextMenu.style.visibility = 'visible'; 
//    return false; 
//  } 
//  else if (document.layers) { 
//    if (evt.which == 3) { 
//      document.contextMenu.left = evt.x; 
//      document.contextMenu.top = evt.y; 
//      document.contextMenu.onmouseout = 
//        function (evt) { this.visibility = 'hide'; }; 
//      document.contextMenu.visibility = 'show'; 
//      return false; 
//    } 
//  } 
//  return true; 
//} 
//if (document.all) 
//  document.oncontextmenu =showMenu; 
//if (document.layers) { 
//  document.captureEvents(Event.MOUSEDOWN); 
//  document.onmousedown = showMenu; 
//} 

var ver3 = (navigator.appVersion.charAt(0) <= "3") ? true : false;
var dom = (document.getElementById) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var ns4 = (document.layers) ? true : false;
var ie5 = (document.all && document.getElementById) ? true : false;
var n6 = (document.getElementById && !document.all) ? true : false;

function findObjekt(objekt) {
	var blok; 
	if (dom) blok = document.getElementById(objekt).style;
  else if (ie4) blok = document.all[objekt].style;
  else if (ns4) blok = document.layers[objekt];
  return blok;
}

function setBgColor(objekt, color) {
var blok = findObjekt(objekt); 
	blok.backgroundColor = color;
}
function setFgColor(objekt,color) {
var blok = findObjekt(objekt);
	blok.color = color;
}
function visObjekt(objekt){
var blok = findObjekt(objekt);
	blok.visibility = "visible";
}
function skjulObjekt(objekt){
var blok = findObjekt(objekt);	
	blok.visibility = "hidden";
}
function expand(objekt){
var blok = findObjekt(objekt);
	blok.display="block"
}
function collapse(objekt){
var blok = findObjekt(objekt);
	blok.display="none"
}
function setBorderBottomColor(objekt,color){
var blok = findObjekt(objekt);
	blok.borderBottomColor = color;
}
function setBorderBottomWidth(objekt,width){
var blok = findObjekt(objekt);
	blok.borderBottomWidth = width;
}

function skjulAlle(){
for (i=1;i<6;i++)
	collapse('panel'+i)
}

function resetColors(){
for (i=1;i<6;i++){
  setBgColor('panel' + i,'#fff');
  setBgColor('tab' + i,'#fff')
  setBorderBottomColor('tab'+i,'black');
}
}
function visPanel(nr) {
  skjulAlle();
  resetColors();
  expand('panel'+nr);
  setBgColor('tab' + nr,'#eee');
  setBgColor('panel' + nr,'#fff');
  setBorderBottomColor('tab'+nr,'#eee');
}
