﻿

// JScript File

var xmlHttp
var browser = new Browser();

function CreateXmlHttp()
	{
		try
		{
			XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttp = null;
					
			}
		}
		if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttp = new XMLHttpRequest();
		}
	}
	
	function CreateXmlHttpGLE()
	{
		try
		{
			XmlHttpGLE = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpGLE = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpGLE = null;
					
			}
		}
		if(!XmlHttpGLE && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpGLE = new XMLHttpRequest();
		}
	}


function Browser()
 {
  var ua, s, i;
  this.isIE    = false;
  this.isNS    = false;
  this.version = null;
  ua = navigator.userAgent;
  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) 
  {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0)
   {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
   }

  // Treat any other "Gecko" browser as NS 6.1.
  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0)
   {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}
var XmlHttpTS;

function CreateXmlHttpTS()
	{
		try
		{
			XmlHttpTS = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpTS = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpTS = null;
					
			}
		}
		if(!XmlHttpTS && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpTS = new XMLHttpRequest();
		}
	}

function ChgEqyityHome(Exchg)
{	
	
	 
	var Exchg;
	if(Exchg=="BSE")
	{		
          document.getElementById("tblFirst").style.display = 'inline';		
		 document.getElementById("tblSecond").style.display = 'none';
		 GetDataBB("BSE");			
				
	}
	else 
	{	
		
         document.getElementById("tblFirst").style.display = 'none';		
		    document.getElementById("tblSecond").style.display = 'inline';
        GetDataBB("NSE");	
		
		
			
				
				//Exchg.style.backgroundColor='red';
	}	
}




function GetTalkingStockHot(SecID,SubSec)
	{	
	//alert(Exchg);	
		CreateXmlHttpTS();
		document.body.style.cursor = "progress";
		document.getElementById("TalkingStockTD").innerHTML = " <img src='../App_Themes/Common/images/loading.gif'>";
		//if(Exchg=="NSE"){document.NseTickImg.src="../images/NSEon.gif";document.BseTickImg.src="../images/BSEoff.gif";}else{document.NseTickImg.src="../images/NSEoff.gif";document.BseTickImg.src="../images/BSEon.gif";}
		var requestUrl = "TalkingStockAjax.aspx?Sec="+ SecID +"&SubSec="+SubSec+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		//alert(requestUrl);
		if(XmlHttpTS){
			XmlHttpTS.onreadystatechange = function(){getDataResponseTalkingStock();};
			XmlHttpTS.open("GET", requestUrl,  true);
			XmlHttpTS.send(null);
		}
}
function getDataResponseTalkingStock()
{
	if(XmlHttpTS.readyState == 4)
	{	
	
		if(XmlHttpTS.status == 200)
		{				
		
			
			var TalkingStockTD = document.getElementById("TalkingStockTD");
			var NewData = XmlHttpTS.responseText;
			//alert(NewData);
						
			if(NewData != "")
		
				TalkingStockTD.innerHTML = NewData;				
				document.body.style.cursor = "auto";
				
		}
		
		//else
			//MarqueeId.innerHTML = "<img src='../CommonImgs/loading1.gif'>";
	}
}



  function CreateXmlHttpPop()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttpPop= new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpPop = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpPop = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttpPop && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpPop = new XMLHttpRequest();
		}
	}
	
    function GetNewsDetail(secId,SubSecId,NewsID,opt)
	{

		var NewsWin = document.getElementById("divNews").style.display='inline';
		var currentDivObj;	
		
			currentDivObj = document.getElementById("TdNews");
			//alert(currentDivObj);
			currentDivObj.innerHTML ="<img src=App_Themes/Common/images/ajax-loader.gif>"; 
		
		CreateXmlHttpPop();
		document.body.style.cursor = "progress";
		var requestUrl = "../PopupNewsData.aspx?SecId="+ secId +"&SubSecId="+ SubSecId+"&NewsID="+NewsID+"&timeStamp="+new Date().getTime()+"opt="+opt;
		//alert(requestUrl);
		if(XmlHttpPop)	{
					XmlHttpPop.onreadystatechange = function(){getDetailsResp();};
					XmlHttpPop.open("GET", requestUrl,  true);
					XmlHttpPop.send(null);					
				}
	}
	
	function getDetailsResp()
	{
		// To make sure receiving response data from server is completed
		if(XmlHttpPop.readyState == 4)
		{
			// To make sure valid response is received from the server, 200 means response received is OK
			if(XmlHttpPop.status == 200)
			{
				
				
					document.getElementById("TdNews").innerHTML = XmlHttpPop.responseText;
				
				document.body.style.cursor = "auto";
			}
			else
			{
				
					document.getElementById("NewsId").innerHTML = "<img src=App_Themes/Common/images/ajax-loader.gif>";
				
			}
		}
	}
	


function GetInternationalData()
{
	CreateXmlHttpGLE();
       var currentDivObj = document.getElementById("tdInterIndices");
       
        
		currentDivObj.innerHTML ="<img src=../App_Themes/Common/images/loading.gif>";
	document.body.style.cursor = "progress";
	
	
	var requestUrl = "AjaxInternationalIndices.aspx?timeStamp="+new Date().getTime();
   //alert(requestUrl) 
	if(XmlHttpGLE!=null)	
	        {
				XmlHttpGLE.onreadystatechange = function(){ChangeResponseInternational()}
				XmlHttpGLE.open('GET', requestUrl,  true);
				XmlHttpGLE.send(null);
			}
			 return false; 
}	
	
function ChangeResponseInternational()
{
 
	// To make sure receiving response data from server is completed
	
	if(XmlHttpGLE.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		var td_Id = document.getElementById("tdInterIndices");
	   // alert(XmlHttpGLE.status)
		if(XmlHttpGLE.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpGLE.responseText;
				
			document.body.style.cursor = "auto";		
		}
		else
		{
			td_Id.innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}	

var XmlHttpMG;
	function CreateXmlHttpMG()
	{
		try
		{
			XmlHttpMG = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpMG = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpMG = null;
					
			}
		}
		if(!XmlHttpMG && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpMG = new XMLHttpRequest();
		}
	}

function GetMarketGlanceData(secId,subSecId)
{
	CreateXmlHttpMG();
       var currentDivObj = document.getElementById("tdInterIndices");
       
        
		currentDivObj.innerHTML ="<img src=../App_Themes/Common/images/loading.gif>";
	document.body.style.cursor = "progress";
	
	
	var requestUrl = "AjaxMarketGlance.aspx?timeStamp="+new Date().getTime()+"&SecId="+secId+"&SubSecId="+subSecId;
//   alert(requestUrl) 
	if(XmlHttpMG!=null)	
	        {
				XmlHttpMG.onreadystatechange = function(){ChangeResponseMarketGlance()}
				XmlHttpMG.open('GET', requestUrl,  true);
				XmlHttpMG.send(null);
			}
			 return false; 
}	
	
function ChangeResponseMarketGlance()
{
 
	// To make sure receiving response data from server is completed
	
	if(XmlHttpMG.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		var td_Id = document.getElementById("tdMarketGlance");
    //	   alert(XmlHttpMG.status)
		if(XmlHttpMG.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpMG.responseText;
				
			document.body.style.cursor = "auto";		
		}
		else
		{
			td_Id.innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}	




function CreateXmlHttpBB()
	{
		try
		{
			XmlHttpBB = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpBB = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpBB = null;
					
			}
		}
		if(!XmlHttpBB && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpBB = new XMLHttpRequest();
		}
	}


function GetDataBB(Exch)
{
	CreateXmlHttpBB();
       var currentDivObj = document.getElementById("Td_DataBB");
       
        
		currentDivObj.innerHTML ="<img src=../App_Themes/Common/images/ajax-loader.gif>";
	    document.body.style.cursor = "progress";
	
	
	var requestUrl = "../Equity/AjaxOnlyBS.aspx?Exchange="+ Exch;
   //alert(requestUrl) 
	if(XmlHttpBB!=null)	
	        {
				XmlHttpBB.onreadystatechange = function(){ChangeResponseBB(Exch)}
				XmlHttpBB.open('GET', requestUrl,  true);
				XmlHttpBB.send(null);
			}
			 return false; 
}	
	
function ChangeResponseBB(Exch)
{
   
	if(XmlHttpBB.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		var td_Id = document.getElementById("Td_DataBB");
	    //alert(XmlHttp.status)
		if(XmlHttpBB.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpBB.responseText;
				
			document.body.style.cursor = "auto";		
		}
		else
		{
			td_Id.innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}



function sensexnifty(val)
{

    if(val=='BSE')
    {
        // document.getElementById("Blend").style.filter = "blendTrans(Duration=1.0,Transition=0)";
       GetDataCTI("BSE");
        document.getElementById('tdBSECTI').src="../App_Themes/Common/images/sensexOn.gif";
        document.getElementById('tdNSECTI').src="../App_Themes/Common/images/NIFTYOFF.gif";
      
       
        
    }
    else
    {
     //document.getElementById("Blend").style.filter = "blendTrans(Duration=1.0,Transition=0)";
        GetDataCTI('NSE');
       
        document.getElementById('tdBSECTI').src="../App_Themes/Common/images/sensexOff.gif";
        document.getElementById('tdNSECTI').src="../App_Themes/Common/images/NIFTYON.gif";
       
       
       
    return true;
}


return true;
}

var XmlHttpCTI;

function CreateXmlHttpCTI()
	{
		try
		{
			XmlHttpCTI = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpCTI = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpCTI = null;
					
			}
		}
		if(!XmlHttpCTI && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpCTI = new XMLHttpRequest();
		}
	}


function GetDataCTI(Exch)
{
	CreateXmlHttpCTI();
       var currentDivObj = document.getElementById("tdCTIndex");
       if(Exch=='BSE')
       {
       document.getElementById("MoreCTI").href="../Equity/ContributionToIndex.aspx?id=13&Option=GAIN&EXCHG=BSE";
       }
       else
       {
         document.getElementById("MoreCTI").href="../Equity/ContributionToIndex.aspx?id=13&Option=GAIN&EXCHG=NSE";
       }
       
        
		currentDivObj.innerHTML ="<img src=../App_Themes/Common/images/loading.gif>";
	    document.body.style.cursor = "progress";
        document.g  
	
	var requestUrl = "../Equity/AjaxCTI.aspx?Exchange="+ Exch;
   //alert(requestUrl) 
	if(XmlHttpCTI!=null)	
	        {
				XmlHttpCTI.onreadystatechange = function(){ChangeResponseCTI(Exch)}
				XmlHttpCTI.open('GET', requestUrl,  true);
				XmlHttpCTI.send(null);
			}
			 return false; 
}	
	
function ChangeResponseCTI(Exch)
{
   
	if(XmlHttpCTI.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		var td_Id = document.getElementById("tdCTIndex");
	    //alert(XmlHttp.status)
		if(XmlHttpCTI.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpCTI.responseText;
				
			document.body.style.cursor = "auto";		
		}
		else
		{
			td_Id.innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}
     // Functions for showing and hiding divs

 var tempX = 0;
 var tempY = 0;
 var m_show = 0;
 var f_sc_id = "";
 var f_sc_dispid = "";
 var f_sc_comp = "";
 var f_topic_id = 0;
 var f_buy_id =0;

 //setInterval("hide_popup1()",1000);
 
 var IE = document.all?true:false
 
 if (!IE) document.captureEvents(Event.MOUSEMOVE)
 document.onmousemove = getMouseXY;
 
 function getMouseXY(e) 
 {
 	if(IE)
 	{
 	    tempX = event.clientX + document.body.scrollLeft;
 		tempY = event.clientY + document.body.scrollTop;
 	}
 	else
 	{
 		tempX = e.pageX;
 	    tempY = e.pageY;
 	}
 	return true;
 }
 
 function show_popup(m_im_id, m_im_shortdesc, m_im_desc, m_ff_desc, m_ff_id, m_fundclass)
 {
 
 	f_im_id = m_im_id;
 	f_im_shortdesc = m_im_shortdesc;
 	f_im_desc = m_im_desc;
 	f_ff_desc = m_ff_desc;
 	f_ff_id = m_ff_id;
 	f_fundclass = m_fundclass;

 	//document.getElementById("head1").innerHTML = " Company Profile " ;
 	document.getElementById("popup").style.left = tempX + "px";
 	document.getElementById("popup").style.top = tempY + "px";
 	document.getElementById("popup").style.visibility = "visible";
 	m_show = 1;
 }
 
 function hide_popup()
 {
   

 	if(m_show == 0)
 	{
 		document.getElementById("popup").style.visibility = "hidden";
 	}
 }

var m_urls = Array('../CompanyProfile/QuoteFinder.aspx?id=1','../CompanyProfile/MF_Holdings.aspx?id=14','../CompanyProfile/FinanceRatios.aspx?id=7','../CompanyProfile/ChartDisplay.aspx?id=9');


function id_click(m_id)
 {
 	
 	if(m_id == 1)
 		window.location = m_urls[m_id-1] +"&FinCode="+ f_im_id;
 	else if(m_id == 2) 	    
 	    window.location = m_urls[m_id-1] +"&FinCode="+ f_im_id;
 	else if(m_id == 3)
 		window.location = m_urls[m_id-1] +"&FinCode="+ f_im_id;
 	else if(m_id == 4)
 		window.location = m_urls[m_id-1] +"&FinCode="+ f_im_id;
 
 	else
 		window.location = m_urls[m_id-1] + f_im_id;
  	
 }
 
 
 
 

