﻿// 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;
  }

  // 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 browser = new Browser();
var clockTimeoutID;
//Global Variables
var XmlHttp,XmlHttpNews,XmlHttpFII,XmlHttpIPO;

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 ChangeBseNSeVal(val)
{
//alert(val);

        if(val=='BSE')
        {
           
         
            document.getElementById('imgBSE').src="../App_Themes/Common/images/BSEOn.gif";
            document.getElementById('imgNSE').src="../App_Themes/Common/images/NseOff.gif";           
           document.getElementById('Sensex').style.display="inline";
           document.getElementById('Nifty').style.display="none";
             ChangeControl("GAIN","BSE");
           GetADVDEC('BSE');
            
        }
        else
        { 
         
            document.getElementById('imgBSE').src="../App_Themes/Common/images/BSEOff.gif";
            document.getElementById('imgNSE').src="../App_Themes/Common/images/NseOn.gif";
              document.getElementById('Sensex').style.display="none";
           document.getElementById('Nifty').style.display="inline";
           ChangeControl('GAIN','NSE');
             GetADVDEC('NSE');
    }
    sensexvaluechart(val)
}





function sensexvaluechart(val)
{
        var StrUrl="../Equity/MarketChartAjax.aspx?Exchg="+val
        var so = new SWFObject("../amline/amline.swf", "BSENSEline", "100%", "100%", "8", "#E9ECF5");
		so.addVariable("path", "../amline/");
		so.addParam("wmode","opaque");		
		so.addVariable("settings_file", encodeURIComponent("../amline/BSENSEline_settings.xml"));	
		so.addVariable("data_file", encodeURIComponent(StrUrl+"&TimeStamp="+new Date().getTime()));
		so.write("MKTChart");
		
}

function ChangeControl(Opt,Exch)
{
	CreateXmlHttp();
       var currentDivObj = document.getElementById("Td_Data");
        
		//currentDivObj.innerHTML ="<img src=App_Themes/CommonTheme/Images/ajax-loader.gif>";
	document.body.style.cursor = "progress";
	
	
	var requestUrl = "../AjaxDataGLVV.aspx?Option="+ Opt +"&Exchange="+ Exch;
   // alert(requestUrl) 
	if(XmlHttp!=null)	
	        {
				XmlHttp.onreadystatechange = function(){ChangeControlResponse(Opt,Exch)}
				XmlHttp.open('GET', requestUrl,  true);
				XmlHttp.send(null);
			}
			 return false; 
}	
	
function ChangeControlResponse(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";
	    if(Exch=='BSE')
	    {
		More.innerHTML="<a class='HomeMore' href='../equity/top-gainers-and-losers.aspx'>More</a>";
		}
		else
		{
		More.innerHTML="<a class='HomeMore' href='../equity/top-gainers-and-losers.aspx'>More</a>";
		}
		
		break;
		
	case "LOSE":
		Head_td.innerHTML="Losers";
		 if(Exch=='BSE')
	    {
		More.innerHTML="<a class='HomeMore' href='../equity/top-gainers-and-losers.aspx'>More</a>";
		}
		else
		{
		//../Equity/top-gainers-and-losers.aspx?Option=LOSE&EXCHG=NSE&id=1&index=0
		More.innerHTML="<a class='HomeMore' href='../equity/top-gainers-and-losers.aspx'>More</a>";
		}
	break;
	
	case "Vol":
		Head_td.innerHTML="Volume";
		 if(Exch=='BSE')
	    {
		More.innerHTML="<a class='HomeMore' href='../equity/most-active-volume-and-value.aspx'>More</a>";
		}
		else
		{
		    More.innerHTML="<a class='HomeMore' href='../equity/most-active-volume-and-value.aspx'>More</a>";
		}
	break;
	
	case "Val":
	    Head_td.innerHTML="Value";
	     if(Exch=='BSE')
	    {
		More.innerHTML="<a class='HomeMore' href='../equity/most-active-volume-and-value.aspx'>More</a>";
		}
		else
		{
		    More.innerHTML="<a class='HomeMore' href='../equity/most-active-volume-and-value.aspx'>More</a>";
		}
	break;
	
	}

	// To make sure receiving response data from server is completed
	
	if(XmlHttp.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(XmlHttp.status == 200)//
		{
			td_Id.innerHTML =  XmlHttp.responseText;
				//alert(td_Id.innerHTML);
			document.body.style.cursor = "auto";		
		}
		else
		{
			td_Id.innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}	
var XmlHttpADVDEC;
function CreateXmlHttpADVDEC()
{
	try
	{
		XmlHttpADVDEC = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpADVDEC = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpADVDEC = null;				
		}
	}
	if(!XmlHttpADVDEC && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpADVDEC = new XMLHttpRequest();
	}
}


function GetADVDEC(exchange)
	{	
	//alert(Exchg);	
		CreateXmlHttpADVDEC();
		document.body.style.cursor = "progress";
		//document.getElementById("tdAdvDec").innerHTML = " <img src='../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 = "../equity/AjaxAdvanceDeclines.aspx?exchange="+exchange+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		//alert(requestUrl);
		if(XmlHttpADVDEC){
			XmlHttpADVDEC.onreadystatechange = function(){getDataResponseADVDEC();};
			XmlHttpADVDEC.open("GET", requestUrl,  true);
			XmlHttpADVDEC.send(null);
		}
}
function getDataResponseADVDEC()
{
	if(XmlHttpADVDEC.readyState == 4)
	{	
	
		if(XmlHttpADVDEC.status == 200)
		{				
		
			
			var tdAdvDec = document.getElementById("tdAdvDec");
			var ADVDECData = XmlHttpADVDEC.responseText;
			//alert(NewData);
						
			if(ADVDECData != "")
		
				tdAdvDec.innerHTML = ADVDECData;				
				document.body.style.cursor = "auto";
				
		}
		
		//else
			//MarqueeId.innerHTML = "<img src='../CommonImgs/loading1.gif'>";
	}
}


function CreateXmlHttpNews()
{
	try
	{
		XmlHttpNews = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpNews = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpNews = null;				
		}
	}
	if(!XmlHttpNews && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpNews = new XMLHttpRequest();
	}
}


function GetNewsHot(SecID,SubSec)
	{	
	//alert(Exchg);	
		CreateXmlHttpNews();
		document.body.style.cursor = "progress";
		document.getElementById("NewTd").innerHTML = " <img src='../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 = "HotnewsAjax.aspx?Sec="+ SecID +"&SubSec="+SubSec+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		//alert(requestUrl);
		if(XmlHttpNews){
			XmlHttpNews.onreadystatechange = function(){getDataResponse();};
			XmlHttpNews.open("GET", requestUrl,  true);
			XmlHttpNews.send(null);
		}
}
function getDataResponse()
{
	if(XmlHttpNews.readyState == 4)
	{	
	
	    var NewTd = document.getElementById("NewTd");
	    
		if(XmlHttpNews.status == 200)
		{	
			var NewData = XmlHttpNews.responseText;
			//alert(NewData);
						
		  
			NewTd.innerHTML = NewData;				
			document.body.style.cursor = "auto";
				
		}
		
		else
		{
			NewTd.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/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 CreateXmlHttpFII()
{
	try
	{
		XmlHttpFII = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpFII = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpFII = null;				
		}
	}
	if(!XmlHttpFII && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpFII = new XMLHttpRequest();
	}
}


function GetFIIMF(Type)
	{	
	//alert(Exchg);	
		CreateXmlHttpFII();
		document.body.style.cursor = "progress";
		//alert(Type);
		if(Type=='FII')
		{
		document.getElementById("tdFII").className="TopBorder";
		document.getElementById("tdMF").className="BottomBorder"
		document.getElementById("tdFII").style.cursor="pointer";
		document.getElementById("tdMF").style.cursor="hand";
		//alert(document.getElementById("tdFII").className);
		}
		else
		{
		document.getElementById("tdFII").className="BottomBorder";
		document.getElementById("tdMF").className="TopBorderL"
		document.getElementById("tdFII").style.cursor="hand";
		document.getElementById("tdMF").style.cursor="pointer";
		}
		//document.getElementById("FIIMF").innerHTML = " <img src='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 = "FIIMFAjax.aspx?Type="+ Type +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		//alert(requestUrl);
		if(XmlHttpFII){
			XmlHttpFII.onreadystatechange = function(){getDataResponseFIIMF();};
			XmlHttpFII.open("GET", requestUrl,  true);
			XmlHttpFII.send(null);
		}
}
function getDataResponseFIIMF()
{
	if(XmlHttpFII.readyState == 4)
	{	
	
		if(XmlHttpFII.status == 200)
		{				
		
			
			var FIIMF = document.getElementById("FIIMF");
			var FIIMFData = XmlHttpFII.responseText;
			//alert(NewData);
						
			if(FIIMFData != "")
		
				FIIMF.innerHTML = FIIMFData;				
				document.body.style.cursor = "auto";
				
		}
		
		//else
			//MarqueeId.innerHTML = "<img src='../CommonImgs/loading1.gif'>";
	}
}


	function CreateXmlHttpIPO()
{
	try
	{
		XmlHttpIPO = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpIPO = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpIPO = null;				
		}
	}
	if(!XmlHttpIPO && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpIPO = new XMLHttpRequest();
	}
}


function GetIPO()
	{	
	//alert(Exchg);	
		CreateXmlHttpIPO();
		document.body.style.cursor = "progress";
		
		var requestUrl = "IpoAjaxData.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
//		alert(requestUrl);
		if(XmlHttpIPO){
			XmlHttpIPO.onreadystatechange = function(){getDataResponseIPO();};
			XmlHttpIPO.open("GET", requestUrl,  true);
			XmlHttpIPO.send(null);
		}
}
function getDataResponseIPO()
{
	if(XmlHttpIPO.readyState == 4)
	{	
	
		if(XmlHttpIPO.status == 200)
		{				
		
			
			var tdIpoData = document.getElementById("IPOdata");
			var IPOData = XmlHttpIPO.responseText;
			//alert(IPOData);
						
			if(IPOData != "")
		
				tdIpoData.innerHTML = IPOData;				
				document.body.style.cursor = "auto";
				
		}
		
		//else
			//MarqueeId.innerHTML = "<img src='../CommonImgs/loading1.gif'>";
	}
}




	function ShowAdd()
{

document.getElementById("AddOn").style.visibility = "visible";


} 
function HideAdd()
{

document.getElementById("AddOn").style.visibility = "hidden";


} 

function switcher()
{
    var ad=new Array()

//    ad[0]='Flash/nb160x600_001.swf';

//    ad[1]='Flash/nb300x250_001.swf';

    ad[0]='Flash/nb780x150_001.swf';

    ad[1]='Flash/nb780x150_002.swf';

    //ad[4]='../Flash/nb160x600_001.swf';

    var xy=Math.floor(Math.random()*ad.length);

    document.getElementById('iframe1').src=ad[xy];
}

 



function popup()
{
window.open("Smallpopup.aspx",'Nirmalbang','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=448,height=225,screenX=0,screenY=0,left=460,top=400');

}

function Homepopup()
{
window.open("PopUp.aspx",'Nirmalbang','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=405,height=174,screenX=0,screenY=0');

}


    
