﻿// 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 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 clockTimeoutID;
var XmlHttp;

var XmlHttpGL;
//Creating object of XMLHTTP For AJAX Method

var clockTimeoutID;
//Global Variables
var XmlHttp;

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}


//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 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/loader.gif'></td></tr></table>";


       for(var i =1; i<=21; i++)
        {
            if(i==id)
                {
                    document.getElementById(i).className= "LeftMenuSelectedItemTD"; 
                    document.getElementById("sid"+i).className= "LeftMenuItemLinkG";
                }
                else
                {
                    document.getElementById(i).className= "LeftMenuSelectedItemTDO";
                    document.getElementById("sid"+i).className= "LeftMenuItemLink";
                }
        }


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){}
                }
}
else
return false
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)
page_request.send(null)
}

function loadpage(page_request, containerid)
{

    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    
   
    document.getElementById(containerid).innerHTML=page_request.responseText
}

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
}
}
}

	

var XmlHttpNew;	
function CreateXmlHttpNew()
{
   //Creating object of XMLHTTP in IE
	try
	{
	 
		XmlHttpNew = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttpNew = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			
			XmlHttpNew = null;	
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttpNew && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpNew = new XMLHttpRequest();
	}
}
var XmlHttpExpDate;	
function CreateXmlHttpExpDate()
{
   //Creating object of XMLHTTP in IE
	try
	{
	 
		XmlHttpExpDate = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttpExpDate = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			
			XmlHttpExpDate = null;	
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttpExpDate && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpExpDate = new XMLHttpRequest();
	}
}

function MenuNavigation(id,url,flag)
{
if(flag=='enable')
{
document.getElementById("ContentTD").innerHTML = "<table cellspacing=0 cellpadding=0 width=100% id=ContentTD><tr><td height=60></td></tr><tr><td align=center><img src='../App_Themes/Common/images/loader.gif'></td></tr></table>";
} 
//    var requestUrl=url;
  function gup( name ){  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  var regexS = "[\\#]"+name+"=([^&#]*)";  var regex = new RegExp( regexS );  var results = regex.exec( window.location.href );  if( results == null )    return "";  else    return results[1];}
    
  var frank_param = gup( 'page' );
  var sid=frank_param.substring(4)
    for(var i=1;i<21;i++)
    {

        if(i==sid)
        {

        document.getElementById(i).className= "LeftMenuSelectedItemTD"; 
        document.getElementById("sid"+i).className= "LeftMenuItemLinkG";
        
        }
        else
        {

        document.getElementById(i).className= "LeftMenuSelectedItemTDO";
        document.getElementById("sid"+i).className= "LeftMenuItemLink";
        }

    }
    var ig_f=sid;
    
    if ((ig_f==1)||(ig_f==2)||(ig_f==3)||(ig_f==4)||(ig_f==5)||(ig_f==6)||(ig_f==7)||(ig_f==8)||(ig_f==9))
        {
            SwitchMenu('1')
        }
        if ((ig_f==10)||(ig_f==11)||(ig_f==12)||(ig_f==13)||(ig_f==14)||(ig_f==15))
        {
            SwitchMenu('2')
        }
        if ((ig_f==16)||(ig_f==17)||(ig_f==18)||(ig_f==19) ||(ig_f==20))
        {
            SwitchMenu('3')
        }
    var tmp=window.location.href;
    var subs=tmp.substring(tmp.indexOf("IpTrack"));
    switch(frank_param)
    {
      
       case "page1":
        {
        if(tmp.indexOf("IpTrack")>0)
        {
       
        url="../Derivatives/GetQuotes.aspx?id=1"+subs;
        }
       else
        { 
        url="../Derivatives/GetQuotes.aspx?id=1";
        }
        break;
        }
       case "page2":
        {
        url="../Derivatives/NiftyFutures.aspx?id=2";
        break;
        } 
       case "page3":
        {
        url="../Derivatives/FIIStatistics.aspx?id=3";
        break;
        } 
       case "page4":
        {
        url="../Derivatives/PutCallRatio.aspx?id=4";
        break;
        } 
        case "page5":
        {
        url="../Derivatives/MarketToday.aspx?id=5&FutOpt=OPT&GainLoss=vol&VolVal=c";
        break;
        } 
        case "page6":
        {
        url="../Derivatives/MarketToday.aspx?id=6&FutOpt=OPT&GainLoss=vol&VolVal=p";
        break;
        }
       case "page7":
        {
        url="../Derivatives/Listofunderlying.aspx?id=7";
        break;
        }
        case "page8":
        {
        url="../Derivatives/DailySettlementPrice.aspx?id=8";
        break;
        }
       case "page9":
        {
        url="../Derivatives/DerivativeSummary.aspx?id=9";
        break;
        }  
        case "page10":
        {
         if(tmp.indexOf("IpTrack")>0)
            {
            url="../Derivatives/MarketToday.aspx?id=10"+subs;
            }
            else
            {
             url="../Derivatives/MarketToday.aspx?id=10&FutOpt=OPT&GainLoss=G&VolVal=";
            }
//        url="../Derivatives/MarketToday.aspx?id=10&FutOpt=OPT&GainLoss=G&VolVal=";
        break;
        } 
         case "page11":
        {
         if(tmp.indexOf("IpTrack")>0)
            {
            url="../Derivatives/MarketToday.aspx?id=11"+subs;
            }
            else
            {
             url="../Derivatives/MarketToday.aspx?id=11&FutOpt=OPT&GainLoss=L&VolVal=";
            }
//        url="../Derivatives/MarketToday.aspx?id=11&FutOpt=OPT&GainLoss=L&VolVal=";
        break;
        } 
         case "page12":
        {
           if(tmp.indexOf("IpTrack")>0)
            {
            url="../Derivatives/MarketToday.aspx?id=12"+subs;
            }
            else
            {
             url="../Derivatives/MarketToday.aspx?id=12&FutOpt=OPT&GainLoss=val&VolVal=";
            }
             break;
        } 
         case "page13":
        {
         if(tmp.indexOf("IpTrack")>0)
            {
            url="../Derivatives/MarketToday.aspx?id=13"+subs;
            }
             else
            {
             url="../Derivatives/MarketToday.aspx?id=13&FutOpt=OPT&GainLoss=vol&VolVal=";
           }
         break;
        } 
         case "page14":
        {
        url="../Derivatives/AllIndexFuture.aspx?id=14";
        
        break;
        } 
         case "page15":
        {
        url="../Derivatives/MostActiveContracts.aspx?id=15&FutOpt=Fut&GainLoss=VOLCNT&VolVal=";
        break;
        }  
        case "page16":
        {
        url="../Derivatives/ContractsAvailable.aspx?id=16";
        break;
        }  
        case "page17":
        {
        url="../Derivatives/PLandCOpentI.aspx?id=17";
        break;
        }  
        case "page18":
        {
        url="../Derivatives/OpenInterest.aspx?id=18&FutOpt=OPT&GainLoss=HOI&VolVal=";
        break;
        }  
        case "page19":
        {
        url="../Derivatives/BasisFutures.aspx?id=19";
        break;
        }  
        case "page20":
        {
        url="../Derivatives/DerivativeNews.aspx?sec=4&subsec=47&id=20";
        break;
        }  
       default:
        {
        url="../Derivatives/DerivativesHome.aspx";
        break;    
        }
    }   
//   alert(url)
	CreateXmlHttpNew()
	
 if(url!="" && url!="../Derivatives/DerivativesHome.aspx")
    {
	    if(XmlHttpNew)	
	    {
        	
    	    XmlHttpNew.onreadystatechange = function(){MenuNavigationResponse()}
		    XmlHttpNew.open("GET", url,  true);
		    XmlHttpNew.send(null);
	    }
    }	
	
 }	
	
function MenuNavigationResponse()
{
    if(XmlHttpNew.readyState == 4)
	{
	
	    // To make sure valid response is received from the server, 200 means response received is OK
		var ContentTD = document.getElementById("ContentTD");
		
		if(XmlHttpNew.status == 200)//
		{
		
            if(ContentTD)
            {
			ContentTD.innerHTML = XmlHttpNew.responseText;// Data;//MainData;
			document.body.style.cursor = "auto";
			}		
		}
		else
		{
			ContentTD.innerHTML =  "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
}



/***************************************************************** Paging ********************************************************************************************/

function Paging(id,FutOpt,pageno,options,symbol,expDate)
{
//alert(id)
    var requestUrl;
    var futropt=FutOpt;

	switch(id)
    {
        case "1":
	        requestUrl = "../Derivatives/GetQuotes.aspx?id=1&PageNo="+pageno+"&Date="+options+"&Type="+symbol;
		break;

        case "2":
		    requestUrl = "../Derivatives/NiftyFutures.aspx?id=2&PageNo="+pageno+"&Date="+options+"&Type="+symbol;
		break;

        case "3":
		    requestUrl = "../Derivatives/FIIStatistics.aspx?id=3&PageNo="+pageno+"&Date="+options+"&Type="+symbol;
		break;

        case "4":
		    requestUrl = "../Derivatives/PutCallRatio.aspx?id=4&PageNo="+pageno+"&Date="+options+"&Type="+symbol+"&Options="+expDate;
		break;

        case "5":if(futropt == "FUT")
        {
		requestUrl = "../Derivatives/MarketToday.aspx?id=5&FutOpt="+futropt+"&GainLoss=vol&VolVal=&PageNo="+pageno+"&Options="+options+"&Type="+symbol;
		}
		else
		{
		requestUrl = "../Derivatives/MarketToday.aspx?id=5&FutOpt="+futropt+"&GainLoss=vol&VolVal=c&PageNo="+pageno+"&Options="+options+"&Type="+symbol;
        }
//             requestUrl = "../Derivatives/MarketToday.aspx?id=5&FutOpt="+ futropt +"&GainLoss=vol&VolVal=c&PageNo="+pageno+"&Options="+options;
          
		break;

        case "6":
    	if(futropt == "FUT")
		  requestUrl = "../Derivatives/MarketToday.aspx?id=6&FutOpt="+futropt+"&GainLoss=vol&VolVal=&PageNo="+pageno+"&Options="+options+"&Type="+symbol;
		else
		  requestUrl = "../Derivatives/MarketToday.aspx?id=6&FutOpt="+futropt+"&GainLoss=vol&VolVal=p&PageNo="+pageno+"&Options="+options+"&Type="+symbol;
     
//		    requestUrl = "../Derivatives/MarketToday.aspx?id=6&FutOpt="+ futropt +"&GainLoss=vol&VolVal=p&PageNo="+pageno+"&Options="+options+"&Type="+symbol;
	       
		break;

        case "7":
		    requestUrl = "../Derivatives/Listofunderlying.aspx?id=7&PageNo="+pageno+"&Date="+options+"&Type="+symbol;
		break;

        case "8":
		    requestUrl = "../Derivatives/DailySettlementPrice.aspx?id=8&PageNo="+pageno+"&Date="+options+"&Type="+symbol;
		break;
		
        case "9":
		    requestUrl = "../Derivatives/DerivativeSummary.aspx?id=9&PageNo="+pageno+"&DdbSelected="+options;
		break;
		
        case "10":
          if(futropt=='OPT')
            {
		    requestUrl = "../Derivatives/MarketToday.aspx?id=10&FutOpt="+ futropt +"&GainLoss=G&VolVal=&PageNo="+pageno+"&Options="+options+"&Type="+symbol;
		    
		    }
		   else
		   {
		    requestUrl = "../Derivatives/MarketToday.aspx?id=10&FutOpt="+ futropt +"&GainLoss=G&VolVal=&PageNo="+pageno+"&Options="+options+"&Type="+symbol;
		    }
		   
		break;
		
        case "11":
          if(futropt=='OPT')
            {
		    requestUrl = "../Derivatives/MarketToday.aspx?id=11&FutOpt="+ futropt +"&GainLoss=L&VolVal=&PageNo="+pageno+"&Options="+options+"&Type="+symbol;
		    }
		   else
		    requestUrl = "../Derivatives/MarketToday.aspx?id=11&FutOpt="+ futropt +"&GainLoss=L&VolVal=&PageNo="+pageno+"&Options="+options+"&Type="+symbol;
		break;
		
        case "12":
//          if(futropt=='OPT')
//            {
//		    requestUrl = "../Derivatives/MarketToday.aspx?id=12&FutOpt="+ futropt +"&GainLoss=val&VolVal=&PageNo="+pageno+"&Options="+options+"&Type="+symbol;
//		    }
//		   else
		    requestUrl = "../Derivatives/MarketToday.aspx?id=12&FutOpt="+ futropt +"&GainLoss=val&VolVal=&PageNo="+pageno+"&Options="+options+"&Type="+symbol;
		break;
		
        case "13":
//         if(futropt=='OPT')
//            {
		    requestUrl = "../Derivatives/MarketToday.aspx?id=13&FutOpt="+ futropt +"&GainLoss=vol&VolVal=&PageNo="+pageno+"&Options="+options+"&Type="+symbol;
//		    }
//		  else
//		    requestUrl = "../Derivatives/MarketToday.aspx?id=13&FutOpt="+ futropt +"&GainLoss=&VolVal=&PageNo="+pageno+"&Options="+options+"&Type="+symbol;
		break;
		
        case "14":
		    requestUrl = "../Derivatives/AllIndexFuture.aspx?id=14&PageNo="+pageno+"&Date="+options+"&Type="+symbol;
		break;
		
        case "15":
		    requestUrl = "../Derivatives/MostActiveContracts.aspx?id=15&FutOpt="+ futropt +"&GainLoss=VOLCNT&VolVal=&PageNo="+pageno+"&Date="+options+"&Type="+symbol;
		break;
		
        case "16":
		    requestUrl = "ContractsAvailable.aspx?id=16&PageNo="+pageno+"&Date="+options+"&Type="+symbol;
		break;
		
        case "17":
		    requestUrl = "PLandCOpentI.aspx?id=17&PageNo="+pageno+"&Date="+options+"&Type="+symbol;
		break;
		
        case "18":
		    requestUrl = "../Derivatives/OpenInterest.aspx?id=18&FutOpt=OPT&GainLoss=HOI&VolVal=&PageNo="+pageno+"&PageName="+options+"&InstName="+symbol+"&ExpDate="+expDate;
		break;				
		
        case "19":
		    requestUrl = "BasisFutures.aspx?id=19&PageNo="+pageno+"&Date="+options+"&Type="+symbol;
		break;
		case "20":
		
		    requestUrl = "DerivativeNews.aspx?sec=4&subsec=47&id=20&PageNo="+pageno;
		break;
		
    }
   
//    alert(requestUrl)
	CreateXmlHttpNew()
    var ContentTD = document.getElementById("ContentTD");
	ContentTD.innerHTML ="<img src=../App_Themes/Common/Images/LOADER.gif>";
	document.body.style.cursor = "progress";

	if(XmlHttpNew)	
	{
	    XmlHttpNew.onreadystatechange = function(){GetPaging()}
		XmlHttpNew.open("GET", requestUrl,  true);
		XmlHttpNew.send(null);
	}
}	
	
function GetPaging()
{
    if(XmlHttpNew.readyState == 4)
	{
	    // To make sure valid response is received from the server, 200 means response received is OK
		var ContentTD = document.getElementById("ContentTD");
		
		if(XmlHttpNew.status == 200)//
		{
		    
		    ContentTD.innerHTML =  XmlHttpNew.responseText;
			document.body.style.cursor = "auto";		
		}
		else
		{
			ContentTD.innerHTML =  "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
} 



function Openvalidation()
{
     var PageName = document.getElementById("ddlPgName");
     var InstName = document.getElementById("ddlInstName");
     var ExpDate  = document.getElementById("ddexpdate");
     document.getElementById("txtPgName").value=PageName.value;
     document.getElementById("txtInstName").value=InstName.value;
     document.getElementById("txtDate").value=ExpDate.value;
    

     var url="../Derivatives/OpenInterest.aspx?id=18&ExpDate="+ document.getElementById("txtDate").value+"&PageName="+document.getElementById("txtPgName").value+"&InstName="+document.getElementById("txtInstName").value;
     ButtonClickFunction('18',url);
}
                     
function Govalidation()
{
    var ExpDate=document.getElementById("ddexpdate");
    var Type = document.getElementById("ddopvtype");
    var option=document.getElementById("ddlDrpInstName");
    document.getElementById("txtDate").value=ExpDate.value;
    document.getElementById("txtType").value=Type.value;
    var url="../Derivatives/PutCallRatio.aspx?id=4&ExpDate="+ document.getElementById("txtDate").value+"&Type="+document.getElementById("txtType").value+"&Options="+option.value;
    ButtonClickFunction('4',url);
}

function IndexChange()
{
    var DerivativeSummary=document.getElementById("ddlDerivativeSummary");
    document.getElementById("txthiddenInstance").value=DerivativeSummary.value;
    var url="../Derivatives/DerivativeSummary.aspx?id=9&DdbSelected="+ document.getElementById("txthiddenInstance").value;
    
    ButtonClickFunction('9',url);
}

function validation(id,FutOpt)
{
    var FutrOpti=FutOpt;
   var url;
    var Options=document.getElementById("ddlDrpInstName");
    document.getElementById("txtOptType").value=Options.value;
    
    //alert(document.getElementById("txtOptType").value);
    if(id==5)
    {
        
        if(FutrOpti=="OPT")
            {
            url="../Derivatives/MarketToday.aspx?id=5&FutOpt="+ FutrOpti +"&GainLoss=vol&VolVal=c&Options="+ document.getElementById("txtOptType").value;
            }
        else
            {
            url="../Derivatives/MarketToday.aspx?id=5&FutOpt="+ FutrOpti +"&GainLoss=vol&VolVal=&Options="+ document.getElementById("txtOptType").value;
            }
        ButtonClickFunction('5',url);
    }
    if(id==6)
    {
         if(FutrOpti=="OPT")
            {
            url="../Derivatives/MarketToday.aspx?id=6&FutOpt="+ FutrOpti +"&GainLoss=vol&VolVal=p&Options="+ document.getElementById("txtOptType").value;
            }
            else
             {
             url="../Derivatives/MarketToday.aspx?id=6&FutOpt="+ FutrOpti +"&GainLoss=vol&VolVal=&Options="+ document.getElementById("txtOptType").value;
             }
        ButtonClickFunction('6',url);
    }
    if(id==10)
    {
        if(FutrOpti=="OPT")
            {
             url="../Derivatives/MarketToday.aspx?id=10&FutOpt="+ FutrOpti +"&GainLoss=G&VolVal=&Options="+ document.getElementById("txtOptType").value;
           }
          else
          {
          url="../Derivatives/MarketToday.aspx?id=10&FutOpt="+ FutrOpti +"&GainLoss=G&VolVal=&Options="+ document.getElementById("txtOptType").value;
          }
        ButtonClickFunction('10',url);
    }
    if(id==11)
     {
     if(FutrOpti=="OPT")
            {
          url="../Derivatives/MarketToday.aspx?id=11&FutOpt="+ FutrOpti +"&GainLoss=L&VolVal=&Options="+ document.getElementById("txtOptType").value;
          }
          else
          {
          url="../Derivatives/MarketToday.aspx?id=11&FutOpt="+ FutrOpti +"&GainLoss=L&VolVal=&Options="+ document.getElementById("txtOptType").value;
          }
        ButtonClickFunction('11',url);
    }
    if(id==12)
    {
//      if(FutrOpti=="OPT")
//          {
           url="../Derivatives/MarketToday.aspx?id=12&FutOpt="+ FutrOpti +"&GainLoss=val&VolVal=&Options="+ document.getElementById("txtOptType").value;
//         }
//       else
//        {
//          url="../Derivatives/MarketToday.aspx?id=12&FutOpt="+ FutrOpti +"&GainLoss=&VolVal=&Options="+ document.getElementById("txtOptType").value;
//        }
        ButtonClickFunction('12',url);
    }
    if(id==13)
    {
//     if(FutrOpti=="OPT")
//        {
         url="../Derivatives/MarketToday.aspx?id=13&FutOpt="+ FutrOpti +"&GainLoss=vol&VolVal=&Options="+ document.getElementById("txtOptType").value;
//        }
//      else
//        {
//         url="../Derivatives/MarketToday.aspx?id=13&FutOpt="+ FutrOpti +"&GainLoss=&VolVal=c&Options="+ document.getElementById("txtOptType").value;
//        }
        ButtonClickFunction('13',url);
    }
}
         
function ButtonClickFunction(id , url)
{
    var requestUrl=url;	
	CreateXmlHttpNew()
    var ContentTD = document.getElementById("ContentTD");
	ContentTD.innerHTML ="<img src=../App_Themes/Common/Images/LOADER.gif>";
	document.body.style.cursor = "progress";
	
	if(XmlHttpNew)	
	{
		XmlHttpNew.onreadystatechange = function(){GetButtonClickFunction()}
		XmlHttpNew.open("GET", requestUrl,  true);
		XmlHttpNew.send(null);
	}
}	
	
function GetButtonClickFunction()
{
    if(XmlHttpNew.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		var ContentTD = document.getElementById("ContentTD");
		if(XmlHttpNew.status == 200)//
		{
			ContentTD.innerHTML =  XmlHttpNew.responseText;
			document.body.style.cursor = "auto";		
		}
		else
		{
			ContentTD.innerHTML =  "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
} 

function Sorting(id,sortexp,sortdir,pgnam,instName,expDate)
{
    var requestUrl;
	
	switch(id)
    {
        case "1":
	        requestUrl = "../Derivatives/GetQuotes.aspx?id=1&SortExp="+sortexp+"&SortDir="+sortdir;
		break;

        case "2":
		    requestUrl = "../Derivatives/NiftyFutures.aspx?id=2&SortExp="+sortexp+"&SortDir="+sortdir;
		break;

        case "3":
		    requestUrl = "../Derivatives/FIIStatistics.aspx?id=3&SortExp="+sortexp+"&SortDir="+sortdir;
		break;

        case "4":
		    requestUrl = "../Derivatives/PutCallRatio.aspx?id=4&SortExp="+sortexp+"&SortDir="+sortdir;
		break;

        case "5":
		    requestUrl = "../Derivatives/MarketToday.aspx?id=5&FutOpt=OPT&GainLoss=vol&VolVal=c&SortExp="+sortexp+"&SortDir="+sortdir;
		break;

        case "6":
		    requestUrl = "../Derivatives/MarketToday.aspx?id=6&FutOpt=OPT&GainLoss=vol&VolVal=p&SortExp="+sortexp+"&SortDir="+sortdir;
		break;

        case "7":
		    requestUrl = "../Derivatives/Listofunderlying.aspx?id=7&SortExp="+sortexp+"&SortDir="+sortdir;
		break;

        case "8":
		    requestUrl = "../Derivatives/DailySettlementPrice.aspx?id=8&SortExp="+sortexp+"&SortDir="+sortdir;
		break;
		
        case "9":
		    requestUrl = "../Derivatives/DerivativeSummary.aspx?id=9&SortExp="+sortexp+"&SortDir="+sortdir;
		break;
		
        case "10":
		    requestUrl = "../Derivatives/MarketToday.aspx?id=10&FutOpt=OPT&GainLoss=G&VolVal=&SortExp="+sortexp+"&SortDir="+sortdir;
		break;
		
        case "11":
		    requestUrl = "../Derivatives/MarketToday.aspx?id=11&FutOpt=OPT&GainLoss=L&VolVal=&SortExp="+sortexp+"&SortDir="+sortdir;
		break;
		
        case "12":
		    requestUrl = "../Derivatives/MarketToday.aspx?id=12&FutOpt=OPT&GainLoss=val&VolVal=&SortExp="+sortexp+"&SortDir="+sortdir;
		break;
		
        case "13":
		    requestUrl = "./Derivatives/MarketToday.aspx?id=13&FutOpt=OPT&GainLoss=vol&VolVal=&SortExp="+sortexp+"&SortDir="+sortdir;
		break;
		
        case "14":
		    requestUrl = "../Derivatives/AllIndexFuture.aspx?id=14&SortExp="+sortexp+"&SortDir="+sortdir;
		break;
		
        case "15":
		    requestUrl = "../Derivatives/MostActiveContracts.aspx?id=15&FutOpt=Fut&GainLoss=VOLCNT&VolVal=&SortExp="+sortexp+"&SortDir="+sortdir;
		break;
		
        case "16":
	    	requestUrl = "ContractsAvailable.aspx?id=16&SortExp="+sortexp+"&SortDir="+sortdir;
		break;
		
        case "17":
		    requestUrl = "PLandCOpentI.aspx?id=17&SortExp="+sortexp+"&SortDir="+sortdir;
		break;
		
        case "18":
		    requestUrl = "../Derivatives/OpenInterest.aspx?id=18&GainLoss=HOI&VolVal=&SortExp="+sortexp+"&SortDir="+sortdir+"&PageName="+pgnam+"&InstName="+instName+"&ExpDate="+expDate;
		break;				
		
        case "19":
		    requestUrl = "BasisFutures.aspx?id=19&SortExp="+sortexp+"&SortDir="+sortdir;
		break;
    }

	CreateXmlHttpNew()
    var ContentTD = document.getElementById("ContentTD");
	ContentTD.innerHTML ="<img src=../App_Themes/Common/Images/LOADER.gif>";
	document.body.style.cursor = "progress";
	
	if(XmlHttpNew)	
	{
	    XmlHttpNew.onreadystatechange = function(){GetSorting()}
		XmlHttpNew.open("GET", requestUrl,  true);
		XmlHttpNew.send(null);
    }
}
	
function GetSorting()
{
    if(XmlHttpNew.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
	    var ContentTD = document.getElementById("ContentTD");
	
		if(XmlHttpNew.status == 200)//
		{
		    ContentTD.innerHTML =  XmlHttpNew.responseText;
			document.body.style.cursor = "auto";		
		}
		else
		{
			ContentTD.innerHTML =  "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
} 


//For Gainer and Loser page
function Tabchange(id,Option, Select,CurrPage)
{
//alert(Option);
    var requestUrl;
    var GainLoss = Select;
    var FutOpt = Option;
    var CurrPageNo=CurrPage;
    if(id==5)
    {
        if(FutOpt == "FUT")
        {
            requestUrl = "../Derivatives/MarketToday.aspx?id=5&VolVal=&FutOpt="+Option+"&GainLoss="+Select+"&PageNo="+CurrPageNo+"&Options="; 
        }
        else
        {
            requestUrl = "../Derivatives/MarketToday.aspx?id=5&VolVal=c&FutOpt="+Option+"&GainLoss="+Select+"&PageNo="+CurrPageNo+"&Options="; 
        }
    }
    if(id==6)
    {
        if(FutOpt == "FUT")
        {
        
            requestUrl = "../Derivatives/MarketToday.aspx?id=6&VolVal=&FutOpt="+Option+"&GainLoss="+Select+"&PageNo="+CurrPageNo+"&Options="; 
        }
        else
        {
        
            requestUrl = "../Derivatives/MarketToday.aspx?id=6&VolVal=p&FutOpt="+Option+"&GainLoss="+Select+"&PageNo="+CurrPageNo+"&Options="; 
        }
    }
    if(id==10)
    {
        if(FutOpt == "FUT")
        {
            requestUrl = "../Derivatives/MarketToday.aspx?id=10&VolVal=&FutOpt="+Option+"&GainLoss="+Select+"&PageNo="+CurrPageNo+"&Options="; 
        }
        else
        {
            requestUrl = "../Derivatives/MarketToday.aspx?id=10&VolVal=&FutOpt="+Option+"&GainLoss="+Select+"&PageNo="+CurrPageNo+"&Options="; 
        }    
    }
    if(id==11)
    {
        if(FutOpt == "FUT")
        {
            requestUrl = "../Derivatives/MarketToday.aspx?id=11&VolVal=&FutOpt="+Option+"&GainLoss="+Select+"&PageNo="+CurrPageNo+"&Options="; 
        }
        else
        {
            requestUrl = "../Derivatives/MarketToday.aspx?id=11&VolVal=&FutOpt="+Option+"&GainLoss="+Select+"&PageNo="+CurrPageNo+"&Options="; 
        }
    }
    if(id==12)
    {
        if(FutOpt == "FUT")
        {
            requestUrl = "../Derivatives/MarketToday.aspx?id=12&VolVal=&FutOpt="+Option+"&GainLoss="+Select+"&PageNo="+CurrPageNo+"&Options="; 
        }
        else
        {
            requestUrl = "../Derivatives/MarketToday.aspx?id=12&VolVal=&FutOpt="+Option+"&GainLoss="+Select+"&PageNo="+CurrPageNo+"&Options="; 
        }
    }
    if(id==13)
    {
        if(FutOpt == "FUT")
        {
            requestUrl = "../Derivatives/MarketToday.aspx?id=13&VolVal=&FutOpt="+Option+"&GainLoss="+Select+"&PageNo="+CurrPageNo+"&Options="; 
        }
        else
        {
            requestUrl = "../Derivatives/MarketToday.aspx?id=13&VolVal=&FutOpt="+Option+"&GainLoss="+Select+"&PageNo="+CurrPageNo+"&Options="; 
        }
    }
    
    CreateXmlHttpNew()
    var ContentTD = document.getElementById("ContentTD");
    ContentTD.innerHTML ="<img src=../App_Themes/Common/Images/LOADER.gif>";
    document.body.style.cursor = "progress";
	
    if(XmlHttpNew)	
    {
        XmlHttpNew.onreadystatechange = function(){TabchangeResponse()}
	    XmlHttpNew.open("GET", requestUrl, true);
	    XmlHttpNew.send(null);
    }
    
   
}

function TabchangeResponse()
{
    if(XmlHttpNew.readyState == 4)
	{
		var ContentTD = document.getElementById("ContentTD");
		if(XmlHttpNew.status == 200)
		{
			ContentTD.innerHTML =  XmlHttpNew.responseText;
			document.body.style.cursor = "auto";		
		}
		else
		{
			ContentTD.innerHTML =  "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
}

//For Getting Symbol Drop Down Contains
function Get_Symbol(optS)
{
// alert(optS)
    if(optS=="Inn")
	{
	    var InstName = document.getElementById("GetQuotesCtrl1_InstrumentType");
	    var Symbol = document.getElementById("GetQuotesCtrl1_Symbol");
 	    var OptionType = document.getElementById("GetQuotesCtrl1_OptionType");
 	    var StrikePrice = document.getElementById("GetQuotesCtrl1_StrikePrice");
 	    var ExpDt = document.getElementById("GetQuotesCtrl1_ExpiryDate");
	}
	else 
	{
	
	    var InstName = document.getElementById("ctl00_ContentPlaceHolder1_DervQuotesCtrl1_InstrumentType");  
	    var Symbol = document.getElementById("Symbol");
 	    var OptionType = document.getElementById("OptionType");
 	    var StrikePrice = document.getElementById("StrikePrice");   
 	    var ExpDt = document.getElementById("ExpiryDate");                  
	}
	
		//alert(InstName)
 	
 	
    if(InstName.value=="OPTIDX")
	{
	    OptionType.options[1] = new Option();
		OptionType.options[1].value="PE";
		OptionType.options[1].text="PE";
		OptionType.options[2] = new Option();
		OptionType.options[2].value="CE";
		OptionType.options[2].text="CE";
		ExpDt.length = 0;
		ExpDt.options[0] = new Option();
		ExpDt.options[0].value="";
		ExpDt.options[0].text="Select Expiry Date";
	}
	else if(InstName.value=="OPTSTK")
	{
	    OptionType.options[1] = new Option();
		OptionType.options[1].value="PA";
		OptionType.options[1].text="PA";
		OptionType.options[2] = new Option();
		OptionType.options[2].value="CA";
		OptionType.options[2].text="CA";
		ExpDt.length = 0;
		ExpDt.options[0] = new Option();
		ExpDt.options[0].value="";
		ExpDt.options[0].text="Select Expiry Date";
	}
	else
	{
	    OptionType.length = 0;
		OptionType.options[0] = new Option();
		OptionType.options[0].value="";
		OptionType.options[0].text="Select Option Type";
		StrikePrice.length = 0;
		StrikePrice.options[0] = new Option();
		StrikePrice.options[0].value="";
		StrikePrice.options[0].text="Select Strike Price";
		ExpDt.length = 0;
		ExpDt.options[0] = new Option();
		ExpDt.options[0].value="";
		ExpDt.options[0].text="Select Expiry Date";
	}
			
	CreateXmlHttpNew()
	document.body.style.cursor = "progress";
	var requestUrl = "GetSymbolAjax.aspx?timeStamp="+ new Date().getTime() +"&InstName="+InstName.value;
	
	if(XmlHttpNew)	
	{
	    XmlHttpNew.onreadystatechange = function(){getSymbolResp(Symbol,optS)}
		XmlHttpNew.open("GET", requestUrl,  true);
		XmlHttpNew.send(null);
	}
 }
 
//Called when response comes back from server Only For Symbol
function getSymbolResp(ig_,optS)
{
    // To make sure receiving response data from server is completed
	if(XmlHttpNew.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpNew.status == 200)
		{		
		    var strData = XmlHttpNew.responseText
			if(strData != "") 
			{	
			    var arrSchm = strData.split("|");
				ig_.length = 0; 	
				
				for(i=0; i<arrSchm.length-1; i++) 
				{	
				    var strSchm = arrSchm[i];
					var arrSchmCode = strSchm.split("~");
					ig_.options[i] = new Option();
					ig_.options[i].value = arrSchmCode[0];
					ig_.options[i].text = arrSchmCode[1];
				}
			}
			else 
			{
			    ig_.length = 0;
				ig_.options[0] = new Option(); 
				ig_.options[0].value = "";
				ig_.options[0].text = "Select Symbol";	
				/*to clear expiry date*/
               var ExpDt;
                if(optS=="Inn")
	              ExpDt = document.getElementById("GetQuotesCtrl1_ExpiryDate");
	            else
	              ExpDt = document.getElementById("ExpiryDate");
                ExpDt.length = 0;
                ExpDt.options[0] = new Option(); 
				ExpDt.options[0].value = "";
				ExpDt.options[0].text = "Select Expiry Date";
				document.body.style.cursor = "auto";
			}
			document.body.style.cursor = "auto";	
		}
		else 
		{
		    ig_.length = 0;
			ig_.options[0] = new Option(); 
			ig_.options[0].value = "";
			ig_.options[0].text = "server is not ready";
			document.body.style.cursor = "auto";		
		}
	}
}
//End of Symbol Function///////////////////////////////////////////////////////////



function Get_ExpDate(optD)
{
    if(optD=="Inn")
	{
	    var InstName = document.getElementById("GetQuotesCtrl1_InstrumentType");
	}
	else
	{		
	    var InstName = document.getElementById("GetQuotesCtrl1_InstrumentType");    
    }
		
 	var Symbol = document.getElementById("GetQuotesCtrl1_Symbol");
 	var ExpiryDate = document.getElementById("GetQuotesCtrl1_ExpiryDate");
		
	CreateXmlHttpNew()
	document.body.style.cursor = "progress";
	var requestUrl = "GetExpDateAjax.aspx?timeStamp="+ new Date().getTime() +"&InstName="+InstName.value +"&Symbol="+Symbol.value;
	
	if(XmlHttpNew)	
	{
	    XmlHttpNew.onreadystatechange = function(){getDateResp(ExpiryDate)}
		XmlHttpNew.open("GET", requestUrl,  true);
		XmlHttpNew.send(null);
	}
 }
 
//Called when response comes back from server Only For Symbol
function getDateResp(ig_)
{
    // To make sure receiving response data from server is completed
	if(XmlHttpNew.readyState == 4)
	{
	    // To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpNew.status == 200)
		{
		    var strData = XmlHttpNew.responseText
			if(strData != "") 
			{	
			    var arrSchm = strData.split("|");
				ig_.length = 0; 	
				
				for(i=0; i<arrSchm.length-1; i++) 
				{	
				    var strSchm = arrSchm[i];
					var arrSchmCode = strSchm.split("~");
					ig_.options[i] = new Option();
					ig_.options[i].value = arrSchmCode[0];
					ig_.options[i].text = arrSchmCode[1];
				}
			}
			else 
			{
			    ig_.length = 0;
				ig_.options[0] = new Option(); 
				ig_.options[0].value = "";
				ig_.options[0].text = "Date not available";			
			}
			
			document.body.style.cursor = "auto";	
		}
		else
		{
		    ig_.length = 0;
			ig_.options[0] = new Option(); 
			ig_.options[0].value = "";
			ig_.options[0].text = "server is not ready";
			document.body.style.cursor = "auto";		
		}
	}
}
// End of Expiry Date Funtion////////////////////////////////////////////

//For Getting Strike Price 
function Get_StrikePrice(optP)
{

    if(optP=="Inn")
    {
        var InstName = document.getElementById("ctl00_ContentPlaceHolder1_DervQuotesCtrl1_InstrumentType");     
	    var Symbol = document.getElementById("Symbol");
 	    var ExpiryDate = document.getElementById("ExpiryDate");
 	    var OptionType = document.getElementById("OptionType");
 	    var StrikePrice = document.getElementById("StrikePrice");  
            
    }
    else
	{
	    var InstName = document.getElementById("GetQuotesCtrl1_InstrumentType");
        var Symbol = document.getElementById("GetQuotesCtrl1_Symbol");
 	    var ExpiryDate = document.getElementById("GetQuotesCtrl1_ExpiryDate");
 	    var OptionType = document.getElementById("GetQuotesCtrl1_OptionType");
 	    var StrikePrice = document.getElementById("GetQuotesCtrl1_StrikePrice"); 
 	                   
	}
		
   
	CreateXmlHttpNew()
	document.body.style.cursor = "progress";
	var requestUrl = "GetStrikePriceAjax.aspx?timeStamp="+ new Date().getTime() +"&InstName="+InstName.value +"&Symbol="+Symbol.value+"&ExpDate="+ExpiryDate.value+"&OptionType="+OptionType.value;
	
	if(XmlHttpNew)	
	{
	    XmlHttpNew.onreadystatechange = function(){Get_StrikePriceResp(StrikePrice)}
		XmlHttpNew.open("GET", requestUrl,  true);
		XmlHttpNew.send(null);
	}
}
 
//Called when response comes back from server Only For Strike Price
function Get_StrikePriceResp(ig_)
{
    // To make sure receiving response data from server is completed
	if(XmlHttpNew.readyState == 4)
	{
	    // To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpNew.status == 200)
		{
		    var strData = XmlHttpNew.responseText;
			
			if(strData != "") 
			{	
			    var arrPrice = strData.split("|");
				ig_.length = 0; 	
				for(i=0; i<arrPrice.length-1; i++) 
				{	
				    var strPrice = arrPrice[i];
					var arrPriceCode = strPrice.split("~");
					ig_.options[i] = new Option();
					ig_.options[i].value = arrPriceCode[0];
					ig_.options[i].text = arrPriceCode[1];
				}
			}
			else 
			{
			    ig_.length = 0;
				ig_.options[0] = new Option(); 
				ig_.options[0].value = "";
				ig_.options[0].text = "Select Strike Price";			
			}
			document.body.style.cursor = "auto";	
		}
		else 
		{
		    ig_.length = 0;
			ig_.options[0] = new Option(); 
			ig_.options[0].value = "";
			ig_.options[0].text = "server is not ready";
			document.body.style.cursor = "auto";		
		}
	}
}
// End of Strike Price funtion ///////////////////////////////////////////////

var XmlHttpTicker;
function CreateXmlHttpTicker()
{
    //Creating object of XmlHttp in IE
	try
	{
		XmlHttpTicker = new ActiveXObject("Msxml2.XmlHttp");
	}
	catch(e)
	{
	    try
		{
			XmlHttpTicker = new ActiveXObject("Microsoft.XmlHttp");
		} 
		catch(oc)
		{
			XmlHttpTicker = null;	
		}
	}
	
	//Creating object of XmlHttp in Mozilla and Safari 
	if(!XmlHttpTicker && typeof XmlHttpRequest != "undefined") 
	{
		XmlHttpTicker = new XmlHttpRequest();
	}
}

function getTickerData(Exchg)
{	
    CreateXmlHttpTicker()
	document.body.style.cursor = "progress";
	document.getElementById("MarqueeId").innerHTML = " <img src='../App_Themes/Common/images/loading.gif'>";
	var requestUrl = "../Derivatives/AjaxTickerData.aspx?Exchange="+ Exchg +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
//	alert("Asd");
	
	if(XmlHttpTicker)
	{
	    XmlHttpTicker.onreadystatechange = function(){getDataResponse(Exchg);}
		XmlHttpTicker.open("GET", requestUrl,  true);
		XmlHttpTicker.send(null);
	}
}
function getDataResponse(Exchg)
{
    if(XmlHttpTicker.readyState == 4)
	{	
	    if(XmlHttpTicker.status == 200)
		{	
		    var arrCol,Time,Code,CompName,ClPrice,DiffVal,DiffImg;
			var ExchgDet="",stkDet="";
			var MarqueeId = document.getElementById("MarqueeId");
			var TickerData = XmlHttpTicker.responseText;
			
			if(TickerData != "")
			    var arrRow = TickerData.split("|");
			
			for(i=0; i<arrRow.length-1; i++)
			{
			    arrCol = arrRow[i].split("~");
				CompName = arrCol[1];
				ClPrice  = arrCol[2];
				DiffVal  = arrCol[3];
				
				if(DiffVal>0) 
				{
				    DiffImg= "<img src='../images/up.gif'>";
					clss = "<span class='Green'>" ;
				}
				else if(DiffVal<0) 
				{							
				    DiffImg="<img src='../images/down.gif'>";
					clss = "<span class='Red'>" ;
				}
				else 
				{
				    DiffImg= "<img src='../images/eq.gif'>";
					clss = "<span class='Green'>"	;				
				}
				
				if(i==0)ExchgDet = "<span class='TickerText'>" + arrCol[0] +" &nbsp; "+ CompName +": "+"<span  class=TickerText>" + ClPrice+"&nbsp;"+ clss +" ["  +"<b>"+ DiffVal+ "</b>"+"]</span> </span>&nbsp;&nbsp;&nbsp;";else stkDet += "<span class='TickerLink'>" + "<a href='../companyprofile/QuoteFinder.aspx?id=1&Fincode="+arrCol[0]+"'><span  class=TickerText>" + CompName +"</span></a>: " + "<span  class=TickerText>" + ClPrice +"&nbsp;"+ clss +" [" +"<b>"+ DiffVal+ "</b>"+"]</span>  &nbsp;</span>&nbsp;";						
			}
				
			if(browser.isIE)
			    MarqueeId.innerHTML = "<marquee id='maqid' onmouseover='this.stop();' onmouseout='this.start();' trueSpeed scrollAmount='1' scrollDelay='50' direction='left' loop='repeat' width='100%'>" + ExchgDet + stkDet + "</marquee>";
			else
			    MarqueeId.innerHTML = ExchgDet + stkDet;				
				document.body.style.cursor = "auto";
				ExchngTimeClock(Exchg);
		}
	}
}

function ExchngTimeClock(Exchg)
{
    var time = new Date()
	var hour = time.getHours()
	if (hour >= 10 && hour <= 20)
	    clockTimeoutID = setTimeout("getTickerData('"+ Exchg +"')",600000);
}

 function ValidateFormHome(opt)
{
 
 var InstType = document.getElementById("ctl00_ContentPlaceHolder1_DervQuotesCtrl1_InstrumentType");


	var Symbol   = document.getElementById("Symbol");
	var ExpDate  = document.getElementById("ExpiryDate");
	var OptType  = document.getElementById("OptionType");
	var StkPrice = document.getElementById("StrikePrice");
	
		if(InstType.value=="")
		{
			alert("Please select the Instrument Type before you proceed")
			InstType.focus();
			return false;
		}
		else if((InstType.value=="OPTIDX")||(InstType.value=="OPTSTK"))
		{
			if(Symbol.value=="Select Symbol")	
			{
			alert("Please select Symbol before you proceed")
			Symbol.focus();
			return false;
			}
			else if(OptType.value=="")
			{
			alert("Please select Option Type before you proceed")
			OptType.focus();
			return false;
			}
			else if(StkPrice.value=="Select Strike Price")
			{
			alert("Please select Price before you proceed")
			StkPrice.focus();
			return false;
			}
		}
		else 
		{
			if(Symbol.value=="Select Symbol")	
			{
			alert("Please select Symbol before you proceed")
			Symbol.focus();
			return false;
			}
		}
		var url="InstType="+InstType.value+"&Symbol="+Symbol.value+"&ExpDate="+ExpDate.value+"&OptType="+OptType.value+"&StkPrice="+StkPrice.value+"&Home=True&id=1";
		//alert(url);
		
		Home_getFOQuotes(url);

		}
		
		function Home_getFOQuotes(strUrl)
	    {
		document.body.style.cursor = "progress";
		window.location="../Derivatives/DervIndex.aspx#page=page1&IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&"+ strUrl;
		 var requestUrl = "../Derivatives/GetQuotes.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&"+ strUrl;
		// alert(requestUrl)
         MenuNavigation('1',requestUrl);				
	    }
  
    //For GetQiote Button Click
    function ValidateForm(opt)
    {
      //  alert(opt)
        if(opt=="Inn")
        {
            var InstType = document.getElementById("GetQuotesCtrl1_InstrumentType");
        }
        else
		{
		    var InstType = document.getElementById("GetQuotesCtrl1_InstrumentType");                       
		}
		//alert(InstType)
	    var Symbol   = document.getElementById("GetQuotesCtrl1_Symbol");
	    var ExpDate  = document.getElementById("GetQuotesCtrl1_ExpiryDate");
	    var OptType  = document.getElementById("GetQuotesCtrl1_OptionType");
	    var StkPrice = document.getElementById("GetQuotesCtrl1_StrikePrice");
	
		if(InstType.value=="")
		{
			alert("Please select the Instrument Type before you proceed")
			InstType.focus();
			return false;
		}
		else if((InstType.value=="OPTIDX")||(InstType.value=="OPTSTK"))
		{
			if(Symbol.value=="Select Symbol")	
			{
			    alert("Please select Symbol before you proceed")
			    Symbol.focus();
			    return false;
			}
			else if(OptType.value=="")
			{
			    alert("Please select Option Type before you proceed")
			    OptType.focus();
			    return false;
			}
			else if(StkPrice.value=="Select Strike Price")
			{
			    alert("Please select Strike Price before you proceed")
			    StkPrice.focus();
			    return false;
			}
		}
		else 
		{
			if(Symbol.value=="Select Symbol")	
			{
			    alert("Please select Symbol before you proceed")
			    Symbol.focus();
			    return false;
			}
		}
		
		var url="InstType="+InstType.value+"&Symbol="+Symbol.value+"&ExpDate="+ExpDate.value+"&OptType="+OptType.value+"&StkPrice="+StkPrice.value+"";
	
	    if(opt=="Home")
	    {
	        //Redirecting from home page to inner
	        //window.location="  .aspx?id=1&url="+url+"";
	    }
	    else
	    {
	        //showing data in the same page
	        //alert("ASD")
	        getFOQuotes(url);
	    }
}
 
//For Loading Data from FOQuotesData.aspx Using AJAX
function getFOQuotes(strUrl)
{
    var Url=strUrl;
	document.body.style.cursor = "progress";
	window.location="../Derivatives/DervIndex.aspx#page=page1&IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&"+ Url;
	var requestUrl = "../Derivatives/GetQuotes.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&"+ Url;
	
	MenuNavigation('1',requestUrl,'enable');

}
	
//Called when response comes back from server Only For FO Quotes Data Response
function getFODataResp()
{
    // To make sure receiving response data from server is completed
	if(XmlHttpNew.readyState == 4)
	{
	    // To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpNew.status == 200)
		{
		    var FO_QuoteData = XmlHttpNew.responseText;
			
			if(FO_QuoteData != "") 
			{
			    var arrRow = FO_QuoteData.split("|");
				for(i=0; i<arrRow.length-1; i++)
				{
				    if((i!='14')&&(i!='15'))
						document.getElementById("FO"+i).innerHTML = arrRow[i];
				}
				document.body.style.cursor = "auto";
			}	
		}
		else
		    document.getElementById("LoadingID").src = " ../App_Themes/Common/Images/LOADER.gif";
	}
}
// End of GetQiote Button  Funtionallty
 
function GetUrlHome()
{
    var strurl=window.location.search;
    
    if(strurl!="?id=1")
    {
        strurl=strurl.substring(10);
        RedirectFOquotHom(strurl);
    }
}

function _trim(ig_)
{
    return ig_.replace(/^\s*|\s*$/g,"")
}	

function showmnu()
{				
    var ig_a=document.location.search.substring(1);				
    var ig_b=ig_a.split("&");			

    for(var ig_c=0;ig_c<ig_b.length;ig_c++)
    {
        var ig_d=ig_b[ig_c].indexOf("id=");
        
        if(ig_d==-1)
            continue;

        var ig_f=ig_b[ig_c].substring(3);
        ig_f=_trim(ig_f);	
        document.getElementById(ig_f).className = "LeftMnuSel";	
        document.getElementById("sid"+ig_f).className = "MenuLinkInnerSelected";

        if ((ig_f==1)||(ig_f==2)||(ig_f==3)||(ig_f==4)||(ig_f==5)||(ig_f==6)||(ig_f==7)||(ig_f==8)||(ig_f==9))
        {
            SwitchMenu('1')
        }
        if ((ig_f==10)||(ig_f==11)||(ig_f==12)||(ig_f==13)||(ig_f==14)||(ig_f==15))
        {
            SwitchMenu('2')
        }
        if ((ig_f==16)||(ig_f==17)||(ig_f==18)||(ig_f==19) ||(ig_f==20))
        {
            SwitchMenu('3')
        }
    }
}

function SwitchMenu(opt)
{
    if (opt=='1')
    {
        document.getElementById("mnu1").style.display="inline";
        document.getElementById("mnu2").style.display="none";
        document.getElementById("mnu3").style.display="none";
        document.getElementById("TitleTD1").style.borderBottom ="none";
        document.getElementById("TitleTD2").style.borderBottom ="solid 1px #FFFFFF";
        document.getElementById("TitleTD3").style.borderBottom ="solid 1px #FFFFFF";
        document.getElementById("TitleTD1").className="LeftMenuMHeadingTD";
        document.getElementById("TitleTD2").className="LeftMenuMMHeadingTD";
        document.getElementById("TitleTD3").className="LeftMenuMMHeadingTD";
    }
    if (opt=='2')
    {
        document.getElementById("mnu1").style.display="none";
        document.getElementById("mnu2").style.display="inline";
        document.getElementById("mnu3").style.display="none";
        document.getElementById("TitleTD2").style.borderBottom ="none";
        document.getElementById("TitleTD1").style.borderBottom ="solid 1px #FFFFFF";
        document.getElementById("TitleTD3").style.borderBottom ="solid 1px #FFFFFF";
        document.getElementById("TitleTD1").className="LeftMenuMHeadingTDP";
        document.getElementById("TitleTD2").className="LeftMenuMMHeadingTDM";
        document.getElementById("TitleTD3").className="LeftMenuMMHeadingTD";
    }
    if (opt=='3')
    {
        document.getElementById("mnu1").style.display="none";
        document.getElementById("mnu2").style.display="none";
        document.getElementById("mnu3").style.display="inline";
        document.getElementById("TitleTD3").style.borderBottom ="none";
        document.getElementById("TitleTD1").style.borderBottom ="solid 1px #FFFFFF";
        document.getElementById("TitleTD2").style.borderBottom ="solid 1px #FFFFFF";
        document.getElementById("TitleTD1").className="LeftMenuMHeadingTDP";
        document.getElementById("TitleTD2").className="LeftMenuMMHeadingTD";
        document.getElementById("TitleTD3").className="LeftMenuMMHeadingTDM";
    }
}

function SwitchSubMenu(opt)
{
    if (opt=='1')
    {
        document.getElementById("Smnu1").style.display="inline";
        document.getElementById("Smnu2").style.display="none";
        document.getElementById("Smnu3").style.display="none";
        document.getElementById("img1").src="../App_Themes/Common/images/price.gif";
        document.getElementById("img2").src="../App_Themes/Common/images/volume.gif";
        document.getElementById("img3").src="../App_Themes/Common/images/volume.gif";
    }
    if (opt=='2')
    {
        document.getElementById("Smnu1").style.display="none";
        document.getElementById("Smnu2").style.display="inline";
        document.getElementById("Smnu3").style.display="none";
        document.getElementById("img1").src="../App_Themes/Common/images/volume.gif";
        document.getElementById("img2").src="../App_Themes/Common/images/price.gif";
        document.getElementById("img3").src="../App_Themes/Common/images/volume.gif";
    }
    if (opt=='3')
    {
        document.getElementById("Smnu1").style.display="none";
        document.getElementById("Smnu2").style.display="none";
        document.getElementById("Smnu3").style.display="inline";
        document.getElementById("img1").src="../App_Themes/Common/images/volume.gif";
        document.getElementById("img2").src="../App_Themes/Common/images/volume.gif";
        document.getElementById("img3").src="../App_Themes/Common/images/price.gif";
    }
}

function GetData(Exch)
{
	CreateXmlHttpGL()
    var currentDivObj = document.getElementById("GLVol_Td");
	currentDivObj.innerHTML ="<img src=../App_Themes/Common/images/LOADER.gif>";
	document.body.style.cursor = "progress";
	
	if(Exch == "BSE")
	{
	    document.getElementById("ImgBse").src = "../App_Themes/Common/images/BSEOn.gif"
	    document.getElementById("ImgNse").src = "../App_Themes/Common/images/NSEOff.gif"
	    document.getElementById("ImgBse").style.cursor = "Default";
	    document.getElementById("ImgNse").style.cursor = "Hand"
	}
	else
	{
	    document.getElementById("ImgBse").src = "../App_Themes/Common/images/BSEOff.gif"
	    document.getElementById("ImgNse").src = "../App_Themes/Common/images/NSEOn.gif"
        document.getElementById("ImgBse").style.cursor = "Hand";
	    document.getElementById("ImgNse").style.cursor = "Default"
	}
	
	var requestUrl = "../Derivatives/AjaxValueVol.aspx?Exchg="+ Exch+"&typeGL=";
	
	if(XmlHttpGL!=null)	
    { 
	    XmlHttpGL.onreadystatechange = function(){ChangeResponseGL()}
		XmlHttpGL.open('GET', requestUrl,  true);
		XmlHttpGL.send(null);
	}
	
	//return false; 
}	

function ChangeResponseGL()
{
    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("GLVol_Td");
	   
		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";
		}
	}
}
   
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();
	}
}

var XmlHttpFO;
	function CreateXmlHttpNew1()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttpFO = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpFO = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpFO = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttpFO && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpFO = new XMLHttpRequest();
		}
	}
	
function Get_ExpDateHome(optD)
 {
 if(optD=="Inn")
		{
	 var InstName = document.getElementById("ctl00_ContentPlaceHolder1_DervQuotesCtrl1_InstrumentType");
		}
		
 		var Symbol = document.getElementById("Symbol");
 		var ExpiryDate = document.getElementById("ExpiryDate");
 				
		CreateXmlHttpExpDate();
		document.body.style.cursor = "progress";
		var requestUrl = "GetExpDateAjax.aspx?timeStamp="+ new Date().getTime() +"&InstName="+InstName.value +"&Symbol="+Symbol.value;
	//alert(requestUrl)
		if(XmlHttpExpDate)	{
					XmlHttpExpDate.onreadystatechange = function(){getDateRespHome(ExpiryDate)};
					XmlHttpExpDate.open("GET", requestUrl,  true);
					XmlHttpExpDate.send(null);
				}
		
 }
 
 //Called when response comes back from server Only For Symbol
function getDateRespHome(ig_)
{
	// To make sure receiving response data from server is completed
	if(XmlHttpExpDate.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpExpDate.status == 200)
		{
			
			var strData = XmlHttpExpDate.responseText
			//alert(strData)  
			if(strData != "") {	
				var arrSchm = strData.split("|");
				ig_.length = 0; 	
				for(i=0; i<arrSchm.length-1; i++) {	
					var strSchm = arrSchm[i];
					var arrSchmCode = strSchm.split("~");
					ig_.options[i] = new Option();
					ig_.options[i].value = arrSchmCode[0];
					ig_.options[i].text = arrSchmCode[1];
				}
			}
			else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "Date not available";			
			}
			document.body.style.cursor = "auto";	
		}
		else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "server is not ready";
					document.body.style.cursor = "auto";		
		}
	}
}



 
 
 var XmlHttpTS;

function CreateXmlHttpTS()
	{
		try
		{
			XmlHttpTS = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpTS = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpTS = null;
					
			}
		}
		if(!XmlHttpTS && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpTS = new XMLHttpRequest();
		}
	}
	
function GetTalkingStockHot(SecID,SubSec)
	{	
	//alert(Exchg);	
		CreateXmlHttpTS();
		document.body.style.cursor = "progress";
		document.getElementById("TalkingStockTD").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 = "TalkingStockAjax.aspx?Sec="+ SecID +"&SubSec="+SubSec+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		//alert(requestUrl);
		if(XmlHttpTS){
			XmlHttpTS.onreadystatechange = function(){getDataResponseTalkingStock();};
			XmlHttpTS.open("GET", requestUrl,  true);
			XmlHttpTS.send(null);
		}
}
function getDataResponseTalkingStock()
{
	if(XmlHttpTS.readyState == 4)
	{	
	
		if(XmlHttpTS.status == 200)
		{				
		
			
			var TalkingStockTD = document.getElementById("TalkingStockTD");
			var NewData = XmlHttpTS.responseText;
			//alert(NewData);
						
			if(NewData != "")
		
				TalkingStockTD.innerHTML = NewData;				
				document.body.style.cursor = "auto";
				
		}
		
		//else
			//MarqueeId.innerHTML = "<img src='../CommonImgs/loading1.gif'>";
	}
}

 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("divNewsPop").style.display='inline';
		var currentDivObj;	
		
			currentDivObj = document.getElementById("NewsPop");
			//alert(currentDivObj);
			currentDivObj.innerHTML ="<img src=App_Themes/Common/images/LOADER.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("NewsPop").innerHTML = XmlHttpPop.responseText;
				
				document.body.style.cursor = "auto";
			}
			else
			{
				
					document.getElementById("NewsId").innerHTML = "<img src=App_Themes/Common/images/LOADER.gif>";
				
			}
		}
	}
	

function futopt(val)
{

    if(val=='FUT')
    {
      
             ShowVolumeValue('FUT','Vol');
	        ShowBseGL('FUT','G')
     
      
       
        
    }
    else
    {
   
                ShowVolumeValue('OPT','Vol');
	             ShowBseGL('OPT','G')
       
       
       
       
    return true;
}


return true;
}



 function ShowVolumeValue(ex,glctrl)
{
  if (ex == "")
    {
         if (glctrl=="Val")
	    {
	         document.getElementById("ValSel").className="TopGLUnSN";
	         document.getElementById("VolSel").className="TopBSEL";
	        document.getElementById("VV").value = "Val"
	    }
	    else
	    {
	     document.getElementById("ValSel").className="TopBSEL";
	         document.getElementById("VolSel").className="TopGLUnSN";
	  	    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 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 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();
		}
	}
	var XmlHttpStrikeP;
	function CreateXmlHttpStrikeP()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttpStrikeP = new ActiveXObject("Msxml2.XmlHttp");
		}
		catch(e)
		{
			try
			{
				XmlHttpStrikeP = new ActiveXObject("Microsoft.XmlHttp");
			} 
			catch(oc)
			{
				XmlHttpStrikeP = null;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if(!XmlHttpStrikeP && typeof XmlHttpRequest != "undefined") 
		{
			XmlHttpStrikeP = new XmlHttpRequest();
		}
	}
	

// for Gainers & Losers

 function ShowBseGL(ex,glctrl)
{

 if (ex == "")
    {
      //  ex=="NCDEX";
         if (glctrl=="G")
	    {
	         document.getElementById("tdLose").className="TopBSEL";
	         document.getElementById("tdGain").className="TopGLUnSN";
	     
	  
	        document.getElementById("GL").value = "G"
	    }
	    else
	    {
	    document.getElementById("tdLose").className="TopGLUnSN";
	      document.getElementById("tdGain").className="TopBSEL";
	    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;
	

	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";
		}
	}

	
} 
var XmlHttpTicker;
		
function CreateXmlHttpTicker()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttpTicker = new ActiveXObject("Msxml2.XmlHttp");
		}
		catch(e)
		{
			try
			{
				XmlHttpTicker = new ActiveXObject("Microsoft.XmlHttp");
			} 
			catch(oc)
			{
				XmlHttpTicker = null;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if(!XmlHttpTicker && typeof XmlHttpRequest != "undefined") 
		{
			XmlHttpTicker = new XmlHttpRequest();
		}
	}

function getTickerData(Exchg)
	{	

		CreateXmlHttpTicker();
		document.body.style.cursor = "progress";
		document.getElementById("MarqueeId").innerHTML = " <img src='../App_Themes/Common/images/loading.gif'>";
		
		var requestUrl = "../Derivatives/AjaxTickerData.aspx?Exchange="+ Exchg +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		
		if(XmlHttpTicker)
		{
			XmlHttpTicker.onreadystatechange = function(){getDataResponse(Exchg);};
			XmlHttpTicker.open("GET", requestUrl,  true);
			XmlHttpTicker.send(null);
		}
    }
function getDataResponse(Exchg)
{
//alert(XmlHttp.status);	
	if(XmlHttpTicker.readyState == 4)
	{	
	
		if(XmlHttpTicker.status == 200)
		{	
				
		
			var arrCol,Time,Code,CompName,ClPrice,DiffVal,DiffImg;
			var ExchgDet="",stkDet="";
			var MarqueeId = document.getElementById("MarqueeId");
			var TickerData = XmlHttpTicker.responseText;
						
			if(TickerData != "")
			var arrRow = TickerData.split("|");
				for(i=0; i<arrRow.length-1; i++)
				 {
					arrCol = arrRow[i].split("~");
						CompName = arrCol[1];
						ClPrice  = arrCol[2];
						DiffVal  = arrCol[3];
						if(DiffVal>0) 
						{
							DiffImg= "<img src='../images/up.gif'>";
							clss = "<span class='Green'>" ;
						}
						else if(DiffVal<0) 
						{							
							DiffImg="<img src='../images/down.gif'>";
							clss = "<span class='Red'>" ;
						}
						else 
						{
							DiffImg= "<img src='../images/eq.gif'>";
							clss = "<span class='Green'>"	;				
						}
						
						//if(i==0)ExchgDet = arrCol[0] +" &nbsp; "+ CompName +": "+ ClPrice +" ["+ DiffVal +"] "+ DiffImg +" &nbsp; ";else stkDet += "<a href='getQuotes.aspx?code="+ arrCol[0] +"' class=TickerLink>" + CompName +"</a>: "+ ClPrice +" ["+ DiffVal +"] "+ DiffImg +" &nbsp; ";    href='../profile/CorpInfo.aspx?id=1&code="+ arrCol[0] +"'
						if(i==0)ExchgDet = "<span class='TickerText'>" + arrCol[0] +" &nbsp; "+ CompName +": "+"<span  class=TickerText>" + ClPrice+"&nbsp;"+ clss +" ["  +"<b>"+ DiffVal+ "</b>"+"]</span> </span>&nbsp;&nbsp;&nbsp;";else stkDet += "<span class='TickerLink'>" + "<a href='../companyprofile/QuoteFinder.aspx?id=1&Fincode="+arrCol[0]+"'><span  class=TickerText>" + CompName +"</span></a>: " + "<span  class=TickerText>" + ClPrice +"&nbsp;"+ clss +" [" +"<b>"+ DiffVal+ "</b>"+"]</span>  &nbsp;</span>&nbsp;";						
						
				}
				
				if(browser.isIE)
					MarqueeId.innerHTML = "<marquee id='maqid' onmouseover='this.stop();' onmouseout='this.start();' trueSpeed scrollAmount='1' scrollDelay='50' direction='left' loop='repeat' width='100%'>" + ExchgDet + stkDet + "</marquee>";
					
				else
					MarqueeId.innerHTML = ExchgDet + stkDet;				
				document.body.style.cursor = "auto";
				ExchngTimeClock(Exchg);
		}
		
		//else
			//MarqueeId.innerHTML = "<img src='../CommonImgs/loading1.gif'>";
	}
}

function ExchngTimeClock(Exchg)
 {
	 var time = new Date()
	 var hour = time.getHours()
	 if (hour >= 10 && hour <= 20)
			  clockTimeoutID = setTimeout("getTickerData('"+ Exchg +"')",600000);
	}

// For High & Low
var XmlHttpOI;
function CreateXmlHttpOI()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttpOI = new ActiveXObject("Msxml2.XmlHttp");
		}
		catch(e)
		{
			try
			{
				XmlHttpOI = new ActiveXObject("Microsoft.XmlHttp");
			} 
			catch(oc)
			{
				XmlHttpOI = null;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if(!XmlHttpOI && typeof XmlHttpRequest != "undefined") 
		{
			XmlHttpOI = new XmlHttpRequest();
		}
	}

 function GetNiftyOI()
{

 
 CreateXmlHttpOI();
	var requestUrl="AjaxNiftyOI.aspx?sid=" + Math.random();
	
	
	
	if(XmlHttpOI)	
			{
					//alert("hi");
					XmlHttpOI.onreadystatechange = function(){ShowNiftyOIData();}; 
					XmlHttpOI.open("GET", requestUrl,  true);
					XmlHttpOI.send(null);
			}
	
}

function ShowNiftyOIData() 
{ 

if(XmlHttpOI.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpOI.status == 200)
		{			
			var ShowVolumeValueData   = document.getElementById("Td_NiftyOI");
		var strData = XmlHttpOI.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 SelectDtType()
{



  var ddlExpDate = document.getElementById("ddexpdate").value;
  var DrpPgName = document.getElementById("ddlPgName").value;
  var DrpInstName = document.getElementById("ddlInstName").value;
   
  document.getElementById("txthiddenexpdate").value = ddlExpDate;
  document.getElementById("txthiddenrrttype").value =DrpInstName ;
  document.getElementById("txthiddenGaLose").value = DrpPgName;

}
function show_hide(val1,val2)
{
document.getElementById(val1).style.display="none";
document.getElementById(val2).style.display="inline";
}
function expand(val)
 {
   if(document.getElementById(val).style.display=="inline")
   {
    document.getElementById(val).style.display="none"
    document.getElementById("tab_lower").style.display="none";
   }
   else
   {
   document.getElementById(val).style.display="inline"
   document.getElementById("tab_lower").style.display="inline";
   }
 }    