﻿// JScript File

//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 = false;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if (!XmlHttpVV && typeof XMLHttpRequest!='undefined') 
		{
	        try 
	        {
		        XmlHttpVV = new XMLHttpRequest();
	        } 
	        catch (e) 
	        {
		        XmlHttpVV=false;
	        }
        }
        if (!XmlHttpVV && window.createRequest) 
        {
	        try 
	        {
		        XmlHttpVV = window.createRequest();
	        } 
	        catch (e)
	        {
		        XmlHttpVV=false;
	        }
        }
	
	}





function CreateXmlHttpVVol()
		{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttpVVol = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{  
				XmlHttpVVol = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpVVol = false;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if (!XmlHttpVVol && typeof XMLHttpRequest!='undefined') 
		{
	        try 
	        {
		        XmlHttpVVol = new XMLHttpRequest();
	        } 
	        catch (e) 
	        {
		        XmlHttpVVol=false;
	        }
        }
        if (!XmlHttpVVol && window.createRequest) 
        {
	        try 
	        {
		        XmlHttpVVol = window.createRequest();
	        } 
	        catch (e)
	        {
		        XmlHttpVVol=false;
	        }
        }
	
	}







function LookUpDataval(str,typ)
{ 

        if (str=="FUT")
        {

	        ShowVolumeValueval('FUT','Val');
	      
	        
	     document.getElementById('BtnNcdex').className ='HomeSelTab';
         document.getElementById('BtnMcx').className='HomeUnSelTab';
          document.getElementById("imgeqlef").src="../App_Themes/Common/images/SelLef.gif";
           document.getElementById("imgeqri").src="../App_Themes/Common/images/SelRig.gif";
           document.getElementById("imgdrlef").src="../App_Themes/Common/images/DeSelLef.gif";
           document.getElementById("imgdrri").src="../App_Themes/Common/images/DeSelRig.gif";


        }
        else
        {
      
	        ShowVolumeValueval('OPT','Val');
	         document.getElementById('BtnNcdex').className ='HomeUnSelTab';
         document.getElementById('BtnMcx').className='HomeSelTab';
          document.getElementById("imgeqlef").src="../App_Themes/Common/images/DeSelLef.gif";
           document.getElementById("imgeqri").src="../App_Themes/Common/images/DeSelRig.gif";
             document.getElementById("imgdrlef").src="../App_Themes/Common/images/SelLef.gif";
           document.getElementById("imgdrri").src="../App_Themes/Common/images/SelRig.gif";
        }
	
} 
function LookUpDatavol(str,typ)
{ 


        if (str=="FUT")
        {

	        ShowVolumeValuevol('FUT','Vol');
	        document.getElementById('volfut').className ='HomeSelTab';
         document.getElementById('volopt').className='HomeUnSelTab';
           document.getElementById("imgeqlef1").src="../App_Themes/Common/images/SelLef.gif";
           document.getElementById("imgeqri1").src="../App_Themes/Common/images/SelRig.gif";
           document.getElementById("imgdrlef1").src="../App_Themes/Common/images/DeSelLef.gif";
           document.getElementById("imgdrri1").src="../App_Themes/Common/images/DeSelRig.gif";
	        

        }
        else
        {
      
	        ShowVolumeValuevol('OPT','Vol');
	          document.getElementById('volfut').className ='HomeUnSelTab';
         document.getElementById('volopt').className='HomeSelTab';
           document.getElementById("imgeqlef1").src="../App_Themes/Common/images/DeSelLef.gif";
           document.getElementById("imgeqri1").src="../App_Themes/Common/images/DeSelRig.gif";
             document.getElementById("imgdrlef1").src="../App_Themes/Common/images/SelLef.gif";
           document.getElementById("imgdrri1").src="../App_Themes/Common/images/SelRig.gif";

        }
	
} 

function LookUpDatadrop(str,typ)
{ 
        if (str=="FUT")
        {
        

	       ShowBseGLdrop('FUT','G')
	       document.getElementById('select').className ='HomeSelTab';
           document.getElementById('unselect').className='HomeUnSelTab';
         
           document.getElementById("imgeqlef2").src="../App_Themes/Common/images/SelLef.gif";
           document.getElementById("imgeqri2").src="../App_Themes/Common/images/SelRig.gif";
           document.getElementById("imgdrlef2").src="../App_Themes/Common/images/DeSelLef.gif";
           document.getElementById("imgdrri2").src="../App_Themes/Common/images/DeSelRig.gif"; 
 
	        
        }
        else
        {
       
	        ShowBseGLdrop('OPT','G')
	        document.getElementById('select').className ='HomeSelTab';
           	document.getElementById('unselect').className='HomeUnSelTab';

            document.getElementById("imgeqlef2").src="../App_Themes/Common/images/SelLef.gif";
           document.getElementById("imgeqri2").src="../App_Themes/Common/images/SelRig.gif";
           document.getElementById("imgdrlef2").src="../App_Themes/Common/images/DeSelLef.gif";
           document.getElementById("imgdrri2").src="../App_Themes/Common/images/DeSelRig.gif"; 
	        
        }
	
} 



// 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="AjaxGainLose.aspx?sid=" + Math.random() + "&Exchg="+document.getElementById("MCXNCD").value+"&typeGL="+document.getElementById("GL").value;
	//alert(requestUrl);

	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";
		}
	}

	
} 
function ShowBseGLdrop(ex,glctrl)
{

 if (ex == "")
    {
      //  ex=="NCDEX";
         if (glctrl=="G")
	    {
	        
	        document.getElementById("GL").value = "G"
	         document.getElementById('select').className ='HomeSelTab';
         document.getElementById('unselect').className='HomeUnSelTab';
          document.getElementById("imgeqlef2").src="../App_Themes/Common/images/SelLef.gif";
           document.getElementById("imgeqri2").src="../App_Themes/Common/images/SelRig.gif";
             document.getElementById("imgdrlef2").src="../App_Themes/Common/images/DeSelLef.gif";
           document.getElementById("imgdrri2").src="../App_Themes/Common/images/DeSelRig.gif"; 
           
     
	    }
	    else
	    {
	     
	        document.getElementById("GL").value = "L"
	         document.getElementById('select').className ='HomeUnSelTab';
         document.getElementById('unselect').className='HomeSelTab';
         
           document.getElementById("imgeqlef2").src="../App_Themes/Common/images/DeSelLef.gif";
           document.getElementById("imgeqri2").src="../App_Themes/Common/images/DeSelRig.gif";
             document.getElementById("imgdrlef2").src="../App_Themes/Common/images/SelLef.gif";
           document.getElementById("imgdrri2").src="../App_Themes/Common/images/SelRig.gif"; 
	        
	    }
	 }
	 else
        {
	        if(ex=="FUT")
	        {
                
		        document.getElementById("MCXNCD").value = "FUT"
	        }
	        else
	        {
        	
		        document.getElementById("MCXNCD").value = "OPT"
	        }
        	
        }
   
        CreateXmlHttp();
       //alert(document.getElementById("GL").value);

	var requestUrl="AjaxGainLose.aspx?sid=" + Math.random() + "&Exchg="+document.getElementById("MCXNCD").value+"&typeGL="+document.getElementById("GL").value;
	//alert(requestUrl);

	if(XmlHttp)	
			{
					//alert("hi");
					XmlHttp.onreadystatechange = function(){ShowShowGLData();}; 
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
			}
	
}

// For High & Low

 function ShowVolumeValueval(ex,glctrl)
{

 
         if (glctrl=="Val")
	    {
	        document.getElementById("VVVal").value = "Val";
	    }
	    else
	    {
	  	    document.getElementById("VVVal").value = "Vol";
	    }
	
	        if(ex=="FUT")
	        {
	        
		        document.getElementById("MCXNCDVal").value = "FUT";
	        }
	        else
	        {
        	
		        document.getElementById("MCXNCDVal").value = "OPT";
	        }
        	
      

        CreateXmlHttpVV();
	var requestUrl="AjaxValueVol.aspx?sid=" + Math.random() + "&Exchg="+document.getElementById("MCXNCDVal").value+"&typeGL="+document.getElementById("VVVal").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("ShowVVDataval");
			
		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 ShowVolumeValuevol(ex,glctrl)
{

         if (glctrl=="Val")
	    {
	        document.getElementById("VVvol").value = "Val"
	    }
	    else
	    {
	  	    document.getElementById("VVvol").value = "Vol"
	    }
	        if(ex=="FUT")
	        {
	        
		        document.getElementById("MCXNCDvol").value = "FUT"
	        }
	        else
	        {
        	
		        document.getElementById("MCXNCDvol").value = "OPT"
	        }
        	


        CreateXmlHttpVVol();
	var requestUrl="AjaxValueVol.aspx?sid=" + Math.random() + "&Exchg="+document.getElementById("MCXNCDvol").value+"&typeGL="+document.getElementById("VVvol").value;
	//alert(requestUrl);
	
	
	if(XmlHttpVV)	
			{
					//alert("hi");
					XmlHttpVVol.onreadystatechange = function(){ShowVolumeValueDatavol();}; 
					XmlHttpVVol.open("GET", requestUrl,  true);
					XmlHttpVVol.send(null);
			}
	
}

function ShowVolumeValueDatavol() 
{ 

if(XmlHttpVVol.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpVVol.status == 200)
		{			
			var ShowVolumeValueData   = document.getElementById("ShowVVDatavol");
			
		var strData = XmlHttpVVol.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 ShowVolumeValuenew(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="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 ShowVolumeValueDatanew() 
{ 

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("ShowVVDatanew");
			
		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/deriv_Future.gif";
        document.getElementById('tdOPT').src="../App_Themes/Common/images/deriv_option.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/deriv_Future.gif";
        document.getElementById('tdOPT').src="../App_Themes/Common/images/deriv_option.gif";
       
       
       
    return true;
}


return true;
}


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();
//		}


if (!XmlHttpNews && typeof XMLHttpRequest!='undefined') 
		{
	        try 
	        {
		        XmlHttpNews = new XMLHttpRequest();
	        } 
	        catch (e) 
	        {
		        XmlHttpNews=false;
	        }
        }
        if (!XmlHttpNews && window.createRequest) 
        {
	        try 
	        {
		        XmlHttpNews = window.createRequest();
	        } 
	        catch (e)
	        {
		        XmlHttpNews=false;
	        }
        }

	}	


function HomeMFNews()
{

		var requestUrl =  "../Derivatives/AjaxHomeNews.aspx";

		CreateXmlHttpNews();
		document.body.style.cursor = "progress";
		if(XmlHttpNews)	
			{
					XmlHttpNews.onreadystatechange = function(){HomeMFNewsResponse();}; 
					XmlHttpNews.open("GET", requestUrl,  true);
					XmlHttpNews.send(null);
			}
			
}

function HomeMFNewsResponse()
{

	// To make sure receiving response data from server is completed
	if(XmlHttpNews.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpNews.status == 200)
		{			
			var HomeMFNewsTd   = document.getElementById("HomeMFNews");
			HomeMFNewsTd.innerHTML = XmlHttpNews.responseText;					
			document.body.style.cursor = "auto";	
		}
		else
		{
			HomeMFNewsTd.innerHTML = "There was a problem retrieving data from the server.";
	
			document.body.style.cursor = "auto";
		}
	}
}

var tempX = 0;
 var tempY = 0;
 

 //setInterval("hide_popup1()",1000);
 
 var IE = document.all?true:false
 
 if (!IE) document.captureEvents(Event.MOUSEMOVE)
 document.onmousemove = getMouseXY;
 
 function getMouseXY(e) 
 {
 	if(IE)
 	{
 	  //  tempX = event.clientX + screen.width/2 ;
 	 tempY = document.body.scrollTop+50;

 	}
 	else
 	{
 		tempX = e.pageX;
 	    tempY = e.pageY;
 	}
 	return true;
 }



function CreateXmlHttpDeriHomeFII()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttpDeriHomeFII = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{  
				XmlHttpDeriHomeFII = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpDeriHomeFII = false;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if (!XmlHttpDeriHomeFII && typeof XMLHttpRequest!='undefined') 
		{
	        try 
	        {
		        XmlHttpDeriHomeFII = new XMLHttpRequest();
	        } 
	        catch (e) 
	        {
		        XmlHttpDeriHomeFII=false;
	        }
        }
        if (!XmlHttpDeriHomeFII && window.createRequest) 
        {
	        try 
	        {
		        XmlHttpDeriHomeFII = window.createRequest();
	        } 
	        catch (e)
	        {
		        XmlHttpDeriHomeFII=false;
	        }
        }
	
	}








function DeriHomeFII(Opt)
{
    CreateXmlHttpDeriHomeFII();
    var currentDivObj = document.getElementById("Td_DataDeriFii");
	document.body.style.cursor = "progress";
	
	if(Opt == "NSE")
	{
	    document.getElementById("tdNSE").className = "HomeSelTab";
	    document.getElementById("tdSEBI").className = "HomeUnSelTab";
	    
	    
	    
           document.getElementById("imgSebilef").src="../App_Themes/Common/images/DeSelLef.gif";
           document.getElementById("imgSebiri").src="../App_Themes/Common/images/DeSelRig.gif";
             document.getElementById("imgNselef").src="../App_Themes/Common/images/SelLef.gif";
           document.getElementById("imgNseri").src="../App_Themes/Common/images/SelRig.gif"; 
	    
	}
	else
	{
	    document.getElementById("tdNSE").className = "HomeUnSelTab";
	    document.getElementById("tdSEBI").className = "HomeSelTab";
	    
	    
	      document.getElementById("imgNselef").src="../App_Themes/Common/images/DeSelLef.gif";
           document.getElementById("imgNseri").src="../App_Themes/Common/images/DeSelRig.gif";
             document.getElementById("imgSebilef").src="../App_Themes/Common/images/SelLef.gif";
           document.getElementById("imgSebiri").src="../App_Themes/Common/images/SelRig.gif"; 
	    
	}
	var requestUrl = "AjaxDeriHomeFllInves.aspx?Option="+ Opt +"&timeStamp="+new Date().getTime();
	
	if(XmlHttpDeriHomeFII!=null)	
	{
	    XmlHttpDeriHomeFII.onreadystatechange = function(){ChangeDeriHomeFII()}
		XmlHttpDeriHomeFII.open('GET', requestUrl,  true);
		XmlHttpDeriHomeFII.send(null);
	}
	return false; 
}	
	
function ChangeDeriHomeFII()
{
   	if(XmlHttpDeriHomeFII.readyState == 4)
	{
		var Td_DataDeriFii = document.getElementById("Td_DataDeriFii");
		
		if(XmlHttpDeriHomeFII.status == 200)//
		{
			Td_DataDeriFii.innerHTML =  XmlHttpDeriHomeFII.responseText;
			document.body.style.cursor = "auto";		
		}
		else
		{
			Td_DataDeriFii.innerHTML =  "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
}


