
function tellerror(){
    //alert('An error has occurred!')
}

window.onerror = tellerror

/* Get HTML DATA*/
var xmlHttp1
function GetHTMLData(Section,PageId,Action)
{
    //alert("next")
    var i;   
    document.getElementById("pnlprevresults").className="displaynone";
    document.getElementById('linkDownload1').className = "displaynone";
    document.getElementById('linkprintable1').className = "displaynone"; 
    for(i=1;i<6;i++)
    {
        document.getElementById('SubLink'+ i).className = "tab";
    }
    document.getElementById('SubLink'+ PageId).className = "tab_selected";        
    document.getElementById("divGetData").innerHTML = "<table cellspacing=0 style='color:Black;font-family:Tahoma;font-size:18px;' cellpadding=0 border=0 align='center' height='190'><tr><td valign='middle' align='center'><img src='images/Loading.gif' /></br>Please wait..</td></tr></table>";    
    xmlHttp1=GetXmlHttpObject()
    if (xmlHttp1==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    } 
    var url="AjaxPage/AjaxRequest.aspx"
    url=url+"?Section="+Section
    url=url+"&Page="+PageId
    url=url+"&Action="+Action
    
    xmlHttp1.onreadystatechange=GetHtmlData
    xmlHttp1.open("GET",url,true)
    xmlHttp1.send(null)    
}
function GetHtmlData() 
{ 
    //alert(xmlHttp1.readyState);
	if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete")
	{
	 if (xmlHttp1.status == 200) 
	     {
            document.getElementById("divGetData").innerHTML = xmlHttp1.responseText;			  		
         } 
        else 
        {
            document.getElementById("divGetData").innerHTML = "<br /><br /><font color='Orange'><b>RESULT WILL BE UPDATED SOON! <br /><br /></font> Error: " + xmlHttp1.status + "</b>";
        }			  
	}
	else {	
	}
} 
/* End HTML DATA*/

/*GET LATEST RESULTS*/
var xmlHttp2
function GetLatestResults(PageId,GameName,Action)
{    
    var i; 
    document.getElementById("ctl00_ContentPlaceHolder1_pnlprevresults").className="displaynone";    
    for(i=1;i<6;i++)
    {
        document.getElementById('ctl00_ContentPlaceHolder1_SubLink'+ i).className = "tab";
    }
    document.getElementById('ctl00_ContentPlaceHolder1_SubLink'+ PageId).className = "tab_selected";        
    document.getElementById("divGetData").innerHTML = "<table cellspacing=0 style='color:Black;font-family:Tahoma;font-size:18px;' cellpadding=0 border=0 align='center' height='190'><tr><td valign='middle' align='center'><img src='images/Loading.gif' /></br>Please wait..</td></tr></table>";    
    xmlHttp2=GetXmlHttpObject()    
    if (xmlHttp2==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    } 
    var url="AjaxRequest.aspx"
    url=url+"?Page="+PageId
    url=url+"&GameName="+GameName
    url=url+"&Action="+Action
    //alert("URL called" + url);
    xmlHttp2.onreadystatechange=GetResults    
    xmlHttp2.open("GET",url,true)
    xmlHttp2.send(null)
} 
function GetResults() 
{    
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
	{	
	 if (xmlHttp2.status == 200) 
	     {	        
	     alert(xmlHttp2.responseText);
            document.getElementById("divGetData").innerHTML = xmlHttp2.responseText;
            document.getElementById('ctl00_ContentPlaceHolder1_linkDownload1').className = "hd_White";
            document.getElementById('ctl00_ContentPlaceHolder1_linkprintable1').className = "hd_White";
         } 
        else 
        {
            document.getElementById("divGetData").innerHTML = "<br /><br /><font color='Orange'><b>Problem communicating with remote server.</font> Error: "+xmlHttp2.status+"</b>";
        }			  
	}
	else {	
	}
} 

/*END LATEST RESULTS*/

/*GET PREVIOUS RESULTS*/
var xmlHttp3
function GetPreviousResults(GameName,ddl1,ddl2,pageno,Action)
{   
    //alert("Results");
    document.getElementById("divGetData").innerHTML = "";
    //document.getElementById('DivPageNos').className = "";
    document.getElementById('DivGetPrevResults').className = "";		            
    document.getElementById("DivGetPrevResults").innerHTML = "<table cellspacing=0 style='color:Black;font-family:Tahoma;font-size:18px;' cellpadding=0 border=0 align='center' height='190'><tr><td valign='middle' align='center'><img src='images/Loading.gif' /></br>Please wait..</td></tr></table>";    
    xmlHttp3=GetXmlHttpObject()    
    if (xmlHttp3==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    } 
    var url="AjaxRequest.aspx"
    url=url+"?GameName="+GameName
    url=url+"&ddl1="+ddl1
    url=url+"&ddl2="+ddl2
    url=url+"&Pageno="+pageno
    url=url+"&Action="+Action
   
    xmlHttp3.onreadystatechange=GetPrevRes
    xmlHttp3.open("GET",url,true)
    xmlHttp3.send(null)    
}
function GetPrevRes() 
{ 
	if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")
	{	
	 if (xmlHttp3.status == 200) 
	     {	        
            document.getElementById("DivGetPrevResults").innerHTML = xmlHttp3.responseText;	
//            document.getElementById('linkDownload2').className = "hd_White";
//            document.getElementById('linkprintable2').className = "hd_White";   
         } 
        else 
        {
            document.getElementById("DivGetPrevResults").innerHTML = "<br /><br /><font color='Orange'><b>Problem communicating with remote server.</font> Error: "+xmlHttp3.status+"</b>";
        }			  
	}
	else {	
	}
} 

/*END PREVIOUS RESULTS*/

function GetXmlHttpObject()
{ 
    var objXMLHttp=null
    if (window.XMLHttpRequest)
    {
        objXMLHttp=new XMLHttpRequest()
    }
    else if (window.ActiveXObject)
    {
        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
    }
    return objXMLHttp
} 

function winOpen(Section,pageid,frdate,todate)
{    
    var game="";
    var fdate=frdate;
    var tdate=todate;    
    if (Section == 1)
        game = 'Joker';
        
    else if (Section == 2)
        game = 'THURSDAY LOTTO';
        
    else if (Section == 3)
        game = 'Thunder ball';
    
    else if (Section == 4)
        game = 'SATURDAY LOTTO';
        
   else if (Section == 5)
        game = 'KENOPLUS';
   
   else if (Section == 6)
        game = 'Lucky 3';
        
   else if (Section == 7)
        game = 'FAST LOTTO';
        
   else if (Section == 8)
        game = 'Joker 5';
   
   else if (Section == 9)
        game = 'TRIPLE TICKET';
   else if (Section == 10)
        game = 'Easy Lotto';
        
   else if (Section == 11)
        game = '201';
        
   else if (Section == 12)
        game = '202';
        
   else if (Section == 14)
        game = '211';
    else if (Section == 13)
        game = 'BADA JOKER'
    else if (Section == 17)
        game = '216'    
             
   var WinPrint =  window.open('printableversion.aspx?GameName=' + game +'&Page='+pageid+'&fdate='+fdate+'&tdate='+tdate,'Printable','left=0,top=0,width=850,height=700,toolbar=0,scrollbars=1,status=0');
	
    WinPrint.print();   
}
