﻿// JScript File


// 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 CreateXmlHttpGL()
	{
		try
		{
			XmlHttpGL = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpGL = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpGL = null;
					
			}
		}
		if(!XmlHttpGL && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpGL = 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;
  }
}


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 GetNewsHot(SecID,SubSec)
	{	
	//alert(Exchg);	
		CreateXmlHttp();
		document.body.style.cursor = "progress";
		document.getElementById("NewTd").innerHTML = " <img src='../App_Themes/Common/images/ajax-loader.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 = "HotnewsAjax.aspx?Sec="+ SecID +"&SubSec="+SubSec+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		//alert(requestUrl);
		if(XmlHttp){
			XmlHttp.onreadystatechange = function(){getDataResponse();};
			XmlHttp.open("GET", requestUrl,  true);
			XmlHttp.send(null);
		}
}
function getDataResponse()
{
	if(XmlHttp.readyState == 4)
	{	
	
		if(XmlHttp.status == 200)
		{				
		
			
			var NewTd = document.getElementById("NewTd");
			var NewData = XmlHttp.responseText;
			//alert(NewData);
						
			if(NewData != "")
		
				NewTd.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 tempY_New = document.body.scrollTop + 50;

		var NewsWin = document.getElementById("divNews").style.display='inline';
		document.getElementById("divNews").style.top = tempY_New + "px";
		
		//document.getElementById("popup").style.left = tempX + "px";
 	//document.getElementById("divNews").style.top = tempY + "px";
		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 GetData(Exch)
{
	CreateXmlHttpGL();
       var currentDivObj = document.getElementById("Td_Data");
       
        
		currentDivObj.innerHTML ="<img src=../App_Themes/Common/images/ajax-loader.gif>";
	document.body.style.cursor = "progress";
	
	
	var requestUrl = "../AjaxValVolGL.aspx?Exchange="+ Exch +"&Opt=In";
   //alert(requestUrl) 
	if(XmlHttpGL!=null)	
	        {
				XmlHttpGL.onreadystatechange = function(){ChangeResponse(Exch)}
				XmlHttpGL.open('GET', requestUrl,  true);
				XmlHttpGL.send(null);
			}
			 return false; 
}	
	
function ChangeResponse(Exch)
{
    var Head_td =document.getElementById("Heading");
    var More=document.getElementById("More");
   

	// To make sure receiving response data from server is completed
	
	if(XmlHttpGL.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		var td_Id = document.getElementById("Td_Data");
	    //alert(XmlHttp.status)
		if(XmlHttpGL.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpGL.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 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;
  	
 }
 
 
 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 = event.clientX + document.body.scrollLeft + "px";
 	document.getElementById("popup").style.top = event.clientY + document.body.scrollTop + "px";
 //alert(event.clientX);
 //alert(event.clientY);
 
 	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=9','../CompanyProfile/FinanceRatios.aspx?id=7','../CompanyProfile/ChartDisplay.aspx?id=10');

 
 
 
 var tempX = 0;
 var tempY = 0;
 var tempY_Div = 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;
 		tempY_Div = document.body.scrollTop + 50;
 	}
 	else
 	{
 		tempX = e.pageX;
 	    tempY = e.pageY;
 	    tempY_Div = e.pageY;
 	}
 	return true;
 }
 
 var XmlMarketBSE;
function CreateXmlMarketBSE()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlMarketBSE = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{  
				XmlMarketBSE = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlMarketBSE = false;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if (!XmlMarketBSE && typeof XMLHttpRequest!='undefined') 
		{
	        try 
	        {
		        XmlMarketBSE = new XMLHttpRequest();
	        } 
	        catch (e) 
	        {
		        XmlMarketBSE=false;
	        }
        }
        if (!XmlMarketBSE && window.createRequest) 
        {
	        try 
	        {
		        XmlMarketBSE = window.createRequest();
	        } 
	        catch (e)
	        {
		        XmlMarketBSE=false;
	        }
        }
	
	}

var XmlMarketNSE;
function CreateXmlMarketNSE()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlMarketNSE = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{  
				XmlMarketNSE = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlMarketNSE = false;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if (!XmlMarketNSE && typeof XMLHttpRequest!='undefined') 
		{
	        try 
	        {
		        XmlMarketNSE = new XMLHttpRequest();
	        } 
	        catch (e) 
	        {
		        XmlMarketNSE=false;
	        }
        }
        if (!XmlMarketNSE && window.createRequest) 
        {
	        try 
	        {
		        XmlMarketNSE = window.createRequest();
	        } 
	        catch (e)
	        {
		        XmlMarketNSE=false;
	        }
        }
	
	}


function BseDatadisplay()
{

   CreateXmlMarketBSE();
    var currentDivObj = document.getElementById("BSEMarketGlanceCtrl");
	document.body.style.cursor = "progress";
	var requestUrl = "EqAjaxMarketGlanceCtrl.aspx?Exchange=BSE&timeStamp="+new Date().getTime();
	
	if(XmlMarketBSE!=null)	
	{
	    XmlMarketBSE.onreadystatechange = function(){ChangeXmlMarketBSE()}
		XmlMarketBSE.open('GET', requestUrl,  true);
		XmlMarketBSE.send(null);
	}
	LoadMarketBSE();
	
}
	
	function NseDatadisplay()
	{

	CreateXmlMarketNSE();
	var currentDivObj = document.getElementById("NSEMarketGlanceCtrl");
	document.body.style.cursor = "progress";
  
	var requestUrl = "EqAjaxMarketGlanceCtrl.aspx?Exchange=NSE&timeStamp="+new Date().getTime();
	
	if(XmlMarketNSE!=null)	
	{
	    XmlMarketNSE.onreadystatechange = function(){ChangeXmlMarketNSE()}
		XmlMarketNSE.open('GET', requestUrl,  true);
		XmlMarketNSE.send(null);
	}
	LoadMarketNSE();
	
}

function ChangeXmlMarketBSE()
{
   	if(XmlMarketBSE.readyState == 4)
	{
		var Td_DataDeriFii = document.getElementById("BSEMarketGlanceCtrl");
		
		if(XmlMarketBSE.status == 200)//
		{
			Td_DataDeriFii.innerHTML =  XmlMarketBSE.responseText;
			document.body.style.cursor = "auto";
			//alert(XmlMarketBSE.responseText);		
		}
		else
		{
			Td_DataDeriFii.innerHTML =  "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
}

function ChangeXmlMarketNSE()
{
   	if(XmlMarketNSE.readyState == 4)
	{
		var Td_DataDeriFii = document.getElementById("NSEMarketGlanceCtrl");
		
		if(XmlMarketNSE.status == 200)//
		{
			Td_DataDeriFii.innerHTML =  XmlMarketNSE.responseText;
			document.body.style.cursor = "auto";	
			//alert(XmlMarketBSE.responseText);	
		}
		else
		{
			Td_DataDeriFii.innerHTML =  "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
}


