﻿// JScript File


var xmlHttp,XmlHttpFO,XmlHttpGL;
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 CreateXmlHttpV()
	{
		try
		{
			XmlHttpV = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpV = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpV = null;
					
			}
		}
		if(!XmlHttpV && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpV = 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 ChangeExch(Exchg)
{	
	
	 
	var Exchg;
	if(Exchg=="BSE")
	{		
       document.getElementById("tblFirst").style.display = 'inline';		
		    document.getElementById("tblSecond").style.display = 'none';
		    
	
		GetData("BSE");			
	
				
	}
	else 
	{	
		
       document.getElementById("tblFirst").style.display = 'none';		
		    document.getElementById("tblSecond").style.display = 'inline';
		    
        GetData("NSE");	
        
	
	}	
}

function ChangeExchV(Exchg)
{	
	var Exchg;
	if(Exchg=="BSE")
	{	   document.getElementById("tblVVF").style.display = 'inline';		
		    document.getElementById("tblVVS").style.display = 'none';
		
		GetDataVol("BSE");	
	}
	else 
	{	    document.getElementById("tblVVF").style.display = 'none';		
		    document.getElementById("tblVVS").style.display = 'inline';
       	GetDataVol("NSE");	
	
	}	
}
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;
	
	 // 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)//
		{
		//alert(XmlHttpGL.responseText);
			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 GetDataVol(Exch)
{
	CreateXmlHttpV();
	
     
      var currentDivObj = document.getElementById("Td_DataVV");
   
       
        
		currentDivObj.innerHTML ="<img src=App_Themes/Common/images/ajax-loader.gif>";
	document.body.style.cursor = "progress";
	
	var requestUrl = "AjaxValVol.aspx?Exchange="+ Exch;
	
	 // alert(requestUrl) 
	if(XmlHttpV!=null)	
	        {
				XmlHttpV.onreadystatechange = function(){ChangeResponseVol(Exch)}
				XmlHttpV.open('GET', requestUrl,  true);
				XmlHttpV.send(null);
			}
			 return false; 
}	
	
function ChangeResponseVol(Exch)
{
    var Head_td =document.getElementById("Heading");
    var More=document.getElementById("More");
   

	// To make sure receiving response data from server is completed
	
	if(XmlHttpV.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		
		    var td_Id = document.getElementById("Td_DataVV");
		
	    //alert(XmlHttp.status)
		if(XmlHttpV.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpV.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 ChangeExchBulk(Exchg)
{	
	var Exchg;
	if(Exchg=="BSE")
	{	   document.getElementById("BulkF").style.display = 'inline';		
		document.getElementById("BulkS").style.display = 'none';
		
		GetDataBulk("BSE");	
	}
	else 
	{	    document.getElementById("BulkF").style.display = 'none';		
		    document.getElementById("BulkS").style.display = 'inline';
       	GetDataBulk("NSE");	
	
	}	
}
var XmlHttpBulk;
function CreateXmlHttpBulk()
	{
		try
		{
			XmlHttpBulk = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpBulk = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpBulk = null;
					
			}
		}
		if(!XmlHttpBulk && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpBulk = new XMLHttpRequest();
		}
	}
function GetDataBulk(Exch)
{
	CreateXmlHttpBulk();
	
     
      var currentDivObj = document.getElementById("BulkData");
   
       
        
		currentDivObj.innerHTML ="<img src=App_Themes/Common/images/ajax-loader.gif>";
	document.body.style.cursor = "progress";
	
	var requestUrl = "AjaxBulkData.aspx?Exchange="+ Exch;
	
	 // alert(requestUrl) 
	if(XmlHttpBulk!=null)	
	        {
				XmlHttpBulk.onreadystatechange = function(){ChangeResponseBulk(Exch)}
				XmlHttpBulk.open('GET', requestUrl,  true);
				XmlHttpBulk.send(null);
			}
			 return false; 
}	
	
function ChangeResponseBulk(Exch)
{
  //  var Head_td =document.getElementById("Heading");
   // var More=document.getElementById("More");
   

	// To make sure receiving response data from server is completed
	
	if(XmlHttpBulk.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		
		    var td_Id = document.getElementById("BulkData");
		
	    //alert(XmlHttp.status)
		if(XmlHttpBulk.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpBulk.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 ChangeExchBlock(Exchg)
{	
	var Exchg;
	if(Exchg=="BSE")
	{	   document.getElementById("BlockF").style.display = 'inline';		
		document.getElementById("BlockS").style.display = 'none';
		
		GetDataBlock("BSE");	
	}
	else 
{	    document.getElementById("BlockF").style.display = 'none';		
	    document.getElementById("BlockS").style.display = 'inline';
       	GetDataBlock("NSE");	
	
	}	
}
var XmlHttpBlock;
function CreateXmlHttpBlock()
	{
		try
		{
			XmlHttpBlock = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpBlock = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpBlock = null;
					
			}
		}
		if(!XmlHttpBlock && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpBlock = new XMLHttpRequest();
		}
	}
function GetDataBlock(Exch)
{
	CreateXmlHttpBlock();
	
     
      var currentDivObj = document.getElementById("BlockData");
   
       
        
		currentDivObj.innerHTML ="<img src=App_Themes/Common/images/ajax-loader.gif>";
	document.body.style.cursor = "progress";
	
	var requestUrl = "AjaxBlockData.aspx?Exchange="+ Exch;
	
	 //alert(requestUrl) 
	if(XmlHttpBlock!=null)	
	        {
				XmlHttpBlock.onreadystatechange = function(){ChangeResponseBlock(Exch)}
				XmlHttpBlock.open('GET', requestUrl,  true);
				XmlHttpBlock.send(null);
			}
			 return false; 
}	
	
function ChangeResponseBlock(Exch)
{
   
	// To make sure receiving response data from server is completed
	
	if(XmlHttpBlock.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		
		    var td_Id = document.getElementById("BlockData");
		
	    //alert(XmlHttp.status)
		if(XmlHttpBlock.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpBlock.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 sensexvalue(val)
{

    if(val=='BSE')
    {
            document.getElementById("tblGraphF").style.display = 'inline';		
		    document.getElementById("tblGraphS").style.display = 'none';
		       document.getElementById("Sensex").style.display = 'inline';		
		    document.getElementById("Nifty").style.display = 'none';
		
        document.getElementById("chart").src="http://content.acesphere.com/charts/ManumangalBse.png?time=" + new Date().getTime() + "";
        
    }
    else
    {
             document.getElementById("tblGraphF").style.display = 'none';		
		    document.getElementById("tblGraphS").style.display = 'inline';
		       document.getElementById("Sensex").style.display = 'none';		
		    document.getElementById("Nifty").style.display = 'inline';
          document.getElementById("chart").src="http://content.acesphere.com/charts/ManumangalNse.png?time=" + new Date().getTime() + "";       
   
    }
}


function CreateXmlHttpNew()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttpFO = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpFO = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpFO = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttpFO && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpFO = new XMLHttpRequest();
		}
	}
	
	function CreateXmlHttpNews()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttpNews = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpNews = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpNews = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttpNews && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpNews = new XMLHttpRequest();
		}
	}
    function ChangeNews(val,SecId,SubSecId)
    {
    //alert("asd");
        if(val=="O")
        {
            document.getElementById("tblFirst").style.display="inline"
            document.getElementById("tblSecond").style.display="none"
            document.getElementById("tblThird").style.display="none"
        }
        else if(val=="M")
        {
            document.getElementById("tblFirst").style.display="none"
            document.getElementById("tblSecond").style.display="inline"
            document.getElementById("tblThird").style.display="none"
        }
        else if(val=="C")
        {
            document.getElementById("tblFirst").style.display="none"
            document.getElementById("tblSecond").style.display="none"
            document.getElementById("tblThird").style.display="inline"
        }
        CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		var requestUrl = "AjaxMktCommentry.aspx?timeStamp="+ new Date().getTime() +"&SecId="+SecId+"&SubSecID="+SubSecId;
		//  alert(requestUrl)
		if(XmlHttpFO)	{
					XmlHttpFO.onreadystatechange = function(){getNewsResp()};
					XmlHttpFO.open("GET", requestUrl,  true);
					XmlHttpFO.send(null);
				}
    }
    
    function getNewsResp()
{

	if(XmlHttpFO.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		
	    //alert(XmlHttp.status)
		if(XmlHttpFO.status == 200)//
		{
		//alert(XmlHttpFO.responseText);
		var strData=XmlHttpFO.responseText;
		var	Td_Marquee = document.getElementById("Td_Marquee");
			Td_Marquee.innerHTML = "<marquee onmouseover='this.stop();' onmouseout='this.start();' trueSpeed scrollAmount='1' height=111px scrollDelay='150' direction='up' loop='repeat' width='100%'>" + strData + "</marquee>";
			//Td_Data.innerHTML=XmlHttpFO.responseText;
				
			document.body.style.cursor = "auto";		
		}
		else
		{
			Td_Data.innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}


  function openNewsHome(SecId,SubSecId)
    {
        
      
        
        	CreateXmlHttpNews();
		document.body.style.cursor = "progress";
		var requestUrl = "GetNews.aspx?timeStamp="+ new Date().getTime() +"&SecId="+SecId+"&SubSecID="+SubSecId;
		 //alert(requestUrl)
		if(XmlHttpNews)	{
					XmlHttpNews.onreadystatechange = function(){getNewsRespHome()};
					XmlHttpNews.open("GET", requestUrl,  true);
					XmlHttpNews.send(null);
				}
    }
    
    function getNewsRespHome()
{

	if(XmlHttpNews.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
	
	   //alert(XmlHttpNews.status) 
	    
			var	Td_HotS = document.getElementById("Td_HotS");
		if(XmlHttpNews.status == 200)//
		{
		   var data=XmlHttpNews.responseText
		   //alert(data);
			Td_HotS.innerHTML = "<marquee onmouseover='this.stop();' onmouseout='this.start();' trueSpeed scrollAmount='1' height=111px scrollDelay='150' direction='up' loop='repeat' width='100%'>" + data + "</marquee>";
		
				
			document.body.style.cursor = "auto";		
		}
		else
		{
			Td_HotS.innerHTML='There was a problem retrieving data from the server.';
			
			document.body.style.cursor = "auto";
		}
	}
}

var XmlHttpCorpNews;
function CreateXmlHttpCorpNews()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttpCorpNews = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpCorpNews = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpCorpNews = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttpCorpNews && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpCorpNews = new XMLHttpRequest();
		}
	}


  function openCorpHome(SecId,SubSecId)
    {
        
      
        
        	CreateXmlHttpCorpNews();
		document.body.style.cursor = "progress";
		var requestUrl = "CorpNewsAjax.aspx?timeStamp="+ new Date().getTime() +"&SecId="+SecId+"&SubSecID="+SubSecId;
		// alert(requestUrl)
		if(XmlHttpCorpNews)	{
					XmlHttpCorpNews.onreadystatechange = function(){getNewsRespCorpHome()};
					XmlHttpCorpNews.open("GET", requestUrl,  true);
					XmlHttpCorpNews.send(null);
				}
    }
    
    function getNewsRespCorpHome()
{

	if(XmlHttpCorpNews.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
	
	//  alert(XmlHttpCorpNews.status) 
	    
			var	Td_HotS = document.getElementById("Td_CorpS");
		if(XmlHttpCorpNews.status == 200)//
		{
		   var data=XmlHttpCorpNews.responseText
		  //alert(data);
			Td_HotS.innerHTML = "<marquee onmouseover='this.stop();' onmouseout='this.start();' trueSpeed scrollAmount='1' height=111px scrollDelay='150' direction='up' loop='repeat' width='100%'>" + data + "</marquee>";
		
				
			document.body.style.cursor = "auto";		
		}
		else
		{
			Td_HotS.innerHTML='There was a problem retrieving data from the server.';
			
			document.body.style.cursor = "auto";
		}
	}
}






function Message(msg)
    {
        if(document.getElementById("MessageBox")==null)
        {
        //alert("Jamir");
           // setInterval('blinkIt();',2000);
            
            width=(screen.width-500)/2;
            height=(screen.height-300)/2-50;
            var striFrame='<iframe id="Myframe" style="filter:revealTrans(duration=0,transition=23);position:absolute;border:0px; width:400px; height:102px; left:'+width+'; top:'+(height-1)+'" z-order="1"></iframe>';
            var strhtml='<table id="MessageBox"  z-order="100" style="width:400px;background-color:#ffffff; height:100px; border:solid #004c8e 6px;  position:absolute; z-index:1; visibility:hidden;left:'+width+';top:'+height+';" align="left" cellpadding="2" cellspacing="2" ><tr><td bgcolor=#bfd3ed align=right><table cellspacing=0 cellpading=0 width=100%><tr><td class=NewsMainHead>NIRMAL BANG - A relationship beyond broking.</td><td align=right><a href="#" onclick="Hide();" ><img src="../App_Themes/Common/Images/close_btn.gif" style="border:0px;" /></a></td></tr></table></td></tr><tr><td>'
            strhtml+='<table   style="background-color:#ffffff;width:400px;height:100px; " border="0"><tr><td style="text-align:center;"><span id="spantext" style="font-family: Arial;font-size: 12px;color: #BA070E;text-align:justify;font-weight:bold;"><blink><strong>'+msg+'</strong></blink></span></td></tr><tr><td style="width:100px; text-align:center;"></td></tr></table></td></tr></table>';
            document.forms[0].insertAdjacentHTML("BeforeEnd",strhtml);
            document.forms[0].insertAdjacentHTML("BeforeEnd",striFrame);
            
            document.getElementById("MessageBox").style.display='block';
            document.getElementById("MessageBox").style.visibility='visible';
        
            
      
            
        }
        else
        {
            document.getElementById("MessageBox").style.display='block';
            document.getElementById("MessageBox").style.visibility='visible';
            document.getElementById("spantext").innerText=msg;
        }
        return false;
    }
    
    function Hide()
    {
        var obj=document.getElementById("MessageBox");
        document.getElementById("Myframe").style.visibility='hidden';
        document.getElementById("Myframe").style.display='none';
        obj.style.display='none';
        obj.style.visibility='hidden';
        document.getElementById("Myframe").parentElement.removeChild(document.getElementById("Myframe"));
        obj.parentElement.removeChild(obj) ;
    }
    
    
    
    
    
    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/loading.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 open_win(url_add)
   {
   //alert("Asd");
           window.open(url_add,'welcome','width=600,height=400,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes');
   }

