'*******************************************
' ALL CODE IS (C) 2007-2008
' SIMON JONASSEN
' IF U WANT SOMETHING, MAIL ME
' SIJO@BRUUNS-HANDEL.DK
'*******************************************


'*******************************************
Public Function GetAmountInput(id, VareNummer)
'*******************************************
    document.getElementByID("BaskTit").style.display=block
    Antal=document.getElementByID("Antal" & id).value

    if instr(document.getElementByID("Vnavn" & id).innertext, " ") > 0 then
      VareText=left(document.getElementByID("Vnavn" & id).innertext, instr(document.getElementByID("Vnavn" & id).innertext," "))
    else
      VareText=document.getElementByID("Vnavn" & id).innertext
    end if
    Price=document.getElementByID("Price" & id).innertext
    ThePrice=FormatNumber(Antal*Price)
    ThePrice=replace(theprice,".","")
    ThePrice=replace(theprice,",",".")
    call inbasket(Antal,VareNummer,VareText,"","",ThePrice) 
    document.getElementByID("Antal" & id).value=1
    call DoOrder()
    if instr(document.location.href,"productshow.asp?ref=") then 
      window.history.go(-1)
    end if
  End Function




'*******************************************  
Public Function GetSizeColorAmountDrop(id, VareNummer)
'*******************************************
    document.getElementByID("BaskTit").style.display=block
    Farve=document.getElementByID("ColSel" & id).value
    Antal=document.getElementByID("Antal" & id).options(document.getElementByID("Antal" & id).selectedIndex).text
    size=document.getElementByID("SizeSel" & id).options(document.getElementByID("SizeSel" & id).selectedIndex).text
    if instr(document.getElementByID("Vnavn" & id).innertext, " ") > 0 then
      VareText=left(document.getElementByID("Vnavn" & id).innertext, instr(document.getElementByID("Vnavn" & id).innertext," "))
    else
      VareText=document.getElementByID("Vnavn" & id).innertext
    end if
    Price=document.getElementByID("Price" & id).innertext
    ThePrice=FormatNumber(Antal*Price)
    ThePrice=replace(theprice,".","")
    ThePrice=replace(theprice,",",".")
    call inbasket(Antal, VareNummer, VareText, size, farve, ThePrice)    
    document.getElementByID("ColSel" & id).selectedindex=0
    document.getElementByID("Antal" & id).selectedindex=0
    document.getElementByID("SizeSel" & id).selectedindex=0
    call DoOrder()
    if instr(document.location.href,"productshow.asp?ref=") then 
      window.history.go(-1)
    end if
  End Function

'*******************************************
Public Function GetSizeColorAmountInput(id, VareNummer)
'*******************************************
    document.getElementByID("BaskTit").style.display=block
    Farve=document.getElementByID("ColSel" & id).value
    Antal=document.getElementByID("Antal" & id).value
    size=document.getElementByID("SizeSel" & id).options(document.getElementByID("SizeSel" & id).selectedIndex).text
    if instr(document.getElementByID("Vnavn" & id).innertext, " ") > 0 then
      VareText=left(document.getElementByID("Vnavn" & id).innertext, instr(document.getElementByID("Vnavn" & id).innertext," "))
    else
      VareText=document.getElementByID("Vnavn" & id).innertext
    end if
    Price=document.getElementByID("Price" & id).innertext
    ThePrice=FormatNumber(Antal*Price)
    ThePrice=replace(theprice,".","")
    ThePrice=replace(theprice,",",".")
    call inbasket(Antal,VareNummer, VareText, size, farve, ThePrice)
    document.getElementByID("ColSel" & id).selectedindex=0
    document.getElementByID("Antal" & id).value=1
    document.getElementByID("SizeSel" & id).selectedindex=0
    call DoOrder()
    if instr(document.location.href,"productshow.asp?ref=") then 
      window.history.go(-1)
    end if
  End Function

'*******************************************
Public Function GetColorAmountDrop(id, VareNummer)
'*******************************************
    document.getElementByID("BaskTit").style.display=block
    Farve=document.getElementByID("ColSel" & id).value
    Antal=document.getElementByID("Antal" & id).options(document.getElementByID("Antal" & id).selectedIndex).text
    if instr(document.getElementByID("Vnavn" & id).innertext, " ") > 0 then
      VareText=left(document.getElementByID("Vnavn" & id).innertext, instr(document.getElementByID("Vnavn" & id).innertext," "))
    else
      VareText=document.getElementByID("Vnavn" & id).innertext
    end if
    Price=document.getElementByID("Price" & id).innertext
    ThePrice=FormatNumber(Antal*Price)
    ThePrice=replace(theprice,".","")
    ThePrice=replace(theprice,",",".")
    call inbasket(Antal,VareNummer, VareText,"", farve, ThePrice)
    document.getElementByID("ColSel" & id).selectedindex=0
    document.getElementByID("Antal" & id).selectedindex=0
    call DoOrder()
    if instr(document.location.href,"productshow.asp?ref=") then 
      window.history.go(-1)
    end if
  End Function

'*******************************************
Public Function GetColorAmountInput(id, VareNummer)
'*******************************************
    document.getElementByID("BaskTit").style.display=block
    Farve=document.getElementByID("ColSel" & id).value
    Antal=document.getElementByID("Antal" & id).value
    if instr(document.getElementByID("Vnavn" & id).innertext, " ") > 0 then
      VareText=left(document.getElementByID("Vnavn" & id).innertext, instr(document.getElementByID("Vnavn" & id).innertext," "))
    else
      VareText=document.getElementByID("Vnavn" & id).innertext
    end if
    Price=document.getElementByID("Price" & id).innertext
    ThePrice=FormatNumber(Antal*Price)
    ThePrice=replace(theprice,".","")
    ThePrice=replace(theprice,",",".")
    call inbasket(Antal,VareNummer, VareText,"", farve, ThePrice)
    document.getElementByID("Antal" & id).value=1
    document.getElementByID("ColSel" & id).selectedindex=0
    call DoOrder()
    if instr(document.location.href,"productshow.asp?ref=") then 
      window.history.go(-1)
    end if
  End Function

'*******************************************
Public Function GetSizeAmountDrop(id, VareNummer)
'*******************************************
    document.getElementByID("BaskTit").style.display=block
    Antal=document.getElementByID("Antal" & id).options(document.getElementByID("Antal" & id).selectedIndex).text
    size=document.getElementByID("SizeSel" & id).options(document.getElementByID("SizeSel" & id).selectedIndex).text
    if instr(document.getElementByID("Vnavn" & id).innertext, " ") > 0 then
      VareText=left(document.getElementByID("Vnavn" & id).innertext, instr(document.getElementByID("Vnavn" & id).innertext," "))
    else
      VareText=document.getElementByID("Vnavn" & id).innertext
    end if
    Price=document.getElementByID("Price" & id).innertext
    ThePrice=FormatNumber(Antal*Price)
    ThePrice=replace(theprice,".","")
    ThePrice=replace(theprice,",",".")
    call inbasket(Antal,VareNummer, VareText, size,"", ThePrice)
    document.getElementByID("Antal" & id).selectedindex=0
    document.getElementByID("SizeSel" & id).selectedindex=0
    call DoOrder()
    if instr(document.location.href,"productshow.asp?ref=") then 
      window.history.go(-1)
    end if
  End Function

'*******************************************
Public Function GetSizeAmountInput(id, VareNummer)
'*******************************************
    document.getElementByID("BaskTit").style.display=block
    Antal=document.getElementByID("Antal" & id).value
    size=document.getElementByID("SizeSel" & id).options(document.getElementByID("SizeSel" & id).selectedIndex).text
    Price=document.getElementByID("Price" & id).innertext
    ThePrice=FormatNumber(Antal*Price)
    if instr(document.getElementByID("Vnavn" & id).innertext, " ") > 0 then
      VareText=left(document.getElementByID("Vnavn" & id).innertext, instr(document.getElementByID("Vnavn" & id).innertext," "))
    else
      VareText=document.getElementByID("Vnavn" & id).innertext
    end if
    ThePrice=replace(theprice,".","")
    ThePrice=replace(theprice,",",".")
    call inbasket(Antal,VareNummer, VareText,size,"", ThePrice)
    document.getElementByID("Antal" & id).value=1
    document.getElementByID("SizeSel" & id).selectedindex=0
    call DoOrder()
    if instr(document.location.href,"productshow.asp?ref=") then 
      window.history.go(-1)
    end if
  End Function

'*******************************************
Public Function GetAmountDrop(id, VareNummer)
'*******************************************
    document.getElementByID("BaskTit").style.display=block
    Antal=document.getElementByID("Antal" & id).options(document.getElementByID("Antal" & id).selectedIndex).text
    if instr(document.getElementByID("Vnavn" & id).innertext, " ") > 0 then
      VareText=left(document.getElementByID("Vnavn" & id).innertext, instr(document.getElementByID("Vnavn" & id).innertext," "))
    else
      VareText=document.getElementByID("Vnavn" & id).innertext
    end if
    Price=document.getElementByID("Price" & id).innertext
    ThePrice=FormatNumber(Antal*Price)
    ThePrice=replace(theprice,".","")
    ThePrice=replace(theprice,",",".")
    call inbasket(Antal,VareNummer, VareText,"","", ThePrice)
    document.getElementByID("Antal" & id).selectedindex=0
    call DoOrder()
    if instr(document.location.href,"productshow.asp?ref=") then 
      window.history.go(-1)
    end if
  End Function


'*********************************
Public Function ShowMe(Path)
'*********************************        
        Path="grafix/lev/" & path & ".jpg" 
        picWidth=150
        picHeight=200   
        offX=10
        offY=10  

        mouseX = window.event.clientX + document.body.scrollLeft
	mouseY = window.event.clientY + document.body.scrollTop
	winWd =  document.body.clientWidth+document.body.scrollLeft
	winHt = document.body.clientHeight+document.body.scrollTop

	if (mouseX+offX+picWidth) > winWd then
           picleft=mouseX-(picWidth+offX)
	else 
           picleft=mouseX+offX
        end if
   
	if (mouseY+offY+picHeight) > winHt then
          pictop=winHt-(picHeight + offY)
	else 
          pictop=mouseY+offY
        end if  

        document.getElementByID("PicDiv").innerhtml="<IMG src='" & path & "' height=200>"
        document.getElementByID("PicDiv").style.visibility="visible"
        document.getElementByID("PicDiv").style.top=pictop
        document.getElementByID("PicDiv").style.left=picleft

      End Function

'*********************************
Public Function HideMe()
'*********************************
        document.getElementByID("PicDiv").style.visibility="hidden"  
      End Function
       
'*********************************
Public Function ChangePage(Path)
'*********************************
        Path="grafix/lev/" & path & ".jpg" 
        document.location.href=path
      End Function


'*********************************
 Public Function CheckStk(id)
'*********************************
       if not IsNumeric(document.getElementByID("Antal" & id).value) then
         document.getElementByID("Antal" & id).value=1
       end if  

       if instr(document.getElementByID("Antal" & id).value,".") > 0 then
         document.getElementByID("Antal" & id).value=1
       end if   

       if instr(document.getElementByID("Antal" & id).value,",") > 0 then
         document.getElementByID("Antal" & id).value=1
       end if   

      End Function

'*********************************
 Public Function showdiv(id, spid, height)
'*********************************
    winHt = document.body.clientHeight+document.body.scrollTop


    if document.getElementByID(id).style.visibility="visible" then
      document.getElementByID(id).style.visibility="hidden"
    else
      document.getElementByID(id).style.visibility="visible"
      document.getElementByID(id).style.left=document.getElementByID(spid).offsetLeft+1
  
      if document.getElementByID(spid).offsetTop+18 + height > winHt then 
     
        document.getElementByID(id).style.top=document.getElementByID(spid).offsetTop-height-1

      else
        document.getElementByID(id).style.top=document.getElementByID(spid).offsetTop+18
      end if    
      window.event.cancelBubble = True
    end if
  End Function

'*********************************
  Public Function Hidediv(id, divid)
'*********************************
    document.getElementByID("colsel1").style.visibility="hidden"

    colors=split(id.datafld , ",")
    if ubound(colors) > 0 then
      numcols=ubound(colors)+1
      myhtml="<IMG SRC='grafix\selarrow.gif' height='14' BORDER='0' align='top'>"  
      mywidth = round(21 / numcols)

      rest = (21 mod numcols)

      for i=0 to ubound(colors)
        myhtml=myhtml & "<SPAN style='font-size:10px;font-family:tahoma;width:" & mywidth & "px;height:14;background-color:#" & colors(i) & "'></SPAN>"
      next
      if rest > 0 then
        myhtml=myhtml & "<SPAN style='font-size:10px;font-family:tahoma;width:" & rest & "px;height:14;background-color:#" & colors(numcols-1) & "'></SPAN>"
      end if
      document.getElementByID("showcol" & divid).innerhtml=myhtml
    else
      color=id.datafld
      document.getElementByID("showcol" & divid).innerhtml="<IMG SRC='grafix\selarrow.gif' BORDER='0' align=top>"
      document.getElementByID("showcol" & divid).style.backgroundcolor=color
    end if
  End Function


'*********************************
  Public Function Hidediv2()
'*********************************
    document.getElementByID("colsel1").style.visibility="hidden"
  End Function

'*********************************
  Public Function border_on(id)
'*********************************
    id.style.border="1px dotted rgb(0,0,0)"
  End Function
 
'*********************************
  Public Function border_off(id)
'*********************************
    id.style.border="1px dotted rgb(255,255,255)"
  End Function

'*********************************
  Public Function DoOrder() 
'*********************************
   Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
   if instr(document.location.href,"checkout.asp") then  
     xmlhttp.Open "POST", "order.asp?yref=" & document.getelementbyid("MainScreen").scrolltop, false
   else
     xmlhttp.Open "POST", "order.asp", false
   end if
   xmlhttp.Send(xmldoc) 

   set xmlhttp=nothing
  End Function

'*********************************
  Public Function ChangeOn(element)
'*********************************
    document.getelementbyid(element).style.color="#909090"
  End Function

'*********************************
  Public Function ChangeOff(element)
'*********************************
    document.getelementbyid(element).style.color="#000000"
  End Function

'*********************************
  Public Function ShowItem(levid,varenummer)
'*********************************
    call DoOrder()
    document.location.href="productshow.asp?ref="& document.getElementByID("MainScreen").scrolltop & "," & levid & "," & varenummer
  End Function

'*********************************
  Public Function SearchForm_onSubmit()
'*********************************
    If Len(Ltrim(Rtrim(document.getElementByID("SearchString").value))) < 3 then
      SearchForm_onSubmit = False
      fejl=msgbox("Søgeord skal være på minimum 3 tegn",64 ,"Fejl")
      document.getElementByID("SearchString").Focus()
    else
      document.getElementByID("SearchString").value=replace(document.getElementByID("SearchString").value,"+",",") 
      SearchForm_onSubmit = True
      'call DoOrder()
    end if
  End Function

'*********************************
  Public Function EmptyCart() 
'*********************************
   answer=msgbox("Er du sikker på at du vil tøm din varekurv ?",308 ,"Advarsel")

   if answer = "6" then
     Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
     xmlhttp.Open "POST", "empty.asp?ref="& document.getElementByID("MainScreen").scrolltop & "caller=" & document.location.href, false
     xmlhttp.Send() 
     set xmlhttp=nothing
     if instr(document.location.href,"default.asp") then
       window.location.reload()
     else
       if instr(document.location.href,"checkout.asp") then
         document.location.href="default.asp"
       else 
         window.history.go(-1)
       end if 
     end if
   end if 
  End Function


'*********************************
  public function killvare(trans)
'*********************************
    call DelFromBasket(Trans)
    call DoOrder()
  end function


'*********************************
  Public Function Finalize()
'*********************************
    call DoOrder()
    document.location.href="checkout.asp"
  End Function



'*******************************************
 Public Function GetAmountInput2(id, VareNummer)
'*******************************************
    Antal=document.getElementByID("Antal" & id).value
    if instr(document.getElementByID("Vnavn" & id).innertext, " ") > 0 then
      VareText=left(document.getElementByID("Vnavn" & id).innertext, instr(document.getElementByID("Vnavn" & id).innertext," "))
    else
      VareText=document.getElementByID("Vnavn" & id).innertext
    end if
    Price=document.getElementByID("Price" & id).innertext
    ThePrice=FormatNumber(Antal*Price)
    ThePrice=replace(theprice,".","")
    ThePrice=replace(theprice,",",".")

    set size=document.getelementbyid("sizesel" & id)
    if not size is nothing then 
      size=document.getelementbyid("sizesel" & id).options(document.getelementbyid("sizesel" &id).selectedindex).text
    else
      size=""
    end if

    set color=document.getelementbyid("colsel" & id)
    if not color is nothing then 
      color=document.getelementbyid("colsel" & id).options(document.getelementbyid("colsel" &id).selectedindex).value
    else
      color=""
    end if
    call inbasket(Antal,VareNummer,VareText,size,color,ThePrice) 
    call DoOrder()
  End Function


'*******************************************
 Public Function UpdateSize(id, varenummer, oldsize, oldcolor)
'*******************************************
    Antal=document.getElementByID("Antal" & id).value
    if instr(document.getElementByID("Vnavn" & id).innertext, " ") > 0 then
      VareText=left(document.getElementByID("Vnavn" & id).innertext, instr(document.getElementByID("Vnavn" & id).innertext," "))
    else
      VareText=document.getElementByID("Vnavn" & id).innertext
    end if

    size=document.getelementbyid("sizesel" & id).options(document.getelementbyid("sizesel" &id).selectedindex).text

    Price=document.getElementByID("Price" & id).innertext
    ThePrice=FormatNumber(Antal*Price)
    ThePrice=replace(theprice,".","")
    ThePrice=replace(theprice,",",".")
    Trace=VareNummer&oldsize&oldcolor
    call UpdateBasket(Antal,VareNummer,vareText,size,oldcolor,ThePrice, Trace)
    call DoOrder()         
  End Function


'*******************************************
 Public Function UpdateColor(id, varenummer, oldsize, oldcolor)
'*******************************************
    Antal=document.getElementByID("Antal" & id).value
    if instr(document.getElementByID("Vnavn" & id).innertext, " ") > 0 then
      VareText=left(document.getElementByID("Vnavn" & id).innertext, instr(document.getElementByID("Vnavn" & id).innertext," "))
    else
      VareText=document.getElementByID("Vnavn" & id).innertext
    end if

    color=document.getelementbyid("colsel" & id).options(document.getelementbyid("colsel" &id).selectedindex).value
    Price=document.getElementByID("Price" & id).innertext
    ThePrice=FormatNumber(Antal*Price)
    ThePrice=replace(theprice,".","")
    ThePrice=replace(theprice,",",".")
    Trace=VareNummer&oldsize&oldcolor
    call UpdateBasket(Antal,VareNummer,vareText,oldsize,color,ThePrice, Trace)
    call DoOrder()         
  End Function

'********************************************
  Public Function isValidEmail(myEmail)
'********************************************
    Set regEx = New RegExp 
    regEx.IgnoreCase = False 
    regEx.Pattern = "^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
    isValidEmail = regEx.Test(myEmail)
  End Function

'********************************************
 Public Function Checkmail()
'********************************************
    if instr(document.getelementbyid("mail").value,"@") then
      if instr(document.getelementbyid("mail").value,".") then
        document.getelementbyid("mailswitch").style.display="block"
      end if
    else
      document.getelementbyid("mailswitch").style.display="none"       
      document.getelementbyid("nyheder").checked=false
    end if 
  End Function

'********************************************
 Public Function ToggleAddr()
'********************************************
    if document.getelementbyid("otheraddress").checked then
      
        if CheckFields() then

          if document.getelementbyid("alternate").style.display="none" then
            document.getelementbyid("alternate").style.display="block" 
            document.getelementbyid("altname").focus()
          else
            document.getelementbyid("alternate").style.display="none" 
            document.getelementbyid("tlf").focus()
          end if  
        else
          document.getelementbyid("otheraddress").checked=false        
        end if    
   else 
      document.getelementbyid("alternate").style.display="none" 
      document.getelementbyid("tlf").focus()

   end if
  End Function

'********************************************
 Public Function CheckPayMethod()
'********************************************
    if document.getelementbyid("otheraddress").checked then
      Msgbox "Det er ikke muligt at sende til en anden adresse" & vbcrlf & "når der betales pr. efterkrav !",16,"Fejl"
      document.getelementbyid("alternate").style.display="none" 
      document.getelementbyid("otheraddress").checked=false
    end if
  End Function
 

'********************************************
 Public Function ClearComments()
'********************************************
    if document.getelementbyid("comments").value = "Skriv evt. bemærkninger til levering osv." then
      document.getelementbyid("comments").value=""
    end if    
  End Function

  
'********************************************
 Public Function Ajaxtlf()
'********************************************
    phone=(document.getelementbyid("tlf").value)
    phone=replace(phone," ","")
    if isnumeric(phone) then
      if len(phone)=8 then
        document.getelementbyid("tlf").value=phone
        call gettlf(phone) 
      end if
    end if
  End Function

'********************************************
 Public Function gettlf(phone)
'********************************************
    set xmlhttp = CreateObject("Microsoft.XMLHTTP")
    xmlhttp.Open "GET", "gettlf.asp?tlf=" & phone, false
    xmlhttp.Send()

    entry=split(xmlhttp.responseText,";")

    set xmlhttp=nothing
    if ubound(entry) > 0 then
      document.getelementbyid("name").value=entry(0)
      document.getelementbyid("addr").value=entry(1)
      document.getelementbyid("zip").value=entry(2)
      document.getelementbyid("city").value=entry(3)
      if entry(4) <> "" then
        document.getelementbyid("mail").value=entry(4)
        document.getelementbyid("mailswitch").style.display="block"
        document.getelementbyid("nyheder").checked=entry(5)
      else
        document.getelementbyid("mail").value=""
        document.getelementbyid("nyheder").checked=false
      end if
    end if
  End Function

'********************************************
 Public Function AjaxZip(id)
'********************************************
    if id=1 then
      zip=(document.getelementbyid("zip").value)
    else
      zip=(document.getelementbyid("altzip").value)
    end if
    if isnumeric(zip) then
      if len(zip)=4 then
        set xmlhttp = CreateObject("Microsoft.XMLHTTP")
        xmlhttp.Open "GET", "getpostnr.asp?zip=" & zip, false
        xmlhttp.Send()

        entry=split(xmlhttp.responseText,";")
        set xmlhttp=nothing
        if ubound(entry) > 0 then
          if id=1 then
            document.getelementbyid("zip").value=entry(0)
            document.getelementbyid("city").value=entry(1)
          else
            document.getelementbyid("altzip").value=entry(0)
            document.getelementbyid("altcity").value=entry(1)
          end if
        end if
      set xmlhttp=nothing  
      end if
    end if
  End Function



'*********************************
 Public Function CheckFields()
'*********************************
    Flag=0 
    Fejl="Følgende felter SKAL udfyldes:" &vbcrlf &vbcrlf
    if ltrim(rtrim(document.getelementbyid("tlf").value)) = "" then
      Fejl=Fejl & "Telefon nr." & vbcrlf 
      Flag=1
    end if
    if ltrim(rtrim(document.getelementbyid("name").value)) = "" then
      Fejl=Fejl & "Navn" & vbcrlf 
      Flag=1
    end if
    if ltrim(rtrim(document.getelementbyid("addr").value)) = "" then
      Fejl=Fejl & "Adresse" & vbcrlf 
      Flag=1
    end if
    if ltrim(rtrim(document.getelementbyid("zip").value)) = "" then
      Fejl=Fejl & "Postnr." & vbcrlf 
      Flag=1
    end if
    if ltrim(rtrim(document.getelementbyid("city").value)) = "" then
      Fejl=Fejl & "By" & vbcrlf 
      Flag=1
    end if
    If Flag <> 0 Then
      Msgbox Fejl,16,"Fejl"
      checkfields=False
    else
      CheckFields=True
    End If
  End Function


'*********************************
 Public Function CustForm_onSubmit()
'*********************************
    CustForm_onSubmit = False
    Flag=0 
    Fejl="Følgende felter SKAL udfyldes:" &vbcrlf &vbcrlf
    if ltrim(rtrim(document.getelementbyid("tlf").value)) = "" then
      Fejl=Fejl & "Telefon nr." & vbcrlf 
      Flag=1
    end if
    if ltrim(rtrim(document.getelementbyid("name").value)) = "" then
      Fejl=Fejl & "Navn" & vbcrlf 
      Flag=1
    end if
    if ltrim(rtrim(document.getelementbyid("addr").value)) = "" then
      Fejl=Fejl & "Adresse" & vbcrlf 
      Flag=1
    end if
    if ltrim(rtrim(document.getelementbyid("zip").value)) = "" then
      Fejl=Fejl & "Postnr." & vbcrlf 
      Flag=1
    end if
    if ltrim(rtrim(document.getelementbyid("city").value)) = "" then
      Fejl=Fejl & "By" & vbcrlf 
      Flag=1
    end if

    if document.getelementbyid("otheraddress").checked then
  
      if ltrim(rtrim(document.getelementbyid("altname").value)) = "" then
        Fejl=Fejl & "Andet navn" & vbcrlf 
        Flag=1
      end if
      if ltrim(rtrim(document.getelementbyid("altaddr").value)) = "" then
        Fejl=Fejl & "Anden adresse" & vbcrlf 
        Flag=1
      end if
      if ltrim(rtrim(document.getelementbyid("altzip").value)) = "" then
        Fejl=Fejl & "Andet postnr." & vbcrlf 
        Flag=1
      end if
      if ltrim(rtrim(document.getelementbyid("altcity").value)) = "" then
        Fejl=Fejl & "Anden by" & vbcrlf 
        Flag=1
      end if

    end if

    
    If Flag <> 0 Then
      Msgbox Fejl,16,"Fejl"
    else
      Fejl="Følgende fejl blev fundet:" &vbcrlf &vbcrlf
      
      if not isnumeric(document.getelementbyid("tlf").value) then
        Fejl=Fejl & "Telefon nr. skal være numerisk !" & vbcrlf 
        Flag=1
      else
        if len(document.getelementbyid("tlf").value) <> 8 then
          Fejl=Fejl & "Telefon nr. skal være på 8 cifre !" & vbcrlf 
          Flag=1
        end if
      end if      

      if not isnumeric(document.getelementbyid("zip").value) then
        Fejl=Fejl & "Postnr. skal være numerisk !" & vbcrlf 
        Flag=1
      else
        if len(document.getelementbyid("zip").value) <> 4 then
          Fejl=Fejl & "Postnr. skal være på 4 cifre !" & vbcrlf 
          Flag=1
        end if
      end if      

      if document.getelementbyid("mail").value <> "" then
        if not isvalidemail(document.getelementbyid("mail").value) then
          Fejl=Fejl & "Ugyldig mail adresse !" & vbcrlf 
          Flag=1
        end if
      end if

      if document.getelementbyid("otheraddress").checked then
        if not isnumeric(document.getelementbyid("altzip").value) then
          Fejl=Fejl & "Andet postnr. skal være numerisk !" & vbcrlf 
          Flag=1
        else
          if len(document.getelementbyid("altzip").value) <> 4 then
            Fejl=Fejl & "Andet postnr. skal være på 4 cifre !" & vbcrlf 
            Flag=1
          end if
        end if      

      End if 

      If Flag <> 0 Then
        Msgbox Fejl,16,"Fejl"
      else
        CustForm_onSubmit = True
      end if   
    end if  

    End Function



'*********************************
  Public Function FakturaTrans(ordreid,paymethod) 
'*********************************


    Set TransDoc = CreateObject("Microsoft.XMLDOM")

    Set file = TransDoc.createElement("file")
    TransDoc.appendChild file
    Set p=TransDoc.createProcessingInstruction("xml","version='1.0' encoding='ISO-8859-1'")
    TransDoc.insertBefore p,TransDoc.childNodes(0)


    Set c1 = TransDoc.createElement("HTMLDOC")
    file.appendchild c1
    Set content = Transdoc.createTextNode(document.getelementbyid("printtab").innerhtml) 
    c1.appendchild content
    Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
    xmlhttp.Open "POST", "faktura.asp", false
    xmlhttp.Send(TransDoc) 

    xmlhttp.Open "GET", "stellarmail.asp?OrdreId=" & Ordreid & "&PayMethod=" & Paymethod, false
    xmlhttp.send()
     
    set xmlhttp=nothing
    set TransDoc=Nothing

  End Function



 Public Function TurnOff(id)
    document.getelementbyid(id).style.display="none"
  End Function
 
 Public Function TurnOn(id)
    document.getelementbyid(id).style.display="block"
  End Function

