﻿// JScript File

// Indices Ctrl...................................................................................
function GetAIndices(val)
{
  var GM=document.getElementById("GM1");
  
  var SM=document.getElementById("SM1");
  
  var MoreAnnc=document.getElementById("MoreSec");
  
  switch(val)
   {
    case "I": 
     {
      document.getElementById("IndicesCen1").className="TabUnSelected";
      
      document.getElementById("IndicesCen2").className="TabSelectedIn";
       MoreAnnc.innerHTML="<a href='../OtherMarket/WorldIndices.aspx?id=63' class='HomeMore' target='_parent'>More</a>";

      break;
     }
     case "S":
      {
      document.getElementById("IndicesCen1").className="TabSelectedIn";
      
      document.getElementById("IndicesCen2").className="TabUnSelected";
     MoreAnnc.innerHTML="<a href='../OtherMarket/sectoral-indices.aspx?id=73' class='HomeMore' target='_parent'>More</a>";
    
       break;
      }
   }
   
  
       
   var requestUrl = "../Homecontrols/AjaxIndices.aspx?Type="+ val+"&timeStamp="+new Date().getTime(); 	
	   ajaxpage(1,requestUrl,'ctl00_ContentPlaceHolder1_IndicesCtrl1_indicesdetails');
		
}
//Mf & fll Ctrl.............................................................................
  function ShowMFFII(id)
{   
    if(id=="1")
    {
    document.getElementById("MFActivites").style.display="";
    document.getElementById("FIIActivites").style.display="none";
    }
    if(id=="2")
    {
    document.getElementById("MFActivites").style.display="none";
    document.getElementById("FIIActivites").style.display="";
    }
    for(i = 1; i<= 2 ; i++)
  {
      if(id == i)
      {
        document.getElementById("FIIMFimgC"+i).className="TabUnSelected";
   

      }
      else
      {
     
        document.getElementById("FIIMFimgC"+i).className="TabSelectedIn";
    
      }
  }
}
//HomeNews JS Start................................................................................................................


function ChooseNewsHome(NewsTxt)
{
NewsTxt = NewsTxt.toUpperCase();

   
  
 if(NewsTxt =="COMPANY RESULTS")
    {

        GetNewsHotGlobalHome('7','16');
    }
  
    if(NewsTxt =="HOT STOCKS")
    {

        GetNewsHotGlobalHome('4','38');
    }
    if(NewsTxt =="OTHER MARKET")
    {
        GetNewsHotGlobalHome('6','12,13,14,45');
    }
    if(NewsTxt =="MARKET PULSE")
    {
        GetNewsHotGlobalHome('5','56');
    }
    if(NewsTxt =="ECONOMY")
    { 
        GetNewsHotGlobalHome('5','23,24,25,26,36,43,44,49');
    }

   
    if(NewsTxt=="CORPORATE NEWS")
    {
        GetNewsHotGlobalHome('7','15');
    }
   
    if(NewsTxt =="FII POSITION")
    {
        GetNewsHotGlobalHome('9','22');
    }
    
    if(NewsTxt =="OPENING BELL")
    {
        GetNewsHotGlobalHome('4','40');
    }

    if(NewsTxt=="CLOSING BELL")
    {
        GetNewsHotGlobalHome('4','42');
    }
   
  
    if(NewsTxt =="MIDDAY REVIEW")
    {
        GetNewsHotGlobalHome('4','41');
    }
    

    if(NewsTxt =="CURRENT AFFAIRS AND POLITICS")
    {
        GetNewsHotGlobalHome('5','11');
    }

     if(NewsTxt =="GLOBAL MARKETS")
    {
        GetNewsHotGlobalHome('4','27');
    }
  
         if(NewsTxt =="MUTUAL FUNDS NEWS")
    {
        GetNewsHotGlobalHome('2','3,58');
    }

}

function CreateXmlHttpNewsHome()
{
	try
	{
		XmlHttpNewsHome = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpNewsHome = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpNewsHome = null;				
		}
	}
	if(!XmlHttpNewsHome && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpNewsHome = new XMLHttpRequest();
	}
}


function GetNewsHotGlobalHome(SecID,SubSec)
{	

    CreateXmlHttpNewsHome();
   
	document.body.style.cursor = "progress";
	//document.getElementById("NewsTdGlobal").innerHTML="<table align=center><tr><td><img src =../App_Themes/Common/images/ajax-loader.gif/></td></tr></table>";
	
	var requestUrl = "../Homecontrols/HomenewsAjaxHome.aspx?Sec="+ SecID +"&SubSec="+SubSec+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();

	if(XmlHttpNewsHome)
	{
	    XmlHttpNewsHome.onreadystatechange = function(){getDataResponseHotHome();};
		XmlHttpNewsHome.open("GET", requestUrl,  true);			
		XmlHttpNewsHome.send(null);
	
	}
	
}

function getDataResponseHotHome()
{
 
    if(XmlHttpNewsHome.readyState == 4)
	{	
	
	    if(XmlHttpNewsHome.status == 200)
		{
				
		    var NewTd = document.getElementById("NewsTdGlobal");
			var NewData = XmlHttpNewsHome.responseText;
			if(NewData != "")
				NewTd.innerHTML = NewData;				
			document.body.style.cursor = "auto";
			
		}
	}
}
function CreateXmlHttpNewsGlobalHome()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttpNewsGlobalHome = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{  
				XmlHttpNewsGlobalHome = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpNewsGlobalHome = false;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if (!XmlHttpNewsGlobalHome && typeof XMLHttpRequest!='undefined') 
		{
	        try 
	        {
		        XmlHttpNewsGlobalHome = new XMLHttpRequest();
	        } 
	        catch (e) 
	        {
		        XmlHttpNewsGlobalHome=false;
	        }
        }
        if (!XmlHttpNewsGlobalHome && window.createRequest) 
        {
	        try 
	        {
		        XmlHttpNewsGlobalHome = window.createRequest();
	        } 
	        catch (e)
	        {
		        XmlHttpNewsGlobalHome=false;
	        }
        }
	}

    function OpenNewsGlobalHomePopUp(NewsID,SecID,SubSecID,FinCode,Opt)
    {

         CreateXmlHttpNewsGlobalHome();
		document.body.style.cursor = "progress";		
		var requestUrl = "../HomeControls/AjaxNewsPopGlobal.aspx?timeStamp="+ new Date().getTime() +"&NewsID="+NewsID +"&SecID="+SecID +"&SubSecID="+SubSecID +"&FinCode="+FinCode;
        document.getElementById("divNews").style.display="inline";
		if(XmlHttpNewsGlobalHome)	{
					XmlHttpNewsGlobalHome.onreadystatechange = function(){getNewsRespGlobalPopUp()};
					XmlHttpNewsGlobalHome.open("GET", requestUrl,  true);
					XmlHttpNewsGlobalHome.send(null);
				}
    }
    
    function getNewsRespGlobalPopUp()
{

	if(XmlHttpNewsGlobalHome.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpNewsGlobalHome.status == 200)//
		{
		
		document.getElementById("PopUpNews").innerHTML=XmlHttpNewsGlobalHome.responseText;
		document.body.style.cursor = "auto";		
		}
		else
		{
			document.getElementById("PopUpNews").innerHTML =  "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
		
	}
}

   
//HomeNews Control JS end.............................................................................................


//HomeChart Control JS Start...........................................................................................

var SelectedTabsensex = "BSE";
var GlobalvalHome='BSE';

function sensexvalue(val)
{ 
         GlobalvalHome=val;
          if(val=='BSE')
         {
          document.getElementById("BSE").className="TabUnSelected";
          document.getElementById("TDDatebse").style.display="inline";
          document.getElementById("NSE").className="TabSelectedIn";
          document.getElementById("TDDatense").style.display="none";
          document.getElementById("SensexNifty1").style.display="inline";
          document.getElementById("SensexNifty2").style.display="none";

         }
         else
          {
          document.getElementById("NSE").className="TabUnSelected";
          document.getElementById("TDDatebse").style.display="none";
          document.getElementById("BSE").className="TabSelectedIn";
          document.getElementById("TDDatense").style.display="inline";
          document.getElementById("SensexNifty1").style.display="none";
          document.getElementById("SensexNifty2").style.display="inline";

          }
        BSENSEchartAjax();
	    Changecontrol('',GlobalvalHome);    
        
}
function BSENSEchartAjax()     
{
        var RequestUrl = "../Homecontrols/BSENSEchartAjax.aspx?Exchg="+GlobalvalHome;       
	    var so = new SWFObject("../amline/amline.swf", "BSENSEline", "231", "142", "8", "#FFFFFF");
	    so.addVariable("path", "../amline/"); 
	    so.addVariable("settings_file", encodeURIComponent("../HomeControls/BSENSEline_settings.xml"));
	    so.addVariable("data_file", encodeURIComponent(RequestUrl + "&TimeStamp="+new Date().getTime()));
	    so.addParam("wmode","opaque");
	    so.write("CompanyChart"); 
}
function CreateXmlHttpGLVolVal()
{
	try
	{
		XmlHttpGLVolVal = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpGLVolVal = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpGLVolVal = null;				
		}
	}
	if(!XmlHttpGLVolVal && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpGLVolVal = new XMLHttpRequest();
	}
}

function Changecontrol(Opt,Exch)
{
if(Opt=="")
{
Opt='1';
}
     Exch=GlobalvalHome;
     
      var currentDivObj = document.getElementById("MKTMover");
      
     CreateXmlHttpGLVolVal(); 
     for(i=1; i<=4;i++)
     {
      document.getElementById("glvv"+i).className="NormalTextBlack"
     
     }
       document.getElementById("glvv"+Opt).className="HomeHeadercolor"
    var requestUrl = "../HomeControls/AjaxDataGLVV.aspx?Option="+ Opt +"&Exchange="+ Exch + "&timeStamp="+new Date().getTime();
	if(XmlHttpGLVolVal!=null)	
	{
	    XmlHttpGLVolVal.onreadystatechange = function(){ChangeControlResponse(Opt,Exch)}
		XmlHttpGLVolVal.open('GET', requestUrl,  true);
		XmlHttpGLVolVal.send(null);
	}
    
	if(Opt=='1')
       {
        document.getElementById("Gainers").style.display="none"
        document.getElementById("Losers").style.display="inline"  
        document.getElementById("Value").style.display="inline"  
        document.getElementById("Volume").style.display="inline" 
        document.getElementById("Gainerstop").style.display="inline"
        document.getElementById("Loserstop").style.display="none"  
        document.getElementById("Valuetop").style.display="none"  
        document.getElementById("Volumetop").style.display="none"  
        document.getElementById("exhageBseNsemore").innerHTML="<a href='../Equity/TopGainersAndLosers.aspx?Option=GAIN&EXCHG="+Exch+"&id=1' class='HomeMore'><span style='text-decoration: none'>More</span></a>";
       }
       else if(Opt=='2')
       {
       document.getElementById("Losers").style.display="none"
       document.getElementById("Gainers").style.display="inline"        
       document.getElementById("Value").style.display="inline"  
       document.getElementById("Volume").style.display="inline"  
       document.getElementById("Loserstop").style.display="inline"
       document.getElementById("Gainerstop").style.display="none"        
       document.getElementById("Valuetop").style.display="none"  
       document.getElementById("Volumetop").style.display="none"  
       document.getElementById("exhageBseNsemore").innerHTML="<a href='../Equity/TopGainersAndLosers.aspx?Option=LOSE&EXCHG="+Exch+"&id=1' class='HomeMore'><span style='text-decoration: none'>More</span></a>"; 
     
       }
       else if(Opt=='3')
       {
       document.getElementById("Value").style.display="none" 
       document.getElementById("Gainers").style.display="inline"        
       document.getElementById("Losers").style.display="inline"  
       document.getElementById("Volume").style.display="inline" 
       document.getElementById("Valuetop").style.display="inline" 
       document.getElementById("Gainerstop").style.display="none"        
       document.getElementById("Loserstop").style.display="none"  
       document.getElementById("Volumetop").style.display="none"   
       document.getElementById("exhageBseNsemore").innerHTML="<a href='../Equity/MostActive.aspx?Option=Value&EXCHG="+Exch+"&id=3' class='HomeMore'><span style='text-decoration: none'>More</span></a>"; 
   
       }
       else if(Opt=='4')
       {
       document.getElementById("Volume").style.display="none" 
       document.getElementById("Gainers").style.display="inline"        
       document.getElementById("Value").style.display="inline"  
       document.getElementById("Losers").style.display="inline"   
       document.getElementById("Volumetop").style.display="inline" 
       document.getElementById("Gainerstop").style.display="none"        
       document.getElementById("Valuetop").style.display="none"  
       document.getElementById("Loserstop").style.display="none"     
       document.getElementById("exhageBseNsemore").innerHTML="<a href='../Equity/MostActive.aspx?Option=Volume&EXCHG="+Exch+"&id=3' class='HomeMore'><span style='text-decoration: none'>More</span></a>"; 

       }
	return false; 
  
 
}
function ChangeControlResponse(Opt,Exch)
{
	
	if(XmlHttpGLVolVal.readyState == 4)
	{
		var td_Id = document.getElementById("MKTMover");
		if(XmlHttpGLVolVal.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpGLVolVal.responseText;
			
			
			document.body.style.cursor = "auto";	
		}
		else
		{
			td_Id.innerHTML =  "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
}


//HomeChart Control JS End............................................................................................

function SchResult()
 {
 

		
	 var txtSchName = document.getElementById("ctl00_ContentPlaceHolder1_txtSchName");
	 if(txtSchName.value=="Enter Company Name")
	{ 
	alert("Please enter company name");
	txtSchName.value="";
	txtSchName.focus();
	
	} 
	else
		{
 		var SearchResult = document.getElementById("ctl00_ContentPlaceHolder1_lbSchResult");	
 		document.getElementById("serchresult").style.display="";		
 		document.getElementById("Go").disabled=false;
		CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		var requestUrl = "GetSchDataAjax.aspx?timeStamp="+ new Date().getTime() +"&txtSchName="+txtSchName.value;
	
		if(XmlHttpFO)	{
					XmlHttpFO.onreadystatechange = function(){fillSymbolResp(SearchResult)};
					XmlHttpFO.open("GET", requestUrl,  true);
					XmlHttpFO.send(null);
				}
				}
		
 }
 
	
