﻿var HostAddressInJSfileForPages="http://money.livemint.com";
function marketchunk(id){if(id=='markets'){document.getElementById('limarkets').className='NewsFirstTabWSelected';document.getElementById('licomm').className=document.getElementById('licurr').className=document.getElementById('lisearch').className='NewsTabSelectedWhite';document.getElementById('tdbsenseg').style.display='';document.getElementById('tdquotes').style.display='none';document.getElementById('tdcommodity').style.display='none';document.getElementById('tdforexdata').style.display='none';}if(id=='comm'){document.getElementById('licomm').className='NewsTabWSelected';document.getElementById('licurr').className=document.getElementById('lisearch').className=document.getElementById('limarkets').className='NewsTabSelectedWhite';document.getElementById('tdcommodity').style.display='';document.getElementById('tdquotes').style.display='none';document.getElementById('tdforexdata').style.display='none';document.getElementById('tdbsenseg').style.display='none';PricecommUpdate('FUT','SPT');}if(id=='search'){document.getElementById('lisearch').className='NewsTabWSelected';document.getElementById('licomm').className=document.getElementById('licurr').className=document.getElementById('limarkets').className='NewsTabSelectedWhite';document.getElementById('tdquotes').style.display='';document.getElementById('tdcommodity').style.display='none';document.getElementById('tdforexdata').style.display='none';document.getElementById('tdbsenseg').style.display='none';}if(id=='curr'){document.getElementById('licurr').className='NewsTabWSelected';document.getElementById('licomm').className=document.getElementById('lisearch').className=document.getElementById('limarkets').className='NewsTabSelectedWhite';document.getElementById('tdquotes').style.display='none';document.getElementById('tdcommodity').style.display='none';document.getElementById('tdbsenseg').style.display='none';document.getElementById('tdforexdata').style.display='';getforex();}}
function getTickerCHUNKData(Exchg){var HomTickerUrl = HostAddressInJSfileForPages +"/common/AjaxMarketTicker.aspx?Exchange="+Exchg+"&IpTrack="+window.location.hostname+"&timeStamp="+new Date().getTime();document.getElementById("mqTicker").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td align='center'><img src='"+HostAddressInJSfileForPages+"/App_Themes/images/loader.gif'></td></tr></table>";ajaxpage(1,HomTickerUrl,'mqTicker');if(navigator.userAgent.indexOf('MSIE')==-1 && navigator.userAgent.indexOf('Opera')==-1){InitializeTimer();}}
function getforex(){var forexUrl=HostAddressInJSfileForPages + "/common/Ajaxforex.aspx?&IpTrack="+window.location.hostname;ajaxpage(1,forexUrl,'tdforexdata');}
function getindices(type){ var requestUrl =HostAddressInJSfileForPages +  "/LiveHome/AjaxhomeData.aspx?id="+type+"&timeStamp="+new Date().getTime();ajaxpage(1,requestUrl,'tdindicesdata');	}
var secs;var timerID = null;var timerRunning = false;
function InitializeTimer(){secs = 1;StopTheClock();StartTheTimer();}
function StopTheClock(){if(timerRunning)clearTimeout(timerID);timerRunning = false;}
function StartTheTimer(){if (secs==0){if(document.getElementById("marqBSENSE")!=null)document.getElementById("marqBSENSE").start();}
else{secs = secs - 1;timerRunning = true;timerID = self.setTimeout("StartTheTimer()", 1000);}}

function sensexautoval(val)
{
 var requestUrl = "../common/ajaxsensexauto.aspx?timeStamp="+new Date().getTime();
    ajaxpage(1,requestUrl,'tdbsenseauto');

}
function sensexautochart(val)
    {var so = new SWFObject("../amline/amline.swf", "BSENSEline", "293", "165", "8", "#FFFFFF");
		so.addVariable("path", "../amline/");
		so.addParam("wmode","opaque");
		so.addVariable("settings_file", encodeURIComponent("../LiveHome/BSENSEline_settings.xml"));
		so.addVariable("data_file", encodeURIComponent("../LiveHome/BSENSEchartAjax.aspx?Exchg="+val+"&TimeStamp="+new Date().getTime()));
		so.write("senseautochart");
//    document.getElementById("sensexchart").src="http://content.acesphere.com/charts/sensexintraday.png?"+ new Date().getTime(); 
    }
 
 function chngesensexautoclass(val)
 {
 if(val=='BSE')
    	{
    	document.getElementById("tdsensex").className="WhiteBk";
    	document.getElementById("tdnifty").className="SensexBk";
    	}
    	else
    	{
    	document.getElementById("tdnifty").className="WhiteBk";
    	document.getElementById("tdsensex").className="SensexBk";
    	}
 }
 
function TopCommodityKeypress(ce)    
             {                    
                 var Ckeynum   
                 if(window.event) // IE                                                
                   { Ckeynum = ce.keyCode   ;        
                    }         
               else if(ce.which) // Netscape/Firefox/Opera                
                   {   
                   Ckeynum = ce.which ;
                   }  
                    if (Ckeynum == 13)      
                      {    
                     
                          Godetails()    ;  
                          return false;
                       }           
                       
                  }
                  
function Gocommsmart(){var Excha=document.getElementById("MarketChunk1_Topsmartquotes1_Commsamrtquote1_ddlcommexchange");
var Symbol=document.getElementById("ddlcommsymbol");
var ExpiryDate=document.getElementById("ExpDate");
if(Excha.value==""){alert("Please select Exchange before you proceed")
Excha.focus();return false;}if(Symbol.value==""){alert("Please select Symbol before you proceed")
Symbol.focus();return false;}else if(ExpiryDate.value==""){alert("Please select Expiry Date  before you proceed")
ExpiryDate.focus()
return false;}var requestUrl="../Commodity/GetQuoteData.aspx?timeStamp="+new Date().getTime()+"&Excha="+Excha.value+"&Symbol="+Symbol.value+"&ExpDate="+ExpiryDate.value+"&id=2&Home=True";var newWindow=window.open(requestUrl,'_parent');newWindow.focus();return false;}
 $(function(){
			$("select#MarketChunk1_Topsmartquotes1_Commsamrtquote1_ddlcommexchange").change(function(){
				$.getJSON("../common/Ajaxcommsymbol.aspx",{id: $(this).val()}, function(j){
					var options = '';
					for (var i = 0; i < j.length; i++) {
						options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
					}
					$("#ddlcommsymbol").html(options);
					$('#ddlcommsymbol option:first').attr('selected', 'selected');
				})
			})			
		})
		
		$(function(){
			$("select#ddlcommsymbol").change(function(){
				$.getJSON("../common/Ajaxcommexpdate.aspx",{exch: $("select#MarketChunk1_Topsmartquotes1_Commsamrtquote1_ddlcommexchange").val(),Symbol: $(this).val()}, function(j){
					var options = '';
					for (var i = 0; i < j.length; i++) {
						options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
					}
					$("#ExpDate").html(options);
					$('#ExpDate option:first').attr('selected', 'selected');
				})
			})			
		})
		function SearchCompany123()
{
  
//   alert("test");
    var SearchTxt = document.getElementById("MarketChunk1_Topsmartquotes1_Compsamrtquote1_txtCompany").value;
  //  alert(SearchTxt);
    var Id = document.getElementById("ddlQuote").value;	
    		
    if(SearchTxt =="" || SearchTxt=="Company Name")
    {
        alert("Please enter company name ..!!!");
        document.getElementById("MarketChunk1_Topsmartquotes1_Compsamrtquote1_txtCompany").value="";
        document.getElementById("MarketChunk1_Topsmartquotes1_Compsamrtquote1_txtCompany").focus();
        return false;
       
    }
    else
    {
        var section;
        var surl=document.location.href.toUpperCase();
         if (surl.indexOf("/LIVEHOME/")>= 0) 
            section="Home";
         else (surl.indexOf("/LIVEMARKET/")>= 0) 
            section="Market";
            
          
       //  alert(document.getElementById("ddlQuote").value);
         var url =HostAddressInJSfileForPages+"/CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=" + ddlQuote+"&section="+section;
         //alert(url);
        var ddlQuote = document.getElementById("ddlQuote").value;
         self.location.href= HostAddressInJSfileForPages+"/CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id=" + ddlQuote+"&section="+section;
             
       
    }
}


function Searchempty()
{
	if (document.getElementById("MarketChunk1_Topsmartquotes1_Compsamrtquote1_txtCompany").value=="Company Name")
	{
		document.getElementById("MarketChunk1_Topsmartquotes1_Compsamrtquote1_txtCompany").value="";
	}
}
function Searchfill()
{
    var getquote=document.getElementById("MarketChunk1_Topsmartquotes1_Compsamrtquote1_txtCompany").value;
    
    if (getquote=="")
    {
        document.getElementById("MarketChunk1_Topsmartquotes1_Compsamrtquote1_txtCompany").value="Company Name";
    }
}




 function TextName_OnKeyDown(e)    
             {                    
                 var keynum   
                 if(window.event) // IE                                                
                   { keynum = e.keyCode   ;        
                    }         
               else if(e.which) // Netscape/Firefox/Opera                
                   {   
                   keynum = e.which ;
                   }  
                    if (keynum == 13)      
                      {      
                          SearchCompany123()    ;  
                          return false;
                       }           
                       
                  }
                  $(function(){
			$("select#MarketChunk1_Topsmartquotes1_Mfsamrtquote1_ddlAMC").change(function(){
				$.getJSON("../common/AjaxGetCategory.aspx",{id: $(this).val()}, function(j){
					var options = '';
					for (var i = 0; i < j.length; i++) {
						options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
					}
					$("#ddlCategory").html(options);
					$('#ddlCategory option:first').attr('selected', 'selected');
				})
			})			
		})
	 $(function(){
			$("select#MarketChunk1_Topsmartquotes1_Mfsamrtquote1_ddlAMC").change(function(){
				$.getJSON("../common/AjaxGetScheme.aspx",{id: $(this).val()}, function(j){
					var options = '';
					for (var i = 0; i < j.length; i++) {
						options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
					}
					$("#ddlScheme").html(options);
					$('#ddlScheme option:first').attr('selected', 'selected');
				})
			})			
		})	
		
		
		 $(function(){
			$("select#ddlCategory").change(function(){  
				$.getJSON("../common/AjaxGetScheme.aspx",{id: $("select#MarketChunk1_Topsmartquotes1_Mfsamrtquote1_ddlAMC").val(),cid: $(this).val()}, function(j){
					var options = '';
					for (var i = 0; i < j.length; i++) {
						options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
					}
					$("#ddlScheme").html(options);
					$('#ddlScheme option:first').attr('selected', 'selected');
				})
			})			
		})
		
		function TopMutualKeypress(me)    
             {                    
                 var Mkeynum   
                 if(window.event) // IE                                                
                   { Mkeynum = me.keyCode   ;        
                    }         
               else if(me.which) // Netscape/Firefox/Opera                
                   {   
                   Mkeynum = me.which ;
                   }  
                    if (Mkeynum == 13)      
                      {    
                     
                          BttnGoClick()    ;  
                          return false;
                       }           
                       
                  }
                  
function gomfsmart()
{ var txtFund=document.getElementById("MarketChunk1_Topsmartquotes1_Mfsamrtquote1_ddlAMC");
var txtFunds=txtFund.value;
var txtCategory=document.getElementById("ddlCategory");
var txtCategorys=txtCategory.value;
var txtScheme=document.getElementById("ddlScheme");
var txtSchemes=txtScheme.value;
if(txtFunds==""&&txtCategorys=="")
{alert("Please Select Fund or Category");
txtFund.focus();return false;}if(txtSchemes==""){alert("Please Select Scheme");txtScheme.focus();return false;}var str="../MutualFund/SnapShot.aspx?id=10&Fund="+txtFunds+"&Category="+txtCategorys+"&SchemeCode="+txtSchemes;window.top.location=str;}
function gainloseupdown(udtab)
  {	
  	var tabcnt;
  	for (tabcnt=1; tabcnt<3; tabcnt++)
  	{
  		if(udtab==tabcnt)
  		{
  			if(document.getElementById("jnew"+tabcnt).className=='plus')
  			{
  		    	document.getElementById("jgainloseNew_"+tabcnt).className='OrangeHeadText';
  			
  				document.getElementById("jnew"+tabcnt).className='minus';	
  				document.getElementById("jmaintg_"+tabcnt).className='PT5';
  				$("#jmaintg_"+tabcnt).slideUp(1);
  				$("#jmaintg_"+tabcnt).slideDown(700);
                
  		    }
  		    else
  		    {
  			    $("#jmaintg_"+tabcnt).slideUp(700);
  			    document.getElementById("jgainloseNew_"+tabcnt).className='OrangeHeadText';
  			    document.getElementById("jnew"+tabcnt).className = 'plus';
        
  		    }
  	    }
  	    else
  		{
  			$("#jmaintg_"+tabcnt).slideUp(700);
  			//document.getElementById("Jamir_"+tabcnt).className='NewsTime';
  			document.getElementById("jnew"+tabcnt).className = 'plus';
    
  		}
  	    }
  }
  
  function marketglchunk(opt,opt1,option,exch)
  { document.getElementById(opt+"1"+1).innerHTML="<img src='../App_Themes/images/SelTabLef.gif' alt='' />";
     document.getElementById(opt+"1"+2).className="BlackS";
     document.getElementById(opt+"1"+2).style.backgroundImage="url('../App_Themes/images/SelTabBk.gif')"
     document.getElementById(opt+"1"+3).innerHTML="<img src='../App_Themes/images/SelTabRig.gif' alt='' />";
     document.getElementById(opt+"1"+2).style.cursor="text";
     document.getElementById(opt1+"1"+1).innerHTML="";
     document.getElementById(opt1+"1"+2).className="BlackBoldS";
     document.getElementById(opt1+"1"+2).style.backgroundImage="";
     document.getElementById(opt1+"1"+3).innerHTML="";
     document.getElementById(opt1+"1"+2).style.cursor="pointer";
    
    var requestUrl="../LiveHome/MktSummaryAjaxDataGLVV.aspx?Option="+option+"&Exchange="+exch+"&timeStamp="+new Date().getTime();
    var td_Id;
    if(option=='GAIN'){ td_Id="tdgainers";}
    else if(option=='LOSE'){ td_Id="tdlosers";}  
    ajaxpage(1,requestUrl,td_Id);	
  
 
 }
 
  function globalIndicesupdwn(udtab)
  {	
  	var tabcnt;
  	for (tabcnt=1; tabcnt<5; tabcnt++)
  	{
  		if(udtab==tabcnt)
  		{
  			if(document.getElementById("globalIndices_"+tabcnt).className=='plus')
  			{
  		    	document.getElementById("globalIndicesNew_"+tabcnt).className='OrangeHeadText';
  			
  				document.getElementById("globalIndices_"+tabcnt).className='minus';	
  				document.getElementById("flobalindia_"+tabcnt).className='PT5';
  				$("#flobalindia_"+tabcnt).slideUp(1);
  				$("#flobalindia_"+tabcnt).slideDown(500);
                
  		    }
  		    else
  		    {
  			    $("#flobalindia_"+tabcnt).slideUp(500);
  			    document.getElementById("globalIndicesNew_"+tabcnt).className='OrangeHeadText';
  			    document.getElementById("globalIndices_"+tabcnt).className = 'plus';
        
  		    }
  	    }
  	    else
  		{
  			$("#flobalindia_"+tabcnt).slideUp(500);
  			//document.getElementById("Jamir_"+tabcnt).className='NewsTime';
  			document.getElementById("globalIndices_"+tabcnt).className = 'plus';
    
  		}
  	    }
  }
  function globalIndices(Opt,Exch)
{ 
     var currentDivObj = document.getElementById("tdus");
    var More = document.getElementById("More") ;

      var td_Id;
 if(Exch =='America')
	{
		 td_Id = "tdus";
	}
	else if(Exch =='Asian')
	{
	    td_Id = "tdasia";
	}
		
	else if(Exch =='Europian')
	{
		 td_Id = "tdeurope";
	}
	else if(Exch =='African')
	{
	     td_Id ="tdafricaa";
	}
		var requestUrl = "../LiveHome/AjaxhomeData.aspx?id="+Opt+"&Contiment="+ Exch + "&timeStamp="+new Date().getTime();
	ajaxpage(1,requestUrl,td_Id);
}	
	
	
	  var XmlHttptick=null;

   function CreateXmlHttptick()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttptick = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttptick = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttptick = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttptick && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttptick = new XMLHttpRequest();
		}
	}
      function commTicker(SecId,SubSecId)
    {
       	CreateXmlHttptick();
		document.body.style.cursor = "progress";
		
	  var requestUrl = "../common/CommodityTickAjax.aspx?timeStamp="+ new Date().getTime()+"&Opt="+SecId.substring(0, SecId.length-2)+"&Exchg="+SubSecId; 
//		alert(requestUrl)
		if(XmlHttptick)	{
				XmlHttptick.onreadystatechange = function(){getcommTickerResponse()};
				XmlHttptick.open("GET", requestUrl,  true);
				XmlHttptick.send(null);
			}
    }
    
    function getcommTickerResponse()
{

	if(XmlHttptick.readyState == 4)
	{
		var	Td_HotS = document.getElementById("Td_commtick");
		
		if(XmlHttptick.status == 200)//
		{
		   var datacomm=XmlHttptick.responseText
		  //  alert(data)
	    	populatetick(datacomm);
				//alert(data)
			document.body.style.cursor = "auto";		
		}
		else
		{
			Td_HotS.innerHTML='<span class=NoData>Server is busy. Try later.</span>';
			
			document.body.style.cursor = "auto";
		}
	}
}
function PricecommUpdate(opt,opt1)
  {
//  var TDData=document.getElementById("TdPrice");
  var Exg=document.getElementById("drpmxnx").value;

     document.getElementById(opt+1).innerHTML="<img src='../App_Themes/images/SelTabLef.gif' alt='' />";
     document.getElementById(opt+2).className="BlackS";
     document.getElementById(opt+2).style.backgroundImage="url('../App_Themes/images/SelTabBk.gif')"
     document.getElementById(opt+3).innerHTML="<img src='../App_Themes/images/SelTabRig.gif' alt='' />";
     document.getElementById(opt+2).style.cursor="text";

     document.getElementById(opt1+1).innerHTML="";
     document.getElementById(opt1+2).className="BlackBoldS";
     document.getElementById(opt1+2).style.backgroundImage="";
     document.getElementById(opt1+3).innerHTML="";
     document.getElementById(opt1+2).style.cursor="pointer";

   commTicker(opt,Exg)
 }

/*   
Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)   
For full source code, 100's more DHTML scripts, and TOS, visit http://www.dynamicdrive.com   
Modified by jscheuer1 for continuous content. Credit MUST stay intact for use   
*/   
    
//Specify the marquee's width (in pixels)   
var marqueewidthc="298px"  
//Specify the marquee's height   
var marqueeheightc="149px"  
//Specify the marquee's marquee speed (larger is faster 1-10)   
var marqueespeed=1  
//Specify initial pause before scrolling in milliseconds   
var initPause=10  
//Specify start with Full(1)or Empty(0) Marquee   
var full=1  
//Pause marquee onMousever (0=no. 1=yes)?   
var pauseit=1  
//Specify Break characters for IE as the two iterations   
//of the marquee, if text, will be too close together in IE   
var iebreak='<p></p>'  
    
//Specify the marquee's content   
//Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):   
    
    
    
////NO NEED TO EDIT BELOW THIS LINE////////////   
var copyspeed=marqueespeed  
var pausespeed=(pauseit==0)? copyspeed: 0   
var iedom=document.all||document.getElementById   
var actualheight=''  
var cross_commmarquee, cross_commmarquee2, ns_commmarquee   
    
function populatetick(marqueecommcontent){ marqueespeed=1  ;
if (iedom){   
var jlb=document.getElementById&&!document.all? '' : iebreak   
cross_commmarquee=document.getElementById? document.getElementById("acc") : document.all.iemarquee   
cross_commmarquee2=document.getElementById? document.getElementById("acc2") : document.all.iemarquee2   
cross_commmarquee.style.top=(full==1)? '8px' : parseInt(marqueeheight)+8+"px"   
cross_commmarquee2.innerHTML=cross_commmarquee.innerHTML=marqueecommcontent+jlb   
actualheight=cross_commmarquee.offsetHeight   
cross_commmarquee2.style.top=(parseInt(cross_commmarquee.style.top)+actualheight+8)+"px" //indicates following #1   

}   
else if (document.layers){   
ns_commmarquee=document.ns_commmarquee.document.ns_commmarquee2   
ns_commmarquee.top=parseInt(marqueeheight)+8   
ns_commmarquee.document.write(marqueecontent)   
ns_commmarquee.document.close()   
actualheight=ns_commmarquee.document.height   
}   
setTimeout('lefttime=setInterval("scrollcommmarquee()",100)',initPause)   
}   
