﻿// JScript File

function CreateXmlHttpHomeNews()
{
	try
	{
		XmlHttpHomeNews = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpHomeNews = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpHomeNews = null;				
		}
	}
	if(!XmlHttpHomeNews && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpHomeNews = new XMLHttpRequest();
	}
}


 function GetNewsHot(SecID,SubSec,NewsType)
	{	
	
			if(NewsType == "Stock")
		    {
		     document.getElementById("TdStock").className= 'TabTextHomeSel';		
		     document.getElementById("TdMrkt").className = 'TabTextHome';
		     document.getElementById("TdCorporate").className = 'TabTextHome';		
		     document.getElementById("TdEconomy").className = 'TabTextHome';
		    }
		   
	        if(NewsType == "Mrkt")
	        {
	         document.getElementById("TdStock").className= 'TabTextHome';		
		     document.getElementById("TdMrkt").className = 'TabTextHomeSel';
		     document.getElementById("TdCorporate").className = 'TabTextHome';		
		     document.getElementById("TdEconomy").className = 'TabTextHome';
	        }
		  
	        if(NewsType == "Cor")
            {
            document.getElementById("TdStock").className= 'TabTextHome';		
		     document.getElementById("TdMrkt").className = 'TabTextHome';
		     document.getElementById("TdCorporate").className = 'TabTextHomeSel';		
		     document.getElementById("TdEconomy").className = 'TabTextHome';
            }
           
             if(NewsType == "Eco")
	         {
	          document.getElementById("TdStock").className= 'TabTextHome';		
		     document.getElementById("TdMrkt").className = 'TabTextHome';
		     document.getElementById("TdCorporate").className = 'TabTextHome';		
		     document.getElementById("TdEconomy").className = 'TabTextHomeSel';
	         }

		CreateXmlHttpHomeNews();
		document.body.style.cursor = "progress"; 
		var requestUrl = "../Equity/AjaxHomeNews.aspx?Sec="+ SecID +"&SubSec="+SubSec+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
	
		//alert(requestUrl);

		if(XmlHttpHomeNews){
			XmlHttpHomeNews.onreadystatechange = function(){getHomeNewDataResponse();};
			XmlHttpHomeNews.open("GET", requestUrl,  true);
			XmlHttpHomeNews.send(null);
		}
}
function getHomeNewDataResponse()
{
var NewTd = document.getElementById("NewTd");
	if(XmlHttpHomeNews.readyState == 4)
	{	
		if(XmlHttpHomeNews.status == 200)
		{				
			var NewData = XmlHttpHomeNews.responseText;	
			if(NewData != "")
		    {	
				NewTd.innerHTML = NewData;	
				
			}
				document.body.style.cursor = "auto";	
		}
		else
		{
			document.getElementById("NewTd").innerHTML = "<img src='../App_Themes/Common/images/ajax-loader.gif'>";
		}
	}
}

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";
		var requestUrl = "AjaxAnnouncements.aspx?Exchange="+opt+"&timeStamp="+new Date().getTime();
		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()
	{
		try
		{
			XmlHttpBAI = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpBAI = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpBAI = null;
					
			}
		}
		if(!XmlHttpBAI && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpBAI = new XMLHttpRequest();
		}
	}
	
	
	function GetBSEAnnInn(srno,Exchange)
	{	
	//alert(srno);	
	    document.getElementById("divNews").style.display = "inline";
		CreateXmlHttpBAI();
		document.body.style.cursor = "progress";
		
		//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 = "BSEAnnDetailsAjax.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime()+"&srno="+srno+"&Exchange="+Exchange;
		//alert(requestUrl);
		if(XmlHttpBAI){
			XmlHttpBAI.onreadystatechange = function(){getDataResponseBSEAnnIN();};
			XmlHttpBAI.open("GET", requestUrl,  true);
			XmlHttpBAI.send(null);
		}
    }
function getDataResponseBSEAnnIN()
{
	if(XmlHttpBAI.readyState == 4)
	{	
	
		if(XmlHttpBAI.status == 200)
		{				
		
			
			var BSEAnn = document.getElementById("TdNews");
			//var AnnDate = document.getElementById("AnnDate");
			var strData = XmlHttpBAI.responseText;
			if(strData != "")
			 {	
			    var arrSchm = strData.split("|");
			   
			    for(i=0; i<arrSchm.length-1; i++) 
			    {	
				    var strSchm = arrSchm[i];
				   
				    var arrSchmCode = strSchm.split("~");
				  //   AnnDate.innerHTML = arrSchmCode[0];
				    BSEAnn.innerHTML = arrSchmCode[1];
				    document.body.style.cursor = "auto";
			    }
			   
			} 
				
		}
		
		else
		document.body.style.cursor = "auto";
			//MarqueeId.innerHTML = "<img src='../CommonImgs/loading1.gif'>";
	}
}

//function Searchempty()
//{
//    if (document.getElementById("GetQuotes_txtCompany").value=="Enter Company Name")
//    {
//        document.getElementById("GetQuotes_txtCompany").value="";
//    }
//}

//function Searchfill()
//{
//    var getquote=document.getElementById("GetQuotes_txtCompany").value;
//    
//    if (getquote=="")
//    {
//        document.getElementById("GetQuotes_txtCompany").value="Company Name";
//    }
//}	
//        
//function QuoteEnterScript(e,id)
//{
//    if(e.keyCode==13)	
//    {
//        var Scripid = document.getElementById(id);
//        Scripid.click();
//    }
//}
//        
//function SearchCompany()
//{
//    var SearchTxt = document.getElementById("GetQuotes_txtCompany").value;
//    var Id = document.getElementById("ddlQuote").value;	
//    		
//    if(SearchTxt =="" || SearchTxt=="Company Name")
//    {
//        alert("Please enter company name ..!!!");
//        document.getElementById("GetQuotes_txtCompany").value="";
//        document.getElementById("GetQuotes_txtCompany").focus();
//        return false;
//    }
//    else
//    {
//        var ddlQuote = document.getElementById("ddlQuote").value
//        
//        if(ddlQuote=="70")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=70";
//            return false;
//            
//        } 
//        if(ddlQuote=="71")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=71";
//            return false;
//        }  
//        if(ddlQuote=="72")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=72";
//            return false;
//        }
//        if(ddlQuote=="73")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=73";
//            return false;
//        } 
//        if(ddlQuote=="74")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=74";
//            return false;
//        }  
//        if(ddlQuote=="75")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=75";
//            return false;
//        }  
//        if(ddlQuote=="76")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=76";
//            return false;
//        } 
//        if(ddlQuote=="78")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=78";
//            return false;
//        } 
//        if(ddlQuote=="79")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=79";
//            return false;
//        } 
//        if(ddlQuote=="80")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=80";
//            return false;
//        } 
//        if(ddlQuote=="81")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=81";
//            return false;
//        } 
//        if(ddlQuote=="82")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=82";
//            return false;
//        } 
//        if(ddlQuote=="83")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=83";
//            return false;
//        } 
//        if(ddlQuote=="84")
//        {
//            document.location = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=84";
//            return false;
//        } 
//       
//    }
//}
function Searchempty()
{
    if (document.getElementById("txtSearch").value=="Company Name")
    {
        document.getElementById("txtSearch").value="";
    }
}

function Searchfill()
{
    var getquote=document.getElementById("txtSearch").value;
    if (getquote=="")
    {
        document.getElementById("txtSearch").value="Company Name";
    }
}	

function QuoteEnterScript(e)
{
    if(e.keyCode==13)	
    {
        var Scripid = document.getElementById("ddlQuote");
       
        var strUrl ="../CompanyProfile/CompanyList.aspx?SrchQuote="+document.getElementById('txtSearch').value+"&id="+ Scripid.value;
       // alert(strUrl)
        var newWindow = window.open(strUrl, '_parent'); 			
        newWindow.focus(); 
        return false; 
        
    }
}


function SearchCompany()
    {
                    	
    var SearchTxt = document.getElementById("txtSearch").value;
    var Compxtbox=document.getElementById("txtSearch");
    var Id = document.getElementById("ddlQuote").value;	
	
    if(SearchTxt =="" || SearchTxt=="Company Name")
    {
        alert("Please enter Company Name");
        Compxtbox.focus();
        return false;
    }
	
    else
    {
	//var StrUrl = ""	
		
   var StrUrl = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id="+Id;

         document.location=StrUrl;
         return false   ;
     
    }
}


function ShowTabEq(Opt1)
{
    if(Opt1 == "Sensex")
    {
        document.getElementById("FirstTab").style.display = "inline";
        document.getElementById("SecondTab").style.display = "none";
        document.getElementById("TdSensexTab").className = "SensexNiftyOn";
        document.getElementById("TdNiftyTab").className = "SensexNiftyOff";
        ChangeControlEq("GAIN","BSE");
    }
    if(Opt1 == "Nifty")
    {
        document.getElementById("FirstTab").style.display = "none";
        document.getElementById("SecondTab").style.display = "inline";
        document.getElementById("TdSensexTab").className = "SensexNiftyOff";
        document.getElementById("TdNiftyTab").className = "SensexNiftyOn";
        ChangeControlEq("GAIN","NSE");
    }
}

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";
		}
	}
}

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 ContributionTab(Opt)
{
    if(Opt == "Sensex")
    {
       GetDataCTI('BSE');
    }
    else
    {
       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=15&Option=GAIN&EXCHG=BSE";
    }
    else
    {
        document.getElementById("MoreCTI").href="../Equity/ContributionToIndex.aspx?id=15&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";
		}
	}
}
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("NewTd").innerHTML = "<img src=../App_Themes/Common/images/ajax-loader.gif>";
					
				
			}
		}
	}
	
	
	
	
	/* Market Update */

function ChangeBseNSeVal(val)
{

        if(val=='BSE')
        {
//            document.getElementById('tdBSE').style.display = "inline"; 
//            document.getElementById('tdNSE').style.display = "none"; 
            
            document.getElementById("tdBSE11").className="SensexNiftyOn";
	        document.getElementById("tdNSE11").className="SensexNiftyOff";
	        document.getElementById('Sensex').style.display="inline";
           document.getElementById('Nifty').style.display="none";
           document.getElementById("chart").src="http://content.acesphere.com/Charts/FortShareBse.png?time=" + new Date().getTime();
         
           ChangeControl("GAIN","BSE");
        }
        else
        { 
        
             document.getElementById("tdNSE11").className="SensexNiftyOn";
	         document.getElementById("tdBSE11").className="SensexNiftyOff";
	         document.getElementById('Sensex').style.display="none";
             document.getElementById('Nifty').style.display="inline";
//            document.getElementById('tdBSE').style.display = "none"; 
//            document.getElementById('tdNSE').style.display = "inline"; 
            document.getElementById("chart").src="http://content.acesphere.com/Charts/FortShareNse.png?time=" + new Date().getTime();
            ChangeControl('GAIN','NSE');
    }
}



var XmlHttpx


function CreateXmlHttpp()
{
	try
	{
		XmlHttpx = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpx = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpx = null;				
		}
	}
	if(!XmlHttpx && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpx = new XMLHttpRequest();
	}
}




function ChangeControl(Opt,Exch)
{
	//alert()
	CreateXmlHttpp();
        var currentDivObj = document.getElementById("Td_Data");
        document.body.style.cursor = "progress";
	
	    var requestUrl = "AjaxDataGLVV.aspx?Option="+ Opt +"&Exchange="+ Exch;
   //alert(requestUrl) 
	if(XmlHttpx!=null)	
	        {
				XmlHttpx.onreadystatechange = function(){ChangeControlResponse(Opt,Exch)}
				XmlHttpx.open('GET', requestUrl,  true);
				XmlHttpx.send(null);
			}
			 return false; 
}	
	
function ChangeControlResponse(Opt,Exch)
{
//alert()
    var Head_td =document.getElementById("Heading");
   // var More=document.getElementById("More");
    var BSE_td =document.getElementById("tdBSE");
    var NSE_td =document.getElementById("tdNSE");
  // alert()	
	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(XmlHttpx.readyState == 4)
	{
	//alert()
		// 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.responseText)
		if(XmlHttpx.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpx.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 SearchCompanyOut()
    {
                    	
    var SearchTxt = document.getElementById("txtSearch").value;
    var Id = document.getElementById("ddlQuote").value;	
	
    if(SearchTxt =="" || SearchTxt=="Company Name")
    {
        alert("Please enter Company Name");
        document.getElementById("txtSearch").focus();
        
        return false;
    }
	
    else
    {
		//var StrUrl = "Underconstruction.aspx";
   var StrUrl = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id="+Id;

         document.location=StrUrl;
         return false   ;
     
    }
}

