﻿// 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 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=""

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", "#ffffff");
		so.addVariable("path", "../amline/");
		so.addParam("wmode","opaque");		
		so.addVariable("settings_file", encodeURIComponent("../amline/LineSettings.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 = GetHostUrlForPages+"/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(flag,Option,id)
//	{
//	if(document.getElementById("countrytabs").style.display=="none")
//	{
//	flag="Y";
//	}

//	//alert(flag)
//	//alert("1"+Option);
//	if(flag=='Y')
//	{
//	 
//        document.getElementById("Div1").style.display="inline"; 
//        document.getElementById("NewsCtrl1_Div2").style.display="none";   
//          document.getElementById("countrytabs").style.display="none";
//          document.getElementById("countrytabs2").style.display="inline";
//           if(Option=='News')
//        {
//        document.getElementById('tdln1').className='selected';document.getElementById('tdmc1').className='';
//        }
//        else
//        {   
//             document.getElementById('tdln1').className='';document.getElementById('tdmc1').className='selected';
//        }
//      
//    }
//    else
//    {
//     document.getElementById("countrytabs").style.display="inline";
//     document.getElementById("countrytabs2").style.display="none";
//        if(Option=='News')
//        {
//          document.getElementById("NewsCtrl1_Div2").style.display="none";          
//             document.getElementById("Div1").style.display="inline";
//             document.getElementById('tdln').className='selected';document.getElementById('tdmc').className='';
//        }
//        else
//        {
//            document.getElementById("NewsCtrl1_Div2").style.display="none";          
//             document.getElementById("Div1").style.display="inline";
//             document.getElementById('tdln').className='';document.getElementById('tdmc').className='selected';
//        }
//    }

//		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?Option="+ Option +"&timeStamp="+new Date().getTime();
//	
//		if(id=='tdln'){document.getElementById('tdln').className='selected';document.getElementById('tdmc').className='';}
//	    if(id=='tdmc'){document.getElementById('tdmc').className='selected';document.getElementById('tdln').className='';}
//		if(XmlHttpNews){
//			XmlHttpNews.onreadystatechange = function(){getDataResponse();};
//			XmlHttpNews.open("GET", requestUrl,  true);
//			XmlHttpNews.send(null);			
//		}
//		//alert("2"+Option);
//        setTimeout("GetNewsHot('"+flag+"','"+Option+"',"+id+")",100000);
//		//setTimeout("alert('1')",1000);
//}
//function getDataResponse()
//{
//	if(XmlHttpNews.readyState == 4)
//	{	
//	
//	    var NewTd = document.getElementById("NewTd");
//	    
//		if(XmlHttpNews.status == 200)
//		{	
//			var NewData = XmlHttpNews.responseText;
//					
//		  
//			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";
//		}
//	}
//}
//////////////////End

function CreateXmlHttpLogin()
{
	try
	{
		XmlHttpLogin = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpLogin = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpLogin = null;				
		}
	}
	if(!XmlHttpLogin && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpLogin = new XMLHttpRequest();
	}
}

function GetLogin()
	{	
//	alert();
	  var NewLogin=window.open("static/login.aspx","NirmalBang1",'scrollbars=no,menubar=no,left=200,toolbar=no,location=no,status=no,height=350px,width=350px');	
	    NewLogin.focus();	
		
		
}

////////////////
//  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("Div1").style.display='inline';
//		var currentDivObj;	
//		
//			currentDivObj = document.getElementById("NewTd");
//			//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("NewTd").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');

}


    
//////////////Index comments


 var OA_p=location.protocol=='https:'?'https:':'http:';
    var OA_r=Math.floor(Math.random()*999999);
    document.write ("<" + "script language='JavaScript' ");
    document.write ("type='text/javascript' src='"+OA_p);
    document.write ("//n.admagnet.net/panda/www/delivery/tjs.php");
    document.write ("?trackerid=175&amp;r="+OA_r+"'><" + "/script>");
    
    
    function getmarketcomm(option)
    {
      CreateXmlHttpIPO();
		document.body.style.cursor = "progress";		
		var requestUrl = "AjaxGetMarketComm.aspx?ftype="+option+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		
		if(XmlHttpIPO){
			XmlHttpIPO.onreadystatechange = function(){getDataResponseComm(option);};
			XmlHttpIPO.open("GET", requestUrl,  true);
			XmlHttpIPO.send(null);
		}
}
function getDataResponseComm(option)
{
	if(XmlHttpIPO.readyState == 4)
	{	
	var Heading='';
		if(XmlHttpIPO.status == 200)
		{
			var getCommentry = XmlHttpIPO.responseText;						
			// alert(getCommentry);
			if(getCommentry != "")
		        {
		      
				PlayerOpen('Market Commentary',getCommentry);							
				document.body.style.cursor = "auto";
				 return false
				 }
		}
		document.body.style.cursor="auto";
		//else
			//MarqueeId.innerHTML = "<img src='CommonImgs/loading1.gif'>";
	}
}

 function HomeResolutionChk(){
var ScreenWidth = screen.availwidth
//alert(ScreenWidth);

	if (ScreenWidth >= 1440)
	{
	    AddOn.style.left = "930px";
		
	}
	if (ScreenWidth <= 800)
	{
		AddOn.style.left = "730px";
		
	} 
		if (ScreenWidth == 1152)
	{
		AddOn.style.left = "785px";
		
	}  
		if (ScreenWidth == 1024)
	{
		AddOn.style.left = "728px";
		
	}
	if (ScreenWidth == 1280)
	{
		AddOn.style.left = "846px";
		
	}
	
}


