﻿var xml_YearToDateIndex;
showYearToDateIndexitems();
function showYearToDateIndexitems()
{
    try
    {
//        if (!document.all)
//        return
        //alert('ok');    
       getallYearToDateIndexitems();   
       setTimeout("showYearToDateIndexitems()",YearToDateIndexTimer)
   }
   catch(oc)
   {
        alert('YearToDateIndexitems.showYearToDateIndexitems Error');
   }
}
function getallYearToDateIndexitems()
{
    try
    {    
    var url="../DataForms/DataYearToDateIndexitems.aspx";
    //alert(url);
    xml_YearToDateIndex=DoCallbackYearToDateIndex(url);
    //alert(xml_YearToDateIndex);
    if (xml_YearToDateIndex!=null)
    {
        xml_YearToDateIndex.onreadystatechange=setallYearToDateIndexitems;
    }
	 }
	catch(oc)
	{
	    //alert('error');
	}
}
function DoCallbackYearToDateIndex(url)
{
var xmlRequest=null;
	try
	{
		xmlRequest=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			xmlRequest=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			try
		    {
		       xmlRequest=new XMLHttpRequest();
		       if (xmlRequest.overrideMimeType) 
		       {
                xmlRequest.overrideMimeType('text/xml');
               }
		    }
		    catch(a)
		    {
			    xmlRequest=null;
			}
		}
	}
	if(!xmlRequest&&typeof XMLHttpreqADSuest!="undefined")
	{
		xmlRequest=new XMLHttpreqADSuest();
	}
 xmlRequest.open("GET", url, true);
   xmlRequest.send(null);
   return  xmlRequest;
}
function setallYearToDateIndexitems()
{
    try
    {
        if (xml_YearToDateIndex.readyState==4)
	    {
	            if (xml_YearToDateIndex.status==200)
		        {
                    //alert(xml_YearToDateIndex.responseText);
                    var result = xml_YearToDateIndex.responseText;
                    //alert(result);
                    var Gitems = "";                                                               
                        
                    if(result!="")
                    {
                        //alert(result);
                        var temp = new Array();
                        var temp1 = new Array();
                        var temp2 = new Array();
                        temp = result.split('@');
                        //alert(temp);                                            
                        if(temp[0].toString() == "Arabic")
                        {
                            Gitems += "<table width=100% cellspacing=0 class=tab-tabe dir=rtl>";
                            Gitems += "<tr >";
                            Gitems += "<th>المؤشر</th>";
                            Gitems += "<th >القيمة فى 31 ديسمبر</th>";                            
                            Gitems += "<th colspan=2>التغير</th>";
                            Gitems += "<th>% التغير</th>";                            
                            Gitems += "</tr>";                                                        
                           
                                                     
                            j = 1;                           
                            temp1 = temp[1].toString().split('#');
                            for(i = 0; i < temp1.length-1; i++)
                            {
                                temp2 = temp1[i].toString().split(';');                                
                                if(j == 1)
                                {
                                    Gitems += "<tr class=firstrow>";
                                    j = j + 1;
                                }
                                else
                                {
                                    Gitems += "<tr class=secondrow>";
                                    j = 1;                                    
                                }
                                Gitems += "<td class=tdHeading>"+temp2[1].toString()+"</td>";
                                Gitems += "<td class=fontrow align=right>"+temp2[3].toString()+"</td>";
                                Gitems += "<td><img src=../Images/"+temp2[6].toString()+".gif /></td>";                                
                                Gitems += "<td class=fontrow align=right dir=ltr><font color="+temp2[7].toString()+">"+temp2[4].toString()+"</font></td>";
                                Gitems += "<td class=fontrow align=right dir=ltr><font color="+temp2[7].toString()+">"+temp2[5].toString()+"</font></td>";                                
                                Gitems += "</tr>";
                            }                          
                        }
                        else
                        {
                            
                            Gitems += "<table width=100% cellspacing=0 class=tab-tabe dir=ltr>";
                            Gitems += "<tr >";
                            Gitems += "<th>Index</th>";
                            Gitems += "<th>31 Dec. Value</th>";                            
                            Gitems += "<th colspan=2>Net Change</th>";
                            Gitems += "<th>% Change</th>";                            
                            Gitems += "</tr>";
             
                                                                                                                
                            temp1 = temp[1].toString().split('#');
                            
                            j = 1;
                            for(i = 0; i < temp1.length-1; i++)
                            {
                                
                                temp2 = temp1[i].toString().split(';');                                
                                if(j == 1)
                                {
                                    Gitems += "<tr class=firstrow>";
                                    j = j + 1;
                                }
                                else
                                {
                                    Gitems += "<tr class=secondrow>";
                                    j = 1;                                    
                                }
                                
                                Gitems += "<td class=tdHeading>"+temp2[0].toString()+"</td>";                                
                                Gitems += "<td align=right>"+temp2[3].toString()+"</td>";
                                Gitems += "<td><img src=../Images/"+temp2[6].toString()+".gif /></td>";                                
                                Gitems += "<td align=right><font color="+temp2[7].toString()+">"+temp2[4].toString()+"</font></td>";
                                Gitems += "<td align=right><font color="+temp2[7].toString()+">"+temp2[5].toString()+"</font></td>";                                
                                Gitems += "</tr>";
                            }
                        }                       
                                            
                     
                    }
                    else
                    {
                    }
                    Gitems += "</table>";
                   
                    document.getElementById('YDIV').innerHTML= Gitems;                   
                }
                else
                {
                    //alert('status');
                }
        }
        else
        {
            //alert('readyState');
        }       
    }
    catch(oc)
    {
        //alert(oc);
    }            
}