//Common
/*Table Comp Profile*/
var tempX = 0;
 var tempY = 0;
 var m_show = 0;
 var f_sc_id = "";
 var f_sc_dispid = "";
 var f_sc_comp = "";
 var f_topic_id = 0;
 var f_buy_id =0;
// smart quotes/buy/ sell/company snapshot/compan/ news/financial summary/chartin
 var m_urls = Array('../profiles/CorpInfo.aspx?&id=12','../profiles/CorpInfo.aspx?id=13','../profiles/CorpInfo.aspx?id=14','../profiles/CorpInfo.aspx?id=18','../profiles/CorpInfo.aspx?id=17','../profiles/CorpInfo.aspx?id=19','../profiles/CorpInfo.aspx?id=16');
 

 //setInterval("hide_popup1()",1000);
 
 var IE = document.all?true:false
 
 if (!IE) document.captureEvents(Event.MOUSEMOVE)
 document.onmousemove = getMouseXY;
 
 function getMouseXY(e) 
 {
 	if(IE)
 	{
 	    tempX = event.clientX + document.body.scrollLeft;
 		tempY = event.clientY + document.body.scrollTop;
 	}
 	else
 	{
 		tempX = e.pageX;
 	    tempY = e.pageY;
 	}
 	return true;
 }
 
function show_popup1(m_im_id, m_im_shortdesc, m_im_desc, m_ff_desc, m_ff_id, m_fundclass)
 {
 	f_im_id = m_im_id;
 	f_im_shortdesc = m_im_shortdesc;
 	f_im_desc = m_im_desc;
 	f_ff_desc = m_ff_desc;
 	f_ff_id = m_ff_id;
 	f_fundclass = m_fundclass;
 
 	//document.getElementById("head1").innerHTML = " Company Profile " ;
 	document.getElementById("popup").style.left = tempX + "px";
 	document.getElementById("popup").style.top = tempY + "px";
 	document.getElementById("popup").style.visibility = "visible";
 	m_show = 1;
 }
  function hide_popup1()
 {
 	if(m_show == 0)
 		document.getElementById("popup").style.visibility = "hidden";
 }
 
 function id_click(m_id)
 {
 //alert(m_id)
 //alert(m_urls[m_id-1] + "+" + f_im_id);
 	//return false;
 
 	if(m_id == 1)
 		window.location = m_urls[m_id-1]+"&code=" + f_im_id  ;
 	else if(m_id == 2)
 		window.location = m_urls[m_id-1] +"&code=" + f_im_id;
 	else if(m_id == 3)
 		window.location = m_urls[m_id-1] +"&code=" + f_im_id;
 	else if(m_id == 4)
 		window.location = m_urls[m_id-1] +"&code=" + f_im_id;
 	else if(m_id == 5)
 		window.location = m_urls[m_id-1] +"&code=" + f_im_id;
	else if(m_id == 6)
 		window.location = m_urls[m_id-1] +"&code=" + f_im_id;	
	else if(m_id == 7)
 		window.location = m_urls[m_id-1] +"&code=" + f_im_id;
	else
 		window.location = m_urls[m_id-1] + f_im_id; 	
 }
 /*End of Table Comp Profile*/
 
 //This is for bulletin
 function ShowA2Z(redUrl_,Index){
 
	var A2ZIndexId = document.getElementById("A2ZTd");
	if(A2ZIndexId.innerHTML==""){
		var A2Z="";A2ZClass ="";
			for(i=65; i<=90; i++)
				
				{
				var Alpha = String.fromCharCode(i);
				A2ZClass = (Index==Alpha) ? "IndexLinkSel" : "IndexLink";
				A2Z += "<a href='"+redUrl_+"&Index="+ Alpha +"' class="+ A2ZClass+ ">"+ Alpha +"</a>";
			}
			A2ZClass = (Index=="0-9") ? "IndexLinkSel" : "IndexLink";	
			A2ZIndexId.innerHTML = A2Z + "<a href='"+redUrl_+"&Index=0-9' class="+ A2ZClass +">0-9</a>";
	}
	else
		A2ZIndexId.innerHTML = "";			
}

//This is for 52 week high low
function A2ZIndex(Index,Group,id,Opt)
{
	var A2ZIndexId = document.getElementById("A2ZIndex");
	if(A2ZIndexId.innerHTML==""){
		var A2Z="",A2ZClass ="";
			for(i=65; i<=90; i++)
			{
				var Alpha = String.fromCharCode(i);
				A2ZClass = (Index==Alpha) ? "IndexLinkSel" : "IndexLink";
				A2Z += "<a href='marketstat.aspx?id="+id+"&Index="+ Alpha +"&Group="+Group+"&Opt="+Opt+"' class="+ A2ZClass +" >"+ Alpha +"</a>";
			}
			A2ZClass = (Index=="0-9") ? "IndexLinkSel" : "IndexLink";	
			A2ZIndexId.innerHTML = A2Z + "<a href='marketstat.aspx?id="+id+"&Index=0-9&Group="+Group+"&Opt="+Opt+"' class="+ A2ZClass +" >0-9</a>";
	}
	else
		A2ZIndexId.innerHTML = "";
				
}

function SearchQuote()
	{
		
		var SrchQuote = document.getElementById("txt_Symbol").value;
		var PageId = document.getElementById("DD_Options").value;	
		var StrUrl = "CompSearch.aspx?schtxt="+SrchQuote+"&id="+PageId;
		if(SrchQuote !="")
		{
			window.location = StrUrl;
		}
		else
		{
			alert("Please enter company name ..!!!");
			return false;
		}
				
   }
   
function Event(e,id)
{
{
		if(e.keyCode==13)	
		{
			//var Scripid = document.getElementById(id);
			var boolval = SearchQuote();
			if(boolval)
			return true;
			else
			return false;
		}
	}
}

function EnterScript1(e,id)
{
		if(e.keyCode==13)	
		{
			//var Scripid = document.getElementById(id);
			var boolval = CompValidate();
			if(boolval)
			return true;
			else
			return false;
		}
}

function Compempty()
{
	if (document.getElementById("txt_Quote2").value=="Change Company")
	{
		document.getElementById("txt_Quote2").value="";
	}
}

function Compfill()
{
	var getquote=document.getElementById("txt_Quote2").value;
	if (getquote=="")
	{
		document.getElementById("txt_Quote2").value="Change Company";
	}
}

function CompValidate()
{
	var SrchQuote = document.getElementById("txt_Quote2");

	var StrUrl = "../Profiles/CompSearch.aspx?id=12&schtxt="+SrchQuote.value;
		
	if((SrchQuote.value=="") ||(SrchQuote.value=="Change Company"))
	{
		alert("Please enter company name ..!!!");
	}
	else
	{
		window.location = StrUrl;
	}
}

//Home Page Popup - For Loading Data to market commentary from NewsData.aspx Using AJAX  
function GetNewsDetail(SrNo,secId,SubSecId,opt)
{
	var NewsWin = document.getElementById("cm_window").style.display='inline';
	var currentDivObj
	if(opt=="main")
	{
		currentDivObj = document.getElementById("NewsId");
		currentDivObj.innerHTML ="<img src=../images/loading1.gif>";
	}
	else if(opt=="in")
	{
		currentDivObj = document.getElementById("NewsId1");
		currentDivObj.innerHTML ="<img src=../images/loading1.gif>";
	}
	else
	{
		currentDivObj = document.getElementById("NewsId2");
		currentDivObj.innerHTML ="<img src=../images/loading1.gif>";
	}
		CreateXmlHttp();
	//	document.body.style.cursor = "progress";
		var requestUrl = "../HomeNewsData.aspx?secno="+ secId +"&SubSecno="+ SubSecId+"&SrNo="+ SrNo +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		if(XmlHttp)	
		{
			XmlHttp.onreadystatechange = function(){getDetails(opt);};
			XmlHttp.open("GET", requestUrl,  true);
			XmlHttp.send(null);					
		}
}
	
function getDetails(opt)
{
// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{
			if(opt=="main")
			document.getElementById("NewsId").innerHTML = XmlHttp.responseText;
			else if(opt=="in")
			document.getElementById("NewsId1").innerHTML = XmlHttp.responseText;
			else
			document.getElementById("NewsId2").innerHTML = XmlHttp.responseText;
			document.body.style.cursor = "auto";
			}
			else
			{
			if(opt=="main")
				document.getElementById("NewsId").innerHTML = "<img src='../images/loading1.gif'>";
			else if(opt=="in")
				document.getElementById("NewsId1").innerHTML = "<img src='../images/loading1.gif'>";
			else
				document.getElementById("NewsId2").innerHTML = "<img src='../images/loading1.gif'>";
			}
		}
	}
//End of Common

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 clockTimeoutID;
//Global Variables
var XmlHttp,XmlHttp1,XmlHttp2,XmlHttp3;
	
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 CreateXmlHttp1()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttp1 = new ActiveXObject("Msxml2.XmlHttp");
		}
		catch(e)
		{
			try
			{
				XmlHttp1 = new ActiveXObject("Microsoft.XmlHttp");
			} 
			catch(oc)
			{
				XmlHttp1 = null;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if(!XmlHttp1 && typeof XmlHttpRequest != "undefined") 
		{
			XmlHttp1 = new XmlHttpRequest();
		}
	}
	
function CreateXmlHttp2()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttp2 = new ActiveXObject("Msxml2.XmlHttp");
		}
		catch(e)
		{
			try
			{
				XmlHttp2 = new ActiveXObject("Microsoft.XmlHttp");
			} 
			catch(oc)
			{
				XmlHttp2 = null;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if(!XmlHttp2 && typeof XmlHttpRequest != "undefined") 
		{
			XmlHttp2 = new XmlHttpRequest();
		}
	}
	
function CreateXmlHttp3()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttp3 = new ActiveXObject("Msxml2.XmlHttp");
		}
		catch(e)
		{
			try
			{
				XmlHttp3 = new ActiveXObject("Microsoft.XmlHttp");
			} 
			catch(oc)
			{
				XmlHttp3 = null;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if(!XmlHttp3 && typeof XmlHttpRequest != "undefined") 
		{
			XmlHttp3 = new XmlHttpRequest();
		}
	}
	
//**** Function ExchngTimeClock Is used for to find out the market hours --- The ticker will automatically refresh only in market timings *****//			
function ExchngTimeClock(Exchg,PGType)
{
	var time = new Date()
	var hour = time.getHours()
	if (hour >= 10 && hour <= 20)
			clockTimeoutID = setTimeout("getTickerData('"+ Exchg +"','"+ PGType +"')",600000);
}	
//**** Function killClock Is used for killing clock timer  *****//
 function killClock(){
	clearTimeout(clockTimeoutID);
	}		


 
//For Market commentry
function getMarketNews(subsecid,sp)
	{
		CreateXmlHttp1();
		//document.body.style.cursor = "progress";
		
		if(sp!="")
		{
			for(var i=3;i<=5;i++)
			{
				document.getElementById("TD"+i).className ="marketSesion"; 
				document.getElementById("spn"+i).className = "linkTxt";
				document.getElementById("spn"+i).style.cursor="hand";
			}	
			document.getElementById("TD"+sp).className = "marketSesion";
			document.getElementById("spn"+sp).className = "linkTxtSelected";
			document.getElementById("spn"+sp).style.cursor="";
		}
		
		var MktCom = document.getElementById("MktCom");
		
		MktCom.innerHTML ="<img src=../images/loading1.gif>";
		var requestUrl = "../GetMktCommentary.aspx?subsecid="+ subsecid+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();		
    
		if(XmlHttp1)	
		{			
			XmlHttp1.onreadystatechange = function(){getNewsData(MktCom);};
			XmlHttp1.open("GET", requestUrl,  true);
			XmlHttp1.send(null);

		}
	}

	function getNewsData(id)
	{
	
		if(XmlHttp1.readyState == 4)
		{
		
			if(XmlHttp1.status == 200)
			{			
				id.innerHTML = XmlHttp1.responseText; 
			}
		}
	}
	
	
	
//For Loading News from NewsData.aspx Using AJAX
function GetNewsDet(secId,SrNo)
	{
		var currentDivObj = document.getElementById(SrNo);
		if(currentDivObj.style.display=='inline'){
				currentDivObj.style.display ='none';eval("document.IMG"+SrNo+".src = '../images/plus.gif'");}
			else
			{
				currentDivObj.style.display ='inline';
				eval("document.IMG"+SrNo+".src = '../images/maines.gif'");
				var tblObj=document.getElementById("NewsId").getElementsByTagName("td");
				var IdName;
				for(var i=1;i<tblObj.length;i++){
					IdName = tblObj[i].id;
					if(IdName)
						if(IdName!=SrNo){
							document.getElementById(IdName).style.display = "none";eval("document.IMG"+IdName+".src = '../images/plus.gif'");}}

				if(currentDivObj.innerHTML=="")
				{
					currentDivObj.innerHTML ="<img src=../images/loading1.gif>";
					CreateXmlHttp2();
					document.body.style.cursor = "progress";
					var requestUrl = "../Markets/NewsData.aspx?SecId="+ secId +"&SrNo="+ SrNo +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
					if(XmlHttp2)	{
								XmlHttp2.onreadystatechange = function(){getNewsDetResp(SrNo);};
								XmlHttp2.open("GET", requestUrl,  true);
								XmlHttp2.send(null);
							}
				}
			}	
	}


	
//Called when response comes back from server Only For NewsData
function getNewsDetResp(SrNo)
{
	// To make sure receiving response data from server is completed
	if(XmlHttp2.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp2.status == 200)
		{
			document.getElementById(SrNo).innerHTML = XmlHttp2.responseText;
			document.body.style.cursor = "auto";
		}
		else
			document.getElementById(SrNo).innerHTML = "<img src='../images/cm_loading.gif'>";
	}
}


//For Loading News from CompNewsData.aspx Using AJAX
function GetCompNewsDet(SrNo)
	{
		var currentDivObj = document.getElementById(SrNo);
		if(currentDivObj.style.display=='inline'){
				currentDivObj.style.display ='none';eval("document.IMG"+SrNo+".src = '../images/plus.gif'");}
			else
			{
				currentDivObj.style.display ='inline';
				eval("document.IMG"+SrNo+".src = '../images/maines.gif'");
				var tblObj=document.getElementById("CompNewsId").getElementsByTagName("td");
				var IdName;
				for(var i=1;i<tblObj.length;i++){
					IdName = tblObj[i].id;
					if(IdName)
						if(IdName!=SrNo){
							document.getElementById(IdName).style.display = "none";eval("document.IMG"+IdName+".src = '../images/plus.gif'");}}

				if(currentDivObj.innerHTML=="")
				{
					currentDivObj.innerHTML ="<img src=../images/loading1.gif>";
					CreateXmlHttp3();
					document.body.style.cursor = "progress";
					var requestUrl = "../Profiles/CompNewsData.aspx?SrNo="+ SrNo +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
					if(XmlHttp3)	{
								XmlHttp3.onreadystatechange = function(){getCompNewsDetResp(SrNo);};
								XmlHttp3.open("GET", requestUrl,  true);
								XmlHttp3.send(null);
							}
				}
			}	
	}

//Called when response comes back from server Only For Company NewsData
function getCompNewsDetResp(SrNo)
{
	// To make sure receiving response data from server is completed
	if(XmlHttp3.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp3.status == 200)
		{
			document.getElementById(SrNo).innerHTML = XmlHttp3.responseText;
			document.body.style.cursor = "auto";
		}
		else
			document.getElementById(SrNo).innerHTML = "<img src='../images/cm_loading.gif'>";
	}
}	
		
function openRequestedPopup()
{
WindowObjectReference = window.open("http://61.17.248.222/cilweb", "DescriptiveWindowName", "width=1010,height=700;left=0,top=0,fullscreen=true;minimizable=yes,resizable,scrollbars=yes,status=1");
}

function winpopup(strUrl)
{	
	 var strUrl;
	 var newWin=window.open(strUrl,'MyWindow1','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=1,copyhistory=no,width=600,height=450,screenX=0,screenY=0,left=200,top=180');	
	 newWin.focus();
}	
function TelCheck(evt) 
{
    if (evt.keyCode > 31 && (evt.keyCode < 43 || evt.keyCode > 57)) 
	{
        return false;
    }
}