<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="windows-1255" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ODBC" %>
<%@ Import Namespace = "MySql.Data.MySqlClient" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

<script runat="server"> 

Public Dim UsersDBConnectionString As String = "Data Source=mysql281.secureserver.net;Database=ecusers;User ID=ecusers;Password=toto1X2;"
Public Dim SiteDBConnectionString As String = "Data Source=mysql273.secureserver.net;Database=ecsite;User ID=ecsite;Password=toto1X2;"


Sub Page_Template_Load (Sender As Object, E As EventArgs)
	Dim Lang as String
	Lang = Request.QueryString("lang")
	
	If (Lang = "") Then
		Lang = "heb"
	End If
	
	If Not Page.IsPostBack Then
		Dim SQLConnectString As String = SiteDBConnectionString
    	Dim mySQLConn As MySqlConnection = Nothing
		mySQLConn = New MySqlConnection(SQLConnectString)
        mySQLConn.Open()
		Dim Readme As MySqlDataReader = Nothing
        Dim cmd As New MySqlCommand("SELECT Type, Label, Link FROM MainMenu WHERE Lang='" & Lang & "' ORDER BY Serial ASC", mySQLConn)
		Readme = cmd.ExecuteReader()
		
		Dim menu_dt As DataTable 
		Dim dr As DataRow
    	Dim i As Integer
		
		menu_dt = New DataTable
    	menu_dt.Columns.Add(New DataColumn("MenuLink", GetType(String)))
	
		i = 0
		While Readme.Read()

			dr = menu_dt.NewRow()
			If Readme.GetString(0) = "Link" Then
				dr(0) = "<td class=""menucell""><a href=""" & Readme.GetString(2) & """ class=menu>"  & ReEncode(Readme.GetString(1)) & "</a></td>"
				menu_dt.Rows.Add(dr)
			End If
			If Readme.GetString(0) = "Label" Then
				dr(0) = "<td class=""menulabelcell""><span class=menulabel>" & ReEncode(Readme.GetString(1)) & "</span></td>"
				menu_dt.Rows.Add(dr)
			End If
			
	
		End While
				
		Readme.close()
		mySQLConn.Close()

		Repeater1.DataSource = New DataView(menu_dt)
		Repeater1.DataBind()

	End If
	
	If (Not Request.Cookies("UserName") Is Nothing) AndAlso _
		(Not Request.Cookies("UserName").Value Is Nothing) Then
		UserNameLabel.Text = Request.Cookies("UserName").Value
		LoginPanel.Visible = False
		UserPanel.Visible = True
	Else
		UserNameLabel.Text = "guest"
		LoginPanel.Visible = True
		UserPanel.Visible = False
	End If

End Sub

Sub SaveButton_Click(sender As Object, e As EventArgs)
	Dim UserName = UserNameTextBox.Text
	Dim PassHash = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(UserPassTextBox.Text,"SHA1").Substring(0,24).ToUpper()
	Dim LoginQuery = "SELECT PassHash, NickHash, Nick FROM UsersTable WHERE Email='" & UserName &"'"
	Dim connectString = UsersDBConnectionString
    Dim myConn As MySqlConnection = Nothing
	myConn = New MySqlConnection(connectString)
	Dim TableOutput As New MySqlCommand(LoginQuery, myConn)
    myConn.Open()
	Dim Readme As MySqlDataReader = TableOutput.ExecuteReader()
	If Readme.Read() then
		If PassHash = Readme.GetString(0).ToUpper() 
			Response.Cookies("UserName").Value = UserName
			Response.Cookies("UserName").Expires = System.DateTime.Now.AddDays(1000) 
			Response.Cookies("PassHash").Value = Readme.GetString(0)
			Response.Cookies("PassHash").Expires = System.DateTime.Now.AddDays(1000) 
			Response.Cookies("NickHash").Value = Readme.GetString(1)
			Response.Cookies("NickHash").Expires = System.DateTime.Now.AddDays(1000) 
		End If
	End If
	Response.AppendHeader("Refresh", "0")
End Sub

Sub DeleteButton_Click(sender As Object, e As EventArgs)
	Response.Cookies("UserName").Value = ""
	Response.Cookies("UserName").Expires = System.DateTime.Now.AddDays(-1)
	Response.Cookies("NickHash").Value = ""
	Response.Cookies("NickHash").Expires = System.DateTime.Now.AddDays(-1) 
	Response.Cookies("PassHash").Value = ""
	Response.Cookies("PassHash").Expires = System.DateTime.Now.AddDays(-1) 
	Response.AppendHeader("Refresh", "0")
End Sub	

Public Function ReEncode(S as String) As String
	Dim encode As Encoding
	encode = System.Text.Encoding.GetEncoding("windows-1255")	
	Dim unicodeBytes As Byte() = Encoding.Unicode.GetBytes(S)
	Dim RawBytes(unicodeBytes.Length/2) As Byte
	Dim j As Integer
	For j = 0 To (unicodeBytes.Length/2-1)
		RawBytes(j) = unicodeBytes(2*j)
	Next j
	Dim encodeChars(encode.GetCharCount(RawBytes, 0, RawBytes.Length-1)) As Char
	encode.GetChars(RawBytes, 0, RawBytes.Length-1, encodeChars, 1)
	Return (New String(encodeChars))
End Function

Public Function GetActiveMahzorID(Game as String) As String
	Dim connectString = UsersDBConnectionString
    Dim myConn As MySqlConnection = Nothing
	MyConn = New MySqlConnection(connectString)
	Dim TableOutput As New MySqlCommand("SELECT MAX(MahzorID) FROM MatchTable WHERE MahzorID LIKE '" & Game.SubString(0,2) & "%'", myConn)
	myConn.Open()
	Dim Readme As MySqlDataReader = TableOutput.ExecuteReader()
	Readme.Read()
	Dim CurrMahzor = Readme.GetString(0)
	Readme.close()
	MyConn.close()
	Return CurrMahzor
End Function
 
Function GetRecLink(MahId As String, NickHash As String, Lang As String, LinkText As String) As String
	Dim Ret As String
	If (Lang = "") Then
		Lang = "heb"
	End If
	Ret = "<a href=""ShowGuess.aspx?MahzorID=" & MahId & "&Nick=" & NickHash & "&Lang=" & Lang & """>" & LinkText & "</a>"
	Return Ret 
End Function

Function GetHomePageLink(NickHash As String, LinkText As String) As String
	Dim Ret As String
	Ret = "<a href=""HomePage.aspx?Nick=" & NickHash & """ >" & LinkText & "</a>"
	Return Ret 
End Function


</script>



<script runat="server"> 

Public Dim FormLines as New ArrayList()
Public Dim IsActive As String
Public Dim FavoritesMode As Boolean
Public Dim InfoWidth As Integer

Private Sub ReloadGame_Click(Sender As Object, E As EventArgs)
	SelectedGame.Text = GameForMahDD.SelectedItem.Value
	ViewState("_CurrentPage") = 0
	Guess_Load(sender, e)
End Sub

Private Sub ReloadNick_Click(Sender As Object, E As EventArgs)
	SelectedNick.Text = NickForMahDD.SelectedItem.Value
	GuessTitle.Text = "ההמלצה של:" & " "  & GetHomePageLink(NickForMahDD.SelectedItem.Value, NickForMahDD.SelectedItem.Text)
	SelectedGame.Text = 0
	ViewState("_CurrentPage") = 0
	Guess_Load(sender, e)
End Sub

Sub FavoritesChMod(M As Boolean)
	FavoritesMode = M
	If M Then
		FavoriteText.Text = "הוסף לפייבוריטים"
	Else
		FavoriteText.Text = "הסר מהפייבוריטים"
	End If
End Sub

Private Sub Favorites_Click(Sender As Object, E As EventArgs)
	If FavoritesMode Then
		Try
			Dim connectString = UsersDBConnectionString
    		Dim myConn As New MySqlConnection(connectString)
			myConn.Open()
			Dim TableOutput As New MySqlCommand("INSERT INTO FavoriteTable (SourceNick, DestNick) VALUES ('" & Request.Cookies("NickHash").Value & "', '" & SelectedNick.Text & "')", MyConn)
			TableOutput.ExecuteNonQuery()
			myConn.Close()
		Catch
		End Try
	Else
		Try
			Dim connectString = UsersDBConnectionString
    		Dim myConn As New MySqlConnection(connectString)
			myConn.Open()
			Dim TableOutput As New MySqlCommand("DELETE FROM FavoriteTable WHERE SourceNick='" & Request.Cookies("NickHash").Value & "' AND DestNick='" & SelectedNick.Text & "'", MyConn)
			TableOutput.ExecuteNonQuery()
			myConn.Close()
		Catch
		End Try
	End If
	Guess_Load(Sender, E)
End Sub

Private Sub SendMessage_Click(Sender As Object, E As EventArgs)
	Response.Redirect("NewMessage.aspx?To="&SelectedNick.Text)
End Sub

Public Sub Prev_Click(ByVal obj As Object, ByVal e As EventArgs) 
	ViewState("_CurrentPage") = pagedData.CurrentPageIndex - 1
	Guess_Load(obj,e)
End Sub 

Public Sub Next_Click(ByVal obj As Object, ByVal e As EventArgs) 
	ViewState("_CurrentPage") = pagedData.CurrentPageIndex + 1
	Guess_Load(obj,e)
End Sub

Function GetSummaryTable(Summary As Integer(), WinnerFlag As Boolean) As String
	
	Dim Ret As String 
	If Not WinnerFlag Then
		Ret = "<table class=""linestriplet"" width=""90%""><tr><td width=""14%"" class=""summarytdtop"">1</td><td width=""14%"" class=""summarytdtop"">X</td><td width=""14%"" class=""summarytdtop"">2</td><td width=""14%"" class=""summarytdtop"">1X</td><td width=""14%"" class=""summarytdtop"">12</td><td width=""14%"" class=""summarytdtop"">X2</td><td width=""14%"" class=""summarytdtop"">1X2</td></tr>" & _
			  "<tr><td class=""summarytd"">" & Summary(0) & "</td><td class=""summarytd"">" & Summary(1) & "</td><td class=""summarytd"">" & Summary(2) & "</td>" & _
			  "<td class=""summarytd"">" & Summary(3) & "</td><td class=""summarytd"">" & Summary(4) & "</td><td class=""summarytd"">" & Summary(5) & "</td><td class=""summarytd"">" & Summary(6) & "</td></tr></table>"
	Else
		Ret = "<table class=""linestriplet"" width=""45%""><tr><td width=""33%"" class=""summarytdtop"">1</td><td width=""33%"" class=""summarytdtop"">X</td><td width=""33%"" class=""summarytdtop"">2</td></tr>" & _
			  "<tr><td class=""summarytd"">" & Summary(0) & "</td><td class=""summarytd"">" & Summary(1) & "</td><td class=""summarytd"">" & Summary(2) & "</td></tr></table>"
	End If		  
	Return Ret
End Function

Function GetLinesTriplet(MatchRow As String()) As String
	Dim BGs as String() = {"#FFFFFF","#FFFFFF","#FFFFFF"}
	Select Case MatchRow(5)
		Case "1"
			BGs(0) = "yellow"
		Case "X"
			BGs(1) = "yellow"
		Case "2"
			BGs(2) = "yellow"
	End Select
	Dim Ret As String = "<table class=""linestriplet"" width=""90%""><tr><td width=""33%"" class=""linestd"" bgcolor=""" & BGs(0) & """>" & MatchRow(1) & "</td><td width=""33%"" class=""linestd"" bgcolor=""" & BGs(1) & """>" &  MatchRow(2) & "</td><td width=""33%"" class=""linestd"" bgcolor=""" & BGs(2) & """>" &  MatchRow(3) & "</td></tr></table>"
	Return Ret
End Function

Function GetRankDisplay(Rank As Integer) As String
	Dim Ret As String
	If (Rank = 999999) Then
		Ret = "&nbsp;לא מדורג&nbsp;"
	Else
		Ret = "&nbsp;מקום <b>" & Rank & "</b>&nbsp;"
	End If
	Return "<table class=""linestriplet""><tr><td class=""linestd"" bgcolor=""#FFFFFF"">"& Ret &"</td></tr></table>"
End Function

Public Dim pagedData As New PagedDataSource() 

Sub Guess_Load (Sender As Object, E As EventArgs)

	Dim Game as String = Request.QueryString("game")
	Dim Lang as String = Request.QueryString("lang")
	Dim MahID as String = MahzorID.Text
	
	Dim WinnerFlag As Boolean = False
	If MahID.SubString(0,2) = "wi" Then
		WinnerFlag = True
	End If
	
	If Lang = "" Then
		Lang = "heb"
	End If
	If Game = "" Then
		Game = "ragil"
	End If
	
	Dim GameNum As Integer = Int(SelectedGame.Text)
	Dim Nick As String = SelectedNick.Text
			
	'First - Reading Infomation for current Period
    Dim connectString = UsersDBConnectionString
    Dim myConn As MySqlConnection = Nothing
	Dim i As Integer
	
	i = 0
	MyConn = New MySqlConnection(connectString)
	myConn.Open()
		
	Dim MyQueryString As String = "SELECT Nick, GameNum, Guess, FreeText, Rank, NickHash FROM GuessTable WHERE MahzorID='" & MahID & "'"
	If (GameNum > 0) Then
		MyQueryString = MyQueryString & " AND GameNum=" & GameNum & " ORDER BY Rank"
		GuessTitle.Text = FormLines(GameNum-1)(0)
		InfoTitle.Text = "סיכויים<BR><table class=""linestriplet""><tr><td class=""linestd"">" & FormLines(GameNum-1)(1) & "</td><td class=""linestd"">" & FormLines(GameNum-1)(2) & "</td><td class=""linestd"">" & FormLines(GameNum-1)(3) & "</td></tr></table>"
	Else
		MyQueryString = MyQueryString & " AND NickHash='" & Nick & "' ORDER BY GameNum ASC"
		InfoTitle.Text = ""
	End If
	
	Dim dt As DataTable
	Dim dr As DataRow
	
	dt = New DataTable
	dt.Columns.Add(New DataColumn("Game", GetType(String)))
	dt.Columns.Add(New DataColumn("Info", GetType(String)))
	dt.Columns.Add(New DataColumn("Guess", GetType(String)))
	dt.Columns.Add(New DataColumn("FreeText", GetType(String)))

	Dim TableOutput As New MySqlCommand(MyQueryString, myConn)
	Dim Readme As MySqlDataReader = TableOutput.ExecuteReader()
	
	Dim Summary As Integer() = {0,0,0,0,0,0,0}
	
	While Readme.Read()	
		i = i + 1
		dr = dt.NewRow()
		
		Dim CurrGame As Integer = GameNum
		If (GameNum > 0) Then
			Dim RankStr As String = GetRankDisplay(Readme.GetInt32(4))
			dr(0) = "<table><tr><td>"& RankStr &"</td><td>"&"<span class=""tipster"">" & Server.HtmlEncode(ReEncode(Readme.GetString(0))) & "</span></td></tr></table>"
			dr(1) =  GetRecLink(MahzorID.Text, Readme.GetString(5), Lang, "להמלצה המלאה") 
			Select Case Readme.GetString(2)
				Case "1"
					Summary(0) += 1
				Case "X"
					Summary(1) += 1
				Case "2"
					Summary(2) += 1
				Case "1X"
					Summary(3) += 1
				Case "12"
					Summary(4) += 1
				Case "X2"
					Summary(5) += 1
				Case "1X2"
					Summary(6) += 1
			End Select
		Else
			CurrGame = Readme.GetInt32(1)
			dr(0) = "<b>" & FormLines(CurrGame-1)(4) & "</b> " & FormLines(CurrGame-1)(0)
			dr(1) = GetLinesTriplet( FormLines(CurrGame-1) )
			InfoTitle.Text = GetRankDisplay(Readme.GetInt32(4))
		End If
		
		dr(2) = Readme.GetString(2)
		
		If Not (Readme.GetString(3) = "") Then
			dr(3) = ReEncode(Readme.GetString(3))
		Else
			dr(3) = "-"
		End If
		
        dt.Rows.Add(dr)
	End While
	
	Readme.Close()
	
	If (GameNum > 0) Then
		InfoWidth=90
		InfoTitle.Text = GetSummaryTable(Summary, WinnerFlag)
		ActionPanel.Visible = "false"
	Else
		InfoWidth=40
		Dim ViewingIP = Request.ServerVariables("REMOTE_ADDR")
		Dim ViewingNick As String
		If (Not Request.Cookies("NickHash") Is Nothing) AndAlso _
			(Not Request.Cookies("NickHash").Value Is Nothing) Then
		 	ViewingNick = Request.Cookies("NickHash").Value
		End If
		Dim ViewQuery = "SELECT COUNT(*) FROM ViewsTable WHERE NickHash='" & Nick & "' AND MahzorID='" & MahID & "' AND IP='" & ViewingIP & "'"
		TableOutput = New MySqlCommand(ViewQuery, myConn)
		If (TableOutput.ExecuteScalar() = 0) Then
			TableOutput = New MySqlCommand("INSERT INTO ViewsTable (NickHash, MahzorID, IP, ViewerNick, Vote) VALUES " & _
										   "('" & Nick & "', '" & MahID & "', '" & ViewingIP & "', '" & ViewingNick & "', 0)" , myConn)
			TableOutput.ExecuteNonQuery()
		End If
		If Not (ViewingNick = "")
			TableOutput = New MySqlCommand("SELECT COUNT(*) FROM FavoriteTable WHERE SourceNick='" & ViewingNick & "' AND DestNick='" & Nick & "'", myConn)
			If (TableOutput.ExecuteScalar() = 0) Then
				FavoritesChMod(True)
				ActionPanel.Visible = "true"
			Else
				FavoritesChMod(False)
				ActionPanel.Visible = "true"
			End If
		Else
			ActionPanel.Visible = "false"
		End If
		
		
		
	End If

	myConn.Close()
	
	If (dt.Rows.Count = 0) Then
		GuessTitle.Text = "לא פורסמו עדיין המלצות למחזור זה…"
		ActionPanel.Visible = "false"
	End If
	
	'GuessDisplay.DataSource = New DataView(dt)
	'GuessDisplay.DataBind
	
	pagedData.DataSource = New DataView(dt)
	pagedData.AllowPaging = (GameNum > 0) 
	pagedData.PageSize = 20
	NPagesLabel.Text = (dt.Rows.Count+19) \ 20
	
	Try 
     	pagedData.CurrentPageIndex = Int32.Parse(ViewState("_CurrentPage"))
  	Catch ex As Exception 
     	pagedData.CurrentPageIndex = 0 
  	End Try 
	
	PageNumLabel.Text = pagedData.CurrentPageIndex + 1

  	btnPrev.Visible = ( NOT pagedData.IsFirstPage ) 
  	btnNext.Visible = ( NOT pagedData.IsLastPage ) 
	
	GuessDisplay.DataSource = pagedData
	GuessDisplay.DataBind
	
End Sub

Sub Selection_Menu(Sender As Object, E As EventArgs)

	Dim Lang as String = Request.QueryString("lang")
	If Lang = "" Then
		Lang = "heb"
	End If
	
	Dim MahID as String = MahzorID.Text
	
	'First - Reading Infomation for current Period
    Dim connectString = UsersDBConnectionString
    Dim myConn As MySqlConnection = Nothing
	Dim i As Integer
	
	i = 0
	MyConn = New MySqlConnection(connectString)
	myConn.Open()
	Dim TableOutput As New MySqlCommand("SELECT MatchString,Line1,LineX,Line2,Odd1,OddX,Odd2,Result FROM MatchTable WHERE MahzorID='" & MahID & "' AND Lang='" & Lang &"' ORDER BY MatchNum", myConn)
	Dim Readme As MySqlDataReader = TableOutput.ExecuteReader()
	
	Dim PercentMode As Boolean = True
	If MahID.SubString(0,2) = "wi" Then
		PercentMode = False
	End If
	
	Readme.Read()
	MahTitleLabel.Text = ReEncode(Readme.GetString(0))
	
	While Readme.Read()
	
		Dim currrow(6) As String
		i = i + 1
		
		currrow(0) = ReEncode(Readme.GetString(0))
		If PercentMode Then
			currrow(1) = Readme.GetString(4) & "%"
        	currrow(2) = Readme.GetString(5) & "%"
			currrow(3) = Readme.GetString(6) & "%"
			currrow(4) = i
			currrow(5) = Readme.GetString(7)
		Else
			currrow(1) = Readme.GetString(1)
        	currrow(2) = Readme.GetString(2)
			currrow(3) = Readme.GetString(3)
			currrow(4) = i
			currrow(5) = Readme.GetString(7)
		End If
        FormLines.Add(currrow)
	End While
	
	Readme.Close()
		
	MyConn.Close()	
	'More of user...
	'SELECT DISTINCT MahzorID FROM GuessTable Where Nick=...

End Sub

Sub Selection_Menu_DD(Sender As Object, E As EventArgs)
	
	Dim GameForMah as New ArrayList()
	Dim NickForMah as New ArrayList()
	Dim MahForNick as New ArrayList()

    Dim connectString = UsersDBConnectionString
    Dim myConn As MySqlConnection = Nothing

	MyConn = New MySqlConnection(connectString)
	myConn.Open()
	Dim TableOutput As New MySqlCommand("SELECT DISTINCT Nick, NickHash, Rank FROM GuessTable WHERE MahzorID = '" & MahzorID.Text & "' ORDER BY RowNum DESC", MyConn)
	
	Dim Readme As MySqlDataReader = TableOutput.ExecuteReader()
		
	Dim Latest as New DataTable
	Dim dr2 As DataRow

	Latest.Columns.Add(New DataColumn("Nick", GetType(String)))
	Latest.Columns.Add(New DataColumn("Link", GetType(String)))
	
	Dim dt As DataTable
	Dim dr As DataRow
	dt = New DataTable
	dt.Columns.Add(New DataColumn("TextField", GetType(String)))
	dt.Columns.Add(New DataColumn("ValueField", GetType(String)))
	dt.Columns.Add(New DataColumn("Rank", GetType(Integer)))
	
	Dim QueryNick As String = Request.QueryString("Nick")
	Dim i As Integer = 0
		
	While Readme.Read()
	
		dr = dt.NewRow()
		
		Dim CurrStr = Readme.GetString(0)
		
		dr(0) = ReEncode(CurrStr)
		
		dr(1) = Readme.GetString(1)
		
		dr(2) = Readme.GetInt32(2)
		
		If (i < 3) Then
			dr2 = Latest.NewRow()
			dr2(0) = ReEncode(CurrStr)
			dr2(1) = "ShowGuess.aspx?MahzorID=" & MahzorID.Text & "&Nick=" & Readme.GetString(1)
			Latest.Rows.Add(dr2)
		End If
		
		dt.Rows.Add(dr)
		
		If (QueryNick = dr(1)) Then
			GuessTitle.Text = "ההמלצה של:" & " " & GetHomePageLink(dr(1),dr(0))
		End If
		
		i = i + 1
		
	End While
	
	NickForMahDD.DataSource = New DataView(dt)
	NickForMahDD.DataSource.Sort = "Rank"
	NickForMahDD.DataBind()
	
	LatestLinks.DataSource = New DataView(Latest)
	LatestLinks.DataBind()
	
	Readme.Close()

	'Reading available Nicks for this period
	TableOutput = New MySqlCommand("SELECT DISTINCT GameNum FROM GuessTable WHERE MahzorID ='" & MahzorID.Text & "' ORDER BY GameNum", MyConn)
	Readme = TableOutput.ExecuteReader()
	
	GameForMahDD.Items.Clear()
	While Readme.Read()
		Dim CurrNum = Readme.GetInt32(0)
		GameForMahDD.Items.Add(New ListItem(FormLines(CurrNum-1)(0), FormLines(CurrNum-1)(4)))
	End While
		
	Readme.Close()
	
	MyConn.Close()
	
End Sub


Sub Page_Load (Sender As Object, E As EventArgs)
	Page_Template_Load(Sender, E)
	
	Dim GameCode As String
	If (Not (Request.QueryString("MahzorID") = "")) Then
		GameCode = Request.QueryString("MahzorID").SubString(0,2)
	Else
		GameCode = Request.QueryString("game").SubString(0,2)
	End If
		
	Dim ActiveMahzorID As String = GetActiveMahzorID(GameCode)
	
	If (Not Page.IsPostBack) Then
		MahzorID.Text = ActiveMahzorID
	End If
	
	If Not(Request.QueryString("MahzorID") = "") Then
		MahzorID.Text = Request.QueryString("MahzorID")
	End If
	
	If (ActiveMahzorID = MahzorID.Text) Then
		IsActive = "true"
	Else
		IsActive = "false"
	End If
	
	SelectionMenuPanel.Visible = IsActive
	
	Selection_Menu(Sender, E)
	
	If Not Page.IsPostBack Then
		Selection_Menu_DD(Sender, E)
		If Not(Request.QueryString("Nick") = "") Then
			SelectedNick.Text = Request.QueryString("Nick")
		Else
			If (NickForMahDD.Items.Count > 0) Then
				Dim RandomClass As New Random()
				Dim RandIndex = RandomClass.Next(0,NickForMahDD.Items.Count)
				SelectedNick.Text = NickForMahDD.Items(RandIndex).Value
				GuessTitle.Text = "ההמלצה של:" & " " & GetHomePageLink(NickForMahDD.Items(RandIndex).Value ,NickForMahDD.Items(RandIndex).Text)
			End If
		End If
		If Not(Request.QueryString("GameNum") = "") Then
			SelectedGame.Text = Int(Request.QueryString("GameNum"))
		Else
			SelectedGame.Text = 0
		End If
	End If
	
	Guess_Load(Sender, E)
	
End Sub
</script>


<head>
<meta http-equiv="Content-Type" content="text/html" charset=windows-1255>



<title>המלצות טוטו - מאגר המלצות לניחוש טוטו וטוטו עולמי</title>

<meta name="KEYWORDS" content="טוטו, ווינר, וינר, טוטו עולמי, מילוי טוטו, המלצות טוטו, מומחים, צמצום, צימצום, תוכנת טוטו, כדורגל, הימורים, סטטיסטיקה, סטטיסטיקות טוטו, ליינים, יחסי הימור, שערי הימור">

<meta name="DESCRIPTION" content="מאגר המלצות טוטו פתוח, המלצות מהמרים, סטטיסטיקות על משחקי המחזור, ההמלצות נבדקות ומדורגות על פי הניחוש הנכון בטוטו.">




<style type="text/css">
<!--
.style2 {font-family: Arial}
.menu {
	color: #000000; font-size: 14px; font-weight: bold; text-decoration: none;
}
.menu:visited {
	color: #000000; font-size: 14px; font-weight: bold; text-decoration: none;
}
.menu:hover {
	color: #0000CC; font-size: 14px; font-weight: bold; text-decoration: none;
}

.winner {
	color: #0000CC; font-size: 11px; text-decoration: none;
}
.winner:visited {
	color: #0000CC; font-size: 11px; text-decoration: none;
}
.winner:hover {
	color: #0000FF; font-size: 11px; text-decoration: none;
}

.alabel {
	font-family:arial; font-size:14px; color:#000000; border:none; background-color:#FFFFFF; FONT-WEIGHT: bold;
}

.menulabel {font-size: 16px; font-weight: bold; color:#000099;}

.tipster {font-size: 15px; font-weight: bold;}

.menucell { vertical-align: bottom; padding: 3px; }

.menulabelcell { vertical-align: middle; border: 2px solid red; padding: 1px; text-align: center; }

.style6 {font-size: 12px}

.style7 {font-size: 10px}

.style9 {font-size: 24px; font-weight: bold; font-style: italic; color:#3300FF}

.guesscell {font-size: 16px; font-weight: bold; border: 1px solid black; background-color:#FFFF99; vertical-align:middle;} 

.freetextcell {font-size: 12px; border: 1px solid black; background-color:#FFFFCC; vertical-align:middle; text-align: right;}  

.gamecell {font-size: 12px; border: 1px solid black; vertical-align:middle; text-align: right;}  

.game {
	border-bottom: 2px solid black; vertical-align: middle;
}

.gametable {
	border-collapse: collapse;
}

.gametabletitle {background-color:#FFFF99; font-weight: bold; font-size: 12px;}

.linestriplet {
	border-collapse: separate;
}

.linestd {
	border: 1px solid red;
}

.summarytd {
	border: 1px solid red; background-color:#FFFFFF;
}

.summarytdtop {
	background-color: #FFFFCC; font-size: 10px; font-weight: bold; border: 1px solid black;  
}

-->
</style>


</head>
<form runat="server"> 
 
<body class="style2" dir=rtl>
<table width="780" height="78" background="/images/yardtitle.gif" hspace="0" vspace="0" align="center" style="border-collapse: separate">
    <tr> 
		<td height="76" width="780"></td>
    </tr>
</table>
  
  <table width="780" border="1" align="center" bordercolor="#6699FF">
    <tr>
      <td width="140px" valign="top">
	  <div style="vertical-align: top; width:135px;">
	  	<BR>
		<asp:Panel id="UserPanel" 
        style="Z-INDEX: 101; vertical-align: top;" 
        runat="server" 
        Height="80px" 
        Width="130px">
		<span class="style6">מחובר<BR>
		<b>
		<asp:Label ID="UserNameLabel" Runat="server" EnableViewState="False"></asp:Label><BR></b></span>
		<asp:Button id="DeleteButton" runat="server" Text="התנתק" Font-Size="9" Width="50px" OnClick="DeleteButton_Click"></asp:Button>
		</asp:Panel>
		
		  <asp:Panel id="LoginPanel" 
        style="Z-INDEX: 102; vertical-align: top;" 
        runat="server" 
        Height="80px" 
        Width="130px">
		<div align="center">
		    <span class="style7">
			<table border="0">
			<tr>
			<td>אימייל</td><td>
		    <asp:TextBox id="UserNameTextBox" runat="server" Font-Size="9" Columns="14" MaxLength="40"></asp:TextBox></td>
			</tr><tr><td>
		    סיסמה</td><td>
		    <asp:TextBox id="UserPassTextBox" TextMode="Password" runat="server" Columns="14"  Font-Size="9" MaxLength="8"></asp:TextBox></td>
			</tr><tr><td colspan="2">
		    <asp:Button id="SaveButton" runat="server" Text="היכנס" Font-Size="9" Width="40px" OnClick="SaveButton_Click"></asp:Button>
			<a href="sitereg.php" style="font-size: 10px">משתמש חדש</a></td>
			</tr>
			</table>
		    </span></div>
	      </asp:Panel>  	    
		
	  	<asp:Repeater id="Repeater1" runat="server">
				<HeaderTemplate><table width="100%" style="border-collapse: separate;"></HeaderTemplate> 
				<ItemTemplate>
					<tr width="100%">
					<%#DataBinder.Eval(Container.DataItem, "MenuLink")%>
					</tr>
				</ItemTemplate>
				<FooterTemplate></table></FooterTemplate>
		  </asp:Repeater>
		</div>
	  </td>

	  <td width="640" valign="top">
	  
	  
		
		<asp:Label id="SelectedGame" runat="server" Visible="false"></asp:Label>
		<asp:Label id="SelectedNick" runat="server" Visible="false"></asp:Label>
		<asp:Label id="MahzorID" runat="server" Visible="false"></asp:Label>
		
		<asp:Panel id="SelectionMenuPanel" Visible="true" runat="server">
	  	<table width="90%" style="border-collapse: separate;">
			<tr>
				<td width="40%" style="border: 1px solid black; background-color:#FFFFFF; padding: 3px; font-size: 12px">
				<table><tr><td colspan="2">טען המלצות למשחק…</td></tr>
				<tr><td><asp:DropDownList id="GameForMahDD" runat="server" Font-Size="12px" Font-Name="Arial" EnableViewState="true"></asp:DropDownList></td>
				<td><asp:button id="butt1"  runat="server" Text="טען" onClick="ReloadGame_Click"></asp:button></td></tr>
				</table>
				</td>
				
				<td width="40%" style="border: 1px solid black; background-color: #FFFFFF; padding: 3px; font-size: 12px">
				<table><tr><td colspan="2">צפה בהמלצה של…</td></tr>
				<tr><td><asp:DropDownList id="NickForMahDD" runat="server" Font-Size="12px" Font-Name="Arial" EnableViewState="true" DataValueField="ValueField" DataTextField="TextField"></asp:DropDownList></td>
				<td><asp:button id="butt2"  runat="server" Text="טען" onClick="ReloadNick_Click"></asp:button></td></tr>
				</table>
				</td>
				
				<td width="20%" style="border: 1px solid black; background-color: #FFFFFF; padding: 3px; font-size: 12px">
				<table><tr><td>פורסמו לאחרונה</td></tr>
				<tr><td>
				<asp:Repeater id="LatestLinks" runat="server">
				<ItemTemplate>
					<a href="<%#DataBinder.Eval(Container.DataItem, "Link")%>">
					<%#DataBinder.Eval(Container.DataItem, "Nick")%></a><BR>
				</ItemTemplate>
				</asp:Repeater>
				</td></tr>
				</table>
				</td>
			</tr>
		</table>
		<BR>
		</asp:Panel>
		<center>
		<table width="99%" bgcolor="#99CCFF">
		<tr><td width="50%">
		<asp:Label id="MahTitleLabel" runat="server"
		Font-Size="12" Font-Bold="true" Font-Italic="True" Font-Name="Arial" text=""></asp:Label>
		<BR>
		<asp:Label id="GuessTitle" runat="server"
		Font-Size="14" Font-Bold="true" Font-Italic="True" Font-Name="Arial" text=""></asp:Label>
		</td><td width="50%">
		<table width="100%"><tr><td width="<%= InfoWidth %>%">
		<asp:Label id="InfoTitle" runat="server"></asp:Label>
		</td><td width="<%= 100-InfoWidth %>%">
		<asp:Panel id="ActionPanel" runat="server" Visible="false">
		<asp:LinkButton id="FavoriteText" OnClick="Favorites_Click" Font-Size="12px" ForeColor="#000000"
		runat="server"></asp:LinkButton><BR>
		<asp:LinkButton id="SendMessageButton" OnClick="SendMessage_Click" Font-Size="12px" ForeColor="#000000"
		Text="שלח הודעה" runat="server"></asp:LinkButton>
		</asp:Panel>
		
		</td></tr></table>
		</td>
		</tr>
		</table>
		</center>
		<BR>
		<asp:Repeater id="GuessDisplay" runat="server">
		<HeaderTemplate>
			<div align="center" style="vertical-align: top; font:Arial, Helvetica, sans-serif; font-size:12px; width:620px;">
			<table width="95%" border="0">
		</HeaderTemplate> 
			<ItemTemplate>
				<tr width="100%" height="30" valign="bottom" border="0" >
				<td width="58%" class="gamecell">
					<table width="98%">
						<td width="60%"><%#DataBinder.Eval(Container.DataItem, "Game")%></td>
						<td width="40%"><%#DataBinder.Eval(Container.DataItem, "Info")%></td>
					 </table>
				</td>
				<td width="7%" class="guesscell">
				<%#DataBinder.Eval(Container.DataItem, "Guess")%>
				<td>
				<td width="35%" class="freetextcell">
				<%#DataBinder.Eval(Container.DataItem, "FreeText")%>
				</td>
				</tr>
			</ItemTemplate>
		<FooterTemplate>
		</table>
		<BR>
		</FooterTemplate>
		</asp:Repeater>
		<span style="font-size: 12pt; font-weight: bold;">
		<asp:LinkButton id="btnPrev" Text="הקודם" OnClick="Prev_Click" Font-Bold="true" Font-Size="12" runat="server" /> 
		עמוד <asp:Label id="PageNumLabel"  Font-Bold="true" Font-Size="10" runat="server" /> 
		מתוך 
		<asp:Label id="NPagesLabel" runat="server"  Font-Bold="true" Font-Size="10" runat="server" />
		<asp:LinkButton id="btnNext" Text="הבא" OnClick="Next_Click"  runat="server" Font-Size="12" Font-Bold="true" Font-Name="Arial" />
		</span>
		</div>

       </td>
    </tr>

  
       </td>
    </tr>
    <tr>
      <td height="15" width="780" colspan="2" align="center" valign="middle">
	  <a href="index.html"><img src="/images/extra1x2_add.gif" border="0"></a> 
	       <center><iframe src="http://dealme.org/show_ad.php?t=1&s=2&p=1059&cat_id=0&width=728&height=90&ref=" width="728px" height="90px" scrolling="no" frameborder="0"></iframe></center>
	  
	  
	  </td></a>
    </tr>
  </table>
</body>
</form>

</html>
