﻿// JScript File
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;
  }
  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}
var browser = new Browser();
var containerid="contentarea";
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""
function showBSENSE(EXCHG)
{
  var strURL = window.location.href;
  if(strURL.indexOf("EXCHG=NSE") != -1)
  {
    EXCHG = "NSE"
  }
  else 
  {
    EXCHG = "BSE"
  }
  
  if(EXCHG == 'BSE')
  {
    document.getElementById("Sen").style.display = 'inline';		
    document.getElementById("Nif").style.display = 'none';
  }
  else
  {
    document.getElementById("Sen").style.display = 'none';
    document.getElementById("Nif").style.display = 'inline';
  }
}                      
/*Master Page*/  
function HIDETSwitch(){var strURL = window.location.href; if(strURL.indexOf("EquityHome.aspx")>= 0 || strURL.indexOf("equityhome.aspx")>= 0 || strURL.indexOf("CorporateAction")>= 0|| strURL.indexOf("OtherMarket")>= 0|| strURL.indexOf("News/")>= 0){document.getElementById("HEADBSE").style.display=document.getElementById("BSENSETAB").style.display="none";  }
else if(strURL.indexOf("CompanyProfile/")>= 0){document.getElementById("EquityHead").style.display="none" ;document.getElementById("CompProfile").style.display="inline";  }   }  
function showDefaultBSENSE(EXCHG,Option,id){var strURL = window.location.href;if(strURL.indexOf("EXCHG=NSE") != -1)   EXCHG="NSE";  else if(strURL.indexOf("EXCHG=BSE") != -1)	EXCHG="BSE"	;
BSENSETab(EXCHG,Option,id);}
function DisplayData(exchgVal,Option,id){	       
	        var strURL = window.location.href;
            if(id==1)   
            document.location = "TopGainersAndLosers.aspx?id=1&Option="+Option+"&EXCHG="+exchgVal;
            if(id==2)  
            document.location = "OutOrUnderPerformers.aspx?id=2&Option="+Option+"&EXCHG="+exchgVal; 
            if(id==4)           
            document.location = "OnlyBuyersAndSellers.aspx?id=4&Option="+Option+"&EXCHG="+exchgVal;
            if(id==5) 
            document.location = "NewHighLow.aspx?id=5&Option="+Option+"&EXCHG="+exchgVal;             
            if(id==6) 
            document.location = "AdvanceAndDeclines.aspx?id=6&EXCHG="+exchgVal; 
            if(id==7)   
            document.location = "BSENSEWeightage.aspx?id=7&Option="+Option+"&EXCHG="+exchgVal;
            if(id==10)   
            document.location = "FiveDaysUpOrDown.aspx?id=10&Option="+Option+"&EXCHG="+exchgVal;
            if(id==17)   
            document.location = "Forex.aspx?id=17&Option="+Option+"&EXCHG="+exchgVal;
            if(id==18)   
            document.location = "TurnOver_Group.aspx?id=18&Option="+Option+"&EXCHG="+exchgVal;
            //Volume
            if(id==3)   
            document.location = "MostActive.aspx?id=3&Option="+Option+"&EXCHG="+exchgVal;
            if(id==8)   
            document.location = "BlockDeals.aspx?id=8&Option="+Option+"&EXCHG="+exchgVal;
            if(id==9)   
            document.location = "BulkDeals.aspx?id=9&Option="+Option+"&EXCHG="+exchgVal;
            if(id==11)   
            document.location = "HighestLowestDelivery.aspx?id=11&Option="+Option+"&EXCHG="+exchgVal;
            if(id==12)   
            document.location = "TopGainersAndLosers.aspx?id=12&Option="+Option+"&EXCHG="+exchgVal;
            if(id==13)   
            document.location = "ContributionToIndex.aspx?id=13&Option="+Option+"&EXCHG="+exchgVal;
            if(id==14)   
            document.location = "LiveIndices.aspx?id=14&Option="+Option+"&EXCHG="+exchgVal;
            if(id==15)   
            document.location = "RisingVDP.aspx?id=15&Option="+Option+"&EXCHG="+exchgVal;
            if(id==16)   
            document.location = "RisingVolDelFallPrice.aspx?id=16&Option="+Option+"&EXCHG="+exchgVal;
            //if(id==20)   
//            document.location = "HighestLowestDelivery.aspx?id=20&Option="+Option+"&EXCHG="+exchgVal;
              }
   function BSENSETab(EXCHG,Option,id)
   {var EXCHANGENAME;if(EXCHG=='BSE'){EXCHANGENAME='NSE'}else{EXCHANGENAME='BSE'}
     document.getElementById("BSENSETAB").innerHTML="<table style='width: 100%' cellpadding='0' cellpacing='0'><tr><td style='width:300px;'></td><td align='center' style='padding-right: 5px;text-align:right;FONT-SIZE: 11px;'  class='HeadingInnerL' nowrap>&nbsp;SWITCH TO </td><td class='HeadingInnerL' style='FONT-SIZE: 11px;;width:3%; padding-right:10px; cursor:pointer;'  onclick='javascript:DisplayData(&#39;"+EXCHANGENAME+"&#39;,&#39;"+Option+"&#39;,&#39;"+id+"&#39;)'>"+EXCHANGENAME+"</td></tr></table>"
   }
   function CommonTab(EXCHG,VAL)
   {
         if(VAL=='GAIN')
         {         
         document.getElementById("CommTab").innerHTML="<ul class='TabMenu'><li id='ulBSE' class='currentTab'><a href='#'><b>&nbsp;&nbsp;Gainers&nbsp;&nbsp;</b></a></li><li id='ulNSE'><a href='javascript:javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;LOSE&#39;)'><b>&nbsp;&nbsp;Losers&nbsp;&nbsp; </b></a></li></ul>"
         }
       else if(VAL=='LOSE')
        {
        document.getElementById("CommTab").innerHTML="<ul class='TabMenu'><li id='ulBSE' ><a href='javascript:javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;GAIN&#39;)'><b>&nbsp;&nbsp;Gainers&nbsp;&nbsp;</b></a></li><li id='ulNSE' class='currentTab'><a href='#'><b>&nbsp;&nbsp;Losers&nbsp;&nbsp; </b></a></li></ul>"
        } 
       if(VAL=='HIGH'){document.getElementById("CommTab").innerHTML="<ul class='TabMenu'><li id='ulBSE' class='currentTab'><a href='#'><b>&nbsp;&nbsp;Highs&nbsp;&nbsp;</b></a></li><li id='ulNSE'><a href='javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;LOW&#39;)'><b>&nbsp;&nbsp;Lows&nbsp;&nbsp; </b></a></li></ul>"}
       else if(VAL=='LOW') {document.getElementById("CommTab").innerHTML="<ul class='TabMenu'><li id='ulBSE' ><a href='javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;HIGH&#39;)'><b>&nbsp;&nbsp;Highs&nbsp;&nbsp;</b></a></li><li id='ulNSE' class='currentTab'><a href='#'><b>&nbsp;&nbsp;Lows&nbsp;&nbsp; </b></a></li></ul>"} 
       if(VAL=='B'){document.getElementById("CommTab").innerHTML="<ul class='TabMenu'><li id='ulBSE' class='currentTab'><a href='#'><b>&nbsp;&nbsp;Only Buyers&nbsp;&nbsp;</b></a></li><li id='ulNSE'><a href='javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;S&#39;)'><b>&nbsp;&nbsp;Only Sellers&nbsp;&nbsp; </b></a></li></ul>"}
       else if(VAL=='S') {document.getElementById("CommTab").innerHTML="<ul class='TabMenu'><li id='ulBSE'><a href='javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;B&#39;)'><b>&nbsp;&nbsp;Only Buyers&nbsp;&nbsp;</b></a></li><li id='ulNSE'  class='currentTab'><a href='#'><b>&nbsp;&nbsp;Only Sellers&nbsp;&nbsp; </b></a></li></ul>"} 
       if(VAL=='O'){document.getElementById("CommTab").innerHTML="<ul class='TabMenu'><li id='ulBSE' class='currentTab'><a href='#'><b>&nbsp;&nbsp;Out Performers&nbsp;&nbsp;</b></a></li><li id='ulNSE'><a href='javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;U&#39;)'><b>&nbsp;&nbsp;Under Performers&nbsp;&nbsp; </b></a></li></ul>"}
       else if(VAL=='Un') {document.getElementById("CommTab").innerHTML="<ul class='TabMenu'><li id='ulBSE'><a href='javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;O&#39;)'><b>&nbsp;&nbsp;Out Performers&nbsp;&nbsp;</b></a></li><li id='ulNSE'  class='currentTab'><a href='#'><b>&nbsp;&nbsp;Under Performers&nbsp;&nbsp; </b></a></li></ul>"} 
       if(VAL=='U'){document.getElementById("CommTab").innerHTML="<ul class='TabMenu'><li id='ulBSE' class='currentTab'><a href='#'><b>&nbsp;&nbsp;5 Days Up&nbsp;&nbsp;</b></a></li><li id='ulNSE'><a href='javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;D&#39;)'><b>&nbsp;&nbsp;5 Days Down&nbsp;&nbsp; </b></a></li></ul>"}
       else if(VAL=='D') {document.getElementById("CommTab").innerHTML="<ul class='TabMenu'><li id='ulBSE' ><a href='javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;U&#39;)'><b>&nbsp;&nbsp;5 Days Up&nbsp;&nbsp;</b></a></li><li id='ulNSE' class='currentTab'><a href='#'><b>&nbsp;&nbsp;5 Days Down&nbsp;&nbsp; </b></a></li></ul>"} 
       if(VAL=='Value'){document.getElementById("CommTab").innerHTML="<ul class='TabMenu'><li id='ulBSE' class='currentTab'><a href='#'><b>&nbsp;&nbsp;Value&nbsp;&nbsp;</b></a></li><li id='ulNSE'><a href='javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;Volume&#39;)'><b>&nbsp;&nbsp;Volume&nbsp;&nbsp; </b></a></li></ul>"}
       else if(VAL=='Volume') {document.getElementById("CommTab").innerHTML=" <ul class='TabMenu'><li id='ulBSE'><a href='javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;Value&#39;)'><b>&nbsp;&nbsp;Value&nbsp;&nbsp;</b></a></li><li id='ulNSE' class='currentTab'><a href='#'><b>&nbsp;&nbsp;Volume&nbsp;&nbsp; </b></a></li></ul>"} 
       if(VAL=='High'){document.getElementById("CommTab").innerHTML="<ul class='TabMenu'><li id='ulBSE' class='currentTab'><a href='#'><b>&nbsp;&nbsp;Highest Delivery&nbsp;&nbsp;</b></a></li><li id='ulNSE'><a href='javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;Low&#39;)'><b>&nbsp;&nbsp;Lowest Delivery&nbsp;&nbsp; </b></a></li></ul>"}
       else if(VAL=='Low') {document.getElementById("CommTab").innerHTML="<ul class='TabMenu'><li id='ulBSE' ><a href='javascript:ShowDataMaintainStatus(&#39;"+EXCHG+"&#39;,&#39;High&#39;)'><b>&nbsp;&nbsp;Highest Delivery&nbsp;&nbsp;</b></a></li><li id='ulNSE' class='currentTab'><a href='#'><b>&nbsp;&nbsp;Lowest Delivery&nbsp;&nbsp; </b></a></li></ul>"} 
    }
function ChangeControl(Opt,typeGL){document.body.style.cursor = "progress";var requestUrl = "../Equity/MktTopGLAjax.aspx?Option="+ Opt+"&Exchange="+ typeGL ;ajaxpage(1,requestUrl,'GLData');}	
function ChangeValVol(Opt,typeGL){document.body.style.cursor = "progress";var requestUrl = "../Equity/AjaxValVol.aspx?Exchange="+ Opt+"&typeGL="+ typeGL ;ajaxpage(1,requestUrl,'VVData');}	
function GetNewsHot(SecID,SubSec){document.body.style.cursor = "progress";document.getElementById("NewsData").innerHTML = " <img src='../App_Themes/Common/Images/loading.gif'>";
var requestUrl = "../Equity/HotnewsAjax.aspx?Sec="+ SecID +"&SubSec="+SubSec+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
ajaxpage(1,requestUrl,'NewsData');
}
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 GetAnnounce(opt)
	{	
	//alert(Exchg);	
		CreateXmlHttpBA();
		document.body.style.cursor = "progress";
		document.getElementById("tdAnnounceData").innerHTML = " <img src='../App_Themes/Common/images/loading.gif'>";
		var requestUrl = "../Equity/AjaxAnnounce.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime()+"&Exch="+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("tdAnnounceData");
			var AnnDate = document.getElementById("AnnDate");
			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("~");
				     AnnDate.innerHTML = arrSchmCode[0];
				    
				    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 GetAnnInn(srno)
	{	
	//alert(srno);	
	    document.getElementById("divNews").style.display = "inline";
		CreateXmlHttpBAI();
		document.body.style.cursor = "progress";
		document.getElementById("NewsPop").innerHTML = " <img src='../App_Themes/Common/images/loading.gif'>";
		var requestUrl = "../Equity/AnnDetailsAjax.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime()+"&srno="+srno;
		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("NewsPop");
			//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 GetNewsDetail(secId,SubSecId,NewsID,opt)
{
    var NewsWin = document.getElementById("divNews").style.display='inline';
	var currentDivObj;		
	currentDivObj = document.getElementById("NewsPop");
	currentDivObj.innerHTML ="<img src=../App_Themes/Common/Images/loader.gif>"; 	
	document.body.style.cursor = "progress";
	var requestUrl = "../News/GetNews.aspx?SecId="+ secId +"&SubSecId="+ SubSecId+"&NewsID="+NewsID+"&timeStamp="+new Date().getTime()+"opt="+opt; 
    ajaxpage(1,requestUrl,'NewsPop');
}
function GetIndices(Val){document.body.style.cursor = "progress"; var requestUrl = "../Equity/AjaxGSIndices.aspx?Type="+Val;ajaxpage(1,requestUrl,'SGIndices');}
function ShowBseNseGraph(Val){sensexvaluechart(Val,'');}	
function OpenTrade(){var wind;wind=window.open("http://www.nowonline.in" ,"Nirman","height=700,width=880,menu=no,scrollbars=yes,top=0,left=0,resizable=0");wind.focus();}
function sensexvaluechart(val,fincode){var so = new SWFObject("../amline/amline.swf", "BSENSEline", "100%", "100%", "8", "#FFFFFF");so.addVariable("path", "../amline/");
		so.addParam("wmode","opaque");so.addVariable("settings_file", encodeURIComponent("../amline/BSENSEline_settings.xml"));	
		so.addVariable("data_file", encodeURIComponent("../Equity/MarketChartAjax.aspx?Exchg="+val+"&fincode="+fincode+"&TimeStamp="+new Date().getTime()));
		so.write("flashcontent");}
function ajaxpage(id,url, containerid){
   // document.getElementById(containerid).innerHTML = "<table cellspacing=0 cellpadding=0 width=100%><tr><td height=60></td></tr><tr><td align=center><img src='../App_Themes/Common/Images/ajax-loader.gif'></td></tr></table>";
    var page_request = false;if (window.XMLHttpRequest) // if Mozilla, Safari etc
           page_request = new XMLHttpRequest();  else if (window.ActiveXObject)   { // if IE
                try {page_request = new ActiveXObject("Msxml2.XMLHTTP")} 
                catch (e){ try{page_request = new ActiveXObject("Microsoft.XMLHTTP")}catch (e){}}}
        page_request.onreadystatechange=function(){loadpage(page_request, containerid)        }
        if (bustcachevar) //if bust caching of external page
        bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
        page_request.open('GET', url+bustcacheparameter, true)
         document.body.style.cursor = "auto";	
        page_request.send(null)    
}
function loadpage(page_request, containerid){if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){if(containerid=='NewsPop')
   {
    showdeadcenterdiv('490','300','divNews');
   }document.getElementById(containerid).innerHTML=page_request.responseText}}
 function showdeadcenterdiv(Xwidth,Yheight,divid)
 { 
// First, determine how much the visitor has scrolled 
var scrolledX, scrolledY; 
if( self.pageYoffset ) { 
scrolledX = self.pageXoffset; 
scrolledY = self.pageYoffset; 
} else if( document.documentElement && document.documentElement.scrollTop ) { 
scrolledX = document.documentElement.scrollLeft; 
scrolledY = document.documentElement.scrollTop; 
} else if( document.body ) { 
scrolledX = document.body.scrollLeft; 
scrolledY = document.body.scrollTop; 
} 
// Next, determine the coordinates of the center of browser's window 
var centerX, centerY; 
if( self.innerHeight ) { 
centerX = self.innerWidth; 
centerY = self.innerHeight; 
} else if( document.documentElement && document.documentElement.clientHeight ) { 
centerX = document.documentElement.clientWidth; 
centerY = document.documentElement.clientHeight; 
} else if( document.body ) { 
centerX = document.body.clientWidth; 
centerY = document.body.clientHeight; 
} 
// Xwidth is the width of the div, Yheight is the height of the 
// div passed as arguments to the function: 
var leftoffset = scrolledX + (centerX - Xwidth) / 2; 
var topoffset = scrolledY + (centerY - Yheight) / 2; 
// The initial width and height of the div can be set in the 
// style sheet with display:none; divid is passed as an argument to // the function 
var o=document.getElementById(divid); 
var r=o.style; 
r.position='absolute'; 
r.top = topoffset + 'px'; 
r.left = leftoffset + 'px'; 
r.display = "block"; 
}
function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
