<!-- #include file="global.const" -->
<!-- #include file="adovbs.inc" -->
<%
' Global functions for DataLab ATENA
'
'   function GetCaption(sCaptionNo)
'   function GetSubjektData(sSubjekt)
'   function FormatCur(fNum,lThous)
'   function FormatDate(dDate,lLoc)
'   function HexToInt(sHex)
'   function StrZeroInt(i,n)
'   Function LoWord(wParam)
'   Function BackButton(pages)
'   Function DoInputType(typ,name,value,size,title)
'	Function DoTypeClass(typ, name, HTMclass, value, size, title)
'   Function DoSelect(name,size,title)
'   Function DoOption(value,selected,caption)
'   Function DoRadio(name,value,checked,caption,title)
'   Function DoForm(method,action,target)
'   Function DoImg(imgname)
'   Function DoHRef(action,target,title	)
'   Function DoHRefClass(action,target,title,clas)
'   Function DoHead(title)
'   Function DoTDClass(HTMLclass,title,colspan,rowspan)
'   Function DoEndDoc()
'
'-----------------------
Function GetCaption(sCaptionNo)
' returns caption for selected caption and laguage
If Session("iLang") = 0 Then
    GetCaption = "Message ID: " & sCaptionNo
Else
    Set rsCaption = Server.CreateObject("ADODB.Recordset")
    Set rsCaption = session("cnnMain").Execute("SELECT CAPTION FROM AtCaption WHERE Lang='" + sLangID(Session("iLang")) + "' AND Id=" + sCaptionNo)
    If Not rsCaption.EOF Then
        GetCaption = Trim(rsCaption("CAPTION"))
    Else
        GetCaption = Application("erNoCaption")
    End If
End If
End Function ' GetCaption

'-----------------------
Function GetSubjektData(sSubjekt)
Dim s
'Set rsCaption = Server.CreateObject("ADODB.Recordset")
'Set rsCaption = Session("cnnMain").Execute("SELECT SUBJEKT.NAZIV,SUBJEKT.NAZIV2,SUBJEKT.NAZIV3,SUBJEKT.NASLOV,SUBJEKT.POSTA,SIFRA, POSTA.NAZIV as MESTO FROM SUBJEKT,POSTA WHERE SUBJEKT.NAZIV='" & sSubjekt & "' AND SUBJEKT.POSTA = POSTA.POSTA")
'response.write sSubjekt
'If Left(Trim(rsCaption("NAZIV")), 2) = Application("sUserPrefix") Then '(0x80020009) Exception occurred
'    s = ""
'Else
'    s = Trim(rsCaption("NAZIV")) + "<BR>"
'End If
 's = s + Trim(rsCaption("NAZIV2")) + "<BR>" + Trim(rsCaption("NAZIV3")) + "<BR>" + Trim(rsCaption("NASLOV")) + "<BR>" + Trim(rsCaption("POSTA")) + " - " + Trim(rsCaption("MESTO")) + "<BR>" + Trim(rsCaption("SIFRA"))
'if Not rsCaption.EOF Then
'   GetSubjektData = s
'else
'    GetSubjektData = GetCaption("133")
'End If
End Function ' GetSubjektData


'-----------------------
Function FormatCur(fNum, lThous)
' Formats a numeric
' FormatCur(1234.567,false) = '1234.567'
' FormatCur(1234.567,true) = '1,234.567'
Dim s
If lThous Then
    s = FormatNumber(fNum, Application("iPriceDecDigits"), -1, 0, -1)
Else
    s = FormatNumber(fNum, Application("iPriceDecDigits"), -1, 0, 0)
End If
s = Replace(s, ".", "x")
s = Replace(s, ",", ".")
s = Replace(s, "x", ",")
FormatCur = s
End Function ' FormatCur

'-----------------------
Function FormatDate(dDate, lLoc)
' Formats date as string
' FormatDate('1999/01/31',false) = '1999/01/31'
' FormatDate('1999/01/31',true) = '31.01.1999'
If Not IsNull(dDate) Then
    If lLoc Then
        If Day(dDate) < 10 Then
            FormatDate = "0"
        End If
        FormatDate = FormatDate & CStr(Day(dDate)) & "."
        If Month(dDate) < 10 Then
            FormatDate = FormatDate & "0"
        End If
        FormatDate = FormatDate & CStr(Month(dDate)) & "." & CStr(Year(dDate))
    Else
        FormatDate = CStr(Year(dDate)) + "/" + CStr(Month(dDate)) + "/" + CStr(Day(dDate))
    End If
Else
    FormatDate = ""
End If
End Function 'FormatDate

'-----------------------

Function HexToInt(sHex)
' vrne DEC from HEX
Dim n,i, c,iHex
dim aHex(3)
aHex(0) = 1
aHex(1) = 16
aHex(2) = 256
aHex(3) = 14096
iHex = 0  
n = Len(sHex)
for i = 1 to n
  c = UCase(Mid(sHex,i,1))	
  if c < "A" then
    iHex = iHex + (Asc(c)-48) * aHex(n-i)
  else
    iHex = iHex + (Asc(c) - 55) * aHex(n-i)
  end if
next
HexToInt = iHex
End Function ' HexToInt
'-----------------------
Function StrZeroInt(i, n)
s = CStr(i)
Do Until Len(s) >= n
    s = "0" + s
Loop
StrZeroInt = s
End Function ' StrZeroInt

'-----------------------
Function LoWord(wParam)
If wParam And &H8000& Then
    LoWord = &H8000& Or (wParam And &H7FFF&)
Else
    LoWord = wParam And &HFFFF&
End If
End Function  ' LoWord

'-----------------------
Function BackButton(pages)
    response.Write "<SCRIPT LANGUAGE=" & "'" & "JavaScript" & "'" & "> function goHist(a) { history.go(a);} </script>"
    response.Write "<FORM METHOD=post>" & Chr(13)
    response.Write "  <INPUT TYPE=" & "'" & "button" & "'" & " VALUE=" & "'" & GetCaption("51") & "'"& " class=" & "'" & "cmdBack" & "'" & " onClick=" & "'" & "goHist(" & pages & ")" & "'" & ">" & Chr(13)
    response.Write "</form>" & Chr(13)
End Function  ' BackButton

'-----------------------
Function DoInputType(typ, name, value, size, title)
DoInputType = "<input type=" & "'" & typ & "'" & " name=" & "'" & name & "'" & _
              " value=" & "'" & value & "'" & " size=" & "'" & size & "'" & _
              " title=" & "'" & title & "'"& ">"
End Function ' DoInputType

'-----------------------
' isto kot DoInputType z dodatkom class name
Function DoTypeClass(typ, name, HTMclass, value, size, title)
DoTypeClass = "<input type=" & "'" & typ & "'" & " name=" & "'" & name & "'" & _
              " value=" & "'" & value & "'"& " class=" & "'" & HTMclass & "'" & " size=" & "'" & size & "'" & _
              " title=" & "'" & title & "'"& ">"
End Function ' DoTypeClass


'-----------------------
Function DoSelect(name, size, title)
DoSelect = "<select name=" & "'" & name & "'" & " size=" & "'" & size & "'" & _
           " title=" & "'" & title & "'" & ">"
End Function ' DoSelect

'-----------------------
Function DoOption(value, selected, caption)
Dim s
s = "<option value=" & "'" & value & "'"
If selected Then
    s = s & " selected"
End If
s = s & ">" & caption & "</option>"
DoOption = s
End Function ' DoOption

'-----------------------
Function DoRadio(name, value, checked, caption, title)
Dim s
s = "<input type=" & "'" & "radio" & "'" & " name=" & "'" & name & "'" & _
" value=" & "'" & value & "'" & " title=" & "'" & title & "'"
If checked Then
    s = s + " checked "
End If
s = s & ">" & caption & "</input>"
DoRadio = s
End Function ' DoRadio

'-----------------------
Function DoForm(method, action, target)
DoForm = "<form method=" & "'" & method & "'" & " action=" & "'" & action & "'" & _
         " target=" & "'" & target & "'" & ">"
End Function ' DoForm

'-----------------------
Function DoImg(imgname)
DoImg = "<img src=" & "'" & imgname & "'" & ">"
End Function ' DoImg


'-----------------------
Function DoHRef(action, target, title)
DoHRef = "<a href=" & "'" & action & "'" & _
         " target=" & "'" & target & "'" & _
         " title=" & "'" & title & "'" & ">"
End Function ' DoHRef

'-----------------------
Function DoHRefClass(action, target, title, clas)
DoHRefClass = "<a href=" & "'" & action & "'" & _
    " class=" & "'" & clas & "'" & _
    " target=" & "'" & target & "'" & _
    " title=" & "'" & title & "'" & ">"
End Function ' DoHRefClass


'-----------------------
Function DoHead(title)
response.Write "<html>" & Chr(13)
response.Write "<head>" & Chr(13)
response.Write " <META HTTP-EQUIV=" & "'" & "Content-Type" & "'" & " content=" & "'" & "text/html; " & sLangCS(Session("iLang")) & "'" & ">" & Chr(13)
response.Write " <title>" & title & ".asp</title>" & Chr(13)
response.Write " <link rel=" & "'" & "stylesheet" & "'" & " type=" & "'" & "text/css" & "'" & _
               " href=" & "'" & Session("Mroot")&"/html/css/" & title & ".css" & "'" & ">" & Chr(13)
response.Write "</head>" & Chr(13)
response.Write "<body alink=" & "'" & "#ffffff" & "'" & _
               " vlink=" & "'" & "#ffffff" & "'" & _
               " link=" & "'" & "#ffffff" & "'" & ">" & Chr(13)
Session("sActivePage") = title & ".asp"
End Function ' DoHead

Function DoQuoted(str)
DoQuoted = "'" & str & "'"
End Function ' DoQuoted

'-----------------------
Function DoTDClass(HTMLclass, title, colspan, rowspan)
Dim s
s = "<td class=" & "'" & HTMLclass & "'"
If title <> "" Then
    s = s + " title=" & "'" & title & "'"
End If
If colspan <> "" Then
    s = s + " colspan=" & "'" & colspan & "'"
End If
If rowspan <> "" Then
    s = s + " colspan=" & "'" & rowspan & "'"
End If
DoTDClass = s + ">"
End Function ' DoTDClass

'-----------------------
Function DoEndDoc()
response.Write "</body>" & Chr(13)
response.Write "</html>" & Chr(13)
Session("sPrevPage") = Session("sActivePage")
End Function 'DoEndDoc

'-----------------------
Function DoLangURL(sPage)
' vrne absolutno pot do strani (prefixa sPage s lang potjo)
	DoLangURL = sLangID(Session("iLang")) & "/" & sPage
End Function

%>