﻿// JScript File
function CreateXmlHttpEqNews()
{
    //Creating object of XMLHTTP in IE
	try
	{
		XmlHttpEqNews= new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttpEqNews = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpEqNews = null;	
		}
	}
	
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttpEqNews && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpEqNews = new XMLHttpRequest();
	}
}

function CreateXmlHttpEqNews1()
{
    //Creating object of XMLHTTP in IE
	try
	{
		XmlHttpEqNews1= new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttpEqNews1 = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpEqNews1 = null;	
		}
	}
	
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttpEqNews1 && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpEqNews1 = new XMLHttpRequest();
	}
}

function GetNewsEquity(SecID,SubSec)
{	
    CreateXmlHttpEqNews();
    CreateXmlHttpEqNews1();
	document.body.style.cursor = "progress";
	
	document.getElementById("NewTdEquity").innerHTML ="";
	document.getElementById("NewTdEquity1").innerHTML ="";
	
	var requestUrl = "AjaxEqNews.aspx?Sec="+ SecID +"&SubSec="+SubSec+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
	var requestUrl1 = "AjaxEqNews1.aspx?Sec="+ SecID +"&SubSec="+SubSec+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
	
	if(XmlHttpEqNews)
	{
	    XmlHttpEqNews.onreadystatechange = function(){getDataResponseEqNews();};
		XmlHttpEqNews.open("GET", requestUrl,  true);
		XmlHttpEqNews.send(null);
	}
	if(XmlHttpEqNews1)
	{
	    XmlHttpEqNews1.onreadystatechange = function(){getDataResponseEqNews1();};
		XmlHttpEqNews1.open("GET", requestUrl1,  true);
		XmlHttpEqNews1.send(null);
	}
}

function getDataResponseEqNews()
{
    if(XmlHttpEqNews.readyState == 4)
	{	
	    if(XmlHttpEqNews.status == 200)
		{				
		    var NewTd = document.getElementById("NewTdEquity");
			var NewData = XmlHttpEqNews.responseText;
					
			if(NewData != "")
				NewTd.innerHTML = NewData;
			
			document.body.style.cursor = "auto";
		}
	}
}
function getDataResponseEqNews1()
{
    if(XmlHttpEqNews1.readyState == 4)
	{	
	    if(XmlHttpEqNews1.status == 200)
		{				
		    var NewTd1 = document.getElementById("NewTdEquity1");
			var NewData1 = XmlHttpEqNews1.responseText;
			
			if(NewData1 != "")
				NewTd1.innerHTML = "<marquee onmouseover='this.stop();' onmouseout='this.start();' trueSpeed scrollAmount='1' height=30px scrollDelay='150' direction='up' loop='repeat' width='100%'>" + NewData1 + "</marquee>";
			document.body.style.cursor = "auto";
		}
	}
}

function CreateXmlHttpEqPop()
{
	try
	{
		XmlHttpEqPop= new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttpEqPop = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpEqPop = null;	
		}
	}
	
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttpEqPop && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpEqPop = new XMLHttpRequest();
	}
}
	
function GetNewsDetailEq(secId,SubSecId,NewsID,opt)
{
    var NewsWin = document.getElementById("divNews").style.display='inline';
	var currentDivObj;	
		
	currentDivObj = document.getElementById("TdNews");
	currentDivObj.innerHTML ="<img src=loading.gif>"; 
	CreateXmlHttpEqPop();
	document.body.style.cursor = "progress";
	
	var requestUrl = "PopupNewsData.aspx?SecId="+ secId +"&SubSecId="+ SubSecId+"&NewsID="+NewsID+"&timeStamp="+new Date().getTime()+"opt="+opt;
	
	if(XmlHttpEqPop)	
	{
	    XmlHttpEqPop.onreadystatechange = function(){getDetailsRespEq();};
		XmlHttpEqPop.open("GET", requestUrl,  true);
		XmlHttpEqPop.send(null);					
	}
}
	
function getDetailsRespEq()
{
    // To make sure receiving response data from server is completed
	if(XmlHttpEqPop.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpEqPop.status == 200)
		{				
		    document.getElementById("TdNews").innerHTML = XmlHttpEqPop.responseText;
			document.body.style.cursor = "auto";
		}
		else
		{
		    document.getElementById("NewsId").innerHTML = "<img src=loading.gif>";
		}
	}
}

function ShowTabEq(Opt1)
{
    if(Opt1 == "FirstTab")
    {
        document.getElementById("FirstTab").style.display = "inline";
        document.getElementById("SecondTab").style.display = "none";
        document.getElementById("PlusMinus1").className = "MinusTab";
        document.getElementById("PlusMinus2").className = "PlusTab";
        ChangeControlEq("GAIN","BSE");
    }
    if(Opt1 == "SecondTab")
    {
        document.getElementById("FirstTab").style.display = "none";
        document.getElementById("SecondTab").style.display = "inline";
        document.getElementById("PlusMinus1").className = "PlusTab";
        document.getElementById("PlusMinus2").className = "MinusTab";
        ChangeControlEq("GAIN","NSE");
    }
}

var XmlHttpGLVolValEq;
function CreateXmlHttpGLVolValEq()
{
	try
	{
		XmlHttpGLVolValEq = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpGLVolValEq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpGLVolValEq = null;				
		}
	}
	
	if(!XmlHttpGLVolValEq && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpGLVolValEq = new XMLHttpRequest();
	}
}

function ChangeControlEq(Opt,Exch)
{
    CreateXmlHttpGLVolValEq();
    var currentDivObj = document.getElementById("Td_Data");
	document.body.style.cursor = "progress";
	var requestUrl = "AjaxDataGLVVEq.aspx?Option="+ Opt +"&Exchange="+ Exch;
   
	if(XmlHttpGLVolValEq!=null)	
	{
	    XmlHttpGLVolValEq.onreadystatechange = function(){ChangeControlResponseEq(Opt,Exch)}
		XmlHttpGLVolValEq.open('GET', requestUrl,  true);
		XmlHttpGLVolValEq.send(null);
	}
	return false; 
}	
	
function ChangeControlResponseEq(Opt,Exch)
{
    var Head_td =document.getElementById("Heading");
    var More=document.getElementById("More");
    var BSE_td =document.getElementById("Td_BSE");
    var NSE_td =document.getElementById("Td_NSE");
	
	switch (Opt)
	{
	    case "GAIN":
		    Head_td.innerHTML="Gainers";
		    break;
		
	    case "LOSE":
		    Head_td.innerHTML="Losers";
	        break;
	    
	    case "Vol":
		    Head_td.innerHTML="Volume";
	        break;
	    
	    case "Val":
	        Head_td.innerHTML="Value";
	        break;
	}
	
	if(XmlHttpGLVolValEq.readyState == 4)
	{
		var td_Id = document.getElementById("Td_Data");
		
		if(XmlHttpGLVolValEq.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpGLVolValEq.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 ContributionTab(Opt)
{
    if(Opt == "Sensex")
    {
       document.getElementById("Sensex").className = "EqHomeSelTab";
       document.getElementById("Nifty").className = "EqHomeUnSelTab";  
       GetDataCTI('BSE');
    }
    else
    {
       document.getElementById("Sensex").className = "EqHomeUnSelTab";
       document.getElementById("Nifty").className = "EqHomeSelTab"; 
       GetDataCTI('NSE');
    }
}

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=12&Option=GAIN&EXCHG=BSE";
    }
    else
    {
        document.getElementById("MoreCTI").href="../Equity/ContributionToIndex.aspx?id=12&Option=GAIN&EXCHG=NSE";
    }
    
    currentDivObj.innerHTML ="<img src='../App_Themes/Seeta/Images/loading.gif'>";
	document.body.style.cursor = "progress";
	
	var requestUrl = "../Equity/AjaxCTI.aspx?Exchange="+ Exch;
	
	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)
	{
		var td_Id = document.getElementById("tdCTIndex");
		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";
		}
	}
}

/* Get Quotes */

function SearchemptyEq()
{
    if (document.getElementById("txtCompanyEq").value=="Enter Company Name")
    {
        document.getElementById("txtCompanyEq").value="";
    }
}

function SearchfillEq()
{
    var getquote=document.getElementById("txtCompanyEq").value;
    
    if (getquote=="")
    {
        document.getElementById("txtCompanyEq").value="Enter Company Name";
    }
}	
        
function QuoteEnterScriptEq(e,id)
{
    if(e.keyCode==13)	
    {
        var Scripid = document.getElementById(id);
        Scripid.click();
    }
}
        
function SearchCompanyEq()
{
    var SearchTxt = document.getElementById("txtCompanyEq").value;
    var Id = document.getElementById("ddlQuoteEq").value;	
    		
    if(SearchTxt =="" || SearchTxt=="Enter Company Name")
    {
        alert("Please enter company name ..!!!");
        document.getElementById("txtCompanyEq").value="";
        document.getElementById("txtCompanyEq").focus();
        return false;
    }
    else
    {
        var ddlQuote = document.getElementById("ddlQuoteEq").value
        
        if(ddlQuote=="1")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=1";
        } 
        if(ddlQuote=="2")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=2";
        }  
        if(ddlQuote=="3")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=3";
        }
        if(ddlQuote=="4")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=4";
        } 
        if(ddlQuote=="5")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=5";
        }  
        if(ddlQuote=="6")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=6";
        }  
        if(ddlQuote=="7")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=7";
        } 
        if(ddlQuote=="8")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=8";
        } 
        if(ddlQuote=="9")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=9";
        } 
        if(ddlQuote=="10")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=10";
        } 
        if(ddlQuote=="11")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=11";
        } 
        if(ddlQuote=="12")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=12";
        } 
        if(ddlQuote=="13")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=13";
        } 
        if(ddlQuote=="14")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=14";
        } 
        if(ddlQuote=="15")
        {
            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=15";
        } 
    }
}

function SearchemptyEq()
{
	if (document.getElementById("txtCompanyEq").value=="Enter Company Name")
	{
		document.getElementById("txtCompanyEq").value="";
	}
}

/* BSE Announcement */
var XmlHttpBA;

function CreateXmlHttpBA()
{
    try
	{
		XmlHttpBA = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttpBA = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpBA = null;
		}
	}
	if(!XmlHttpBA && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpBA = new XMLHttpRequest();
	}
}
	
function GetBSEAnn(opt)
{	
    CreateXmlHttpBA();
	document.body.style.cursor = "progress";
	document.getElementById("tdBseAnn").innerHTML = " <img src='../App_Themes/Seeta/Images/loading.gif'>";
	var requestUrl = "../Equity/BseAnnAjax.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime()+"&Opt="+opt;
	
	if(XmlHttpBA)
	{
		XmlHttpBA.onreadystatechange = function(){getDataResponseBSEAnn();};
		XmlHttpBA.open("GET", requestUrl,  true);
		XmlHttpBA.send(null);
	}
}

function getDataResponseBSEAnn()
{
    if(XmlHttpBA.readyState == 4)
	{	
	    if(XmlHttpBA.status == 200)
		{				
		    var BSEAnn = document.getElementById("tdBseAnn");
			var strData = XmlHttpBA.responseText;
			
			if(strData != "")
			 {	
			    var arrSchm = strData.split("|");
			   
			    for(i=0; i<arrSchm.length-1; i++) 
			    {	
				    var strSchm = arrSchm[i];
				    var arrSchmCode = strSchm.split("~");
				    BSEAnn.innerHTML = arrSchmCode[1];
			    }
			}
		}
	}
}

var XmlHttpBAI;

function CreateXmlHttpBAI_1()
{
	try
	{
		XmlHttpBAI_1 = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpBAI_1 = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
    	{
			XmlHttpBAI_1 = null;
		}
	}
	if(!XmlHttpBAI_1 && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpBAI_1 = new XMLHttpRequest();
	}
}
	
function GetBSEAnnInn(srno)
{	
	var NewsWin = document.getElementById("divNews").style.display='inline';
	var currentDivObj;
	currentDivObj = document.getElementById("TdNews");
	currentDivObj.innerHTML ="<img src=../App_Themes/Seeta/Images/loading.gif>"; 
	CreateXmlHttpBAI_1();
	document.body.style.cursor = "progress";
	
	var requestUrl = "../Equity/BSEAnnPopUp.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime()+"&srno="+srno;	
	
    if(XmlHttpBAI_1)	
	{
	    XmlHttpBAI_1.onreadystatechange = function(){getDetailsRespBAI();};
		XmlHttpBAI_1.open("GET", requestUrl,  true);
		XmlHttpBAI_1.send(null);					
	}
}

function getDetailsRespBAI()
{
    // To make sure receiving response data from server is completed
	if(XmlHttpBAI_1.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpBAI_1.status == 200)
		{		
		    document.getElementById("TdNews").innerHTML = XmlHttpBAI_1.responseText;
			document.body.style.cursor = "auto";
		}
		else
		{
		    document.getElementById("TdNews").innerHTML = "No Data Found..";
		}
	}
}

/* Grid PopUp */
// 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;
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("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=9','../CompanyProfile/FinanceRatios.aspx?id=7','../CompanyProfile/ChartDisplay.aspx?id=10');

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 ItemMouseOver(currentRow)
{
    oRow = document.getElementById(currentRow);
    oRow.originalBackgroundColor = oRow.style.backgroundColor
    oRow.style.backgroundColor = 'red';
}

function ItemMouseOut(currentRow)
{
    oRow = document.getElementById(currentRow);
    oRow.style.backgroundColor = oRow.originalBackgroundColor;
}
    
    
 function GetData(Exch)
{
	CreateXmlHttpGL();
       var currentDivObj = document.getElementById("Td_Data");
       
        
		currentDivObj.innerHTML ="<img src=../App_Themes/CommonTheme/images/loading.gif>";
	document.body.style.cursor = "progress";
	
	
	var requestUrl = "AjaxValVolGL.aspx?Exchange="+ Exch;
   // window.open(requestUrl) 
	if(XmlHttpGL!=null)	
	        {
				XmlHttpGL.onreadystatechange = function(){ChangeResponse(Exch)}
				XmlHttpGL.open('GET', requestUrl,  true);
				XmlHttpGL.send(null);
			}
			 return false; 
}	
	
	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 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";
		}
	}
}	
    
    


