﻿var xml_ML;
showMLitems();
function showMLitems()
{
    try
    {
//        if (!document.all)
//        return
        //alert('ok');    
       getallMLitems();   
       setTimeout("showMLitems()",MLTimer)
   }
   catch(oc)
   {
        alert('MLitems.showMLitems Error');
   }
}
function getallMLitems()
{
    try
    {    
    var url="../DataForms/DataMLitems.aspx";
    //alert(url);
    xml_ML=DoCallbackML(url);
    //alert(xml_ML);
    if (xml_ML!=null)
    {
        xml_ML.onreadystatechange=setallMLitems;
    }
	 }
	catch(oc)
	{
	    //alert('error');
	}
}
function DoCallbackML(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 setallMLitems()
{
    try
    {
        if (xml_ML.readyState==4)
	    {
	            if (xml_ML.status==200)
		        {
                    //alert(xml_ML.responseText);
                    var result = xml_ML.responseText;
                    //alert(result);
                    var VOLitems = "";
                    var VALitems = "";
                    var TRAitems = "";
                        
                    if(result!="")
                    {
                        //alert(result);
                        var temp = new Array();
                        var temp1 = new Array();
                        var temp2 = new Array();
                        temp = result.split('@');
                        //alert(temp[1]);                                            
                        if(temp[0].toString() == "Arabic")
                        {
                            VOLitems += "<table width=100% cellspacing=0  class=tab-tabe dir=rtl>";
                            VOLitems += "<tr >";
                            VOLitems += "<th align=right>الشركة</th>";
                            VOLitems += "<th align=right>آخر سعر</th>";                            
                            VOLitems += "<th align=right colspan=2>صافى التغير</th>";
                            VOLitems += "<th align=right>الحجم الكلي</th>";                            
                            VOLitems += "</tr>";                                                        
                            
                            VALitems += "<table width=100% cellspacing=0 class=tab-tabe dir=rtl>";
                            VALitems += "<tr >";
                            VALitems += "<th align=right>الشركة</th>";
                            VALitems += "<th align=right>آخر سعر</th>";                            
                            VALitems += "<th align=right colspan=2>صافى التغير</th>";
                            VALitems += "<th align=right>إجمالي القيمة</th>";                            
                            VALitems += "</tr>";
                            
                            TRAitems += "<table width=100% cellspacing=0 class=tab-tabe dir=rtl>";
                            TRAitems += "<tr >";
                            TRAitems += "<th align=right>الشركة</th>";
                            TRAitems += "<th align=right>آخر سعر</th>";                            
                            TRAitems += "<th align=right colspan=2>صافى التغير</th>";
                            TRAitems += "<th align=right>إجمالي قيمة</th>";                            
                            TRAitems += "</tr>";
                             
                            j = 1;                              
                            temp1 = temp[1].toString().split('#');
                            for(i = 0; i < 10; i++)
                            {
                                temp2 = temp1[i].toString().split(';');                                
                                if(j == 1)
                                {
                                    VOLitems += "<tr class=firstrow>";
                                    j = j + 1;
                                }
                                else
                                {
                                    VOLitems += "<tr class=secondrow>";
                                    j = 1;                                    
                                }
                                VOLitems += "<td class=tdHeading>"+temp2[1].toString()+"</td>";
                                VOLitems += "<td class=fontrow align=right>"+temp2[2].toString()+"</td>";
                                VOLitems += "<td><img src=../Images/"+temp2[5].toString()+".gif /></td>";                                
                                VOLitems += "<td class=fontrow dir=ltr align=right><font color="+temp2[6].toString()+">"+temp2[3].toString()+"</font></td>";
                                VOLitems += "<td class=fontrow align=right>"+temp2[4].toString()+"</td>";                                
                                VOLitems += "</tr>";
                            }
                            j = 1;
                            temp1 = temp[2].toString().split('#');
                            for(i = 0; i < 10; i++)
                            {
                                temp2 = temp1[i].toString().split(';');
                                if(j == 1)
                                {
                                    VALitems += "<tr class=firstrow>";
                                    j = j + 1;
                                }
                                else
                                {
                                    VALitems += "<tr class=secondrow>";
                                    j = 1;                                    
                                }
                                VALitems += "<td class=tdHeading>"+temp2[1].toString()+"</td>";                                
                                VALitems += "<td class=fontrow align=right>"+temp2[2].toString()+"</td>";
                                VALitems += "<td><img src=../Images/"+temp2[5].toString()+".gif /></td>";
                                VALitems += "<td class=fontrow align=right dir=ltr><font color="+temp2[6].toString()+">"+temp2[3].toString()+"</font></td>";
                                VALitems += "<td class=fontrow align=right dir=ltr>"+temp2[4].toString()+"</td>";                                
                                VALitems += "</tr>";
                            }
                            j = 1;
                            temp1 = temp[3].toString().split('#');
                            for(i = 0; i < 10; i++)
                            {
                                temp2 = temp1[i].toString().split(';');
                                if(j == 1)
                                {
                                    TRAitems += "<tr class=firstrow>";
                                    j = j + 1;
                                }
                                else
                                {
                                    TRAitems += "<tr class=secondrow>";
                                    j = 1;                                    
                                }                                
                                TRAitems += "<td class=tdHeading>"+temp2[1].toString()+"</td>";                                
                                TRAitems += "<td class=fontrow align=right>"+temp2[2].toString()+"</td>";
                                TRAitems += "<td><img src=../Images/"+temp2[5].toString()+".gif /></td>";
                                TRAitems += "<td class=fontrow align=right dir=ltr><font color="+temp2[6].toString()+">"+temp2[3].toString()+"</font></td>";
                                TRAitems += "<td class=fontrow align=right dir=ltr>"+temp2[4].toString()+"</td>";                                
                                TRAitems += "</tr>";
                            }
                        }
                        else
                        {
                            
                            VOLitems += "<table width=100% cellspacing=0 class=tab-tabe dir=ltr>";
                            VOLitems += "<tr >";
                            VOLitems += "<th>Company</th>";
                            VOLitems += "<th>L.Price</th>";                            
                            VOLitems += "<th colspan=2>Change</th>";
                            VOLitems += "<th>Volume</th>";                            
                            VOLitems += "</tr>";
                            
                            VALitems += "<table width=100% cellspacing=0 class=tab-tabe  dir=ltr>";
                            VALitems += "<tr >";
                            VALitems += "<th>Company</th>";
                            VALitems += "<th>L.Price</th>";                           
                            VALitems += "<th colspan=2>Change</th>";
                            VALitems += "<th>Value</th>";                            
                            VALitems += "</tr>";
                            
                            TRAitems += "<table width=100% cellspacing=0 class=tab-tabe dir=ltr>";
                            TRAitems += "<tr >";
                            TRAitems += "<th>Company</th>";
                            TRAitems += "<th>L.Price</th>";                            
                            TRAitems += "<th colspan=2>Change</th>";
                            TRAitems += "<th>Trade</th>";                            
                            TRAitems += "</tr>";
                                                                                                                
                            temp1 = temp[1].toString().split('#');
                            j = 1;
                            for(i = 0; i < 10; i++)
                            {
                                temp2 = temp1[i].toString().split(';');
                                if(j == 1)
                                {
                                    VOLitems += "<tr class=firstrow>";
                                    j = j + 1;
                                }
                                else
                                {
                                    VOLitems += "<tr class=secondrow>";
                                    j = 1;                                    
                                }
                                VOLitems += "<td class=tdHeading>"+temp2[0].toString()+"</td>";                                
                                VOLitems += "<td align=right>"+temp2[2].toString()+"</td>";
                                VOLitems += "<td><img src=../Images/"+temp2[5].toString()+".gif /></td>";                                
                                VOLitems += "<td align=right ><font color="+temp2[6].toString()+">"+temp2[3].toString()+"</font></td>";
                                VOLitems += "<td align=right>"+temp2[4].toString()+"</td>";                                
                                VOLitems += "</tr>";
                            }
                            j = 1;
                            temp1 = temp[2].toString().split('#');
                            for(i = 0; i < 10; i++)
                            {
                                temp2 = temp1[i].toString().split(';');
                                if(j == 1)
                                {
                                    VALitems += "<tr class=firstrow>";
                                    j = j + 1;
                                }
                                else
                                {
                                    VALitems += "<tr class=secondrow>";
                                    j = 1;                                    
                                }
                                VALitems += "<td class=tdHeading>"+temp2[0].toString()+"</td>";                                
                                VALitems += "<td align=right>"+temp2[2].toString()+"</td>";
                                VALitems += "<td><img src=../Images/"+temp2[5].toString()+".gif /></td>";
                                VALitems += "<td align=right><font color="+temp2[6].toString()+">"+temp2[3].toString()+"</font></td>";
                                VALitems += "<td align=right>"+temp2[4].toString()+"</td>";                                
                                VALitems += "</tr>";
                            }
                            j = 1;
                            temp1 = temp[3].toString().split('#');
                            for(i = 0; i < 10; i++)
                            {
                                temp2 = temp1[i].toString().split(';');
                                if(j == 1)
                                {
                                    TRAitems += "<tr class=firstrow>";
                                    j = j + 1;
                                }
                                else
                                {
                                    TRAitems += "<tr class=secondrow>";
                                    j = 1;                                    
                                }
                                TRAitems += "<td class=tdHeading>"+temp2[0].toString()+"</td>";                                
                                TRAitems += "<td align=right>"+temp2[2].toString()+"</td>";
                                TRAitems += "<td><img src=../Images/"+temp2[5].toString()+".gif /></td>";
                                TRAitems += "<td align=right><font color="+temp2[6].toString()+">"+temp2[3].toString()+"</font></td>";
                                TRAitems += "<td align=right>"+temp2[4].toString()+"</td>";                                
                                TRAitems += "</tr>";
                            }
                        }                       
                        //alert(MLitems);                            
                     
                    }
                    else
                    {
                    }
                    VOLitems += "</table>";
                    VALitems += "</table>";
                    TRAitems += "</table>";
                                   
                    document.getElementById('VOLDIV').innerHTML= VOLitems;
                    document.getElementById('VALDIV').innerHTML= VALitems;
                    document.getElementById('TRADIV').innerHTML= TRAitems;
                }
                else
                {
                    //alert('status');
                }
        }
        else
        {
            //alert('readyState');
        }       
    }
    catch(oc)
    {
        //alert(oc);
    }            
}