<!--#include file="db.asp"-->
<%
StTime = Timer
'<#SiteName#> <#PayamSend#> 
'

NewsCod = SQLinj(Request.QueryString("id"))
	HiLite = Request.QueryString("Hi")

    Msql = "Select valu FROM Setting Where IDN='Stop'"
    rs.Open Msql, con
        If Not rs.EOF Then isStop = rs("valu") Else GoSAFE "[" & URLstr & "]->{Setting.Stop.Valu} not found!"
    rs.Close
    If isStop<>"No" Then GoSAFE "[" & URLstr & "]->{Setting.Stop.Valu} is Yes!"

    Msql = "Select valu FROM Setting Where IDN='SiteName'"
    rs.Open Msql, con
        If Not rs.EOF Then SiteName = rs("valu") Else GoSAFE "[" & URLstr & "]->{Setting.SiteName.Valu} not found!"
    rs.Close

	If Not Len(NewsCod)>0 Then
		Msql = "Select TOP 1 Cod FROM News ORDER BY CreateDate DESC"
		rs.Open Msql, con
		    If Not rs.EOF Then NewsCod = rs("Cod") Else GoSAFE "[" & URLstr & "]->{News.Cod} not found!"
		rs.Close
	End If
		
If (fso.FileExists(TempPath)) Then
    Set fs = fso.OpenTextFile(TempPath, 1)
		tmp = fs.ReadAll
    fs.Close()
    
		Msql = "SELECT * FROM News WHERE Show<>0 AND Cod=" & NewsCod
		rs.Open Msql, con
		    If Not rs.EOF Then
				NewsTitle = HiLight(rs("Title"), HiLite)
				NewsDate = RemSefr(rs("NewsDate"))
				NewsLead = HiLight(RepMatn(rs("Lead")), HiLite)
				NewsMatn = HiLight(RepMatn(rs("Text")), HiLite)
			Else
				GoSAFE "[" & URLstr & "]->{News.Title} not found!"
			End If
		rs.Close

		PicPath = mid(ThisPath,1,InStrRev(ThisPath,"\")) & "Pic\"
		BigPic = PicPath & "\Emaad-News-" & NewsCod & "-big.jpg"

		BP = GetLoop(tmp, "HasPic")
		If (fso.FileExists(BigPic)) Then
			Call SetLoop(tmp, "HasPic", BP)
		Else
			Call SetLoop(tmp, "HasPic", "")
		End If

	Set rs = Nothing
    con.Close
    Set con = Nothing

'=================================================

	Call SetVars(tmp)
	
    EnTime = Timer
	'Response.Write EnTime - StTime 'زماني كه اجراي تمپليت طول مي كشد
	tmp = tmp & "<!-- Generate Time: " & (EnTime - StTime) & " Second -->"

	Response.Write tmp

Else
	GoSAFE "[" & URLstr & "]->{TempFile} not found!"
End If

Sub SetVars(Ltxt)
	'---------------------------------------------------------------
    Ltxt = Replace(Ltxt, "<#Page_Header_First#>", Page_Header_First)
    Ltxt = Replace(Ltxt, "<#Page_Header_Last#>", Page_Header_Last)
    Ltxt = Replace(Ltxt, "<#Page_Footer#>", Page_Footer)
    Ltxt = Replace(Ltxt, "<#Box_Header_First#>", Box_Header_First)
    Ltxt = Replace(Ltxt, "<#Box_Header_Last#>", Box_Header_Last)
    Ltxt = Replace(Ltxt, "<#Box_Footer#>", Box_Footer)
	'---------------------------------------------------------------
    Ltxt = Replace(Ltxt, "<#SiteName#>", SiteName)
    Ltxt = Replace(Ltxt, "<#NewsTitle#>", NewsTitle)
    Ltxt = Replace(Ltxt, "<#NewsDate#>", NewsDate)
    Ltxt = Replace(Ltxt, "<#NewsLead#>", NewsLead)
    Ltxt = Replace(Ltxt, "<#NewsMatn#>", NewsMatn)
    Ltxt = Replace(Ltxt, "<#NewsCod#>", NewsCod)
    Ltxt = Replace(Ltxt, "<#FileNaam#>", FileNaam)
    Ltxt = Replace(Ltxt, "<#ID#>", NewsCod)
    Ltxt = Replace(Ltxt, "<#BackURL#>", BackURL)
End Sub

%>
<!--#include file="fc.asp"-->
