﻿// JScript File
   
function HIDETSwitch()
    {
   
        //  alert("test");
             var strURL = window.location.href;
	           	//	alert(strURL);   
            if(strURL.indexOf("derivative-home.aspx")>= 0 || strURL.indexOf("Derivative-home.aspx")>= 0)
            {  
           // alert("test1");  		        
            document.getElementById("NseBseSwitch").style.display="none";                        
            } 
    }  
        


//Global Variables
var XmlHttp;

//Creating object of XMLHTTP For AJAX Method
function CreateXmlHttp()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttp = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttp&& typeof XMLHttpRequest != "undefined") 
		{
			XmlHttp = new XMLHttpRequest();
		}
	}
	
		
function CreateXmlHttpVV()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttpVV = new ActiveXObject("Msxml2.XmlHttp");
		}
		catch(e)
		{
			try
			{
				XmlHttpVV = new ActiveXObject("Microsoft.XmlHttp");
			} 
			catch(oc)
			{
				XmlHttpVV = null;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if(!XmlHttpVV && typeof XmlHttpRequest != "undefined") 
		{
			XmlHttpVV = new XmlHttpRequest();
		}
	}

function LookUpData(str,typ)
{ 
//alert(str);

        if (str=="FUT")
        {
        	
            
	        document.getElementById("tblFirst").style.display = 'inline';		
		    document.getElementById("tblSecond").style.display = 'none';
	        
	        
	        ShowVolumeValue('FUT','Vol');
	        ShowBseGL('FUT','G')
        }
        else
        {
        //	alert('F');

	       document.getElementById("tblFirst").style.display = 'none';		
		    document.getElementById("tblSecond").style.display = 'inline';
	       
	        ShowVolumeValue('OPT','Vol');
	        ShowBseGL('OPT','G')
        }
	
} 

// for Gainers & Losers

 function ShowBseGL(ex,glctrl)
{
 if (ex == "")
    {
      //  ex=="NCDEX";
         if (glctrl=="G")
	    {
	        
	        document.getElementById("GL").value = "G"
	    }
	    else
	    {
	     
	        document.getElementById("GL").value = "L"
	    }
	 }
	 else
        {
	        if(ex=="FUT")
	        {
                
		        document.getElementById("MCXNCD").value = "FUT"
	        }
	        else
	        {
        	
		        document.getElementById("MCXNCD").value = "OPT"
	        }
        	
        }
   
        CreateXmlHttp();
        //alert(document.getElementById("GL").value);

	var requestUrl=GetHostUrlForPages+"/FNO/AjaxGainLose.aspx?sid=" + Math.random() + "&Exchg="+document.getElementById("MCXNCD").value+"&typeGL="+document.getElementById("GL").value;
	
	
	if(XmlHttp)	
			{
					//alert("hi");
					XmlHttp.onreadystatechange = function(){ShowShowGLData();}; 
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
			}
	
}

function ShowShowGLData() 
{ 

if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{			
			var ShowGLData   = document.getElementById("ShowGLData");
		var strData = XmlHttp.responseText;
			//alert(strData);
			if(strData != "")
			{
				ShowGLData.innerHTML   =  strData;
			}
			document.body.style.cursor = "auto";	
		}
		else
		{
			ShowGLData.innerHTML = "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}

	
} 


// For High & Low

 function ShowVolumeValue(ex,glctrl)
{
  if (ex == "")
    {
         if (glctrl=="Val")
	    {
	        document.getElementById("VV").value = "Val"
	    }
	    else
	    {
	  	    document.getElementById("VV").value = "Vol"
	    }
	 }
	 else
        {
	        if(ex=="FUT")
	        {
	        
		        document.getElementById("MCXNCD").value = "FUT"
	        }
	        else
	        {
        	
		        document.getElementById("MCXNCD").value = "OPT"
	        }
        	
        }

        CreateXmlHttpVV();
	var requestUrl=GetHostUrlForPages+"/FNO/AjaxValueVol.aspx?sid=" + Math.random() + "&Exchg="+document.getElementById("MCXNCD").value+"&typeGL="+document.getElementById("VV").value;
	//alert(requestUrl);
	
	
	if(XmlHttpVV)	
			{
					//alert("hi");
					XmlHttpVV.onreadystatechange = function(){ShowVolumeValueData();}; 
					XmlHttpVV.open("GET", requestUrl,  true);
					XmlHttpVV.send(null);
			}
	
}

function ShowVolumeValueData() 
{ 

if(XmlHttpVV.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpVV.status == 200)
		{			
			var ShowVolumeValueData   = document.getElementById("ShowVVData");
		var strData = XmlHttpVV.responseText;
			//alert(strData);
			if(strData != "")
			{
				ShowVolumeValueData.innerHTML   =  strData;
			}
			document.body.style.cursor = "auto";	
		}
		else
		{
			ShowVolumeValueData.innerHTML = "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}

	
}


function futopt(val)
{

    if(val=='FUT')
    {
        // document.getElementById("Blend").style.filter = "blendTrans(Duration=1.0,Transition=0)";
             ShowVolumeValue('FUT','Vol');
	        ShowBseGL('FUT','G')
        document.getElementById('tdFUT').src="../App_Themes/Common/images/FutOn.gif";
        document.getElementById('tdOPT').src="../App_Themes/Common/images/OptOff.gif";
      
       
        
    }
    else
    {
     //document.getElementById("Blend").style.filter = "blendTrans(Duration=1.0,Transition=0)";
                ShowVolumeValue('OPT','Vol');
	             ShowBseGL('OPT','G')
       
        document.getElementById('tdFUT').src="../App_Themes/Common/images/FutOff.gif";
        document.getElementById('tdOPT').src="../App_Themes/Common/images/OptOn.gif";
       
       
       
    return true;
}


return true;
}

var XmlHttpGL;

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 GetDataGL(Exch)
{
	CreateXmlHttpGL();
       var currentDivObj = document.getElementById("tdCTIndex");
       
        
		currentDivObj.innerHTML ="<img src=../App_Themes/Common/images/loading.gif>";
	    document.body.style.cursor = "progress";
	
	
	var requestUrl = GetHostUrlForPages+"/Equity/AjaxCTI.aspx?Exchange="+ Exch;
   //alert(requestUrl) 
	if(XmlHttpGL!=null)	
	        {
				XmlHttpGL.onreadystatechange = function(){ChangeResponseFUT(Exch)}
				XmlHttpGL.open('GET', requestUrl,  true);
				XmlHttpGL.send(null);
			}
			 return false; 
}	
	
function ChangeResponseFUT(Exch)
{
   
	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("tdCTIndex");
	    //alert(XmlHttp.status)
		if(XmlHttpGL.status == 200)//
		{
			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";
		}
	}
}


var XmlHttpMS;
	function CreateXmlHttpMS()
	{
		try
		{
			XmlHttpMS = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpMS = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpMS = null;
					
			}
		}
		if(!XmlHttpMS && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpMS = new XMLHttpRequest();
		}
	}

function GetMarketScoopData(secId,subSecId)
{
	CreateXmlHttpMS();
       var currentDivObj = document.getElementById("tdMarketScoop");
       
        
		currentDivObj.innerHTML ="<img src=../App_Themes/Common/images/loading.gif>";
	document.body.style.cursor = "progress";
	
	
	var requestUrl = GetHostUrlForPages+"/FNO/AjaxMktScoop.aspx?timeStamp="+new Date().getTime()+"&SecId="+secId+"&SubSecId="+subSecId;
//   alert(requestUrl) 
	if(XmlHttpMS!=null)	
	        {
				XmlHttpMS.onreadystatechange = function(){ChangeResponseMarketScoop()}
				XmlHttpMS.open('GET', requestUrl,  true);
				XmlHttpMS.send(null);
			}
			 return false; 
}	
	
function ChangeResponseMarketScoop()
{
 
	// To make sure receiving response data from server is completed
	
	if(XmlHttpMS.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		var td_Id = document.getElementById("tdMarketScoop");
    //	   alert(XmlHttpMG.status)
		if(XmlHttpMS.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpMS.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 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>";
				
			}
		}
	}
