﻿//This java script file is used for fetching data from XML files and 
//binding that data to respective pages.

////////////////////////////// XML File Loading ///////////////////////////////
if(!icount)
{
var icount=4;
}
//Firefox only function - happens when a XML file is loaded
var isChrome = navigator.userAgent.indexOf("Chrome/");  
function loadHandler() 
{
    xmlProcessor(this); //Call the Common function with 'this' data.
}

//Load the xml file - using different method for different browsers
var xmlDocument;

function LoadXMLData(xml_file,dataId) 
{
    //debugger;
     //Initializations
    feed_id = 0;
    feed_total = 0;
    xmlDocument = "";
    feed_file = xml_file;
    
      if (xmlDocument == null)
      {
      alert ("Your browser does not support XMLHTTP!");
      return;
      } 
   
    //Following if statement is used for firefox and other bowsers
      if(navigator.appName!="Microsoft Internet Explorer")
{
    if(document.implementation && document.implementation.createDocument) 
    {   
         //xmlDocument = document.implementation.createDocument('', '', null);
        // xmlDocument.async=false;
                 
	    // var loadResult = xmlDocument.load(xml_file);
	    	    var loadResult;
         if(isChrome>-1)
{
var xmlhttpchrome = new window.XMLHttpRequest();
xmlhttpchrome.open("GET", xml_file, false);
xmlhttpchrome.send(null);
xmlDocument=xmlhttpchrome.responseXML.documentElement;
loadResult= xmlDocument;

}else
{
xmlDocument = document.implementation.createDocument('', '', null);
xmlDocument.async=false;
loadResult=xmlDocument.load(xml_file);

}  
         if (loadResult) 
         {
            if ((xml_file=="../XML/MCX-TopGainers.xml"))
            {
                xmlProcessorMCXTopGFireFox(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/NCDEX-TopGainers.xml"))
            {
                xmlProcessorNCDEXTopGFireFox(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/MCX-TopLosers.xml"))
            {
                xmlProcessorMCXTopLooserFireFox(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/NCDEX-TopLosers.xml"))
            {
                xmlProcessorNCDEXTopLooserFireFox(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/MCX-TopValues.xml"))
            {
                xmlProcessorMCXTopValueFireFox(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/NCDEX-TopValues.xml"))
            {
                xmlProcessorNCDEXTopValueFireFox(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/MCX-TopVolumes.xml"))
            {
                xmlProcessorMCXTopVolumeFireFox(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/NCDEX-TopVolumes.xml"))
            {
                xmlProcessorNCDEXTopVolumeFireFox(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/MarketNews.xml"))
            {
                xmlProcessorNewsFireFox(xmlDocument,xml_file)
            }
            else if((xml_file=="../XML/MCX-ListOfCommodity.xml"))
            {
                xmlProcessorMCXListFireFox(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/NCDEX-ListOfCommodity.xml"))
            {
                xmlProcessorNCDEXListFireFox(xmlDocument,xml_file,dataId)
            }
            
                        
        } 
        else 
        {
            xmlError();
            return false;
        }
        
    }//Main if closed
    }
    else //Following if statement is used for IE Browser 
    {
        xmlDocument="";
       	xmlDocument = new ActiveXObject("Microsoft.XMLDOM");
        xmlDocument.async = "false";
        xmlDocument.onreadystatechange=verify;
        
            
        var loadResult = xmlDocument.load(xml_file);
       //alert(xml_file);

        if (loadResult) 
        {
            if ((xml_file == "../XML/MCX-TopGainers.xml"))
            {
                xmlProcessorMCXTopG(xmlDocument,xml_file,dataId)
            }
            else if((xml_file == "../XML/NCDEX-TopGainers.xml"))
            {
                xmlProcessorNCDEXTopG(xmlDocument,xml_file,dataId)
            }
             else if((xml_file=="../XML/MCX-TopLosers.xml"))
            {
                xmlProcessorMCXTopLooser(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/NCDEX-TopLosers.xml"))
            {
                xmlProcessorNCDEXTopLooser(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/MCX-TopValues.xml"))
            {
                xmlProcessorMCXTopValue(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/NCDEX-TopValues.xml"))
            {
                xmlProcessorNCDEXTopValue(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/MCX-TopVolumes.xml"))
            {
                xmlProcessorMCXTopVolume(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/NCDEX-TopVolumes.xml"))
            {
                xmlProcessorNCDEXTopVolume(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/MarketNews.xml"))
            {
                xmlProcessorNews(xmlDocument,xml_file)
            }
            else if((xml_file=="../XML/MCX-ListOfCommodity.xml"))
            {
                xmlProcessorMCXList(xmlDocument,xml_file,dataId)
            }
            else if((xml_file=="../XML/NCDEX-ListOfCommodity.xml"))
            {
                xmlProcessorNCDEXList(xmlDocument,xml_file,dataId)
            }
            
            
        }//inner if close
        else 
        {
            xmlError();
            return false;
            
        }//inner else close
        
    }//main else close
    
}//function 

// Throwing Error
function xmlError() 
{
    //alert("Some error has occurred!")
}

function verify() 
{ 
    if(xmlDocument.readyState!=4)
    return false; 
}


function MM_openBrWindow(theURL)
{
    window.open(theURL,"mywindow","scrollbars=1,width=497,height=600");
}

function closepopup()
{
    window.close();
}
        
//-----------------------------------------------Top Gainers Start------------------------------------------------------------
//-----------------------------------------------Top Gainers Start------------------------------------------------------------
//following function is used to display Top 5 MCX Gainers on markets/commodity-markets.aspx page for IE
function xmlProcessorMCXTopG(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    // In case of IE
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        MainTag = xmlDoc.childNodes[1];
    }
    // not IE
    else
    {        
        MainTag = xmlDoc.childNodes[0];
    }
    
    MainTagLength = MainTag.childNodes.length;
    
    if(dataID == 0)
    {
        //taking top 5 data for MCX gainers
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GPChange="";
        var strHTML;
        
        if (xml_file=="../XML/MCX-TopGainers.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Gainers - MCX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>% Change</th>';
            
            for(var i = 0; i < MainTagLength; i++)
            {
            if(i<=icount)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                    GSymbol=MainTag.childNodes[i].childNodes[0].text;
                    GExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    GLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    GPChange=MainTag.childNodes[i].childNodes[9].text;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GPChange +' </td>';
                                    
                    strHTML += '</tr>';
                }//if close
                }
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-gainers.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopGainers.xml")
        {
            document.getElementById('ExchangeTopGainers').innerHTML=strHTML;
        }
    }//if for data id close
    else if(dataID == 1)
    {
        //taking all data for MCX top gainers 
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGPChange="";
        var strHTML;
        
        if(xml_file == "../XML/MCX-TopGainers.xml" )
        {
        
           //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag.childNodes[k].childNodes[11].text;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag.childNodes[maxPos].childNodes[10].text;
            
//            strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Gainers - MCX</center></h6>';
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Gainers - MCX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>% Change</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                if(i<=icount)
                {
                    AGSymbol=MainTag.childNodes[i].childNodes[0].text;
                    AGExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    AGLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    AGPreClose= new Number(MainTag.childNodes[i].childNodes[5].text);
                    AGHighPrice= new Number(MainTag.childNodes[i].childNodes[6].text);
                    AGLowPrice= new Number(MainTag.childNodes[i].childNodes[7].text);
                    AGPChange=MainTag.childNodes[i].childNodes[9].text;
                    
                    if(i%2 != 0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:14%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGPChange +'</td>';
                    
                    strHTML += '</tr>';
                    }
                    
                }//if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopGainers.xml")
        {
            document.getElementById('ExchangeAllGainers').innerHTML=strHTML;
        }
    }//else if for dataID close
    
     delete xmlDoc;
}
//Top 5 MCX gainers for markets/commodity-markets.aspx page for IE close

//following function is used to display Top 5 MCX Gainers on markets/commodity-markets.aspx page for FireFox
function xmlProcessorMCXTopGFireFox(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
        
    MainTag = xmlDoc.getElementsByTagName("Table");
    MainTagLength = MainTag.length;
    
    if(dataID == 0)
    {
        //taking data for MCX gainers
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GPChange="";
        var strHTML;
        
        if (xml_file=="../XML/MCX-TopGainers.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Gainers - MCX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>% Change</th>';
            
            for(var i = 0; i <MainTagLength; i++)
            {
             
             if(i<=icount)
             {
                //if(MainTag.childNodes[i].nodeName == "Table")
                //{
                    GSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    GExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    GLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    GPChange=MainTag[i].childNodes[19].childNodes[0].nodeValue;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GPChange +' </td>';
                                    
                    strHTML += '</tr>';
                    }else
                    {
                    break;
                    }
               // }//if close
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-gainers.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopGainers.xml")
        {
            document.getElementById('ExchangeTopGainers').innerHTML=strHTML;
        }
    }//if for dataID close
    else if(dataID == 1)
    {
        //taking all data for MCX top gainers 
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGPChange="";
        var strHTML;
        
        if(xml_file == "../XML/MCX-TopGainers.xml" )
        {
        
            //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag[k].childNodes[23].childNodes[0].nodeValue;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag[maxPos].childNodes[21].childNodes[0].nodeValue;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Gainers - MCX</center></h6>';
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Gainers - MCX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>% Change</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
                if(i<=icount)
                //if(MainTag.childNodes[i].nodeName == "Table")
                {
                    AGSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    AGExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    AGLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    AGPreClose= new Number(MainTag[i].childNodes[11].childNodes[0].nodeValue);
                    AGHighPrice= new Number(MainTag[i].childNodes[13].childNodes[0].nodeValue);
                    AGLowPrice= new Number(MainTag[i].childNodes[15].childNodes[0].nodeValue);
                    AGPChange=MainTag[i].childNodes[19].childNodes[0].nodeValue;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:14%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGPChange +'</td>';
                    
                    strHTML += '</tr>';
                    
                }else
                {
                break;
                }
                
                //if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopGainers.xml")
        {
            document.getElementById('ExchangeAllGainers').innerHTML=strHTML;
        }
    }//else if for dataID close
    
    
     delete xmlDoc;
}
//Top 5 MCX gainers for markets/commodity-markets.aspx page for FireFox close

//following function is used to display Top 5 NCDEX Gainers on markets/commodity-markets.aspx page for IE
function xmlProcessorNCDEXTopG(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    // In case of IE
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        MainTag = xmlDoc.childNodes[1];
    }
    // not IE
    else
    {        
        MainTag = xmlDoc.childNodes[0];
    }
    
    MainTagLength = MainTag.childNodes.length;
    
    
    if(dataID == 0)
    {
        //taking data for MCX gainers
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GPChange="";
        var strHTML;
        
        if (xml_file=="../XML/NCDEX-TopGainers.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Gainers - NCDEX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>% Change</th>';
            
            for(var i = 0; i < MainTagLength; i++)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                if(i<=icount)
                {
                    GSymbol=MainTag.childNodes[i].childNodes[0].text;
                    GExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    GLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    GPChange=MainTag.childNodes[i].childNodes[9].text;
                    
                    if(i == 1 || i == 3)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GPChange +' </td>';
                                    
                    strHTML += '</tr>';
                    }
                }//if close
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-gainers-ncdex.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopGainers.xml")
        {
            document.getElementById('ExchangeTopGainers').innerHTML=strHTML;
        }    
    
    }//if for dataId close
    else if(dataID == 1)
    {
        //taking all data for MCX top gainers 
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGPChange="";
        var strHTML;
        
        if(xml_file == "../XML/NCDEX-TopGainers.xml" )
        {
            //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag.childNodes[k].childNodes[11].text;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag.childNodes[maxPos].childNodes[10].text;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Gainers - NCDEX</center></h6>';
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Gainers - NCDEX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>% Change</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                if(i<=icount)
                {
                    AGSymbol=MainTag.childNodes[i].childNodes[0].text;
                    AGExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    AGLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    AGPreClose= new Number(MainTag.childNodes[i].childNodes[5].text);
                    AGHighPrice= new Number(MainTag.childNodes[i].childNodes[6].text);
                    AGLowPrice= new Number(MainTag.childNodes[i].childNodes[7].text);
                    AGPChange=MainTag.childNodes[i].childNodes[9].text;
                    
                    if(i%2 != 0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:14%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGPChange +'</td>';
                    
                    strHTML += '</tr>';
                    }
                    
                }//if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopGainers.xml")
        {
            document.getElementById('ExchangeAllGainers').innerHTML=strHTML;
        }
    }//else if for data is close
    
     delete xmlDoc;
}
//Top 5 NCDEX gainers for markets/commodity-markets.aspx page for IE close

//following function is used to display Top 5 NCDEX Gainers on markets/commodity-markets.aspx page for FireFox
function xmlProcessorNCDEXTopGFireFox(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
        
    MainTag = xmlDoc.getElementsByTagName("Table");
    MainTagLength = MainTag.length;
    
    if(dataID == 0)
    {
        
        //taking data for MCX gainers
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GPChange="";
        var strHTML;
        
        if (xml_file=="../XML/NCDEX-TopGainers.xml")
        {
          try
          {
            strHTML += '<center><span class=spanHeader>Top Gainers - NCDEX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>% Change</th>';
            
            for(var i = 0; i <MainTagLength; i++)
            {
                //if(MainTag.childNodes[i].nodeName == "Table")
                if(i<=icount)
                {
                    GSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    GExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    GLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    GPChange=MainTag[i].childNodes[19].childNodes[0].nodeValue;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GPChange +' </td>';
                                    
                    strHTML += '</tr>';
                }else
                {
                break;
                }
                
                //if close
                
            }//for loop close
            
            }catch(e)
            {
          //  alert(e);
            }
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-gainers-ncdex.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopGainers.xml")
        {
            document.getElementById('ExchangeTopGainers').innerHTML=strHTML;
        }
        
    }//if for dataID close
    else if(dataID == 1)
    {
        //taking all data for MCX top gainers 
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGPChange="";
        var strHTML;
        
        if(xml_file == "../XML/NCDEX-TopGainers.xml" )
        {
        
             //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag[k].childNodes[23].childNodes[0].nodeValue;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag[maxPos].childNodes[21].childNodes[0].nodeValue;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Gainers - NCDEX</center></h6>';
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Gainers - NCDEX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>% Change</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
                if(i<=icount)
                //if(MainTag.childNodes[i].nodeName == "Table")
                {
                    AGSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    AGExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    AGLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    AGPreClose= new Number(MainTag[i].childNodes[11].childNodes[0].nodeValue);
                    AGHighPrice= new Number(MainTag[i].childNodes[13].childNodes[0].nodeValue);
                    AGLowPrice= new Number(MainTag[i].childNodes[15].childNodes[0].nodeValue);
                    AGPChange=MainTag[i].childNodes[19].childNodes[0].nodeValue;
                    
                    if(i%2!=0 )
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:14%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGPChange +'</td>';
                    
                    strHTML += '</tr>';
                    
                }else
                {
                break;
                }
                
                //if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopGainers.xml")
        {
            document.getElementById('ExchangeAllGainers').innerHTML=strHTML;
        }
    }//else if for DataId close
    
    
     delete xmlDoc;
}
//Top 5 NCDEX gainers for markets/commodity-markets.aspx page for FireFox close

//-----------------------------------------------------Top Gainers Close----------------------------------------------
//-----------------------------------------------------Top Gainers Close----------------------------------------------


//-----------------------------------------------------Top Losers start-----------------------------------------------
//-----------------------------------------------------Top Losers start-----------------------------------------------

//following function is used to display Top 5 MCX Loosers on markets/commodity-markets.aspx page for IE
function xmlProcessorMCXTopLooser(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    // In case of IE
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        MainTag = xmlDoc.childNodes[1];
    }
    // not IE
    else
    {        
        MainTag = xmlDoc.childNodes[0];
    }
    
    MainTagLength = MainTag.childNodes.length;
    
    if(dataID == 0)
    {
        //taking data for MCX gainers
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GPChange="";
        var strHTML;
    
        if (xml_file=="../XML/MCX-TopLosers.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Losers - MCX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>% Change</th>';
            
            for(var i = 0; i < MainTagLength; i++)
            {
            if(i<=icount)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                    GSymbol=MainTag.childNodes[i].childNodes[0].text;
                    GExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    GLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    GPChange=MainTag.childNodes[i].childNodes[9].text;
                    
                    if(i == 1 || i == 3)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GPChange +' </td>';
                                    
                    strHTML += '</tr>';
                }//if close
                }
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-losers.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopLosers.xml")
        {
            document.getElementById('ExchangeTopLosers').innerHTML=strHTML;
        }    
    }//data Id if close
    else if(dataID == 1 )
    {
        //taking all data for MCX top gainers 
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGPChange="";
        var strHTML;
        
        if(xml_file == "../XML/MCX-TopLosers.xml" )
        {
        
           //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag.childNodes[k].childNodes[11].text;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag.childNodes[maxPos].childNodes[10].text;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Losers - MCX</center></h6>';
            
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Losers - MCX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>% Change</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                   if(i<=icount)
                   {
                    AGSymbol=MainTag.childNodes[i].childNodes[0].text;
                    AGExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    AGLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    AGPreClose= new Number(MainTag.childNodes[i].childNodes[5].text);
                    AGHighPrice= new Number(MainTag.childNodes[i].childNodes[6].text);
                    AGLowPrice= new Number(MainTag.childNodes[i].childNodes[7].text);
                    AGPChange=MainTag.childNodes[i].childNodes[9].text;
                    
                    if(i%2 != 0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:14%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGPChange +'</td>';
                    
                    strHTML += '</tr>';
                    }
                    
                }//if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopLosers.xml")
        {
            document.getElementById('ExchangeAllLosers').innerHTML=strHTML;
        }
    }//Else if for data ID close
    
    
     delete xmlDoc;
}
//Top 5 MCX Losers for markets/commodity-markets.aspx page for IE close

//following function is used to display Top 5 MCX Losers on markets/commodity-markets.aspx page for FireFox
function xmlProcessorMCXTopLooserFireFox(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
        
    MainTag = xmlDoc.getElementsByTagName("Table");
    MainTagLength = MainTag.length;
    
    
    if(dataID == 0)
    {
        //taking data for MCX gainers
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GPChange="";
        var strHTML;
    
        if (xml_file=="../XML/MCX-TopLosers.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Losers - MCX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>% Change</th>';
            
            for(var i = 0; i <MainTagLength; i++)
            {
               // if(MainTag.childNodes[i].nodeName == "Table")
               if(i<=icount)
                {
                    GSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    GExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    GLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    GPChange=MainTag[i].childNodes[19].childNodes[0].nodeValue;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GPChange +' </td>';
                                    
                    strHTML += '</tr>';
                }else
                {
                break;
                }
                
                //if close
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-losers.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopLosers.xml")
        {
            document.getElementById('ExchangeTopLosers').innerHTML=strHTML;
        }    
    }//If for data id close
    else if(dataID == 1)
    {
            
        //taking all data for MCX top gainers 
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGPChange="";
        var strHTML;
        
        if(xml_file == "../XML/MCX-TopLosers.xml" )
        {
        
            //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag[k].childNodes[23].childNodes[0].nodeValue;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag[maxPos].childNodes[21].childNodes[0].nodeValue;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Losers - MCX</center></h6>';
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Losers - MCX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
                        
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>% Change</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
            if(i<=icount)
                //if(MainTag.childNodes[i].nodeName == "Table")
                {
                    AGSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    AGExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    AGLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    AGPreClose= new Number(MainTag[i].childNodes[11].childNodes[0].nodeValue);
                    AGHighPrice= new Number(MainTag[i].childNodes[13].childNodes[0].nodeValue);
                    AGLowPrice= new Number(MainTag[i].childNodes[15].childNodes[0].nodeValue);
                    AGPChange=MainTag[i].childNodes[19].childNodes[0].nodeValue;
                    
                    if(i%2!=0 )
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else 
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:14%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGPChange +'</td>';
                    
                    strHTML += '</tr>';
                    
                }else
                {
                break;
                }
                
                //if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopLosers.xml")
        {
            document.getElementById('ExchangeAllLosers').innerHTML=strHTML;
        }
    
    }//else if for data id close
    
    delete xmlDoc;
}
//Top 5 MCX Losers for markets/commodity-markets.aspx page for FireFox close

//following function is used to display Top 5 NCDEX Losers on markets/commodity-markets.aspx page for IE
function xmlProcessorNCDEXTopLooser(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    // In case of IE
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        MainTag = xmlDoc.childNodes[1];
    }
    // not IE
    else
    {        
        MainTag = xmlDoc.childNodes[0];
    }
    
    MainTagLength = MainTag.childNodes.length;
    
    if(dataID == 0)
    {
           
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GPChange="";
        var strHTML;
        
        if (xml_file=="../XML/NCDEX-TopLosers.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Losers - NCDEX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>% Change</th>';
            
            for(var i = 0; i < MainTagLength; i++)
            {
               
               if(i<=icount)
               {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                if(i<=icount)
                {
                    GSymbol=MainTag.childNodes[i].childNodes[0].text;
                    GExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    GLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    GPChange=MainTag.childNodes[i].childNodes[9].text;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GPChange +' </td>';
                                    
                    strHTML += '</tr>';
                    }
                }//if close
                }
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-losers-ncdex.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopLosers.xml")
        {
            document.getElementById('ExchangeTopLosers').innerHTML=strHTML;
        } 
    }//If for DataId close
    else if(dataID == 1)
    {
            
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGPChange="";
        var strHTML;
        
        if(xml_file == "../XML/NCDEX-TopLosers.xml" )
        {
        
           //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag.childNodes[k].childNodes[11].text;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag.childNodes[maxPos].childNodes[10].text;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Losers - NCDEX</center></h6>';
            
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Losers - NCDEX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>% Change</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                if(i<=icount)
                {
                    AGSymbol=MainTag.childNodes[i].childNodes[0].text;
                    AGExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    AGLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    AGPreClose= new Number(MainTag.childNodes[i].childNodes[5].text);
                    AGHighPrice= new Number(MainTag.childNodes[i].childNodes[6].text);
                    AGLowPrice= new Number(MainTag.childNodes[i].childNodes[7].text);
                    AGPChange=MainTag.childNodes[i].childNodes[9].text;
                    
                    if(i%2 != 0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:14%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGPChange +'</td>';
                    
                    strHTML += '</tr>';
                    }
                    
                }//if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopLosers.xml")
        {
            document.getElementById('ExchangeAllLosers').innerHTML=strHTML;
        }
    }//else if for data id close
    
    
     delete xmlDoc;
}
//Top 5 NCDEX Losers for markets/commodity-markets.aspx page for IE close

//following function is used to display Top 5 NCDEX Losers on markets/commodity-markets.aspx page for FireFox
function xmlProcessorNCDEXTopLooserFireFox(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
        
    MainTag = xmlDoc.getElementsByTagName("Table");
    MainTagLength = MainTag.length;
    
    if(dataID == 0)
    {
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GPChange="";
        var strHTML;
        
        if (xml_file=="../XML/NCDEX-TopLosers.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Losers - NCDEX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>% Change</th>';
            
            for(var i = 1; i <MainTagLength; i++)
            {
            if(i<=icount)
                //if(MainTag.childNodes[i].nodeName == "Table")
                {
                    GSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    GExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    GLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    GPChange=MainTag[i].childNodes[19].childNodes[0].nodeValue;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GPChange +' </td>';
                                    
                    strHTML += '</tr>';
                }else
                {
                break;
                }
                
                //if close
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-losers-ncdex.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopLosers.xml")
        {
            document.getElementById('ExchangeTopLosers').innerHTML=strHTML;
        }        
    }//if for data id close
    else if (dataID == 1)
    {
         //taking all data for MCX top gainers 
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGPChange="";
        var strHTML;
        
        if(xml_file == "../XML/NCDEX-TopLosers.xml" )
        {
        
            //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag[k].childNodes[23].childNodes[0].nodeValue;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag[maxPos].childNodes[21].childNodes[0].nodeValue;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Losers - NCDEX</center></h6>';
            
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Losers - NCDEX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>% Change</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
                //if(MainTag[i].nodeName == "Table")
               // {
                if(i<=icount)
                {
                    AGSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    AGExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    AGLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    AGPreClose= new Number(MainTag[i].childNodes[11].childNodes[0].nodeValue);
                    AGHighPrice= new Number(MainTag[i].childNodes[13].childNodes[0].nodeValue);
                    AGLowPrice= new Number(MainTag[i].childNodes[15].childNodes[0].nodeValue);
                    AGPChange=MainTag[i].childNodes[19].childNodes[0].nodeValue;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:14%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGPChange +'</td>';
                    
                    strHTML += '</tr>';
                    }
                    
              //  }//if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopLosers.xml")
        {
            document.getElementById('ExchangeAllLosers').innerHTML=strHTML;
        }

    }//else if for data id close
    
    
     delete xmlDoc;
}
//Top 5 NCDEX gainers for markets/commodity-markets.aspx page for FireFox close
//-----------------------------------------------------Top Losers close-----------------------------------------------
//-----------------------------------------------------Top Losers close-----------------------------------------------


//-----------------------------------------------------Top Value start-----------------------------------------------
//-----------------------------------------------------Top Value start-----------------------------------------------


//following function is used to display Top 5 MCX Top Values on markets/commodity-markets.aspx page for IE
function xmlProcessorMCXTopValue(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    // In case of IE
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        MainTag = xmlDoc.childNodes[1];
    }
    // not IE
    else
    {        
        MainTag = xmlDoc.childNodes[0];
    }
    
    MainTagLength = MainTag.childNodes.length;
    
    if(dataID == 0)
    {
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GValue="";
        var strHTML;
        
        if (xml_file=="../XML/MCX-TopValues.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Value - MCX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Value in Lakhs</th>';
            
            for(var i = 0; i < MainTagLength; i++)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                if(i<=icount)
                {
                    GSymbol=MainTag.childNodes[i].childNodes[0].text;
                    GExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    GLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    GValue=MainTag.childNodes[i].childNodes[8].text;
                    
                    if(i == 1 || i == 3)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GValue +' </td>';
                                    
                    strHTML += '</tr>';
                    }
                }//if close
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-values.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopValues.xml")
        {
            document.getElementById('ExchangeTopValue').innerHTML=strHTML;
        }
    }//If for data id close.
    else if(dataID == 1)
    {
         
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGValues="";
        var strHTML;
        
        if(xml_file == "../XML/MCX-TopValues.xml" )
        {
        
           //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag.childNodes[k].childNodes[10].text;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag.childNodes[maxPos].childNodes[9].text;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Value - MCX</center></h6>';
            
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Value - MCX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>Value (in lakhs)</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                if(i<=icount)
                {
                    AGSymbol=MainTag.childNodes[i].childNodes[0].text;
                    AGExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    AGLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    AGPreClose= new Number(MainTag.childNodes[i].childNodes[5].text);
                    AGHighPrice= new Number(MainTag.childNodes[i].childNodes[6].text);
                    AGLowPrice= new Number(MainTag.childNodes[i].childNodes[7].text);
                    AGValues=MainTag.childNodes[i].childNodes[8].text;
                    
                    if(i%2 != 0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:13%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:11%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:10%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGValues +'</td>';
                    
                    strHTML += '</tr>';
                    }
                    
                }//if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopValues.xml")
        {
            document.getElementById('ExchangeAllValues').innerHTML=strHTML;
        }

    }//else if for data id close
        
    
     delete xmlDoc;
}
//Top 5 MCX Top Values for markets/commodity-markets.aspx page for IE close

//following function is used to display Top 5 MCX Top Value on markets/commodity-markets.aspx page for FireFox
function xmlProcessorMCXTopValueFireFox(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
        
    MainTag = xmlDoc.getElementsByTagName("Table");
    MainTagLength = MainTag.length;
    
    
    if(dataID == 0)
    {
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GValue="";
        var strHTML;
        
        if (xml_file=="../XML/MCX-TopValues.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Value - MCX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Value in Lakhs</th>';
            
            for(var i = 0; i <MainTagLength; i++)
            {
                if(i<=icount)
                //if(MainTag.childNodes[i].nodeName == "Table")
                {
                    GSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    GExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    GLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    GValue=MainTag[i].childNodes[17].childNodes[0].nodeValue;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GValue +' </td>';
                                    
                    strHTML += '</tr>';
                }else{
                
                break;
                }
                
                //if close
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-values.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopValues.xml")
        {
            document.getElementById('ExchangeTopValue').innerHTML=strHTML;
        }
    }//if for data id close
    else if(dataID == 1)
    {
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGValue="";
        var strHTML;
        
        if(xml_file == "../XML/MCX-TopValues.xml" )
        {
        
            //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag[k].childNodes[21].childNodes[0].nodeValue;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag[maxPos].childNodes[19].childNodes[0].nodeValue;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Value - MCX</center></h6>';
            
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Value - MCX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>Value (in lakhs)</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
               if(i<=icount)
               // if(MainTag.childNodes[i].nodeName == "Table")
                {
                    AGSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    AGExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    AGLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    AGPreClose= new Number(MainTag[i].childNodes[11].childNodes[0].nodeValue);
                    AGHighPrice= new Number(MainTag[i].childNodes[13].childNodes[0].nodeValue);
                    AGLowPrice= new Number(MainTag[i].childNodes[15].childNodes[0].nodeValue);
                    AGValue=MainTag[i].childNodes[17].childNodes[0].nodeValue;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:13%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:11%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:10%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGValue +'</td>';
                    
                    strHTML += '</tr>';
                    
                }//if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopValues.xml")
        {
            document.getElementById('ExchangeAllValues').innerHTML=strHTML;
        }

    }//else if for dataid close
    
    
     delete xmlDoc;
}
//Top 5 MCX Top Value for markets/commodity-markets.aspx page for FireFox close

//following function is used to display Top 5 NCDEX Top value on markets/commodity-markets.aspx page for IE
function xmlProcessorNCDEXTopValue(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    // In case of IE
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        MainTag = xmlDoc.childNodes[1];
    }
    // not IE
    else
    {        
        MainTag = xmlDoc.childNodes[0];
    }
    
    MainTagLength = MainTag.childNodes.length;
    
    if(dataID == 0)
    {
            var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GValue="";
        var strHTML;
        
        if (xml_file=="../XML/NCDEX-TopValues.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Value - NCDEX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Value in Lakhs</th>';
            
            for(var i = 0; i < MainTagLength; i++)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                   if(i<=icount)
                   {
                    GSymbol=MainTag.childNodes[i].childNodes[0].text;
                    GExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    GLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    GValue=MainTag.childNodes[i].childNodes[8].text;
                    
                    if(i == 1 || i == 3)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GValue +' </td>';
                                    
                    strHTML += '</tr>';
                    }
                }//if close
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-values-ncdex.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopValues.xml")
        {
            document.getElementById('ExchangeTopValue').innerHTML=strHTML;
        }
    }//If for data Id close
    else if(dataID == 1)
    {
           var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGValues="";
        var strHTML;
        
        if(xml_file == "../XML/NCDEX-TopValues.xml" )
        {
        
           //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag.childNodes[k].childNodes[10].text;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag.childNodes[maxPos].childNodes[9].text;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Value - NCDEX</center></h6>';
            
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Value - NCDEX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>Value (in lakhs)</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                if(i<=icount)
                {
                    AGSymbol=MainTag.childNodes[i].childNodes[0].text;
                    AGExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    AGLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    AGPreClose= new Number(MainTag.childNodes[i].childNodes[5].text);
                    AGHighPrice= new Number(MainTag.childNodes[i].childNodes[6].text);
                    AGLowPrice= new Number(MainTag.childNodes[i].childNodes[7].text);
                    AGValues=MainTag.childNodes[i].childNodes[8].text;
                    
                    if(i%2 != 0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:13%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:11%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:10%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGValues +'</td>';
                    
                    strHTML += '</tr>';
                    }
                    
                }//if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopValues.xml")
        {
            document.getElementById('ExchangeAllValues').innerHTML=strHTML;
        }
    }//else if for data id close
    
     delete xmlDoc;
}
//Top 5 NCDEX Top Value for markets/commodity-markets.aspx page for IE close

//following function is used to display Top 5 NCDEX Top Value on markets/commodity-markets.aspx page for FireFox
function xmlProcessorNCDEXTopValueFireFox(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
        
    MainTag = xmlDoc.getElementsByTagName("Table");
    MainTagLength = MainTag.length;
    
    if(dataID == 0)
    {
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GValue="";
        var strHTML;
        
        if (xml_file=="../XML/NCDEX-TopValues.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Value - NCDEX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Value in Lakhs</th>';
            
            for(var i = 0; i <MainTagLength; i++)
            {
            if(i<=icount)
               // if(MainTag.childNodes[i].nodeName == "Table")
                {
                    GSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    GExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    GLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    GValue=MainTag[i].childNodes[17].childNodes[0].nodeValue;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else 
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GValue +' </td>';
                                    
                    strHTML += '</tr>';
                }else
                {
                break;
                }
                
                //if close
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-values-ncdex.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopValues.xml")
        {
            document.getElementById('ExchangeTopValue').innerHTML=strHTML;
        }
            
    }//If for dataId close
    else if(dataID == 1)
    {
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGValue="";
        var strHTML;
        
        if(xml_file == "../XML/NCDEX-TopValues.xml" )
        {
        
            //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag[k].childNodes[21].childNodes[0].nodeValue;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag[maxPos].childNodes[19].childNodes[0].nodeValue;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Value - NCDEX</center></h6>';
            
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Value - NCDEX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>Value (in lakhs)</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
               if(i<=icount)
               // if(MainTag.childNodes[i].nodeName == "Table")
                {
                    AGSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    AGExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    AGLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    AGPreClose= new Number(MainTag[i].childNodes[11].childNodes[0].nodeValue);
                    AGHighPrice= new Number(MainTag[i].childNodes[13].childNodes[0].nodeValue);
                    AGLowPrice= new Number(MainTag[i].childNodes[15].childNodes[0].nodeValue);
                    AGValue=MainTag[i].childNodes[17].childNodes[0].nodeValue;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:13%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:11%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:10%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGValue +'</td>';
                    
                    strHTML += '</tr>';
                    
                }else
                {
                break;
                }
                
                //if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopValues.xml")
        {
            document.getElementById('ExchangeAllValues').innerHTML=strHTML;
        }

    }//else if for data id close
    
     delete xmlDoc;
}
//Top 5 NCDEX Top Value for markets/commodity-markets.aspx page for FireFox close

//-----------------------------------------------------Top Value close-----------------------------------------------
//-----------------------------------------------------Top Value close-----------------------------------------------


//-----------------------------------------------------Top Volume start-----------------------------------------------
//-----------------------------------------------------Top Volume start-----------------------------------------------

//following function is used to display Top 5 MCX Top Volume on markets/commodity-markets.aspx page for IE
function xmlProcessorMCXTopVolume(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    // In case of IE
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        MainTag = xmlDoc.childNodes[1];
    }
    // not IE
    else
    {        
        MainTag = xmlDoc.childNodes[0];
    }
    
    MainTagLength = MainTag.childNodes.length;
    
    
    if(dataID == 0)
    {
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GVolume="";
        var strHTML;
        
        if (xml_file=="../XML/MCX-TopVolumes.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Volume - MCX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Volume</th>';
            
            for(var i = 0; i < MainTagLength; i++)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                if(i<=icount)
                {
                    GSymbol=MainTag.childNodes[i].childNodes[0].text;
                    GExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    GLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    GVolume=MainTag.childNodes[i].childNodes[8].text;
                    
                    if(i == 1 || i == 3)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GVolume +' </td>';
                                    
                    strHTML += '</tr>';
                    }
                }//if close
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-volume.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopVolumes.xml")
        {
            document.getElementById('ExchangeTopVolume').innerHTML=strHTML;
        }    
    }//If for Data id close
    else if(dataID == 1)
    {
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGValues="";
        var strHTML;
        
        if(xml_file == "../XML/MCX-TopVolumes.xml" )
        {
        
           //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag.childNodes[k].childNodes[10].text;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag.childNodes[maxPos].childNodes[9].text;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Volume - MCX</center></h6>';
            
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Volume - MCX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>Volume</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                if(i<=icount)
                {
                    AGSymbol=MainTag.childNodes[i].childNodes[0].text;
                    AGExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    AGLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    AGPreClose= new Number(MainTag.childNodes[i].childNodes[5].text);
                    AGHighPrice= new Number(MainTag.childNodes[i].childNodes[6].text);
                    AGLowPrice= new Number(MainTag.childNodes[i].childNodes[7].text);
                    AGValues=MainTag.childNodes[i].childNodes[8].text;
                    
                    if(i%2 != 0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:14%; >'+ AGValues +'</td>';
                    
                    strHTML += '</tr>';
                    }
                    
                }//if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopVolumes.xml")
        {
            document.getElementById('ExchangeAllVolume').innerHTML=strHTML;
        }

    }//Else if for data id close
    
    
     delete xmlDoc;
}
//Top 5 MCX Top Volume for markets/commodity-markets.aspx page for IE close

//following function is used to display Top 5 MCX Top Volume on markets/commodity-markets.aspx page for FireFox
function xmlProcessorMCXTopVolumeFireFox(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
        
    MainTag = xmlDoc.getElementsByTagName("Table");
    MainTagLength = MainTag.length;
    
    if(dataID == 0)
    {
    
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GVolume="";
        var strHTML;
        
        if (xml_file=="../XML/MCX-TopVolumes.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Volume - MCX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Volume</th>';
            
            for(var i = 0; i <MainTagLength; i++)
            {
            if(i<=icount)
                //if(MainTag.childNodes[i].nodeName == "Table")
                {
                    GSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    GExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    GLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    GVolume=MainTag[i].childNodes[17].childNodes[0].nodeValue;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else 
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GVolume +' </td>';
                                    
                    strHTML += '</tr>';
                }else
                {
                break;
                }
                
                //if close
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-volume.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopVolumes.xml")
        {
            document.getElementById('ExchangeTopVolume').innerHTML=strHTML;
        }
    }//if for data id close
    else if(dataID ==1)
    {
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGValue="";
        var strHTML;
        
        if(xml_file == "../XML/MCX-TopVolumes.xml" )
        {
        
            //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag[k].childNodes[21].childNodes[0].nodeValue;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag[maxPos].childNodes[19].childNodes[0].nodeValue;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Volume - MCX</center></h6>';
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Volume - MCX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>Volume</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
               if(i<=icount)
                //if(MainTag.childNodes[i].nodeName == "Table")
                {
                    AGSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    AGExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    AGLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    AGPreClose= new Number(MainTag[i].childNodes[11].childNodes[0].nodeValue);
                    AGHighPrice= new Number(MainTag[i].childNodes[13].childNodes[0].nodeValue);
                    AGLowPrice= new Number(MainTag[i].childNodes[15].childNodes[0].nodeValue);
                    AGValue=MainTag[i].childNodes[17].childNodes[0].nodeValue;
                    
                    if(i%2!=0 )
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else 
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:14%; >'+ AGValue +'</td>';
                    
                    strHTML += '</tr>';
                    
                }else
                {
                break;
                }
                
                //if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/MCX-TopVolumes.xml")
        {
            document.getElementById('ExchangeAllVolume').innerHTML=strHTML;
        }

        
    }//Else if for data id close.
    
     delete xmlDoc;
}
//Top 5 MCX Top Volume for markets/commodity-markets.aspx page for FireFox close

//following function is used to display Top 5 NCDEX Top Volume on markets/commodity-markets.aspx page for IE
function xmlProcessorNCDEXTopVolume(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    // In case of IE
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        MainTag = xmlDoc.childNodes[1];
    }
    // not IE
    else
    {        
        MainTag = xmlDoc.childNodes[0];
    }
    
    MainTagLength = MainTag.childNodes.length;
    
    if(dataID == 0)
    {
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GVolume="";
        var strHTML;
        
        if (xml_file=="../XML/NCDEX-TopVolumes.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Volume - NCDEX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Volume</th>';
            
            for(var i = 0; i < MainTagLength; i++)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                if(i<=icount)
                {
                    GSymbol=MainTag.childNodes[i].childNodes[0].text;
                    GExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    GLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    GVolume=MainTag.childNodes[i].childNodes[8].text;
                    
                    if(i == 1 || i == 3)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GVolume +' </td>';
                                    
                    strHTML += '</tr>';
                    }
                }//if close
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-volume-ncdex.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopVolumes.xml")
        {
            document.getElementById('ExchangeTopVolume').innerHTML=strHTML;
        }
    }//if for Data id close
    else if(dataID == 1)
    {
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGValues="";
        var strHTML;
        
        if(xml_file == "../XML/NCDEX-TopVolumes.xml" )
        {
        
           //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag.childNodes[k].childNodes[10].text;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag.childNodes[maxPos].childNodes[9].text;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Volume - NCDEX</center></h6>';
            
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Volume - NCDEX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>Volume</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                if(i<=icount)
                {
                    AGSymbol=MainTag.childNodes[i].childNodes[0].text;
                    AGExpiryDate=MainTag.childNodes[i].childNodes[3].text;
                    AGLTP= new Number(MainTag.childNodes[i].childNodes[4].text);
                    AGPreClose= new Number(MainTag.childNodes[i].childNodes[5].text);
                    AGHighPrice= new Number(MainTag.childNodes[i].childNodes[6].text);
                    AGLowPrice= new Number(MainTag.childNodes[i].childNodes[7].text);
                    AGValues=MainTag.childNodes[i].childNodes[8].text;
                    
                    if(i%2 != 0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:14%; >'+ AGValues +'</td>';
                    
                    strHTML += '</tr>';
                    }
                    
                }//if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopVolumes.xml")
        {
            document.getElementById('ExchangeAllVolume').innerHTML=strHTML;
        }
    }//else if for data id close
    
     delete xmlDoc;
}
//Top 5 NCDEX Top Volume for markets/commodity-markets.aspx page for IE close

//following function is used to display Top 5 NCDEX Top Volume on markets/commodity-markets.aspx page for FireFox
function xmlProcessorNCDEXTopVolumeFireFox(xmlDoc,xml_file,dataID)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
        
    MainTag = xmlDoc.getElementsByTagName("Table");
    MainTagLength = MainTag.length;
    
    if(dataID == 0)
    {
        var GSymbol = "";
        var GExpiryDate = "";
        var GLTP="";
        var GVolume="";
        var strHTML;
        
        if (xml_file=="../XML/NCDEX-TopVolumes.xml")
        {
            strHTML += '<center><span class=spanHeader>Top Volume - NCDEX</span></center>';
            strHTML += '<table width="100%" id="Grid_View" >';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Volume</th>';
            
            for(var i = 0; i <MainTagLength; i++)
            {
               if(i<=icount)
               // if(MainTag.childNodes[i].nodeName == "Table")
                {
                    GSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    GExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    GLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    GVolume=MainTag[i].childNodes[17].childNodes[0].nodeValue;
                    
                    if(i%2!=0)
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                    
                    strHTML += '<td style=width:25%; >' + GSymbol +' </td>';
                    strHTML += '<td style=width:25%; >' + GExpiryDate +' </td>';
                    strHTML += '<td style=width:25%; >' + GLTP.toFixed(2) +' </td>';
                    strHTML += '<td style=width:25%; >' + GVolume +' </td>';
                                    
                    strHTML += '</tr>';
                }else
                {
                break;
                }
                
                //if close
                
            }//for loop close
        }//XML if close
        strHTML += '<tr>';
        strHTML += '<td colspan=4 class=more style=text-align:right;><a href="top-volume-ncdex.aspx">More</a></td>';
        strHTML += '</tr>';
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopVolumes.xml")
        {
            document.getElementById('ExchangeTopVolume').innerHTML=strHTML;
        }    
    }//if for data id close
    else if(dataID == 1)
    {
        var AGSymbol = "";
        var AGExpiryDate = "";
        var AGLTP="";
        var AGPreClose="";
        var AGHighPrice="";
        var AGLowPrice="";
        var AGValue="";
        var strHTML;
        
        if(xml_file == "../XML/NCDEX-TopVolumes.xml" )
        {
        
            //Following lines of code is used to compare two time and take out max date
            var allTime=new Array();
            var k=0;
            var AGMaxDate="";
            var AGDate1="";
            var maxTime=0;
            var sec1="";
            var maxPos;
            
            //Following for loop is used to fill array with seconds           
            for(k=0;k<MainTagLength;k++)
            {
                AGDate1=MainTag[k].childNodes[21].childNodes[0].nodeValue;
                sec1=( AGDate1.split(":")[0] * 3600 )+( AGDate1.split(":")[1] * 60 );
                allTime[k]=sec1
            }
            //Following for loop is used to find max value of array
            for(k=0; k < allTime.length; k++)
            {
                if(allTime[k]>maxTime)
                {
                    maxTime=allTime[k];
                }
            }
            //Following for loop is used to get max value array position
            for(k=0; k< allTime.length; k++)
            {
                if(maxTime==allTime[k])
                {
                    maxPos=k;
                }
            }
            

            AGMaxDate=MainTag[maxPos].childNodes[19].childNodes[0].nodeValue;
            
            //strHTML += '<h4>'+ AGMaxDate +'</h4><h6><center>Top Volume - NCDEX</center></h6>';
            
            strHTML += '<table width=100% cellpadding=0 cellspacing=1 border=0>';
            strHTML += '<tr><td class=MarketTopHeading style=width:60%;text-align:right>Top Volume - NCDEX</td><td style=width:40%;text-align:right>'+ AGMaxDate+'</td></tr>';
            strHTML += '</table>';
            
            strHTML += '<table width=100% class=Grid_View cellpadding=0 cellspacing=1>';
            strHTML += '<th>Symbol</th><th>Expiry Date</th><th>LTP</th><th>Previous Close</th><th>High Price</th><th>Low Price</th><th>Volume</th>';
            
            for (var i=0; i < MainTagLength; i++)
            {
            if(i<=icount)
                //if(MainTag.childNodes[i].nodeName == "Table")
                {
                    AGSymbol=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                    AGExpiryDate=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                    AGLTP= new Number(MainTag[i].childNodes[9].childNodes[0].nodeValue);
                    AGPreClose= new Number(MainTag[i].childNodes[11].childNodes[0].nodeValue);
                    AGHighPrice= new Number(MainTag[i].childNodes[13].childNodes[0].nodeValue);
                    AGLowPrice= new Number(MainTag[i].childNodes[15].childNodes[0].nodeValue);
                    AGValue=MainTag[i].childNodes[17].childNodes[0].nodeValue;
                    
                    if(i%2!=0 )
                    {
                        strHTML += '<tr class=alternateRowStyle>';
                    }
                    else
                    {
                        strHTML += '<tr class=rowStyle>';
                    }
                        
                    strHTML += '<td style=width:18%; >'+ AGSymbol +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGExpiryDate +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLTP.toFixed(2) +'</td>';
                    strHTML += '<td style=width:16%; >'+ AGPreClose.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGHighPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:12%; >'+ AGLowPrice.toFixed(2) +'</td>';
                    strHTML += '<td style=width:14%; >'+ AGValue +'</td>';
                    
                    strHTML += '</tr>';
                    
                }else
                {
                break;
                }
                
                //if for table close
                
            }//For loop close
            
        }//if for xml_file close
        
        strHTML += '</table>';
        if (xml_file=="../XML/NCDEX-TopVolumes.xml")
        {
            document.getElementById('ExchangeAllVolume').innerHTML=strHTML;
        }

        
    }//else if for data id close
    
     delete xmlDoc;
}
//Top 5 NCDEX Top Value for markets/commodity-markets.aspx page for FireFox close


//-----------------------------------------------------Top Volume close-----------------------------------------------
//-----------------------------------------------------Top Volume close-----------------------------------------------

//-----------------------------------------------------Market News Start-----------------------------------------------
//-----------------------------------------------------Market News Start-----------------------------------------------

//following function is used to display Commodity Market News on markets/commodity-markets.aspx page for IE
function xmlProcessorNews(xmlDoc,xml_file)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    // In case of IE
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        MainTag = xmlDoc.childNodes[1];
    }
    // not IE
    else
    {        
        MainTag = xmlDoc.childNodes[0];
    }
    
    MainTagLength = MainTag.childNodes.length;
    
    var NSrNo = "";
    var NNDate = "";
    var Ntime="";
    var NHeading="";
    
    
    var strHTML;
    
    if (xml_file=="../XML/MarketNews.xml")
    {
        strHTML += '<table width="96%" id="Grid_View" cellspacing=0 cellpadding=0 border=0 align=center >';
                
        for(var i = 0; i < MainTagLength; i++)
        {
            if(MainTag.childNodes[i].nodeName == "Table")
            {
            if(i<=icount)
            {
                NSrNo=MainTag.childNodes[i].childNodes[0].text;
                NNDate=MainTag.childNodes[i].childNodes[1].text;
                Ntime=MainTag.childNodes[i].childNodes[3].text;
                NHeading=MainTag.childNodes[i].childNodes[4].text;
                var NewsData=NHeading;
                
                strHTML+='<tr>';
                strHTML+='<td><hr class=news_top_line /></td>';    
                strHTML+='</tr>';   
                
                strHTML+='<tr>';
                strHTML+='<td align=left class=new_marketnews1><a style=color:#808285; href=Javascript:MM_openBrWindow("comm-news.aspx?time='+ NSrNo +'"); >'+ NHeading +'</a></td>';    
                strHTML+='</tr>';
                
                strHTML += '<tr>';
                strHTML += '<td align=left class=news_Date_time>'+ NNDate + '&nbsp;|&nbsp;'+ Ntime +'</td>';
                strHTML += '</tr>';
                }
                         
               
            }//if close
            
        }//for loop close
    }//XML if close
    strHTML += '</table>';
    if (xml_file=="../XML/MarketNews.xml")
    {
        document.getElementById('commodityMarketNews').innerHTML=strHTML;
    }
     delete xmlDoc;
}
//Commodity market news for markets/commodity-markets.aspx page for IE close

//following function is used to display Commodity Market News on markets/commodity-markets.aspx page for FireFox
function xmlProcessorNewsFireFox(xmlDoc,xml_file)
{
    //debugger;
    if(!xmlDoc)
    {
        feedError();
    }
    
    //playing with XML Data
    
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    MainTag = xmlDoc.getElementsByTagName("Table");
    MainTagLength = MainTag.length;
    
    var NSrNo = "";
    var NNDate = "";
    var Ntime="";
    var NHeading="";
    var strHTML;
    
    if (xml_file=="../XML/MarketNews.xml")
    {
        strHTML += '<table width="96%" id="Grid_View" cellspacing=0 cellpadding=0 border=0 align=center >';
                
        for(var i = 0; i < MainTagLength; i++)
        {
            if(i<=icount)
            //if(MainTag.childNodes[i].nodeName == "Table")
            {
                NSrNo=MainTag[i].childNodes[1].childNodes[0].nodeValue;
                NNDate=MainTag[i].childNodes[3].childNodes[0].nodeValue;
                Ntime=MainTag[i].childNodes[7].childNodes[0].nodeValue;
                NHeading=MainTag[i].childNodes[9].childNodes[0].nodeValue;
                
                strHTML+='<tr>';
                strHTML+='<td><hr class=news_top_line /></td>';    
                strHTML+='</tr>';   
                
                strHTML+='<tr>';
                strHTML+='<td align=left class=new_marketnews1><a style=color:#808285; href=Javascript:MM_openBrWindow("comm-news.aspx?time='+ NSrNo +'"); >'+ NHeading +'</a></td>';    
                strHTML+='</tr>';
                
                strHTML += '<tr>';
                strHTML += '<td align=left class=news_Date_time>'+ NNDate + '&nbsp;|&nbsp;'+ Ntime +'</td>';
                strHTML += '</tr>';
                         
               
            }else
            
            {
            break;
            }
            
            //if close
            
        }//for loop close
    }//XML if close
    strHTML += '</table>';
    if (xml_file=="../XML/MarketNews.xml")
    {
        document.getElementById('commodityMarketNews').innerHTML=strHTML;
    }
     delete xmlDoc;
}
//Commodity market news for markets/commodity-markets.aspx page for FireFox close


//-----------------------------------------------------Market News Close-----------------------------------------------
//-----------------------------------------------------Market News Close-----------------------------------------------

//-----------------------------------------------------Get Quotes and Commodity Chart Start-----------------------------------------------
//-----------------------------------------------------Get Quotes and Commodity Chart Start-----------------------------------------------

//following function is used to display MCX List of Commodity on markets/commodity-markets.aspx page for IE
function xmlProcessorMCXList(xmlDoc,xml_file,dataId)
{
    if(!xmlDoc)
    {
        xmlError();
    }
    
    //Do whatever you want with the XML data...
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    // In case of IE
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        MainTag = xmlDoc.childNodes[1];
    }
    // not IE
    else
    {        
        MainTag = xmlDoc.childNodes[0];
    }
    
    MainTagLength = MainTag.childNodes.length;
        
    if(dataId == 1)
    {
        for(var i = 0; i < MainTagLength; i++)
        {     
            if(i==0)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                    var dataText=MainTag.childNodes[i].childNodes[0].text;
                    document.getElementById('ddlCommodities').options[1] = new Option(MainTag.childNodes[i].childNodes[0].text);    
                           
                }
            }
            else
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                    document.getElementById('ddlCommodities').options[i+1] = new Option(MainTag.childNodes[i].childNodes[0].text);             
                    
                }
            }
        }//For loop Close
        
        document.getElementById('ddlCommodities').options[0] = new Option("Select","Select"); 
        document.getElementById('ddlCommodities').selectedIndex = 0;
    }// if for data id close
    else if (dataId ==2)
    {
        for(var i = 0; i < MainTagLength; i++)
        {     
            if(i==0)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                    document.getElementById('ddlCommoditiesChart').options[1] = new Option(MainTag.childNodes[i].childNodes[0].text);         
                }
            }
            else
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                    document.getElementById('ddlCommoditiesChart').options[i+1] = new Option(MainTag.childNodes[i].childNodes[0].text);             
                }
            }
         
        }//For loop close 
         document.getElementById('ddlCommoditiesChart').options[0] = new Option("Select","Select"); 
         document.getElementById('ddlCommoditiesChart').selectedIndex = 0;
    }//else for data id close
}
//MCX List of Commodity on markets/commodity-markets.aspx page for IE Close

//following function is used to display MCX List of Commodity on markets/commodity-markets.aspx page for FireFox
function xmlProcessorMCXListFireFox(xmlDoc,xml_file,dataID)
{
    if(!xmlDoc)
    {
        xmlError();
    }
    
    //Do whatever you want with the XML data...
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    MainTag = xmlDoc.getElementsByTagName("Table");
    MainTagLength = MainTag.length;
        
    var j=2;
    
    if(dataID == 1)
    {
        for(var i = 0; i < MainTagLength; i++)
        {  
            if(i==0)
            {
                //if(MainTag.childNodes[i].nodeName == "Table")
               // {
                    document.getElementById('ddlCommodities').options[1] = new Option(MainTag[i].childNodes[1].childNodes[0].nodeValue);
                //}
            }
            else
            {
                //if(MainTag.childNodes[i].nodeName == "Table")
               // {
                    document.getElementById('ddlCommodities').options[j] = new Option(MainTag[i].childNodes[1].childNodes[0].nodeValue);
               // }
                j=j+1;
            }
        }//For loop close
         
        document.getElementById('ddlCommodities').options[0] = new Option("Select","Select"); 
        document.getElementById('ddlCommodities').selectedIndex = 0;
    }//if for data close
    else if(dataID  == 2)
    {
        for(var i = 0; i < MainTagLength; i++)
        {  
            if(i==0)
            {
               // if(MainTag.childNodes[i].nodeName == "Table")
               // {
                    document.getElementById('ddlCommoditiesChart').options[1] = new Option(MainTag[i].childNodes[1].childNodes[0].nodeValue);             
                //}
            }
            else
            {
               // if(MainTag.childNodes[i].nodeName == "Table")
               // {
                    document.getElementById('ddlCommoditiesChart').options[j] = new Option(MainTag[i].childNodes[1].childNodes[0].nodeValue);
                //}
                j=j+1;
            }
         }//For loop close
     
        document.getElementById('ddlCommoditiesChart').options[0] = new Option("Select","Select"); 
        document.getElementById('ddlCommoditiesChart').selectedIndex = 0;   
    }//else if for data close
    
}
//MCX List of Commodity on markets/commodity-markets.aspx page for FireFox Close


//following function is used to display NCDEX List of Commodity on markets/commodity-markets.aspx page for IE
function xmlProcessorNCDEXList(xmlDoc,xml_file,dataID)
{
    if(!xmlDoc)
    {
        xmlError();
    }
    
    //Do whatever you want with the XML data...
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    // In case of IE
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        MainTag = xmlDoc.childNodes[1];
    }
    // not IE
    else
    {        
        MainTag = xmlDoc.childNodes[0];
    }
    
    MainTagLength = MainTag.childNodes.length;
    
    if(dataID == 1)
    {
        for(var i = 0; i < MainTagLength; i++)
        {     
            if(i==0)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                    document.getElementById('ddlCommodities').options[1] = new Option(MainTag.childNodes[i].childNodes[0].text);
                }
            }
            else
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                    document.getElementById('ddlCommodities').options[i+1] = new Option(MainTag.childNodes[i].childNodes[0].text);
                }
            }
        }//For loop close 
        document.getElementById('ddlCommodities').options[0] = new Option("Select","Select"); 
        document.getElementById('ddlCommodities').selectedIndex = 0;
        
    }//if for dataID close
    else if(dataID ==2 )
    {
        for(var i = 0; i < MainTagLength; i++)
        {     
            if(i==0)
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                    document.getElementById('ddlCommoditiesChart').options[1] = new Option(MainTag.childNodes[i].childNodes[0].text);
                }
            }
            else
            {
                if(MainTag.childNodes[i].nodeName == "Table")
                {
                    document.getElementById('ddlCommoditiesChart').options[i+1] = new Option(MainTag.childNodes[i].childNodes[0].text);
                }
            }
        }//For loop close 
     
        document.getElementById('ddlCommoditiesChart').options[0] = new Option("Select","Select"); 
        document.getElementById('ddlCommoditiesChart').selectedIndex = 0;
    }//else if for dataID close
     
     
}
//NCDEX List of Commodity on markets/commodity-markets.aspx page for IE Close

//following function is used to display MCX List of Commodity on markets/commodity-markets.aspx page for FireFox
function xmlProcessorNCDEXListFireFox(xmlDoc,xml_file,dataID)
{
    if(!xmlDoc)
    {
        xmlError();
    }
    
    //Do whatever you want with the XML data...
    var MainTag;
    var MainTagLength;
    var ChildTagLength;
    var strHTML = "";
    
    MainTag = xmlDoc.getElementsByTagName("Table");
    MainTagLength = MainTaglength;
        
    var j=2;
    
    if(dataID == 1)
    {
        for(var i = 0; i < MainTagLength; i++)
        {  
            if(i==0)
            {
                //if(MainTag.childNodes[i].nodeName == "Table")
                //{
                    document.getElementById('ddlCommodities').options[1] = new Option(MainTag[i].childNodes[1].childNodes[0].nodeValue);             
             
                //}
            }
            else
            {
                
               // if(MainTag.childNodes[i].nodeName == "Table")
              //  {
                    document.getElementById('ddlCommodities').options[j] = new Option(MainTag[i].childNodes[1].childNodes[0].nodeValue);
                 
               // }
                j=j+1;
            }
         }//For loop close
        document.getElementById('ddlCommodities').options[0] = new Option("Select","Select"); 
        document.getElementById('ddlCommodities').selectedIndex = 0;
    }//if for dataID close
    else if (dataID == 2)
    {
        for(var i = 0; i < MainTagLength; i++)
        {  
            if(i==0)
            {
               // if(MainTag.childNodes[i].nodeName == "Table")
               // {
                    document.getElementById('ddlCommoditiesChart').options[1] = new Option(MainTag[i].childNodes[1].childNodes[0].nodeValue);             
               // }
            }
            else
            {
                
               // if(MainTag.childNodes[i].nodeName == "Table")
               // {
                    document.getElementById('ddlCommoditiesChart').options[j] = new Option(MainTag[i].childNodes[1].childNodes[0].nodeValue);             
               // }
                j=j+1;
            }
         }//For loop close
     
     document.getElementById('ddlCommoditiesChart').options[0] = new Option("Select","Select"); 
     document.getElementById('ddlCommoditiesChart').selectedIndex = 0;
    }//else if for dataID close
}
//NCDEX List of Commodity on markets/commodity-markets.aspx page for FireFox Close


//-----------------------------------------------------Get Quotes and Commodity Chart Close-----------------------------------------------
//-----------------------------------------------------Get Quotes and Commodity Chart Close-----------------------------------------------




