﻿function openSite(ID)
{
    if(ID == '1')
    {
        window.open('http://www.angelbroking.com', '_blank')            
    }
    else if(ID == '2')
    {
         window.open('http://www.angelcommodities.com', '_blank')            
    }
    else if(ID == '3')
    {
         window.open('http://www.angelsecurelife.com', '_blank')    
    }
     else if(ID == '4')
    {
         window.open('http://www.angelsecurities.in', '_blank')            
    }
    else
    {
    return false;
    }
}  

// Code for Creating the XMLHTTP Obj
var xmlReq = new Array(); // ARRAY OF XML-HTTP REQUESTS
var xmlIndex = new Array(0); // ARRAY OF XML-HTTP REQUEST INDEXES
xmlIndex[0] = 1; // FIRST INDEX SET TO 1 MAKING IT AVAILABLE


function xhrRequest(type) 
{
    if (!type) 
    {
        type = 'html';
    }
    // xhrsend IS THE xmlIndex POSITION THAT GETS PASSED BACK
    // INITIALIZED TO THE LENGTH OF THE ARRAY(LAST POSITION + 1)
    var xhrsend = xmlIndex.length;

    // GO THROUGH AVAILABLE xi VALUES
    for (var i=0; i<xmlIndex.length; i++) 
    {
        // IF IT'S 1 (AVAILABLE), ALLOCATE IT FOR USE AND BREAK
        if (xmlIndex[i] == 1) 
        {
            xmlIndex[i] = 0;
            xhrsend = i;
            break;
        }
    }
    // SET TO 0 SINCE IT'S NOW ALLOCATED FOR USE
    xmlIndex[xhrsend] = 0;


    // SET UP THE REQUEST
    if (window.ActiveXObject) 
    {
        try 
        {
            xmlReq[xhrsend] = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
            try 
            {
                xmlReq[xhrsend] = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e) 
            {
                
            }
        }
    } 
    else if (window.XMLHttpRequest) 
    {
        xmlReq[xhrsend] = new XMLHttpRequest();
        if (xmlReq[xhrsend].overrideMimeType) 
        {
            xmlReq[xhrsend].overrideMimeType('text/' + type);
        }
    }
    return (xhrsend);
}

//Index Page Data
function loadData()
{ 
//debugger;   
    //
    document.getElementById('spnMFNews').innerHTML = "<table width=100% height=200px><tr><td align=center><img src=images/loading.gif /><span style='color:#4F6E80'>Loading Data.....</span></td></tr></table>";
    
    //
   document.getElementById('spnLatestNFOs').innerHTML = "<table width=100% height=200px><tr><td align=center><img src=images/loading.gif /><span style='color:#4F6E80'>Loading Data.....</span></td></tr></table>";    

    // CALL A FUNCTION THAT USES xmlHttp MULTIPLE TIMES
    LoadRequest('AJAX/indexDAL.aspx?id=FundHouse');
    LoadRequest('AJAX/indexDAL.aspx?id=MFNews');
    LoadRequest('AJAX/indexDAL.aspx?id=LatestNFOs');
    LoadXMLRequest('XML/State.xml');     
}

function LoadRequest(url, reqType) 
{
//debugger;
    var xhri = xhrRequest('html');
    xmlReq[xhri].open('GET', url, true);
    xmlReq[xhri].onreadystatechange = function() 
    { 
        if(xmlReq[xhri].readyState == 3 && url == "AJAX/indexDAL.aspx?id=FundHouse")
        {
            var ddlFH = document.getElementById("ddlFundHouse");
            var ddlScheme = document.getElementById("ddlScheme");
            (ddlFH).length = 0;  
            (ddlScheme).length = 0;
            ddlFH.options[0] = new Option("Loading...","Loading...");
            ddlScheme.options[0] = new Option("Loading...","Loading...");
            document.getElementById('ddlFundHouse').selectedIndex = 0;
            document.getElementById('ddlScheme').selectedIndex = 0;
        }             
        if (xmlReq[xhri].readyState == 4 && xmlReq[xhri].status == 200) 
        {  
            if(url == "AJAX/indexDAL.aspx?id=FundHouse")
            {   
                var ddlFH = document.getElementById("ddlFundHouse");
                var ddlScheme = document.getElementById("ddlScheme");
                var Output = xmlReq[xhri].responseText; 
                
                if(Output != '')
                {
                    var ddlFH = document.getElementById("ddlFundHouse");
                    var ddlScheme = document.getElementById("ddlScheme");
                    var arr = Output.split(";");    
                    //To Remove All Items of Drop Down
                    (ddlFH).length = 0;  
                    (ddlScheme).length = 0;   
                    //To Add Items In Drop Down
                    for(var i = 0; i < arr.length-1; i++)
                    {
                        (ddlFH).options[i+1] = new Option(arr[i].split("##")[1],arr[i].split("##")[0]);
                    }
                    ddlFH.options[0] = new Option("-- Select Fund House --","-- Select Fund House --");
                    ddlScheme.options[0] = new Option("-- Select Scheme --","-- Select Scheme --");
                    document.getElementById('ddlFundHouse').selectedIndex = 0;
                    document.getElementById('ddlScheme').selectedIndex = 0;
                }
                else
                {
                    ddlFH.options[0] = new Option("-- No Data --","-- No Data --");
                    ddlScheme.options[0] = new Option("-- No Data --","-- No Data --"); 
                }            
                
            }
            if(url == "AJAX/indexDAL.aspx?id=MFNews")
            {
                //debugger;
                var arResponce;
                var arOutput = xmlReq[xhri].responseText; 
                
                var spnMFNews =document.getElementById("spnMFNews");
                var arr = arOutput.split(";");   
                strHTML = "";
                strHTML = "<table cellpadding='0' cellspacing='0' align='center' width='250px' height='212px;'>";
                strHTML += "<tr>";
                    strHTML += "<td style='height:10px;'></td>";
                    strHTML += "</tr>";
                // strHTML += "<th align='left'>Cocode</th><th align='left'>lname</th>";
                if(arOutput != '')
                {
                    for(var i=0; i < arr.length; i++)
                    {
                        arResponce = "";
                        arResponce = arr[i].split('##');
                        
                        strHTML += "<tr>";
                        //strHTML += "<td><a class='newsDetail' href='mfDetailNews.aspx?sno="+ arResponce[0] +"' title='News' rel='gb_page_center[600, 500]'>" + arResponce[3] + "</a></td>";
                        strHTML += "<td style='padding-bottom:5px;'><b><a href='#' style='font-size:11px; color:#808285;' onclick=popUp('DetailNews-PopUp.htm?sno="+ arResponce[0] +"','News','scrollbars=1,width=600,height=500')>" + arResponce[3] + "</a></b></td>";
                        strHTML += "</tr>";
                        
                        strHTML += "<tr>";
                        //strHTML += "<td width=100px>" + arResponce[0] + "</td>";
                        strHTML += "<td><h5 style='font-weight:normal; font-size:11px;'>" + arResponce[1] + "|" + arResponce[2] + "</h5></td>";
                        //strHTML += "<td width=100px>"  "</td>";
                        strHTML += "</tr>";
                        
                        strHTML += "<tr>";
                        strHTML += "<td align='right'><a href='#' style='font-size:11px; font-weight:bold;' onclick=popUp('DetailNews-PopUp.htm?sno="+ arResponce[0] +"','','scrollbars=yes,width=600,height=500')>Read More</a></td>";
                        strHTML += "</tr>";
                        
                        strHTML += "<tr>";
                        strHTML += "<td><hr style='color: #bfdbed; height:1px; width:250px; text-align:left;'/></td>";
                        strHTML += "</tr>";                       
                        
                    }
                }
                 else
                 {
                        strHTML += "<tr>";
                        strHTML += "<td align='center' style='color:#4F6E80; font-size:12px; text-align:center; height:212px;'><b>No Data Available</b></td>";
                        strHTML += "</tr>";
                 }
                    //  strHTML += "<tr>";
                    //   strHTML += "<td align='right' style='background-color:#f4f4f4; vertical-align:middle;'><a style='color:#696966; font-size:11px; text-decoration:none;' href='#'><b>More News</b></a></td>";
                    //                strHTML += "</tr>";
                strHTML += "<tr>";
                strHTML += "<td style='height:6px;'></td>";
                strHTML += "</tr>";
                strHTML += "</table>"; 
                document.getElementById("spnMFNews").innerHTML = strHTML;   
            } 
            if(url == "AJAX/indexDAL.aspx?id=LatestNFOs")
            {
                //debugger;
                var arResponce;
                var arOutput = xmlReq[xhri].responseText; 
                
                var spnMFNews =document.getElementById("spnLatestNFOs");
                var arr = arOutput.split(";");   
                strHTML = "";
                strHTML = "<table cellpadding='0' cellspacing='0' align='center' width='225px' height='200px'>";
                strHTML += "<tr>";
                    strHTML += "<td></td>";
                    strHTML += "</tr>";
                // strHTML += "<th align='left'>Cocode</th><th align='left'>lname</th>";
                if(arOutput != '')
                {
                    for(var i=0; i < arr.length; i++)
                    {
                        arResponce = "";
                        arResponce = arr[i].split('##');
                        
                        strHTML += "<tr>";
                        //strHTML += "<td><a class='newsDetail' href='mfDetailNews.aspx?sno="+ arResponce[0] +"' title='News' rel='gb_page_center[600, 500]'>" + arResponce[3] + "</a></td>";
                        strHTML += "<td style='font-size:10px;'><b><a href='#' onclick=popUp('NFO-Details.htm?code="+ arResponce[0] +"','NFODetails','scrollbars=1,width=600,height=500')>" + arResponce[1] + "</a></b></td>";
                        strHTML += "</tr>";
                        
                        //strHTML += "<tr>";
                        //strHTML += "<td width=100px>" + arResponce[0] + "</td>";
                        //strHTML += "<td><h5>" + arResponce[1] + "|" + arResponce[2] + "</h5></td>";
                        //strHTML += "<td width=100px>"  "</td>";
                        //strHTML += "</tr>";
                        
//                        strHTML += "<tr>";
//                        strHTML += "<td align='right' style='font-size:10px;'><a href='#' onclick=popUp('DetailNews-PopUp.htm?sno="+ arResponce[0] +"','','scrollbars=yes,width=600,height=500')>Read More</a></td>";
//                        strHTML += "</tr>";
                        if(i != 4)
                        {
                        strHTML += "<tr>";
                        strHTML += "<td><hr style='color: #bfdbed; height:1px; width:225px; text-align:left;'/></td>";
                        strHTML += "</tr>";                       
                        }
                        
                    }
                }
                 else
                 {
                        strHTML += "<tr>";
                        strHTML += "<td align='center' style='color:#4F6E80; font-size:12px; text-align:center; height:212px;'><b>No Data Available</b></td>";
                        strHTML += "</tr>";
                 }
                    //  strHTML += "<tr>";
                    //   strHTML += "<td align='right' style='background-color:#f4f4f4; vertical-align:middle;'><a style='color:#696966; font-size:11px; text-decoration:none;' href='#'><b>More News</b></a></td>";
                    //                strHTML += "</tr>";
                strHTML += "<tr>";
                strHTML += "<td style='height:0px;'></td>";
                strHTML += "</tr>";
                strHTML += "</table>"; 
                document.getElementById("spnLatestNFOs").innerHTML = strHTML;   
            }   
        }
    };
    xmlReq[xhri].send(null);
}

function stateChangedFH() 
{ 
//debugger;
var xhri = xhrRequest('html');
//for a succesful event ready state  value of the xmlhttp object must contain these values
if (xmlReq[xhri].readyState==1)
{
    var ddlScheme = document.getElementById("ddlScheme"); 
    ddlScheme.innerText = "";
    ddlScheme.options[0] = new Option("Loading...","Loading...");
}
  if (xmlReq[xhri].readyState==4 || xmlReq[xhri].readyState=="complete") 
  { //Display contents 
    
    var xmlResponse = xmlReq[xhri].responseText; 
    if (xmlResponse!='') 
        { 
            var ddlScheme = document.getElementById("ddlScheme");                                   
            fillDDL(ddlScheme,xmlResponse)
            ddlScheme.options[0] = new Option("-- Select Scheme --","-- Select Scheme --");
            document.getElementById('ddlScheme').selectedIndex = 0; 
            //if (document.all.table.rows.length > 0) document.all.table.rows[0].cells[0].focus();                      
        } 
        else 
        { 
           // alert("An Error Occured!");
            var ddlScheme = document.getElementById("ddlScheme"); 
            ddlScheme.options[0] = new Option("-- No Data --","-- No Data --"); 
        } 
    } 
} 

function fillDDL(ddl,str)
{
    var arr = str.split(";");    
    //To Remove All Items of Drop Down
    (ddl).length = 0;    
    //To Add Items In Drop Down
    for(var i = 0; i < arr.length-1; i++)
    {
        (ddl).options[i+1] = new Option(arr[i].split("##")[1],arr[i].split("##")[0]);
    }
} 

//Load Schemes
function loadSchemes()
{        
//debugger;    
    
    var xhri = xhrRequest('html');
    var url = "AJAX/indexDAL.aspx"; 
    url = url + "?co_code=" + document.getElementById('ddlFundHouse').value +"&id=Scheme";
    xmlReq[xhri].open('GET', url, true);
    xmlReq[xhri].onreadystatechange = function() 
    {                     
        var ddlScheme = document.getElementById("ddlScheme");
        if (xmlReq[xhri].readyState == 3)
        {            
            (ddlScheme).length = 0;
            ddlScheme.options[0] = new Option("Loading...","Loading..."); 
            document.getElementById('ddlScheme').selectedIndex = 0;
        }
         
        if (xmlReq[xhri].readyState == 4 && xmlReq[xhri].status == 200) 
        { 
            if(url == "AJAX/indexDAL.aspx?co_code=" + document.getElementById('ddlFundHouse').value +"&id=Scheme")
            {            
                var Output = xmlReq[xhri].responseText; 
                
                if(Output != '')
                {
                    var ddlScheme = document.getElementById("ddlScheme");
                    var arr = Output.split(";");    
                    //To Remove All Items of Drop Down
                    (ddlScheme).length = 0;   
                    //To Add Items In Drop Down
                    for(var i = 0; i < arr.length-1; i++)
                    {
                        (ddlScheme).options[i+1] = new Option(arr[i].split("##")[1],arr[i].split("##")[0]);
                    }
                    ddlScheme.options[0] = new Option("-- Select Scheme --","-- Select Scheme --");
                    document.getElementById('ddlScheme').selectedIndex = 0;
                }
                else
                {
                    ddlScheme.options[0] = new Option("-- No Data --","-- No Data --"); 
                    document.getElementById('ddlScheme').selectedIndex = 0;
                }  
            }
        }
    };
    xmlReq[xhri].send(null); 
}

///////////////////////// load Schemes Using XmlHttp ///////////////////////////////////
function LoadSchemesUsingXmlHttp()
{      
    xmlHttp = GetXmlHttpObject(); 
        if (xmlHttp==null) 
        { 
            alert ("Browser does not support HTTP Request");
             return; 
        } 
    var url = "AJAX/indexDAL.aspx"; 
    url = url + "?co_code=" + document.getElementById('ddlFundHouse').value +"&id=Scheme";

    //state change event-this will occur ass soon as response comes from the url
    
       xmlHttp.onreadystatechange = stateChanged;
       xmlHttp.open("GET",url,true); 
       xmlHttp.send(null);     
}

var xmlHttp;
function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

function stateChanged() 
{ 
//debugger;
//for a succesful event ready state  value of the xmlhttp object must contain these values
if (xmlHttp.readyState==1)
{
    var ddlSchemes = document.getElementById("ddlScheme"); 
    ddlSchemes.innerText = "";
    ddlSchemes.options[0] = new Option("Loading...","Loading...");
}
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") 
  { //Display contents 
  
    var xmlResponse = xmlHttp.responseText; 
    if (xmlResponse!='') 
        { 
            var ddlSchemes = document.getElementById("ddlScheme");                                   
            fillDDL(ddlSchemes,xmlResponse)
            ddlSchemes.options[0] = new Option("-- Select Schemes --","-- Select Schemes --");
            document.getElementById('ddlScheme').selectedIndex = 0; 
            //if (document.all.table.rows.length > 0) document.all.table.rows[0].cells[0].focus();                      
        } 
        else 
        { 
           // alert("An Error Occured!");
            var ddlSchemes = document.getElementById("ddlScheme"); 
            ddlSchemes.options[0] = new Option("-- No Data --","-- No Data --"); 
        } 
    } 
}  

/////////////////////////// End of load Schemes Using XmlHttp ///////////////////////////////

////////////////////////// Read XML Data////////////////////////////////////////////////////////
var xmlhttp;

function LoadXMLRequest(xml_file)
{
//debugger;
    xmlhttp=null;
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE5, IE6
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }

    if (xml_file=="XML/State.xml")
    {
        xmlhttp.onreadystatechange=onResponse;
        xmlhttp.open("GET",xml_file,true);
        xmlhttp.send(null);
    } 
    if (xml_file=="XML/City.xml")
    {
        xmlhttp.onreadystatechange=onResponseCity;
        xmlhttp.open("GET",xml_file,true);
        xmlhttp.send(null);
    } 
}

function onResponse()
{
    if(xmlhttp.readyState!=4) return;
    if(xmlhttp.status!=200)
      {
          alert("Problem retrieving XML data");
          return;
      }
      
    var ddlState = document.getElementById("ddlState"); 
    var ddlCity = document.getElementById("ddlCity");
      
    x=xmlhttp.responseXML.documentElement.getElementsByTagName("Table");
    
    for (i=0;i<x.length;i++)
      {     
        xx=x[i].getElementsByTagName("state_name");
        {
            try
              {
                (ddlState).options[i+1] = new Option(xx[0].firstChild.nodeValue); 
              }
            catch (er)
              {
                ddlState.options[0] = new Option("-- No Data --","-- No Data --"); 
              }
        } 
      }
      
      ddlState.options[0] = new Option("-- State --","-- State --");
      document.getElementById('ddlState').selectedIndex = 0; 
      ddlCity.options[0] = new Option("-- City --","-- City --");
      document.getElementById('ddlCity').selectedIndex = 0; 
}

function onResponseCity()
{
    if(xmlhttp.readyState!=4) return;
    if(xmlhttp.status!=200)
      {
          alert("Problem retrieving XML data");
          return;
      }
    var ddlCity = document.getElementById("ddlCity"); 
    //debugger;
    (ddlCity).length = 0;
    var index = document.getElementById('ddlState').selectedIndex;
    var selected_State = document.getElementById('ddlState').options[index].text;
    
    x=xmlhttp.responseXML.documentElement.getElementsByTagName("Table");
    var j=1;
    for (i=0;i<x.length;i++)
      { 
        xy=x[i].getElementsByTagName("state_name");  
        if( selected_State == xy[0].firstChild.nodeValue)
         {   
            xx=x[i].getElementsByTagName("location");
            {
                try
                  {
                    (ddlCity).options[j] = new Option(xx[0].firstChild.nodeValue); 
                    j=j+1;
                  }
                catch (er)
                  {
                    ddlCity.options[0] = new Option("-- No Data --","-- No Data --"); 
                  }
            } 
        }
      }
      
      ddlCity.options[0] = new Option("-- City --","-- City --");
      document.getElementById('ddlCity').selectedIndex = 0;
}

function cityChange(elementThis)
            {
            //debugger;
                for (var  i=1;i<elementThis.length;i++)
                {
                    if(elementThis.options[i].selected)
                    {
                        window.open ("http://www.angelbroking.com/branch_index.aspx?city="+elementThis.options[i].text,
            "mywindow","menubar=0,resizable=0,width=600,height=350,status=0,location=0,directories=0,scrollbars=1");
                    }
                }
            }
////////////////////////// End XML Data/////////////////////////////////////////////////////////

function getNAV()
{
//debugger;
    if(document.getElementById('ddlFundHouse').selectedIndex == 0 ||  document.getElementById('ddlScheme').selectedIndex == 0)
    {
        if(document.getElementById('ddlFundHouse').selectedIndex == 0)
        {
            alert('Please select fundhouse.');
            document.getElementById('ddlFundHouse').focus();
            return false;
        }
        else
        {
            alert('Please select scheme.');
            document.getElementById('ddlScheme').focus();
            return false;
        }       
    }
    else
    {
        var url = "NAV-PopUp.htm"; 
        url = url + "?fh=" + document.getElementById('ddlFundHouse').value +"&scheme=" + document.getElementById('ddlScheme').value;
        popUp(url,'mywindow','menubar=0,resizable=0,width=860,height=250, status=0,location=0,directories=0');
        return false;
    }
}

function loadNAVPopUp()
{
//debugger;
    document.getElementById('spnNAVPopUp').innerHTML = "<table width=100% height='80px'><tr><td align=center><img src=images/loading.gif /><span style='color:#4F6E80'>Loading Data.....</span></td></tr></table>";
    fh = getQueryVariable("fh");
    scheme = getQueryVariable("scheme"); 
//fh = '21273';
//scheme = '205';    
    LoadRequestNAVPopUp('AJAX/indexDAL.aspx?id=NAVPopUp&fh='+ fh +'&scheme='+ scheme);
}

function LoadRequestNAVPopUp(url, reqType) 
{
//debugger;
    var xhri = xhrRequest('html');
    xmlReq[xhri].open('GET', url, true);
    xmlReq[xhri].onreadystatechange = function() 
    {                     
        if (xmlReq[xhri].readyState == 4 && xmlReq[xhri].status == 200) 
        {              
            fh = getQueryVariable("fh");
            scheme = getQueryVariable("scheme"); 
//fh = '21273';
//scheme = '205';
            if(url == "AJAX/indexDAL.aspx?id=NAVPopUp&fh="+ fh +"&scheme="+ scheme)
            {
                var arResponce;
                var Output = xmlReq[xhri].responseText;
                var arr = Output.split(";");    
                
                    strHTML = "";
                    strHTML = "<table cellpadding='0' cellspacing='2' align='center' width='800px' height='80px' style='background-color: #fff; border:solid 1px #fff;'>";
                            strHTML += "<tr style='font-weight:bold;'>";
                            strHTML += "<td class='dataHeaderGV' style='text-align:left;'>Scheme</td>";
                            strHTML += "<td class='dataHeaderGV'>NAV Date</td>";
                            strHTML += "<td class='dataHeaderGV'>NAV</td>";
                            strHTML += "<td class='dataHeaderGV'>NAV REPrice</td>";
                            strHTML += "<td class='dataHeaderGV'>NAV SAPrice</td>";
                            strHTML += "</tr>";
                    if(Output != '')
                     {
                        for(var i=0; i < arr.length; i++)
                            {                            
                                    arResponce = "";
                                    arResponce = arr[i].split('##');                           
                                    strHTML += "<tr>";
                                    strHTML += "<td style='text-align:left;' class='rowGV'><a href='#' onclick=popUpClose('mf-analyser/get-quote.aspx?Page=GetQuote&mfSchCode="+ arResponce[1]+"') style='text-decoration:none; color:#4F6E80;' >"+ arResponce[2]+"</a></td>";
                                    strHTML += "<td class='rowGV'>"+ arResponce[3] +"</td>";
                                    strHTML += "<td class='rowGV'>"+ arResponce[4] +"</td>";
                                    strHTML += "<td class='rowGV'>"+ arResponce[5] +"</td>";
                                    strHTML += "<td class='rowGV'>"+ arResponce[6] +"</td>";
                                    strHTML += "</tr>";
                                
                            }
                         
                     }
                     else
                     {
                            strHTML += "<tr>";
                            strHTML += "<td align='center' style='color:#4F6E80; font-size:12px; text-align:center; height:30px;'><b>No Data Available</b></td>";
                            strHTML += "</tr>";
                     }
                    strHTML += "</table>"; 
                
                document.getElementById("spnNAVPopUp").innerHTML = strHTML;              
                
            }
        }
    };
    xmlReq[xhri].send(null);
} 

//loadDetailNewsPopUp
function loadDetailNewsPopUp()
{
    //debugger;
    document.getElementById('spnDetailNewsPopUp').innerHTML = "<table width=100% height='80px'><tr><td align=center><img src=images/loading.gif /><span style='color:#4F6E80'>Loading Data.....</span></td></tr></table>";
    var sno = getQueryVariable("sno");   
    LoadRequestDetailNewsPopUp('AJAX/indexDAL.aspx?id=DetailNewsPopUp&sno='+ sno);
}

function LoadRequestDetailNewsPopUp(url, reqType) 
{
//debugger;
    var xhri = xhrRequest('html');
    xmlReq[xhri].open('GET', url, true);
    xmlReq[xhri].onreadystatechange = function() 
    {                     
        if (xmlReq[xhri].readyState == 4 && xmlReq[xhri].status == 200) 
        {    
        var sno = getQueryVariable("sno"); 
            if(url == "AJAX/indexDAL.aspx?id=DetailNewsPopUp&sno="+ sno)
            {
                var arResponce;
                var Output = xmlReq[xhri].responseText;
                var arr = Output.split(";");    
                
                    strHTML = "";
                    strHTML = "<table cellpadding='10' cellspacing='0' align='center' width=100% height=100% style='background-color: #fff;'>";
//                    strHTML += "<tr>";
//                    strHTML += "<td style='text-align:Center;'><h3>Mutual Fund News</h3></td>";
//                    strHTML += "</tr>";
                  
                    if(Output != '')
                     {
                        for(var i=0; i < arr.length; i++)
                            {                            
                                    arResponce = "";
                                    arResponce = arr[i].split('##');                           
//                                    strHTML += "<tr>";
//                                    strHTML += "<td class='rowGQ2' style='text-align:left;'>"+ arResponce[1] +"&nbsp;|&nbsp;"+ arResponce[2] +"</td>";
//                                    strHTML += "</tr>";
//                                    strHTML += "<tr>";
//                                    strHTML += "<td class='rowGQ' style='text-align:left;'>"+ arResponce[3] +"</td>";
//                                    strHTML += "</tr>";
                                    strHTML += "<tr>";
                                    strHTML += "<td class='data' style='text-align:left;'>"+ arResponce[0] +"</td>";
                                    strHTML += "</tr>";
                                
                            }
                         
                     }
                     else
                     {
                            strHTML += "<tr>";
                            strHTML += "<td align='center' style='color:#4F6E80; font-size:12px; text-align:center; height:300px;'><b>No Data Available</b></td>";
                            strHTML += "</tr>";
                     }
                    
                    strHTML += "<tr>";
                    strHTML += "<td class='rowGQ' style='text-align:center;'><a href='#' onclick='window.close()' style='text-decoration:none; color:#4F6E80;'><b>Close</b></a></td>";
                    strHTML += "</tr>";
                    strHTML += "</table>"; 
                
                document.getElementById("spnDetailNewsPopUp").innerHTML = strHTML;              
                
            }
        }
    };
    xmlReq[xhri].send(null);
} 

//NFO Details
function loadNFODetailsPopUp()
{
     //debugger;
    document.getElementById('spnNFODetails').innerHTML = "<table width=100% height='80px'><tr><td align=center><img src=images/loading.gif /><span style='color:#4F6E80'>Loading Data.....</span></td></tr></table>";
    var code = getQueryVariable("code");   
    LoadRequestNFODetailsPopUp('AJAX/indexDAL.aspx?id=NFODetailsPopUp&code='+ code);
}

function LoadRequestNFODetailsPopUp(url, reqType) 
{
//debugger;
    var xhri = xhrRequest('html');
    xmlReq[xhri].open('GET', url, true);
    xmlReq[xhri].onreadystatechange = function() 
    {                     
        if (xmlReq[xhri].readyState == 4 && xmlReq[xhri].status == 200) 
        {    
        var code = getQueryVariable("code"); 
            if(url == "AJAX/indexDAL.aspx?id=NFODetailsPopUp&code="+ code)
            {
                var arResponce;
                var Output = xmlReq[xhri].responseText;
                var arr = Output.split(";");    
                
                    strHTML = "";
                    strHTML = "<table cellpadding='9' cellspacing='2' border='0' align='center' width='560px' height='100%' style='text-align:left;font-family:Tahoma; font-size:11px; color:#808285;'>";
                    strHTML += "<tr>";
                    strHTML += "<td style='text-align:Center; font-size:14px; font-weight:bold; color:#0072bc; background-color:#F0F0F0;' colspan='2'>NFO Details</td>";
                    strHTML += "</tr>";
                  
                    if(Output != '')
                     {
                        for(var i=0; i < arr.length; i++)
                            {                            
                                arResponce = "";
                                arResponce = arr[i].split('##'); 
                                strHTML += "<tr>";
                                strHTML += "<td width=130px style='background-color:#D9F6FE;'>Company Name :</td><td class='data' style='text-align:left;background-color:#D9F6FE;'>"+ arResponce[1] +"</td>";
                                strHTML += "</tr>";
                                strHTML += "<tr>";
                                strHTML += "<td>Scheme Name :</td><td class='data' style='text-align:left;'>"+ arResponce[2] +"</td>";
                                strHTML += "</tr>";
                                strHTML += "<tr>";
                                strHTML += "<td style='background-color:#D9F6FE;'>Fund Manager :</td><td class='data' style='text-align:left;background-color:#D9F6FE;'>"+ arResponce[3] +"</td>";
                                strHTML += "</tr>";
                                strHTML += "<tr>";
                                strHTML += "<td valign='top'>Objective :</td><td class='data' style='text-align:left;'>"+ arResponce[4] +"</td>";
                                strHTML += "</tr>";
                                strHTML += "<tr>";
                                //debugger;
                                var minInvest = roundNumber(arResponce[5], 2) ;
                                strHTML += "<td style='background-color:#D9F6FE;'>Min Investment :</td><td class='data' style='text-align:left; background-color:#D9F6FE;'>"+ minInvest +"</td>";
                                strHTML += "</tr>";
                                strHTML += "<tr>";
                                var maxEntry = roundNumber(arResponce[6], 2) ;
                                strHTML += "<td>Max Entry Load :</td><td class='data' style='text-align:left;'>"+ maxEntry +"</td>";
                                strHTML += "</tr>";
                                strHTML += "<tr>";
                                var maxExit = roundNumber(arResponce[7], 2) ;
                                strHTML += "<td style='background-color:#D9F6FE;'>Max Exit Load :</td><td class='data' style='text-align:left; background-color:#D9F6FE;'>"+ maxExit +"</td>";
                                strHTML += "</tr>";
                                strHTML += "<tr>";
                                strHTML += "<td>Option Type :</td><td class='data' style='text-align:left;'>"+ arResponce[8] +"</td>";
                                strHTML += "</tr>";
                            }
                         
                     }
                     else
                     {
                            strHTML += "<tr>";
                            strHTML += "<td align='center' style='color:#4F6E80; font-size:12px; text-align:center; height:300px;'><b>No Data Available</b></td>";
                            strHTML += "</tr>";
                     }
                    
                    strHTML += "<tr>";
                    strHTML += "<td class='rowGQ' style='text-align:center;' colspan='2'><a href='#' onclick='window.close()' style='text-decoration:none; color:#0072bc; font-weight:bold;'>Close</a></td>";
                    strHTML += "</tr>";
                    strHTML += "</table>"; 
                
                document.getElementById("spnNFODetails").innerHTML = strHTML;              
                
            }
        }
    };
    xmlReq[xhri].send(null);
} 

function getQueryVariable(variable) 
{ 
    var query = window.location.search.substring(1); 
    var vars = query.split("&"); 
    for (var i=0;i<vars.length;i++) 
    { 
        var pair = vars[i].split("="); 
        if (pair[0] == variable) 
        { 
        return pair[1]; 
        } 
    } 
}

function popUp(theURL,winName,features) 
    { //v2.0
        window.open(theURL,winName,features);
    }
    
function popUpClose(url) 
    { //v2.0
        window.opener.location= url;
        window.close();
        
    }
    
function roundNumber(num, dec) 
{
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}
    
