function updatePage() {
	
	if ( request.readyState == 4 ) {
		
		if ( request.status == 200 ) {
			
			
			var response = request.responseText.split("\n");
			gameLimit = response.length - 1;
			gameLimitLess = gameLimit -1;
			
			var gmsOld = document.getElementById('gms').value;
			var gms = '';
			//var totGames = Number ( document.getElementById('totGames').value );
			
			ftScoreFont = '#252525';
			etScoreFont = '#252525';
			ptScoreFont = '#252525';
			teamColor = '#252525';
			teamBg = '#FBFBFB';
			pink = '#ffcccc';
			ftScoreBg = '#E1E1E1';
			red = '#ff0000';
			red2 = '#FF4343';
			orange = '#FF7800';
			blue = '#3d7ebf';
			green = '#13c800';
			lightgreen = '#d0f4cc';
			lightred = '#ffd9d9';
			lightblue = '#d6e5ef';
			oddHlg = '#254F76';
			oddFade = '#8CB1C6';
			
			for ( i=0; i<(gameLimit); i++ ) {
				
				var gameToks = response[i].split(";");
				id = gameToks[0];
				
				gameCntr = Number ( gameToks[31] );
				
				if ( gameToks[1] != "" ) {
					dateTimeToks = gameToks[1].split(" ");
					gameDate = dateTimeToks[0];
					kickOff = dateTimeToks[1];
				}				
				
				if ( gameToks[4] != "" ) {
		      			leagueCodeToks = gameToks[2].split(".");
		      			gameCode = leagueCodeToks[0];
			      		gameFlag = leagueCodeToks[1];
			      		gameAbr = leagueCodeToks[2];
			      		leagueName = gameToks[3];
	      			}
	      			
	      			gameCode = gameToks[3];
				homeTeam = gameToks[6];
				awayTeam = gameToks[7];
				ftGoals = gameToks[8];
				htGoals = gameToks[10];
				etGoals = gameToks[12];
				ptGoals = gameToks[14];
				scoreC1 = gameToks[17];
				scoreC2 = gameToks[18];
				gameStatus = gameToks[19];
				minute = gameToks[20];
				homeRed = gameToks[21];
				awayRed = gameToks[22];
				
				odds1 = gameToks[23];
				oddsX = gameToks[24];
				odds2 = gameToks[25];
				odds1X = gameToks[26];
				odds12 = gameToks[27];
				oddsX2 = gameToks[28];
				oddsu = gameToks[29];
				oddso = gameToks[30];
					
				
				
				
	        			if ( document.getElementById('tr'+id) == undefined ) {
	        				
	        				gameDate = gameToks[1];
	        				kickOff = gameToks[2];
	        				gameCode = gameToks[3];
		      			leagueCodeToks = gameToks[4].split(".");
		      			gameCode = leagueCodeToks[0];
		      			gameFlag = leagueCodeToks[1];
		      			gameAbr = leagueCodeToks[2];
		      			leagueName = gameToks[5];
					homeTeam = gameToks[6];
					awayTeam = gameToks[7];
					ftGoal1 = gameToks[8];
					ftGoal2 = gameToks[9];
					htGoal1 = gameToks[10];
					htGoal2 = gameToks[11];
					etGoal1 = gameToks[13];
					etGoal2 = gameToks[14];
					ptGoal1 = gameToks[15];
					ptGoal2 = gameToks[16];
					
					if ( gameStatus == 'F' ) {
						liveStatus = 'Τελικό';
						liveStatusColor = red;
					} else  if ( gameStatus == 'ADB' ) {
						liveStatus = 'Εγκατ';
						liveStatusColor = red;
					} else  if ( gameStatus == 'IR' ) {
						liveStatus = 'Διακ';
						liveStatusColor = red;
					} else  if ( gameStatus == 'PP' ) {
						liveStatus = 'Αναβ';
						liveStatusColor = red;
					} else if ( gameStatus == 'NS' ) {
						liveStatus = 'Προγ';
		    				liveStatusColor = blue;
		    			} else if ( gameStatus == 'ET' ) {
						liveStatus = 'Παρατ';
						liveStatusColor = green;
					} else if ( gameStatus == 'PEN' ) {
						liveStatus = 'Πεναλ';
						liveStatusColor = green;
					} else if ( gameStatus == 'HT' ) {
						liveStatus = 'Ημιχ';
						liveStatusColor = green;			    			
		    			}
					
					var tableRef = document.getElementById('cntrTable');
					var newRow = tableRef.insertRow(gameCntr);
					newRow.id = 'tr'+id;
					newRow.setAttribute ( 'height','16px' );
					newRow.innerHTML = '<td id=lf'+id+' style=background-color:#d6e5ef;width:21px;text-align:center><img src=http://69.64.33.91/images/flags/tiny/'+gameFlag+'.gif title="'+leagueName+'"></td>';
					newRow.innerHTML = newRow.innerHTML + '<td id=lc'+id+' style=background-color:#d6e5ef;width:30px;text-align:center>'+gameAbr+'</td>';
					newRow.innerHTML = newRow.innerHTML + '<td id=tm'+id+' style=background-color:#ebf1f5;width:40px;text-align:center;font-weight:bold>'+kickOff+'</td>';
					newRow.innerHTML = newRow.innerHTML + '<td id=ht'+id+' style=background-color:#ebf1f5;width:155px;text-align:right;color:#001b2e>'+homeTeam+'&nbsp;&nbsp;</td>';
					newRow.innerHTML = newRow.innerHTML + '<td id=sfb'+id+' style=background-color:#d6e5ef;width:40px;text-align:center;font-weight:bold><a id=sf'+id+' target='+id+' href=sscores.php?matchid='+id+'&date='+gameDate+' onclick="javascript:popup( '+id+' )" style=color:#005596>' + ftGoal1 + '-' + ftGoal2 + '</a></td>';
					newRow.innerHTML = newRow.innerHTML + '<td id=at'+id+' style=background-color:#ebf1f5;width:155px;text-align:left;color:#001b2e>&nbsp;&nbsp;'+awayTeam+'</td>';
					newRow.innerHTML = newRow.innerHTML + '<td id=sh'+id+' style=background-color:#ebf1f5;width:36px;text-align:center>' + htGoal1 + '-' + htGoal2 + '</td>';
					newRow.innerHTML = newRow.innerHTML + '<td id=seb'+id+' style=background-color:#d6e5ef;width:36px;text-align:center;color:#005596><a id=se'+id+' target='+id+' href="sscores.php?matchid='+id+'&timezone='+timeZone+'&date='+gameDate+'" onclick="javascript:popup( '+id+' )" style=color:#005596>' + etGoal1 + '-' + etGoal2 + '</a></td>';
					newRow.innerHTML = newRow.innerHTML + '<td id=spb'+id+' style=background-color:#d6e5ef;width:36px;text-align:center;color:#005596><a  id=sp'+id+' target='+id+' href="scores.php?matchid='+id+'&timezone='+timeZone+'&date='+gameDate+'" onclick="javascript:popup( '+id+' )" style=color:#005596>' + ptGoal1 + '-' + ptGoal2 + '</a></td>';
					newRow.innerHTML = newRow.innerHTML + '<td id=st'+id+' style=background-color:'+ liveStatusColor +';width:32px;text-align:center;font-weight:bold;color:#ffffff>'+liveStatus+'</td>';
					newRow.innerHTML = newRow.innerHTML + '<td id=cho'+id+' style=background-color:#d6e5ef;width:40px;text-align:center;font-weight:bold><div id=ho'+id+'>-</div></td>';
					newRow.innerHTML = newRow.innerHTML + '<td id=cdo'+id+' style=background-color:#d6e5ef;width:40px;text-align:center;font-weight:bold><div id=do'+id+'>-</div></td>';
					newRow.innerHTML = newRow.innerHTML + '<td id=cao'+id+' style=background-color:#d6e5ef;width:40px;text-align:center;font-weight:bold><div id=ao'+id+'>-</div></td>';
										
					gms = gms + id + ',';
					
				} else {
										
					gmsOld = gmsOld.replace ( id, '', 'gi' );
					
					if ( gameToks[1] != "" && kickOff != undefined ) {
		        				document.getElementById('tm'+id).innerHTML = kickOff;
						if ( document.getElementById('tr'+id).rowIndex != gameCntr ) {
							document.getElementById('cntrTable').moveRow( document.getElementById('tr'+id).rowIndex, gameCntr );
						}
					}
					
					if ( gameToks[4] != "" ) {
			      			document.getElementById('lf'+id).innerHTML = '<../images/flags/'+gameFlag+'.gif title="'+leagueName+'">';
				      		document.getElementById('lc'+id).innerHTML = gameAbr;
		      			}
		      			
		      			if ( minute != "" ) {
						document.getElementById('st'+id).innerHTML = minute;
						document.getElementById('st'+id).style.backgroundColor = green;
					}
					
					if ( homeTeam != "" ) {
						homeTeamToks = homeTeam.split("|");
						homeTeamName = '';
						homeReds = Number ( homeTeamToks[1] );
						if ( homeReds > 0 ) {
							for ( rc=1; rc<=homeReds; rc++ ) {
								homeTeamName = homeTeamName + '<img src=../images/red.gif>&nbsp;';
							}
						}
						homeTeamName = homeTeamName + homeTeamToks[0] + '&nbsp;&nbsp;';
						document.getElementById('ht'+id).innerHTML = homeTeamName;
					}
					
					if ( awayTeam != "" ) {
						awayTeamToks = awayTeam.split("|");
						awayTeamName = '';
						awayReds = Number ( awayTeamToks[1] );
						if ( awayReds > 0 ) {
							for ( rc=1; rc<=awayReds; rc++ ) {
								awayTeamName = awayTeamName + '&nbsp;<img src=../images/red.gif>';
							}
						}
						awayTeamName = '&nbsp;&nbsp;' + awayTeamToks[0] + awayTeamName;
						document.getElementById('at'+id).innerHTML = awayTeamName;
					}					
					
					if ( gameStatus != "" && gameStatus != "FH" && gameStatus != "SH" ) {
						if ( gameStatus == 'F' ) {
							liveStatus = 'Τελικό';
							liveStatusColor = red2;
						} else  if ( gameStatus == 'ADB' ) {
							liveStatus = 'Εγκατ';
							liveStatusColor = orange;
						} else  if ( gameStatus == 'IR' ) {
							liveStatus = 'Διακ';
							liveStatusColor = orange;
						} else  if ( gameStatus == 'PP' ) {
							liveStatus = 'Αναβ';
							liveStatusColor = orange;
						} else if ( gameStatus == 'NS' ) {
							liveStatus = 'Προγ';
			    				liveStatusColor = blue;
			    			} else if ( gameStatus == 'ET' ) {
							liveStatus = 'Παρατ';
							liveStatusColor = green;
						} else if ( gameStatus == 'PEN' ) {
							liveStatus = 'Πεναλ';
							liveStatusColor = green;
						} else if ( gameStatus == 'HT' ) {
							liveStatus = 'Ημιχ';
							liveStatusColor = green;			    			
			    			}
						
						document.getElementById('st'+id).innerHTML = liveStatus;
						document.getElementById('st'+id).style.backgroundColor = liveStatusColor;
					}
					
					
					if ( ftGoals != "" ) {
						document.getElementById('sf'+id).innerHTML = ftGoals;
					}
					
					if ( htGoals != "" ) {
						document.getElementById('sh'+id).innerHTML = htGoals;
					}
					
					if ( etGoals != "" ) {
						document.getElementById('se'+id).innerHTML = etGoals;
					}
					
					if ( ptGoals != "" ) {
						document.getElementById('sp'+id).innerHTML = ptGoals;
					}
					
					
								
					if ( scoreC1 != "" || scoreC2 != "" ) {
						
						if ( scoreC1 == "1" || scoreC2 == "1" ) {
							
							if ( gameStatus == 'FH' || gameStatus == 'HT' || gameStatus == 'SH' ) {
								document.getElementById('sf'+id).style.color = red;
								document.getElementById('sfb'+id).style.backgroundColor = pink;
							} else if ( gameStatus == 'ET' ) {
								document.getElementById('se'+id).style.color = red;
								document.getElementById('seb'+id).style.backgroundColor = pink;
							} else if ( gameStatus == 'PEN' ) {
								document.getElementById('sp'+id).style.color = red;
								document.getElementById('spb'+id).style.backgroundColor = pink;
							} else if ( gameStatus == 'F' ) {
								document.getElementById('sf'+id).style.color = ftScoreFont;
								document.getElementById('sfb'+id).style.backgroundColor = ftScoreBg;
								document.getElementById('se'+id).style.color = ftScoreFont;
								document.getElementById('seb'+id).style.backgroundColor = ftScoreBg;
								document.getElementById('sp'+id).style.color = ftScoreFont;
								document.getElementById('spb'+id).style.backgroundColor = ftScoreBg;
							}
				    			
				    		} else if ( scoreC1 == "0" || scoreC2 == "0" ) {
				    		
							if ( gameStatus == 'FH' || gameStatus == 'HT' || gameStatus == 'SH' ) {
								document.getElementById('sf'+id).style.color = ftScoreFont;
								document.getElementById('sfb'+id).style.backgroundColor = ftScoreBg;
							} else if ( gameStatus == 'ET' ) {
								document.getElementById('se'+id).style.color = ftScoreFont;
								document.getElementById('seb'+id).style.backgroundColor = ftScoreBg;
							} else if ( gameStatus == 'PEN' ) {
								document.getElementById('sp'+id).style.color = ftScoreFont;
								document.getElementById('spb'+id).style.backgroundColor = ftScoreBg;
							} else if ( gameStatus == 'F' ) {
								document.getElementById('sf'+id).style.color = ftScoreFont;
								document.getElementById('sfb'+id).style.backgroundColor = ftScoreBg;
								document.getElementById('se'+id).style.color = ftScoreFont;
								document.getElementById('seb'+id).style.backgroundColor = ftScoreBg;
								document.getElementById('sp'+id).style.color = ftScoreFont;
								document.getElementById('spb'+id).style.backgroundColor = ftScoreBg;
							}
				    		}
				    		
					}
					
					
						
					if ( scoreC1 != "" ) {
						
						if ( scoreC1 == "1" ) {
							
							if ( gameStatus == 'FH' || gameStatus == 'HT' || gameStatus == 'SH' ) {
								document.getElementById('ht'+id).style.color = red;
								document.getElementById('ht'+id).style.backgroundColor = pink;
							} else if ( gameStatus == 'ET' ) {
								document.getElementById('ht'+id).style.color = red;
								document.getElementById('ht'+id).style.backgroundColor = pink;
							} else if ( gameStatus == 'PEN' ) {
								document.getElementById('ht'+id).style.color = red;
								document.getElementById('ht'+id).style.backgroundColor = pink;
							} else if ( gameStatus == 'F' ) {
								document.getElementById('ht'+id).style.color = teamColor;
								document.getElementById('ht'+id).style.backgroundColor = teamBg;
							}
				    			
				    		} else if ( scoreC1 == "0" ) {
				    		
							if ( gameStatus == 'FH' || gameStatus == 'HT' || gameStatus == 'SH' ) {
								document.getElementById('ht'+id).style.color = teamColor;
								document.getElementById('ht'+id).style.backgroundColor = teamBg;
							} else if ( gameStatus == 'ET' ) {
								document.getElementById('ht'+id).style.color = teamColor;
								document.getElementById('ht'+id).style.backgroundColor = teamBg;
							} else if ( gameStatus == 'PEN' ) {
								document.getElementById('ht'+id).style.color = teamColor;
								document.getElementById('ht'+id).style.backgroundColor = teamBg;
							} else if ( gameStatus == 'F' ) {
								document.getElementById('ht'+id).style.color = teamColor;
								document.getElementById('ht'+id).style.backgroundColor = teamBg;
							}
				    		}
				    	}
				    	
				    	
				    	if ( scoreC2 != "" ) {
						
						if ( scoreC2 == "1" ) {
							
							if ( gameStatus == 'FH' || gameStatus == 'HT' || gameStatus == 'SH' ) {
								document.getElementById('at'+id).style.color = red
								document.getElementById('at'+id).style.backgroundColor = pink;
							} else if ( gameStatus == 'ET' ) {
								document.getElementById('at'+id).style.color = red;
								document.getElementById('at'+id).style.backgroundColor = pink;
							} else if ( gameStatus == 'PEN' ) {
								document.getElementById('at'+id).style.color = red;
								document.getElementById('at'+id).style.backgroundColor = pink;
							} else if ( gameStatus == 'F' ) {
								document.getElementById('at'+id).style.color = teamColor;
								document.getElementById('at'+id).style.backgroundColor = teamBg;
							}
				    			
				    		} else if ( scoreC2 == "0" ) {
				    		
							if ( gameStatus == 'FH' || gameStatus == 'HT' || gameStatus == 'SH' ) {
								document.getElementById('at'+id).style.color = teamColor;
								document.getElementById('at'+id).style.backgroundColor = teamBg;
							} else if ( gameStatus == 'ET' ) {
								document.getElementById('at'+id).style.color = teamColor;
								document.getElementById('at'+id).style.backgroundColor = teamBg;
							} else if ( gameStatus == 'PEN' ) {
								document.getElementById('at'+id).style.color = teamColor;
								document.getElementById('at'+id).style.backgroundColor = teamBg;
							} else if ( gameStatus == 'F' ) {
								document.getElementById('at'+id).style.color = teamColor;
								document.getElementById('at'+id).style.backgroundColor = teamBg;
							}
				    		}
				    	}
				    	
				    	
				    	
				    	if ( ftGoals != "" ) {
				    		
				    		goalToks = ftGoals.split("-");
				    		ftGoal1 = Number ( goalToks[0] );
				    		ftGoal2 = Number ( goalToks[1] );
				    		totGoals = ftGoal1 + ftGoal2;
				    		
				    		if ( ftGoal1 > ftGoal2 ) {
				    			
				    			if ( document.getElementById('o1'+id).innerHTML != "-" ) {
				    				document.getElementById('o1'+id).style.color = oddHlg;
				    				document.getElementById('oX'+id).style.color = oddFade;
				    				document.getElementById('oX'+id).style.color = oddFade;
				    			} 
				    			if ( document.getElementById('o1X'+id).innerHTML != "-" ) {
				    				document.getElementById('o1X'+id).style.color = oddHlg;
				    			}
				    			if ( document.getElementById('o12'+id).innerHTML != "-" ) {
				    				document.getElementById('o12'+id).style.color = oddHlg;
				    			}
				    			document.getElementById('oX2'+id).style.color = oddFade;
				    			
				    		} else if ( ftGoal1 < ftGoal2 ) {
				    			
				    			if ( document.getElementById('o2'+id).innerHTML != "-" ) {
				    				document.getElementById('o2'+id).style.color = oddHlg;
				    				document.getElementById('o1'+id).style.color = oddFade;
				    				document.getElementById('oX'+id).style.color = oddFade;
				    			}
				    			if ( document.getElementById('oX2'+id).innerHTML != "-" ) {
				    				document.getElementById('oX2'+id).style.color = oddHlg;
				    			}
				    			if ( document.getElementById('o12'+id).innerHTML != "-" ) {
				    				document.getElementById('o12'+id).style.color = oddHlg;
				    			}
				    			document.getElementById('o1X'+id).style.color = oddFade;
				    			
				    		} else if ( ftGoal1 == ftGoal2 ) {
				    			
				    			if ( document.getElementById('oX'+id).innerHTML != "-" ) {
				    				document.getElementById('oX'+id).style.color = oddHlg;
				    				document.getElementById('o1'+id).style.color = oddFade;
				    				document.getElementById('o2'+id).style.color = oddFade;
				    			}
				    			if ( document.getElementById('o1X'+id).innerHTML != "-" ) {
				    				document.getElementById('o1X'+id).style.color = oddHlg;
				    			}
				    			if ( document.getElementById('oX2'+id).innerHTML != "-" ) {
				    				document.getElementById('oX2'+id).style.color = oddHlg;
				    			}
				    			document.getElementById('o12'+id).style.color = oddFade;
				    			
				    		}
				    		
				    		
				    		if ( totGoals > 2 ) {
				    			if ( document.getElementById('oo'+id).innerHTML != "-" ) {
				    				document.getElementById('oo'+id).style.color = oddHlg;
				    				document.getElementById('ou'+id).style.color = oddFade;
				    			}
				    		} else {
				    			if ( document.getElementById('ou'+id).innerHTML != "-" ) {
				    				document.getElementById('ou'+id).style.color = oddHlg;
				    				document.getElementById('oo'+id).style.color = oddFade;
				    			}
				    		}
				    		
				    	}
				    	
					
					gms = gms + id + ',';
      						
				}	
			
			}
      			
      			var existingGames = gmsOld.split(',');
      			for ( m=0; m<existingGames.length; m++ ) {
      				if ( document.getElementById('tr'+existingGames[m]) != undefined ) {
      					var remIndex = document.getElementById('tr'+existingGames[m]).rowIndex;
      					document.getElementById('cntrTable').deleteRow(remIndex);
      				}
      			}
      			
      			document.getElementById('gms').value = gms;
      			if ( gameLimit >= document.getElementById('totGames').value ) {
				//document.getElementById('pass').value = 2;
			}
			
		} else {
			window.location = location.href;
		}
		
	}
	
	now = new Date();
      	//document.getElementById('debug').innerHTML = document.getElementById('debug').innerHTML + now + '<br>';
}



function initLiveData() {
	setTimeout ( 'getLiveData()', 10000 );
}

