
function isBlank(obj)
{
    if (obj.value == null)
    {
        return true;
    }
    for (var i=0; i < obj.value.length; i++)
    {
        if ((obj.value.charAt(i) != ' ') && (obj.value.charAt(i) != "\t") && (obj.value.charAt(i) != "\n"))
        {
            return false;
        }
    }
    obj.value = "";
    return true;
}
function isWrongFormat(obj)
{
    regNo = obj.value
    tmp = "";
    //remove blanks in the string
    if(regNo!=null)
    {
      for(i=0; i < regNo.length; i++)
      {
        if(regNo.charAt(i)!=' ')
        {
          tmp += regNo.charAt(i);
        }
      }
      regNo = tmp;
    }
    //check that the reg no consist of 3 letters and 3 numbers
    var validatedRegNo = regNo.match(/^[a-z]{3}\d{3}$/gi);
    if(validatedRegNo==null)
    {
      return true;
     }
}

function validate(form){
    var str = form.regNo;
    if(isBlank(str)){
        alert("Ange ditt registreringsnummer");
        return false;
    }
	else if(str.value.toUpperCase() == 'ABC132') {
		alert("Ange ditt registreringsnummer");
		return false;
	}
    else if(isWrongFormat(str))
    {
      alert("Registreringsnumret är ej korrekt inskrivet");
      return false;
    }
    return true;
}
function vs(a,b,c)
{
 window.open(a,b,c);
}
function changeURL(winName, newURL) {
  win = window.open("", winName);
  win.location.href = newURL;
}
function tabort(url)
{
 if(confirm('Du kommer nu att ta bort\n\nÄr du säker?'))
 {
  location.href = url;
 }
}
function kontroll(url)
{
 if(confirm('Du kommer nu att redigera din Kontrollrapport.\n\nÄr du säker?'))
 {
  location.href = url;
 }
}
function makulerakvitto(url)
{
 if(confirm('Du kommer nu att göra ett återköp.\n\nÄr du säker?'))
 {
  location.href = url;
 }
}
function ConfirmModell(url)
{
 if(confirm('Är du säker?'))
 {
  location.href = url;
 }
}
function tomvarukorg(url)
{
 if(confirm('Varukorgen kommer nu att tömmas\n\nÄr du säker?'))
 {
  location.href = url;
 }
}

function kvitto(url)
{
 if(confirm('Du kommer nu att skapa ett kvitto\n\nÄr du säker?'))
 {
  location.href = url;
 }
}
function sms(url)
{
 if(confirm('Ett sms kommer nu att skickas till kunden att bilen är klar\n\nÄr du säker?'))
 {
  location.href = url;
 }
}
function isNumberKey(evt) {
   var charCode = (evt.which) ? evt.which : event.keyCode
   if ((charCode > 31 && (charCode < 48 || charCode > 57)))
      return false;

   return true;
}
function isDecimalKey(evt) {
   var charCode = (evt.which) ? evt.which : event.keyCode
   if ((charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 44 || charCode > 44) && (charCode < 46 || charCode > 46)))
      return false;

   return true;
}

function formstep1(){
	if (f_kostnad_step1.f_namn.value == null || f_kostnad_step1.f_namn.value == "" )
  {
   alert ("Namn får inte vara tomt.") ;
   	f_kostnad_step1.f_namn.focus() ;
	f_kostnad_step1.f_namn.select() ;
    return false;
  }
  	if (f_kostnad_step1.f_telenr.value == null || f_kostnad_step1.f_telenr.value == "" )
  {
   alert ("Telefonnummer får inte vara tomt.") ;
   	f_kostnad_step1.f_telenr.focus() ;
	f_kostnad_step1.f_telenr.select() ;
    return false;
  }


    return true;
}

// Material nedan tillagt av Tobias 2009-03
// för att dölja varukorg vid mouseover på huvudmenyn
var nav = null;

function checkMouseOverMainMenu() {
    nav = document.getElementById('inloggad');
    var varukorg = document.getElementById('varukorgDD');
    if (varukorg) {
        if (nav.addEventListener) {
            nav.addEventListener('mouseover', function() {
                varukorg.style.visibility = 'hidden';
            }, false);
        } else if (nav.attachEvent) {
        nav.attachEvent('onmouseover', function() {
            varukorg.style.visibility = 'hidden';
        });
        }
        if (nav.addEventListener) {
            nav.addEventListener('mouseout', function() {
                varukorg.style.visibility = 'visible';
            }, false);
        } else if (nav.attachEvent) {
        nav.attachEvent('onmouseout', function() {
            varukorg.style.visibility = 'visible';
        });
        }
    }
}

var alreadyrunflag=0 //flag to indicate whether target function has already been run

if (document.addEventListener)
    document.addEventListener("DOMContentLoaded", function() { alreadyrunflag = 1; checkMouseOverMainMenu() }, false)
else if (document.all && !window.opera){
  document.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>')
  var contentloadtag=document.getElementById("contentloadtag")
  contentloadtag.onreadystatechange=function(){
    if (this.readyState=="complete"){
      alreadyrunflag=1
      checkMouseOverMainMenu()
    }
  }
}

window.onload=function(){
setTimeout("if (!alreadyrunflag) checkMouseOverMainMenu()", 0)
}
