﻿
function loadGLData(Category)
{

	var TopGl;
	var Period;
	if(Period=='')
	  Period = "1YEAR";
	if(Category=='')	
		Category="ALL";
	var requestUrl = GetHostUrlForPages+"AjaxFundData.aspx?Period="+ Period +"&Category="+ Category +"&TopGl="+ TopGl;
	ajaxpage(1,requestUrl,'TopPerform');
	
}	
	
function ChangeControl(Opt,Exch)
{
 var linkId;
            if(Exch=='BSE')
            {
               linkId='GainMoreBSE';
            }
            else
            {
               linkId='GainMoreNSE';
            }
            
         if(Opt=='GAIN')
            { 
                document.getElementById(linkId).href="Equity/TopGainersAndLosers.aspx?id=1&Option=GAIN&EXCHG="+Exch+"&Period=Daily&Group=&Indices=2";                  
            }
        if(Opt=='LOSE')
            {  
                document.getElementById(linkId).href="Equity/TopGainersAndLosers.aspx?id=1&Option=LOSE&EXCHG="+Exch+"&Period=Daily&Group=&Indices=";                        
            }
        if(Opt=='Val')
            {
                 document.getElementById(linkId).href="Equity/MostActive.aspx?id=3&EXCHG="+Exch;                     
            }
        if(Opt=='Vol')
            {
                 document.getElementById(linkId).href="Equity/MostActive.aspx?id=3&Option=Volume&EXCHG="+Exch+"&Group=&Indices=&IsAll=undefined";                      
            } 
            
       var requestUrl = "AjaxDataGLVV.aspx?Option="+ Opt +"&Exchange="+ Exch;
       if(Exch=='BSE')
       {
        ajaxpage(1,requestUrl,'Td_DataBSE');
       }
       else
       {
        ajaxpage(1,requestUrl,'Td_DataNSE');
       }
}
  
    
    var GlobalOptionHome;
var GlobalExchg;
function SwitchCommoditySymbol(Option,Exchg)
{ 
    if(Option!="")
    {
    GlobalOptionHome=Option;
    }
         document.getElementById("ImgGold").className="HomeHeadPink" ;
         document.getElementById("ImgSilver").className="HomeHeadPink" ;
         document.getElementById("ImgCrude").className="HomeHeadPink" ;
         document.getElementById("ImgSuger").className="HomeHeadPink" ;
         
    if(GlobalOptionHome.toLowerCase() =="gold")
    {
         document.getElementById("ImgGold").className="HomeHeadSelPink" ;         
         CommodityPriceAjaxCall(GlobalOptionHome,Exchg);  
    }
    else  if(GlobalOptionHome.toLowerCase() =="silver")
    {
         document.getElementById("ImgSilver").className="HomeHeadSelPink" ;         
         CommodityPriceAjaxCall(GlobalOptionHome,Exchg);
    }
    
    else  if(GlobalOptionHome.toLowerCase() =="crudeoil")
    {
         document.getElementById("ImgCrude").className="HomeHeadSelPink" ;       
         CommodityPriceAjaxCall(GlobalOptionHome,Exchg);
    }
    else
    {
         document.getElementById("ImgSuger").className="HomeHeadSelPink";
         CommodityPriceAjaxCall(GlobalOptionHome,Exchg);
    } 
        var so = new SWFObject("../amline/amline.swf", "BSENSEline", "260", "200", "8", "");
		so.addVariable("path", "../amline/");
		so.addParam("wmode","opaque");
		so.addVariable("settings_file", encodeURIComponent("amline/GoldSilverChart.xml"));
        var requrl="BullionchartComAjax.aspx?Exchg="+Exchg+"&Symbol="+GlobalOptionHome+"&TimeStamp="+new Date().getTime();
      
		so.addVariable("data_file", encodeURIComponent(requrl));		
		so.write("CommodityGraph");	    
}

    
    function ChangeControlComm(Opt,Exch)
{
    SwitchCommoditySymbol(GlobalOptionHome,Exch);  
    var currentDivObj = document.getElementById("Td_DataComm");
	document.getElementById("tdMCX").innerHTML='MCX';
	document.getElementById("tdNCDEX").innerHTML='NCDEX';
	document.getElementById("tdMCX").className = "HomeUnSelTab";
	document.getElementById("tdNCDEX").className = "HomeUnSelTab";
	if(Exch == "MCX")
	{
	    document.getElementById("tdMCX").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td  class='InnerSelTab'>MCX</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";         
	}
	else
	{
	    document.getElementById("tdNCDEX").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td  class='InnerSelTab'>NCDEX</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";         
	}
	
	var requestUrl = "AjaxDataGLVVComm.aspx?Option="+ Opt +"&Exchange="+ Exch;

    ajaxpage(1,requestUrl,'Td_DataComm');
    var Head_tdComm =document.getElementById("HeadingComm");
	
	switch (Opt)
	{
	    case "G":
		    Head_tdComm.innerHTML="Gainers";
		    break;
		
	    case "L":
		    Head_tdComm.innerHTML="Losers";
	        break;
	    
	    case "Volume":
		    Head_tdComm.innerHTML="Volume";
	        break;
	    
	    case "Value":
	        Head_tdComm.innerHTML="Value";     
	
	return false; 
	
  }
}	
	


function CommodityPriceCreateXmlHttp()
	{
		//Creating object of XmlHttp in IE
		try
		{
			CommodityPriceXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{  
				CommodityPriceXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				CommodityPriceXmlHttp = false;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if (!CommodityPriceXmlHttp && typeof XMLHttpRequest!='undefined') 
		{
	        try 
	        {
		        CommodityPriceXmlHttp = new XMLHttpRequest();
	        } 
	        catch (e) 
	        {
		        CommodityPriceXmlHttp=false;
	        }
        }
        if (!CommodityPriceXmlHttp && window.createRequest) 
        {
	        try 
	        {
		        CommodityPriceXmlHttp = window.createRequest();
	        } 
	        catch (e)
	        {
		        CommodityPriceXmlHttp=false;
	        }
        }
	
	}

function CommodityPriceAjaxCall(Commodity,Exch)
	{		
	
		CommodityPriceCreateXmlHttp();
		var requestUrl = "AjaxCommodityPrice.aspx?Symbol="+Commodity+"&Exchange="+Exch;
		
		if(CommodityPriceXmlHttp)	
			{
					CommodityPriceXmlHttp.onreadystatechange = function(){CommodityPriceHandleResponse();}; 
					CommodityPriceXmlHttp.open("GET", requestUrl,  true);
					CommodityPriceXmlHttp.send(null);
			}
			
	}	
	
	
function CommodityPriceHandleResponse()
{

	// To make sure receiving response data from server is completed
	if(CommodityPriceXmlHttp.readyState == 4)
	{
	    	
		// To make sure valid response is received from the server, 200 means response received is OK
		if(CommodityPriceXmlHttp.status == 200)
		{	
		
		  var ArrResponse = CommodityPriceXmlHttp.responseText.split("|");
		  
		  document.getElementById("TdCommodityName").innerHTML = ArrResponse[0];
		  document.getElementById("TdCommoditPrice").innerHTML = ArrResponse[1];
		  document.getElementById("TdCommodityChg").innerHTML = ArrResponse[2];
		  document.getElementById("TdCommodityPerChg").innerHTML = ArrResponse[3];
		  
			document.body.style.cursor = "auto";	
		}
		else
		{
			//ContentTD.innerHTML = "There was a problem retrieving data from the server.";
			
		}
	}
	
}	



 function ShowVolumeValue(ex,glctrl,id)
{
if(id!='1')
{ 
  if (ex == "")
    {
         if (glctrl=="Val")
	    {
	         document.getElementById("tdval").className="HomeHeadSelPink";
	         document.getElementById("tdvol").className="HomeHeadPink";
	         document.getElementById("VV").value = "Val"
	         ex=document.getElementById("MCXNCD").value;
	    }
	    else
	    {
	         document.getElementById("tdval").className="HomeHeadPink";
	         document.getElementById("tdvol").className="HomeHeadSelPink";
	  	     document.getElementById("VV").value = "Vol"
	  	    //  document.getElementById("MCXNCD").value=glctrl;
	  	     ex=document.getElementById("MCXNCD").value;
	    }
	 }
	 else
        {
	        if(ex=="FUT")
	        {
	        
		        document.getElementById("MCXNCD").value = "FUT"
	        }
	        else
	        {
        	
		        document.getElementById("MCXNCD").value = "OPT"
	        }
        	
        }
        
     }
     var requestUrl=GetHostUrlForPages+"AjaxValueVol.aspx?sid=" + Math.random() + "&Exchg="+ex+"&typeGL="+glctrl;
     ajaxpage(1,requestUrl,'ShowVVData');
     return false;	

}
  
   function ShowBseGL(ex,glctrl,id)
{
if(id!=1)
{
 if (ex == "")
    {
         if (glctrl=="G")
	    {
	         document.getElementById("tdgain").className="HomeHeadSelPink";
	         document.getElementById("tdlos").className="HomeHeadPink";
	         ex= document.getElementById("MCXNCD").value
	  
	        document.getElementById("GL").value = "G"
	    }
	    else
	    {
     	      document.getElementById("tdgain").className="HomeHeadPink";
	          document.getElementById("tdlos").className="HomeHeadSelPink";
	          document.getElementById("GL").value = "L"
	          ex= document.getElementById("MCXNCD").value
	    }
	 }
	 else
        {
	        if(ex=="FUT")
	        {
                
		        document.getElementById("MCXNCD").value = "FUT"
	        }
	        else
	        {
        	
		        document.getElementById("MCXNCD").value = "OPT"
	        }
        	
        }
    }   
 
	 var requestUrl="AjaxGainLose.aspx?sid=" + Math.random() + "&Exchg="+ex+"&typeGL="+glctrl;	
	 ajaxpage(1,requestUrl,'ShowGLData');
	 return false;		
}
 

function GetIndicator(optionvalue)
{	
    var requestUrl = "Ajaxindicator.aspx?Option="+optionvalue+"&timeStamp="+new Date().getTime();
    ajaxpage(1,requestUrl,'Bind');
	return false;	
}

function LookUpData(str,typ)
{ 
        if (str=="FUT")
        {
            document.getElementById("tdfuture").className="FOselect" 
            document.getElementById("tdoption").className="FOUnselect"	        
	        ShowVolumeValue('FUT',document.getElementById("VV").value);
	        ShowBseGL('FUT', document.getElementById("GL").value)
        }
        else
        {
            document.getElementById("tdfuture").className="FOUnselect" 
            document.getElementById("tdoption").className="FOselect"	       
	        ShowVolumeValue('OPT',document.getElementById("VV").value);
	        ShowBseGL('OPT',document.getElementById("GL").value)
        }
	
} 


 function c_h(){
 	document.getElementById('floatad1').style.width="180px";
 	document.getElementById('flashcontent').className="ad_float_off";
 }
 function rc_h(){
 	document.getElementById('floatad1').style.width="500px";
 	document.getElementById('flashcontent').className="ad_float_on";
 }
 
 function mktroundtool_2(mkttool)
 {	
       document.getElementById("mktround_3").className="HomeUnSelTab";
       document.getElementById("mktround_1").className="HomeUnSelTab";
       document.getElementById("mktround_2").className="HomeUnSelTab";
       document.getElementById("mktround_4").className="HomeUnSelTab";
       document.getElementById("mktrounddiv_1").style.display="none";
       document.getElementById("mktrounddiv_2").style.display="none";
       document.getElementById("mktrounddiv_3").style.display="none";
       document.getElementById("mktrounddiv_4").style.display="none";
       document.getElementById("mktround_3").innerHTML='Equity';
       document.getElementById("mktround_1").innerHTML='Derivatives';
       document.getElementById("mktround_2").innerHTML='Commodities';
       document.getElementById("mktround_4").innerHTML='MF';
 
 	for (mktcnt=1; mktcnt<=4; mktcnt++)
 	{
 	   if(mkttool=='1')
 	   { 
           document.getElementById("mktround_1").className="HomeSelTab";          
           document.getElementById("mktrounddiv_1").style.display="";
           document.getElementById("mktround_1").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Derivatives</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";         
 	   }
 	   else if(mkttool=='2')
 	   { 	       
           document.getElementById("mktround_2").className="HomeSelTab";
           document.getElementById("mktrounddiv_2").style.display="";          
           document.getElementById("mktround_2").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Commodities</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";         
 	   }
 	   
 	   else if(mkttool=='3')
 	   {
           document.getElementById("mktround_3").className="HomeSelTab";           
           document.getElementById("mktrounddiv_3").style.display="";  
           document.getElementById("mktround_3").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Equity</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";        
 	   }
 	   else if(mkttool=='4')
 	   { 	      
           document.getElementById("mktround_4").className="HomeSelTab";          
           document.getElementById("mktrounddiv_4").style.display="";
           document.getElementById("mktround_4").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>MF</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";         
 	   }
 		
 	}
 }
 
 
 function c_h(){
 	document.getElementById('floatad1').style.width="180px";
 	document.getElementById('flashcontent').className="ad_float_off";
 }
 function rc_h(){
 	document.getElementById('floatad1').style.width="500px";
 	document.getElementById('flashcontent').className="ad_float_on";
 }
 
 function mktroundtool_2(mkttool)
 {	
       document.getElementById("mktround_3").className="HomeUnSelTab";
       document.getElementById("mktround_1").className="HomeUnSelTab";
       document.getElementById("mktround_2").className="HomeUnSelTab";
       document.getElementById("mktround_4").className="HomeUnSelTab";
       document.getElementById("mktrounddiv_1").style.display="none";
       document.getElementById("mktrounddiv_2").style.display="none";
       document.getElementById("mktrounddiv_3").style.display="none";
       document.getElementById("mktrounddiv_4").style.display="none";
       document.getElementById("mktround_3").innerHTML='Equity';
       document.getElementById("mktround_1").innerHTML='Derivatives';
       document.getElementById("mktround_2").innerHTML='Commodities';
       document.getElementById("mktround_4").innerHTML='MF';
 
 	for (mktcnt=1; mktcnt<=4; mktcnt++)
 	{
 	   if(mkttool=='1')
 	   { 
           document.getElementById("mktround_1").className="HomeSelTab";          
           document.getElementById("mktrounddiv_1").style.display="";
           document.getElementById("mktround_1").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Derivatives</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";         
 	   }
 	   else if(mkttool=='2')
 	   { 	       
           document.getElementById("mktround_2").className="HomeSelTab";
           document.getElementById("mktrounddiv_2").style.display="";          
           document.getElementById("mktround_2").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Commodities</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";         
 	   }
 	   
 	   else if(mkttool=='3')
 	   {
           document.getElementById("mktround_3").className="HomeSelTab";           
           document.getElementById("mktrounddiv_3").style.display="";  
           document.getElementById("mktround_3").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Equity</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";        
 	   }
 	   else if(mkttool=='4')
 	   { 	      
           document.getElementById("mktround_4").className="HomeSelTab";          
           document.getElementById("mktrounddiv_4").style.display="";
           document.getElementById("mktround_4").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>MF</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";         
 	   }
 		
 	}
 }
 
function erupdown_stk1(udtab)
  {	
  	var tabcnt;
  	for (tabcnt=1; tabcnt<3; tabcnt++)
  	{
  		if(udtab==tabcnt)
  		{
  		
  			if(document.getElementById("ermain_"+tabcnt).className=='plus')
  			{
  				document.getElementById("ermain_"+tabcnt).className='minus';	
  				document.getElementById("ermaintg_"+tabcnt).className='PT5';
  				$("#ermaintg_"+tabcnt).slideUp(1);
  				$("#ermaintg_"+tabcnt).slideDown(500);
                  if(tabcnt==1 && document.getElementById('erctab2').className =='bl-11-L')
  				{
  				document.getElementById('erctab1').className = "b-12";
  				}
  				else if(tabcnt==2 && document.getElementById('erctab4').className =='bl-11-L')
  				{
  					document.getElementById('erctab3').className = "b-12";
  				}
  				else if(tabcnt==3 && document.getElementById('erctab6').className =='bl-11-L')
  				{
  					document.getElementById('erctab5').className = "b-12";
  				}
  				else if(tabcnt==4 && document.getElementById('erctab8').className =='bl-11-L')
  				{
  					document.getElementById('erctab7').className = "b-12";
  				}
  				else if(tabcnt==5 && document.getElementById('erctab10').className =='bl-11-L')
  				{
  				document.getElementById('erctab9').className = "b-12";
    			}
  				else if(tabcnt==6 && document.getElementById('erctab12').className =='bl-11-L')
  				{
  				document.getElementById('erctab11').className = "b-12";
  
  				}
  				else if(tabcnt==7 && document.getElementById('erctab14').className =='bl-11-L')
  				{
  				document.getElementById('erctab13').className = "b-12";
  
  				}
  				else if(tabcnt==8 && document.getElementById('erctab16').className =='bl-11-L')
  				{
  				document.getElementById('erctab15').className = "b-12";
 
  				}
  				else if(tabcnt==9 && document.getElementById('erctab18').className =='bl-11-L')
  				{
  				document.getElementById('erctab17').className = "b-12";
   				}
   				
  			}
  			else
  			{
  				document.getElementById("ermain_"+tabcnt).className='plus';
  				$("#ermaintg_"+tabcnt).slideUp(500);
  			}
  		}
  		else
  		{
  			$("#ermaintg_"+tabcnt).slideUp(500);  			
  			document.getElementById("ermain_"+tabcnt).className = 'plus';               
  		}
  	}
  }
  
  function erctab(num,fs,ls){

  	for(var i=fs; i<=ls; i++)
  	{
  		if(num==i){
  			
  		   document.getElementById('block_'+i).style.display = 'block';
  		   document.getElementById('erctab'+i).className = "b-12";
  		}
  		else{
  			document.getElementById('block_'+i).style.display = 'none';
  			document.getElementById('erctab'+i).className = "bl-11-L";
  		}
  		
  	}
  if(num==10)
  	{
  		   document.getElementById('block_10').style.display = 'block';
  		   document.getElementById('erctab10').className = "b-12";
  		   document.getElementById('block_9').style.display = 'none';
  			document.getElementById('erctab9').className = "bl-11-L";
  
  	}
  if(num==9)
  	{
  		   document.getElementById('block_9').style.display = 'block';
  		   document.getElementById('erctab9').className = "b-12";
  		   document.getElementById('block_10').style.display = 'none';
  			document.getElementById('erctab10').className = "bl-11-L";
  
  	}
  for(var i=1; i<=2; i++)
  	{
           if(i!=fs && i!=ls)
  		{
  			document.getElementById('erctab'+i).className = "bl-11-L";
  
  		}
      }
  
   if(fs==1 && ls==2)
  	{
   if(document.getElementById("ermain_1").className=='plus')
  		{
  	     updown_stk(1);
  		}
  	}
  	else if(fs==3 && ls==4)
  	{
  		if(document.getElementById("ermain_2").className=='plus')
  		{
  			
  		updown_stk(2);
  		
  		}
  	}
  	else if(fs==5 && ls==6)
  	{ 
  		if(document.getElementById("main_3").className=='plus')
  		{
  		updown_stk(3);
  		}
  	}
  	else if(fs==7 && ls==8)
  	{ 
  		if(document.getElementById("main_4").className=='plus')
  		{
  		updown_stk(4);
  		}
  	}
  	else if(fs==9 && ls==10)
  	{ 
  		if(document.getElementById("main_5").className=='plus')
  		{
  		updown_stk(5);
  		}
  	}
      else if(fs==11 && ls==12)
  	{ 
  		if(document.getElementById("main_6").className=='plus')
  		{
  		updown_stk(6);
  		}
  	}
  	else if(fs==13 && ls==14)
  	{ 
  		if(document.getElementById("main_7").className=='plus')
  		{
  		updown_stk(7);
  		}
  	}
     else if(fs==15 && ls==16)
  	{ 
  		if(document.getElementById("main_8").className=='plus')
  		{
  		updown_stk(8);
  		}
  	}
  	else if(fs==17 && ls==18)
  	{ 
  		if(document.getElementById("main_9").className=='plus')
  		{
  		updown_stk(9);
  		}
  	}
  
  
  }
  
 
function SwitchSensexNifty(Option)
{


    if(Option =="BSE")
        {
             var RequestUrl = "BSENSEchartAjax.aspx?Exchg=BSE";
	     // alert(RequestUrl);
	        var so = new SWFObject("amline/amline.swf", "BSENSEline", "260", "200", "8", "#FFFFFF");
	        so.addVariable("path", "amline/");
	        so.addParam("wmode","opaque");
	        so.addVariable("settings_file", encodeURIComponent("amline/BSENSEline_settings.xml")); 
	        so.addVariable("data_file", encodeURIComponent(RequestUrl + "&TimeStamp="+new Date().getTime()));
	        so.write("BSEChart");
        }
        else
        {
        var RequestUrl = "BSENSEchartAjax.aspx?Exchg=NSE";
        //alert(RequestUrl);
	    var so = new SWFObject("amline/amline.swf", "BSENSEline", "260", "200", "8", "#FFFFFF");
	    so.addVariable("path", "amline/");
	    so.addParam("wmode","opaque");
	    so.addVariable("settings_file", encodeURIComponent("amline/BSENSEline_settings.xml")); 
	    so.addVariable("data_file", encodeURIComponent(RequestUrl + "&TimeStamp="+new Date().getTime()));
	    so.write("NSEChart");
	    }
}

            function HideSensex()
            {
            if(document.getElementById("ermaintg_2").style.display=="")
                document.getElementById("Sensex").style.display="none";
            else
                document.getElementById("Sensex").style.display="none";
            }
            function ShowSensex()
            {
             document.getElementById("Sensex").style.display=""; 
            }
            
            function ChangeTab(Ex,ID)
            {
                if(Ex=='BSE')
                {
                    document.getElementById("tdGain1").innerHTML='Gainers';
                    document.getElementById("tdLose").innerHTML='Losers';
                    document.getElementById("tdValue").innerHTML='Value';
                    document.getElementById("tdVolume").innerHTML='Volume';
                    document.getElementById("tdGain1").className='HomeUnselected';
                    document.getElementById("tdLose").className='HomeUnselected';
                    document.getElementById("tdValue").className='HomeUnselected';
                    document.getElementById("tdVolume").className='HomeUnselected';
                    if(ID=='tdGain1')
                    {
                     document.getElementById("tdGain1").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Gainers</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";
                      document.getElementById("tdGain1").className='';
                    }
                    if(ID=='tdLose')
                    {
                     document.getElementById("tdLose").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Losers</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";
                     document.getElementById("tdLose").className='';
                    }
                     if(ID=='tdValue')
                    {
                     document.getElementById("tdValue").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Value</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";
                     document.getElementById("tdValue").className='';
                    }
                    if(ID=='tdVolume')
                    {
                     document.getElementById("tdVolume").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Volume</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";
                     document.getElementById("tdVolume").className='';
                    }
                }
                if(Ex=='NSE')
                {
                    document.getElementById("tdGainNSE").innerHTML='Gainers';
                    document.getElementById("tdLoseNSE").innerHTML='Losers';
                    document.getElementById("tdValueNSE").innerHTML='Value';
                    document.getElementById("tdValNSE").innerHTML='Volume';
                    document.getElementById("tdGainNSE").className='HomeUnselected';
                    document.getElementById("tdLoseNSE").className='HomeUnselected';
                    document.getElementById("tdValueNSE").className='HomeUnselected';
                    document.getElementById("tdValNSE").className='HomeUnselected';
                    
                    if(ID=='tdGainNSE')
                    {
                     document.getElementById("tdGainNSE").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Gainers</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";
                      document.getElementById("tdGainNSE").className='';
                    }
                    if(ID=='tdLoseNSE')
                    {
                     document.getElementById("tdLoseNSE").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Losers</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";
                      document.getElementById("tdLoseNSE").className='';
                    }
                     if(ID=='tdValueNSE')
                    {
                     document.getElementById("tdValueNSE").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Value</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";
                      document.getElementById("tdValueNSE").className='';
                    }
                    if(ID=='tdValNSE')
                    {
                     document.getElementById("tdValNSE").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'><img src='App_Themes/Common/images/LeftSelectTab.gif'  align='right' /></td><td id='imgC1' class='InnerSelTab'>Volume</td><td valign='top' align='left'><img src='App_Themes/Common/images/RightSelectTab.gif'  align='left' /></td></tr></table>";
                      document.getElementById("tdValNSE").className='';
                    }
                }
            }
 
 
 




var ddaccordion={
	
	contentclassname:{}, //object to store corresponding contentclass name based on headerclass

	expandone:function(headerclass, selected){ //PUBLIC function to expand a particular header
	//alert(headerclass)
		this.toggleone(headerclass, selected, "expand")
	},

	collapseone:function(headerclass, selected){ //PUBLIC function to collapse a particular header
		this.toggleone(headerclass, selected, "collapse")
	},

	expandall:function(headerclass){ //PUBLIC function to expand all headers based on their shared CSS classname
		var $=jQuery
		var $headers=$('.'+headerclass)
		$('.'+this.contentclassname[headerclass]+':hidden').each(function(){
			$headers.eq(parseInt($(this).attr('contentindex'))).trigger("evt_accordion")
		})
	},

	collapseall:function(headerclass){ //PUBLIC function to collapse all headers based on their shared CSS classname
		var $=jQuery
		var $headers=$('.'+headerclass)
		$('.'+this.contentclassname[headerclass]+':visible').each(function(){
			$headers.eq(parseInt($(this).attr('contentindex'))).trigger("evt_accordion")
		})
	},

	toggleone:function(headerclass, selected, optstate){ //PUBLIC function to expand/ collapse a particular header
		var $=jQuery
		var $targetHeader=$('.'+headerclass).eq(selected)
		var $subcontent=$('.'+this.contentclassname[headerclass]).eq(selected)		
		if (typeof optstate=="undefined" || optstate=="expand" && $subcontent.is(":hidden") || optstate=="collapse" && $subcontent.is(":visible"))
			$targetHeader.trigger("evt_accordion")
	},

	expandit:function($targetHeader, $targetContent, config, useractivated, directclick){
		$targetContent.slideDown(config.animatespeed, function(){
			config.onopenclose($targetHeader.get(0), parseInt($targetHeader.attr('headerindex')), $targetContent.css('display'), useractivated)
			if (config.postreveal=="gotourl" && directclick){ //if revealtype is "Go to Header URL upon click", and this is a direct click on the header
				var targetLink=($targetHeader.is("a"))? $targetHeader.get(0) : $targetHeader.find('a:eq(0)').get(0)
				if (targetLink) //if this header is a link
					setTimeout(function(){location=targetLink.href}, 200) //ignore link target, as window.open(targetLink, targetLink.target) doesn't work in FF if popup blocker enabled
			}
		})
		this.transformHeader($targetHeader, config, "expand")
	},

	collapseit:function($targetHeader, $targetContent, config, isuseractivated){
		$targetContent.slideUp(config.animatespeed, function(){config.onopenclose($targetHeader.get(0), parseInt($targetHeader.attr('headerindex')), $targetContent.css('display'), isuseractivated)})
		this.transformHeader($targetHeader, config, "collapse")
	},

	transformHeader:function($targetHeader, config, state){
		$targetHeader.addClass((state=="expand")? config.cssclass.expand : config.cssclass.collapse) //alternate btw "expand" and "collapse" CSS classes
		.removeClass((state=="expand")? config.cssclass.collapse : config.cssclass.expand)
		if (config.htmlsetting.location=='src'){ //Change header image (assuming header is an image)?
			$targetHeader=($targetHeader.is("img"))? $targetHeader : $targetHeader.find('img').eq(0) //Set target to either header itself, or first image within header
			$targetHeader.attr('src', (state=="expand")? config.htmlsetting.expand : config.htmlsetting.collapse) //change header image
		}
		else if (config.htmlsetting.location=="prefix") //if change "prefix" HTML, locate dynamically added ".accordprefix" span tag and change it
			$targetHeader.find('.accordprefix').html((state=="expand")? config.htmlsetting.expand : config.htmlsetting.collapse)
		else if (config.htmlsetting.location=="suffix")
			$targetHeader.find('.accordsuffix').html((state=="expand")? config.htmlsetting.expand : config.htmlsetting.collapse)
	},

	urlparamselect:function(headerclass){
		var result=window.location.search.match(new RegExp(headerclass+"=((\\d+)(,(\\d+))*)", "i")) //check for "?headerclass=2,3,4" in URL
		if (result!=null)
			result=RegExp.$1.split(',')
		return result //returns null, [index], or [index1,index2,etc], where index are the desired selected header indices
	},

	getCookie:function(Name){ 
		var re=new RegExp(Name+"=[^;]+", "i") //construct RE to search for target name/value pair
		if (document.cookie.match(re)) //if cookie found
			return document.cookie.match(re)[0].split("=")[1] //return its value
		return null
	},

	setCookie:function(name, value){
		document.cookie = name + "=" + value + "; path=/"
	},

	init:function(config){
	document.write('<style type="text/css">\n')
	document.write('.'+config.contentclass+'{display: none}\n') //generate CSS to hide contents
	document.write('<\/style>')
	jQuery(document).ready(function($){
		ddaccordion.urlparamselect(config.headerclass)
		var persistedheaders=ddaccordion.getCookie(config.headerclass)
		ddaccordion.contentclassname[config.headerclass]=config.contentclass //remember contentclass name based on headerclass
		config.cssclass={collapse: config.toggleclass[0], expand: config.toggleclass[1]} //store expand and contract CSS classes as object properties
		config.revealtype=config.revealtype.replace(/mouseover/i, "mouseenter")
		if (config.revealtype=="clickgo"){
			config.postreveal="gotourl" //remember added action
			config.revealtype="click" //overwrite revealtype to "click" keyword
		}
		if (typeof config.togglehtml=="undefined")
			config.htmlsetting={location: "none"}
		else
			config.htmlsetting={location: config.togglehtml[0], collapse: config.togglehtml[1], expand: config.togglehtml[2]} //store HTML settings as object properties
		config.oninit=(typeof config.oninit=="undefined")? function(){} : config.oninit //attach custom "oninit" event handler
		config.onopenclose=(typeof config.onopenclose=="undefined")? function(){} : config.onopenclose //attach custom "onopenclose" event handler
		var lastexpanded={} //object to hold reference to last expanded header and content (jquery objects)
		var expandedindices=ddaccordion.urlparamselect(config.headerclass) || ((config.persiststate && persistedheaders!=null)? persistedheaders : config.defaultexpanded)
		if (typeof expandedindices=='string') //test for string value (exception is config.defaultexpanded, which is an array)
			expandedindices=expandedindices.replace(/c/ig, '').split(',') //transform string value to an array (ie: "c1,c2,c3" becomes [1,2,3]
		var $subcontents=$('.'+config["contentclass"])
		if (expandedindices.length==1 && expandedindices[0]=="-1") //check for expandedindices value of [-1], indicating persistence is on and no content expanded
			expandedindices=[]
		if (config["collapseprev"] && expandedindices.length>1) //only allow one content open?
			expandedindices=[expandedindices.pop()] //return last array element as an array (for sake of jQuery.inArray())
		if (config["onemustopen"] && expandedindices.length==0) //if at least one content should be open at all times and none are, open 1st header
			expandedindices=[0]
		$('.'+config["headerclass"]).each(function(index){ //loop through all headers
			if (/(prefix)|(suffix)/i.test(config.htmlsetting.location) && $(this).html()!=""){ //add a SPAN element to header depending on user setting and if header is a container tag
				$('<span class="accordprefix"></span>').prependTo(this)
				$('<span class="accordsuffix"></span>').appendTo(this)
			}
			$(this).attr('headerindex', index+'h') //store position of this header relative to its peers
			$subcontents.eq(index).attr('contentindex', index+'c') //store position of this content relative to its peers
			var $subcontent=$subcontents.eq(index)
			var needle=(typeof expandedindices[0]=="number")? index : index+'' //check for data type within expandedindices array- index should match that type
			if (jQuery.inArray(needle, expandedindices)!=-1){ //check for headers that should be expanded automatically (convert index to string first)
				if (config.animatedefault==false)
					$subcontent.show()
				ddaccordion.expandit($(this), $subcontent, config, false) //Last param sets 'isuseractivated' parameter
				lastexpanded={$header:$(this), $content:$subcontent}
			}  //end check
			else{
				$subcontent.hide()
				config.onopenclose($(this).get(0), parseInt($(this).attr('headerindex')), $subcontent.css('display'), false) //Last Boolean value sets 'isuseractivated' parameter
				ddaccordion.transformHeader($(this), config, "collapse")
			}
		})
		$('.'+config["headerclass"]).bind("evt_accordion", function(e, isdirectclick){ //assign custom event handler that expands/ contacts a header
				var $subcontent=$subcontents.eq(parseInt($(this).attr('headerindex'))) //get subcontent that should be expanded/collapsed
				if ($subcontent.css('display')=="none"){
					ddaccordion.expandit($(this), $subcontent, config, true, isdirectclick) //2nd last param sets 'isuseractivated' parameter
					if (config["collapseprev"] && lastexpanded.$header && $(this).get(0)!=lastexpanded.$header.get(0)){ //collapse previous content?
						ddaccordion.collapseit(lastexpanded.$header, lastexpanded.$content, config, true) //Last Boolean value sets 'isuseractivated' parameter
					}
					lastexpanded={$header:$(this), $content:$subcontent}
				}
				else if (!config["onemustopen"] || config["onemustopen"] && lastexpanded.$header && $(this).get(0)!=lastexpanded.$header.get(0)){
					ddaccordion.collapseit($(this), $subcontent, config, true) //Last Boolean value sets 'isuseractivated' parameter
				}
 		})
		$('.'+config["headerclass"]).bind(config.revealtype, function(){
			if (config.revealtype=="mouseenter"){
				clearTimeout(config.revealdelay)
				var headerindex=parseInt($(this).attr("headerindex"))
				config.revealdelay=setTimeout(function(){ddaccordion.expandone(config["headerclass"], headerindex)}, config.mouseoverdelay || 0)
			}
			else{
				$(this).trigger("evt_accordion", [true])
				return false //cancel default click behavior
			}
		})
		$('.'+config["headerclass"]).bind("mouseleave", function(){
			clearTimeout(config.revealdelay)
		})
		config.oninit($('.'+config["headerclass"]).get(), expandedindices)
		$(window).bind('unload', function(){ //clean up and persist on page unload
			$('.'+config["headerclass"]).unbind()
			var expandedindices=[]
			$('.'+config["contentclass"]+":visible").each(function(index){ //get indices of expanded headers
				expandedindices.push($(this).attr('contentindex'))
			})
			if (config.persiststate==true){ //persist state?
				expandedindices=(expandedindices.length==0)? '-1c' : expandedindices //No contents expanded, indicate that with dummy '-1c' value?
				ddaccordion.setCookie(config.headerclass, expandedindices)
			}
		})
	})
	}
}




