﻿// JScript File

/* News Tab */

var XmlHttp;

//Creating object of XMLHTTP For AJAX Method
function CreateXmlHttpNews()
{
    //Creating object of XMLHTTP in IE
	try
	{
	    XmlHttp_News = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttp_News = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp_News = null;	
		}
	}
	
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp_News && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp_News = new XMLHttpRequest();
	}
}


function getNews(opt,secid,subsecid)
{

    CreateXmlHttpNews();
    
    var MktCom=document.getElementById("NewsTab1_NewsTd");
    
    var requestUrl="GetNewsTab.aspx?secid="+secid+"&subsecid="+subsecid+"&opt="+opt+"&timeStamp="+new Date().getTime();
   
	if(XmlHttp_News)
	{
		XmlHttp_News.onreadystatechange=function(){getNewsData(MktCom,opt);};
		XmlHttp_News.open("GET",requestUrl,true);
		XmlHttp_News.send(null);
	}
}

function getNewsData(id,opt)
{
    if(XmlHttp_News.readyState==4)
	{
	    if(XmlHttp_News.status == 200)
		{
	    id.innerHTML = XmlHttp_News.responseText;
//alert( id.innerHTML);
		    if(opt !=null)
            {
                for(var i=1;i<=5;i++)
                {
                    if(i==opt)
                    {
                        document.getElementById("L"+opt).className = "selectedTabLeft";
                        document.getElementById("M"+opt).className = "selectedTabBack";
                        document.getElementById("R"+opt).className = "selectedTabRight";
                    }
                    else
                    
                    {
                        document.getElementById("L"+i).className = "UnSelectedTabLeft";
                        document.getElementById("M"+i).className = "UnSelectedTabBack";
                        document.getElementById("R"+i).className = "UnSelectedTabRight";
                    }
                }
            }
           // id.innerHTML = "<marquee id='maqid' onmouseover='this.stop();' onmouseout='this.start();' trueSpeed scrollAmount='1' scrollDelay='50' direction='left' loop='repeat' width='100%'>" + id.innerHTML + "</marquee>";
		}
	}
}


//function sensexvalue(val)
//{

//    if(val=='BSE')
//    {
// 
//        var BSE = document.getElementById("BSE");
//		var NSE = document.getElementById("NSE");
//		BSE.className = "TopBSEL";
//		NSE.className = "TopGLUnSN";
//        document.getElementById("ChartBseTr").style.display="inline";
//        document.getElementById("ChartNseTr").style.display="none";
//       // document.getElementById('Sensex').style.display="inline";
//      //  document.getElementById('Nifty').style.display="none";
//     
//    }
//    else
//    {
//        var BSE = document.getElementById("BSE");
//		var NSE = document.getElementById("NSE");
//        BSE.className = "TopGLUnSN";
//		NSE.className = "TopNSEL";
//       document.getElementById("ChartBseTr").style.display="none";
//        document.getElementById("ChartNseTr").style.display="inline";
//        //document.getElementById('Sensex').style.display="none";
//      //  document.getElementById('Nifty').style.display="inline";
//     
//        return true;
//    }
//    
//    return true;
//    
//}

var globalexchng;
function Homesensexvalue(Exchg,Size)
{  
    globalexchng=Exchg;
    var BSE = document.getElementById("HomeBSE");
    var NSE = document.getElementById("HomeNSE");
   
    if(Exchg=='BSE')
    {
		BSE.className = "TopBSEL";
		NSE.className = "TopGLUnSN";
		BSEDate.style.display="inline";
		NSEDate.style.display="none";
    }
    else
     {
        BSE.className = "TopGLUnSN";
        NSE.className = "TopBSEL";
        BSEDate.style.display="none";
		NSEDate.style.display="inline";
     }
    var RequestUrl = "BSENSEchartAjax.aspx?Exchg="+Exchg; 
    var so = new SWFObject("amline/amline.swf", "BSENSEline", "240", "135", "8", "#FFFFFF");
    if(Size=='L')
    {
        so = new SWFObject("amline/amline.swf", "BSENSEline", "440", "235", "8", "#FFFFFF");
    }
    so.addVariable("path", "amline/"); 
    so.addVariable("settings_file", encodeURIComponent("BSENSEline_settingsToday.xml"));
    so.addVariable("data_file", encodeURIComponent(RequestUrl + "&TimeStamp="+new Date().getTime()));
    so.addParam("wmode","opaque");
    so.write("HomeCompanyChart"); 
    return false;
}
// function showbigchart()
//{

//window.open("PopupchartBSE.aspx?Exchg="+globalexchng+"",'BSEChart','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=600,height=420,=screenX=0,screenY=0,left=210,top=200');
//}
// function Homedisbsense(exchg)
//{  
//    var RequestUrl = "BSENSEchartAjax.aspx?Exchg="+exchg; 
//    var so = new SWFObject("amline/amline.swf", "BSENSEline", "280", "110", "8", "#FFFFFF");
//    so.addVariable("path", "amline/"); 
//    so.addVariable("settings_file", encodeURIComponent("BSENSEline_settingsToday.xml"));
//    so.addVariable("data_file", encodeURIComponent(RequestUrl + "&TimeStamp="+new Date().getTime()));
//    so.addParam("wmode","opaque");
//    so.write("HomeChartBSENSE"); 
//    return false;
//}

//function chart_onclick(idval)
//{

//if(idval=="BSE")
//{

//window.open("PopupchartBSE.aspx",'BSEChart','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=600,height=420,=screenX=0,screenY=0,left=210,top=200');
//}

//else if(idval=="NSE")
//{

//window.open("PopupchartNSE.aspx",'NSEChart','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=600,height=420,screenX=0,screenY=0,left=210,top=200');

//}

//}

var XmlHttpChange;
function CreateXmlHttpChange()
	{
		try
		{
			XmlHttpChange = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpChange = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpChange = null;
					
			}
		}
		if(!XmlHttpChange && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpChange = new XMLHttpRequest();
		}
	}


function ChangeControl(Opt,Exch)
{
    CreateXmlHttpChange();
       
    var currentDivObj = document.getElementById("Td_Data");

//alert(Opt);

    if(Exch=='')
    {
        if (Opt=="GAIN")
	    {
	        document.getElementById("tdGain").className="TopBSEL";
	        document.getElementById("tdLose").className="TopGLUnSN";
	        document.getElementById("GL").value = "GAIN";
	         if(Exch=="BSE")
	        {
	            document.getElementById("BSETab").className="PinkTxtG";
	            document.getElementById("NSETab").className="GrayTxtG";
		        document.getElementById("Exchange").value = "BSE"
//		        alert(document.getElementById("BSETab"));
//		        alert(document.getElementById("NSETab").className);
	        }
	        else
	        {
        	    document.getElementById("BSETab").className="GrayTxtG";
	            document.getElementById("NSETab").className="PinkTxtG";
		        document.getElementById("Exchange").value = "NSE"
//		        alert(document.getElementById("BSETab"));
//		        alert(document.getElementById("NSETab"));
		        //alert("NSETab");
	        }
	    }
	    else
	    {
	     document.getElementById("tdGain").className="TopGLUnSN";
	        document.getElementById("tdLose").className="TopBSEL";
	        document.getElementById("GL").value = "LOSE";
	         if(Exch=="BSE")
	        {
	            document.getElementById("BSETab").className="PinkTxtG";
	            document.getElementById("NSETab").className="GrayTxtG";
		        document.getElementById("Exchange").value = "BSE"
//		        alert(document.getElementById("BSETab"));
//		        alert(document.getElementById("NSETab").className);
	        }
	        else
	        {
        	    document.getElementById("BSETab").className="GrayTxtG";
	            document.getElementById("NSETab").className="PinkTxtG";
		        document.getElementById("Exchange").value = "NSE"
//		        alert(document.getElementById("BSETab"));
//		        alert(document.getElementById("NSETab"));
		        //alert("NSETab");
	        }
	    }
	}
	 else
        {
	        
	        if(Exch=="BSE")
	        {
	            document.getElementById("BSETab").className="PinkTxtG";
	            document.getElementById("NSETab").className="GrayTxtG";
		        document.getElementById("Exchange").value = "BSE"
//		        alert(document.getElementById("BSETab"));
//		        alert(document.getElementById("NSETab").className);
	        }
	        else
	        {
        	    document.getElementById("BSETab").className="GrayTxtG";
	            document.getElementById("NSETab").className="PinkTxtG";
        	    document.getElementById("tdGain").className="TopBSEL";
		        document.getElementById("Exchange").value = "NSE"
//		        alert(document.getElementById("BSETab"));
//		        alert(document.getElementById("NSETab"));
		        //alert("NSETab");
	        }
        	
        }
		//currentDivObj.innerHTML ="<img src=App_Themes/CommonTheme/Images/ajax-loader.gif>";
	document.body.style.cursor = "progress";
	
	
	var requestUrl = "AjaxDataGL.aspx?Option="+ document.getElementById("GL").value +"&Exchange="+ document.getElementById("Exchange").value;
    //alert(requestUrl) 
	if(XmlHttpChange!=null)	
	        {
				XmlHttpChange.onreadystatechange = function(){ChangeControlResponse(Opt,Exch)}
				XmlHttpChange.open('GET', requestUrl,  true);
				XmlHttpChange.send(null);
			}
			 return false; 
}	
	
function ChangeControlResponse(Opt,Exch)
{
	if(XmlHttpChange.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		var td_Id = document.getElementById("Td_Data");
	    //alert(XmlHttp.status)
		if(XmlHttpChange.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpChange.responseText;
				
			document.body.style.cursor = "auto";		
		}
		else
		{
			td_Id.innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}


/* Indices */
var XmlHttpGLE;
function CreateXmlHttpGLE()
	{
		try
		{
			XmlHttpGLE = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpGLE = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpGLE = null;
					
			}
		}
		if(!XmlHttpGLE && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpGLE = new XMLHttpRequest();
		}
	}



function GetInternationalData()
{
	CreateXmlHttpGLE();
       var currentDivObj = document.getElementById("tdInterIndices");
       
        
		currentDivObj.innerHTML ="<img src=../App_Themes/Common/images/loading.gif>";
	document.body.style.cursor = "progress";
	
	
	var requestUrl = "AjaxInternationalIndices.aspx?timeStamp="+new Date().getTime();
   //alert(requestUrl) 
	if(XmlHttpGLE!=null)	
	        {
				XmlHttpGLE.onreadystatechange = function(){ChangeResponseInternational()}
				XmlHttpGLE.open('GET', requestUrl,  true);
				XmlHttpGLE.send(null);
			}
			 return false; 
}	
	
function ChangeResponseInternational()
{
 
	// To make sure receiving response data from server is completed
	
	if(XmlHttpGLE.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		var td_Id = document.getElementById("tdInterIndices");
	   // alert(XmlHttpGLE.status)
		if(XmlHttpGLE.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpGLE.responseText;
				
			document.body.style.cursor = "auto";		
		}
		else
		{
			td_Id.innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}

var XmlHttpBull;
    
    function CreateXmlHttpBull()
	{
		try
		{
			XmlHttpBull = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpBull = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpBull = null;
					
			}
		}
		if(!XmlHttpBull && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpBull = new XMLHttpRequest();
		}
	}


function GetBullion()
{
	CreateXmlHttpBull();
	
      var currentDivObj = document.getElementById("TD_Bullion");
        
currentDivObj.innerHTML ="<img src=App_Themes/Common/images/ajax-loader.gif>";
	document.body.style.cursor = "progress";
	
	var requestUrl = "AjaxBullion.aspx?time="+ Math.random();
	
	 // alert(requestUrl) 
	if(XmlHttpBull!=null)	
	        {
				XmlHttpBull.onreadystatechange = function(){ChangeResponseBull()}
				XmlHttpBull.open('GET', requestUrl,  true);
				XmlHttpBull.send(null);
			}
			 return false; 
}	
	
function ChangeResponseBull(Exch)
{
   
	if(XmlHttpBull.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		
		    var td_Id = document.getElementById("TD_Bullion");
		
	    //alert(XmlHttp.status)
		if(XmlHttpBull.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpBull.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 SearchCompany()
{
                                              	
var SearchTxt = document.getElementById("<%=txtCompany.ClientID%>").value;
 
    var Id = document.getElementById("ddlQuote").value;	
	
    if(SearchTxt =="" || SearchTxt=="Enter Company Name")
    {
        alert("Please enter company name ..!!!");
        return false;
    }
	
    else
    {
		
        var StrUrl = "CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id="+Id;
   
         document.location=StrUrl;
         return false   ;
     
    }
}
		
		
 function Searchempty()
{

    if (document.getElementById("SearchCompanyInfo1_txtCompany").value=="Enter Company Name")
    {
        document.getElementById("SearchCompanyInfo1_txtCompany").value="";
    }
}

function Searchfill()
{
    var getquote=document.getElementById("SearchCompanyInfo1_txtCompany").value;
    if (getquote=="")
    {
        document.getElementById("SearchCompanyInfo1_txtCompany").value="Enter Company Name";
    }
}	

function QuoteEnterScript(e,id)
{
    if(e.keyCode==13)	
    {
        var Scripid = document.getElementById(id);
        Scripid.click();
    }
}	


var XmlHttp

function CreateXmlHttp()
{
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttp = null;				
		}
	}
	if(!XmlHttp && typeof XMLHttpRequest != "undefined")
	{
		XmlHttp = new XMLHttpRequest();
	}
}


function getTickerData(Exchg)
	{	
	//alert(Exchg);	
		CreateXmlHttp();
		document.body.style.cursor = "progress";
		document.getElementById("MarqueeId").innerHTML = " <img src='App_Themes/CommonTheme/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 = "AjaxTickerData.aspx?Exchange="+ Exchg +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		
		if(XmlHttp){
			XmlHttp.onreadystatechange = function(){getDataResponse(Exchg);};
			XmlHttp.open("GET", requestUrl,  true);
			XmlHttp.send(null);
		}
}
function getDataResponse(Exchg)
{
//alert(XmlHttp.status);	
	if(XmlHttp.readyState == 4)
	{	
	
		if(XmlHttp.status == 200)
		{	
				
		    
			var arrCol,Time,Code,CompName,ClPrice,DiffVal,DiffImg;
			var ExchgDet="",stkDet="";
			var MarqueeId = document.getElementById("MarqueeId");
			var TickerData = XmlHttp.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='BlackNormal'>" + arrCol[0] +" &nbsp; "+ CompName +": "+"<span  class=BlackNormal>" + ClPrice+"&nbsp;"+ clss +" ["  +"<b>"+ DiffVal+ "</b>"+"]</span> </span>&nbsp;&nbsp;&nbsp;";else stkDet += "<span class='TickerLink'>" + "<a target='_blank' href='http://www.16anna.com/companyinfo.asp?id=1&Fincode="+arrCol[0]+"' target='_parent'><span  class=BlackNormal>" + CompName +"</span></a>: " + "<span  class=BlackNormal>" + 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);
	}
	


function ChangeSpeed(Option)
	{
	
	 var Marq = document.getElementById("maqid");
	 

	 if(Option=="+")
	 {
	 if(Marq.scrollDelay == "10")
	 return;
	 else
	 Marq.scrollDelay = eval(Marq.scrollDelay)-10;
	 }
	 
	 else
	 {
	 if(Marq.scrollDelay == "90")
	 return;
	 else
	 Marq.scrollDelay = eval(Marq.scrollDelay)+10;
	 
	 }
	 
	 if(Marq.scrollDelay == "10")
	 {
	 document.getElementById("ImgUp").style.cursor = "text";
	 //document.getElementById("ImgUp").src = "App_Themes/CommonTheme/images/plus_disable.gif";
	 }
	 else
	 {
	 document.getElementById("ImgUp").style.cursor = "hand";
	 //document.getElementById("ImgUp").src = "App_Themes/CommonTheme/images/plus_act.gif";
	 }
	 
	 if(Marq.scrollDelay == "90")
	 {
	 document.getElementById("ImgDown").style.cursor = "text";
	 //document.getElementById("ImgDown").src = "App_Themes/CommonTheme/images/minus_disable.gif";
	 }
	 else
	 {
	 document.getElementById("ImgDown").style.cursor = "hand";
	 //document.getElementById("ImgDown").src = "App_Themes/CommonTheme/images/minus_act.gif";
	 }
	 
	 
	}
	
  function Redirect(sec,subsec,newid)
{

window.open("AllNewsDetails.aspx?Newsid="+newid+"&id=21",'16ANNA','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=600,height=400,screenX=0,screenY=0,left=210,top=200,menubar=no');

}