﻿

    
   

    

// 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)
			{
					
			}
		}
		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='GetHostUrlForCSS+/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 = GetHostUrlForPages+"/Equity/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 = GetHostUrlForPages+"/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=GetHostUrlForCSS+/App_Themes/Common/images/loading.gif>";
	document.body.style.cursor = "progress";
	
	
	var requestUrl = GetHostUrlForPages+"/Equity/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=GetHostUrlForCSS+/App_Themes/Common/images/loading.gif>";
	document.body.style.cursor = "progress";
	
	
	var requestUrl = GetHostUrlForPages+"/Equity/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=GetHostUrlForCSS+/App_Themes/Common/images/ajax-loader.gif>";
	    document.body.style.cursor = "progress";
	
	
	var requestUrl = GetHostUrlForPages+"/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=GetHostUrlForPages+"/equity/contribution-to-index.aspx";
       }
       else
       {
         document.getElementById("MoreCTI").href=GetHostUrlForPages+"/equity/contribution-to-index.aspx";
       }
       
        
		//currentDivObj.innerHTML ="<img src=GetHostUrlForCSS+/App_Themes/Common/images/loading.gif>";/Equity/contribution-to-index.aspx?id=13&Option=GAIN&EXCHG=BSE
	    document.body.style.cursor = "progress";
	
	var requestUrl = GetHostUrlForPages+"/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)
 {
   // alert("hide");
 	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()
 {
 //alert("dipti");
   if(m_show == 0)
 	{
 		document.getElementById("popup").style.visibility = "hidden";
 	}
 }

//var m_urls = Array('http://localhost:2568/NirmalBang/CompanyProfile/QuoteFinder.aspx?id=1','http://localhost:2568/NirmalBang/CompanyProfile/MF_Holdings.aspx?id=9','http://localhost:2568/NirmalBang/CompanyProfile/FinanceRatios.aspx?id=7','http://localhost:2568/NirmalBang/CompanyProfile/ChartDisplay.aspx?id=10');
var m_urls = Array('http://www.nirmalbang.com/CompanyProfile/QuoteFinder.aspx?id=1','http://www.nirmalbang.com/CompanyProfile/MF_Holdings.aspx?id=9','http://www.nirmalbang.com/CompanyProfile/FinanceRatios.aspx?id=7','http://www.nirmalbang.com/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;
  	
 }
 
 
 
 
 var dragObj = new Object();
dragObj.zIndex =0;
function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}




    function SearchCompany()
        {
    	
            var SearchTxt = document.getElementById("txtCompany").value;
            var Id = document.getElementById("ddlQuote").value;	
    		
            if(SearchTxt =="" || SearchTxt=="Enter Company Name")
            {
                alert("Please enter company name ..!!!");
                return false;
            }
    		
            else
            {
    			
                var StrUrl = GetHostUrlForPages+"/CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id="+Id;
               // alert(StrUrl);
                 document.location=StrUrl;
                 return false   ;
             
            }
        }
    			
    			
         function Searchempty()
        {
            if (document.getElementById("txtCompany").value=="Enter Company Name")
            {
                document.getElementById("txtCompany").value="";
            }
        }

        function Searchfill()
        {
            var getquote=document.getElementById("txtCompany").value;
            if (getquote=="")
            {
                document.getElementById("txtCompany").value="Enter Company Name";
            }
        }	
    	
        function QuoteEnterScript(e,id)
        {
            if(e.keyCode==13)	
            {
                var Scripid = document.getElementById(id);
                Scripid.click();
            }
        }
        




                                                      
