﻿// JScript File

//Global Variables
var XmlHttp;
var XmlHttp2;
var XmlHttp3;
var XmlHttpTOP;
var XmlHttpNews;

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();
		}
	}	
	


/* MFHome */

var XmlHttpMFNews;

function CreateXmlHttpMFNews()
{
    //Creating object of XMLHTTP in IE
	try
	{
		XmlHttpMFNews= new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttpMFNews = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpMFNews = null;	
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttpMFNews && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpMFNews = new XMLHttpRequest();
	}
}

function GetNewsMutual(SecID,SubSec)
{	
    CreateXmlHttpMFNews();
	document.body.style.cursor = "progress";
	document.getElementById("NewTdMF").innerHTML = "<table align=center><tr><td ><img src =../App_Themes/HomeCommon/Homeimages/loader.gif /></td></tr></table>";
	var requestUrl = "../MutualFund/AjaxMFNews.aspx?Sec="+ SecID +"&SubSec="+SubSec+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
	
	if(XmlHttpMFNews)
	{
	    XmlHttpMFNews.onreadystatechange = function(){getDataResponseMutual();};
		XmlHttpMFNews.open("GET", requestUrl,  true);
		XmlHttpMFNews.send(null);
	}
}

function getDataResponseMutual()
{
    if(XmlHttpMFNews.readyState == 4)
	{	
	    if(XmlHttpMFNews.status == 200)
		{				
		    var NewTd = document.getElementById("NewTdMF");
			var NewData = XmlHttpMFNews.responseText;
						
			if(NewData != "")
				NewTd.innerHTML = NewData;				
			document.body.style.cursor = "auto";
		}
	}
}

var XmlHttpMFPop;

function CreateXmlHttpMFPop()
{
    //Creating object of XMLHTTP in IE
	try
	{
		XmlHttpMFPop= new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttpMFPop = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpMFPop = null;	
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttpMFPop && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpMFPop = new XMLHttpRequest();
	}
}
	
function GetNewsDetailEq(secId,SubSecId,NewsID,opt)
{
    var NewsWin = document.getElementById("divNews").style.display='inline';
	var currentDivObj;	
		
	currentDivObj = document.getElementById("TdNews");
	currentDivObj.innerHTML ="<img src=../App_Themes/HomeCommon/Homeimages/loader.gif>"; 
	CreateXmlHttpMFPop();
	document.body.style.cursor = "progress";
	var requestUrl = "PopupNewsData.aspx?SecId="+ secId +"&SubSecId="+ SubSecId+"&NewsID="+NewsID+"&timeStamp="+new Date().getTime()+"opt="+opt;
	
	if(XmlHttpMFPop)	
	{
	    XmlHttpMFPop.onreadystatechange = function(){getDetailsRespMF();};
		XmlHttpMFPop.open("GET", requestUrl,  true);
		XmlHttpMFPop.send(null);					
	}
}
	
function getDetailsRespMF()
{
    // To make sure receiving response data from server is completed
	if(XmlHttpMFPop.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpMFPop.status == 200)
		{				
		    document.getElementById("TdNews").innerHTML = XmlHttpMFPop.responseText;
			document.body.style.cursor = "auto";
		}
		else
		{
		    document.getElementById("NewsId").innerHTML = "<img src=../loading.gif>";
		}
	}
}

/* Category Return Ctrl */

function CategoryCtrl(Type)
{
	var Type;
    
	var EquityId = document.getElementById("Categoryretctrl2_EquityId");
	var DebtId  =  document.getElementById("CategoryRetCtrl2_DebtId");
	var BalancedId  =  document.getElementById("CategoryRetCtrl2_BalancedId");
	document.getElementById("hdType").value =Type;
		
		if (Type=="EQUITY")
		{
				document.getElementById("tdEquity").src="../App_Themes/Common/images/EquityOn.gif";
				document.getElementById("tdDebt").src="../App_Themes/Common/images/DebtOff.gif";
				document.getElementById("tdHyb").src="../App_Themes/Common/images/HybridOff.gif";
				
				loadCatRet(Type,'1YEARRET');
				
					
		}
		else if (Type=="Debt")
		{
				document.getElementById("tdEquity").src="../App_Themes/Common/images/EquityOff.gif";
				document.getElementById("tdDebt").src="../App_Themes/Common/images/DebtOn.gif";
				document.getElementById("tdHyb").src="../App_Themes/Common/images/HybridOff.gif";
				loadCatRet(Type,'1YEARRET');
				
		}
		
		else if (Type=="Hybrid")
		{
				document.getElementById("tdEquity").src="../App_Themes/Common/images/EquityOff.gif";
				document.getElementById("tdDebt").src="../App_Themes/Common/images/DebtOff.gif";
				document.getElementById("tdHyb").src="../App_Themes/Common/images/HybridOn.gif";
				loadCatRet(Type,'1YEARRET');
				
				
					
		}
	
		
}

	
function CategoryCtrl(Type)
{
	var Type;
	document.getElementById("hdType").value =Type;
	loadCatRet(Type,'1YEARRET');		
}

function loadCatRet(Type,option)
	{		
		CreateXmlHttp1();
		document.body.style.cursor = "progress";
		
		var requestUrl = "AjaxCategoryData.aspx?Type="+Type+"&option="+option;
		if(XmlHttp1)	
			{
					
					XmlHttp1.onreadystatechange = function(){CatRetResponse(Type,option);}; 
					XmlHttp1.open("GET", requestUrl,  true);
					XmlHttp1.send(null);
			}
	}	
	
	//Called when response comes back from server Only For Category Return
function CatRetResponse(Type,option)
{//alert(option);
	// To make sure receiving response data from server is completed
	if(XmlHttp1.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp1.status == 200)
		{	
//		     if(document.getElementById("EquityId")==null)
//		    {
//		       CategoryCtrl(Type);
//		    }	

             if(document.getElementById("EquityId")==null)
		    {
		    
		       CategoryCtrl(Type);
		    }		
	if(option=='1WEEKRET')
		{
		    document.getElementById("1W").className ="ComHomeSelTab";
		    document.getElementById("1M").className ="ComHomeUnSelTab"; 
		    document.getElementById("3M").className ="ComHomeUnSelTab";
		    document.getElementById("1Y").className ="ComHomeUnSelTab"; 
		    document.getElementById("3Y").className ="ComHomeUnSelTab";
		}
		if(option=='1MONTHRET')
		{
		    document.getElementById("1W").className ="ComHomeUnSelTab";
		    document.getElementById("1M").className ="ComHomeSelTab"; 
		    document.getElementById("3M").className ="ComHomeUnSelTab";
		    document.getElementById("1Y").className ="ComHomeUnSelTab"; 
		    document.getElementById("3Y").className ="ComHomeUnSelTab";
		}
		if(option=='3MONTHRET')
		{
		    document.getElementById("1W").className ="ComHomeUnSelTab";
		    document.getElementById("1M").className ="ComHomeUnSelTab"; 
		    document.getElementById("3M").className ="ComHomeSelTab";
		    document.getElementById("1Y").className ="ComHomeUnSelTab"; 
		    document.getElementById("3Y").className ="ComHomeUnSelTab";
		}
		if(option=='1YEARRET')
		{
		     document.getElementById("1W").className ="ComHomeUnSelTab";
		    document.getElementById("1M").className ="ComHomeUnSelTab"; 
		    document.getElementById("3M").className ="ComHomeUnSelTab";
		    document.getElementById("1Y").className ="ComHomeSelTab"; 
		    document.getElementById("3Y").className ="ComHomeUnSelTab";
		}
		if(option=='3YEARRET')
		{
		
		    document.getElementById("1W").className ="ComHomeUnSelTab";
		    document.getElementById("1M").className ="ComHomeUnSelTab"; 
		    document.getElementById("3M").className ="ComHomeUnSelTab";
		    document.getElementById("1Y").className ="ComHomeUnSelTab"; 
		    document.getElementById("3Y").className ="ComHomeSelTab";
		}







	
			var EquityId   = document.getElementById("EquityId");
			
			var strData = XmlHttp1.responseText;
			//alert(strData);
			if(strData != "")
			{
				
				EquityId.innerHTML   = strData;
				
			}
			document.body.style.cursor = "auto";	
		}
		else
		{
			EquityId.innerHTML = "There was a problem retrieving data from the server.";
			DebtId.innerHTML = "There was a problem retrieving data from the server.";
			BalancedId.innerHTML = "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}	
}

function loadPerformData(Period,Category,TopGl)
{
	CreateXmlHttp()
	document.body.style.cursor = "progress";
	var TopGl;
	if(Period=='')
		Period = "1YEAR";
	if(Category=='')	
		Category="ALL";
	
	var requestUrl = "AjaxFundData.aspx?Period="+ Period +"&Category="+ Category +"&TopGl="+ TopGl;
	

	
	if(XmlHttp)	{
				XmlHttp.onreadystatechange = function(){GLResponse(TopGl)}
				XmlHttp.open("GET", requestUrl,  true);
				XmlHttp.send(null);
			}
}	
	
	function GLResponse(TopGl)
{
            var FundPerformance = document.getElementById("FundPerformance");
			
	// 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)
		{	
			var strGlData = XmlHttp.responseText
			
				FundPerformance.innerHTML = strGlData;
			 
				
			document.body.style.cursor = "auto";		
		}
		else
		{
			
				FundPerformance.innerHTML = "There was a problem retrieving data from the server.";
			
			
			document.body.style.cursor = "auto";
		}
	}
}
	
/* NFO Updates */

function CreateXmlHttpNFO()
{
	try
	{
		XmlHttpNFO = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpNFO = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpNFO = null;				
		}
	}
	if(!XmlHttpNFO && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpNFO = new XMLHttpRequest();
	}
}

function LoadNFOUpdate(Option)
	{		
	
	
	var OLef=document.getElementById("OLef");
    var ORig=document.getElementById("ORig");
    var Omid=document.getElementById("Omid");
  
    var FLef=document.getElementById("FLef");
    var FRig=document.getElementById("FRig");
    var Fmid=document.getElementById("Fmid");

    
   if(Option == "ENFO")
    {
       Omid.style.background="url(../App_Themes/HomeCommon/Homeimages/ChTabBk.gif)";
       OLef.innerHTML="<img src=../App_Themes/HomeCommon/Homeimages/ChTabLef.gif align=absbottom />";
       ORig.innerHTML="<img src=../App_Themes/HomeCommon/Homeimages/ChTabRig.gif align=absbottom />";
       
      Fmid.style.background="";
      FRig.innerHTML="";
      FLef.innerHTML="";
      
     
    }
    
    if(Option == "FNFO")
    {
       Fmid.style.background="url(../App_Themes/HomeCommon/Homeimages/ChTabBk.gif)";
       FLef.innerHTML="<img src=../App_Themes/HomeCommon/Homeimages/ChTabLef.gif align=absbottom />";
       FRig.innerHTML="<img src=../App_Themes/HomeCommon/Homeimages/ChTabRig.gif align=absbottom />";
       
      Omid.style.background="";
      ORig.innerHTML="";
      OLef.innerHTML="";
      
     
    }
    
	
	
	
	
		CreateXmlHttpNFO();
		document.body.style.cursor = "progress";
		
		var requestUrl = "AjaxNFOUpdateData.aspx?&Option="+Option;
		
		if(XmlHttpNFO)	
			{
					
					XmlHttpNFO.onreadystatechange = function(){NFOUpdateResponse();}; 
					XmlHttpNFO.open("GET", requestUrl,  true);
					XmlHttpNFO.send(null);
			}
	}
	
	
	function NFOUpdateResponse()
{

	// To make sure receiving response data from server is completed
	if(XmlHttpNFO.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpNFO.status == 200)
		{	
		//alert("in respnse OK")	;	
			var NFOId   = document.getElementById("NFOId");
			
			var strData = XmlHttpNFO.responseText;
			//alert(strData);
			if(strData != "")
			{
			
				NFOId.innerHTML   = strData;
				

			}
			document.body.style.cursor = "auto";	
		}
		else
		{
			NFOId.innerHTML = "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
}



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;

 //setInterval("hide_popup1()",1000);
 
 var IE = document.all?true:false
 
 if (!IE) document.captureEvents(Event.MOUSEMOVE)
 document.onmousemove = getMouseXY;
 
 function getMouseXY(e) 
 {
 	if(IE)
 	{
 	     tempY = document.body.scrollTop+50;
 	}
 	else
 	{
 		 tempY = document.body.scrollTop+50;
 	}
 	return true;
 }
 
 
 var XmlHttpMFNews;

function CreateXmlHttpMFNFo()
{
    //Creating object of XMLHTTP in IE
	try
	{
		XmlHttpMFNFo= new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttpMFNFo = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpMFNFo = null;	
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttpMFNFo && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpMFNFo = new XMLHttpRequest();
	}
}

function GetNewsNFO(SecID,SubSec)
{	
    CreateXmlHttpMFNFo();
	document.body.style.cursor = "progress";
	document.getElementById("NewTdNFO").innerHTML = "<table align=center><tr><td ><img src =../App_Themes/HomeCommon/Homeimages/loader.gif /></td></tr></table>";
	var requestUrl = "../MutualFund/AjaxMFNewsNFO.aspx?Sec="+ SecID +"&SubSec="+SubSec+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
	
	if(XmlHttpMFNFo)
	{
	    XmlHttpMFNFo.onreadystatechange = function(){getDataResponseMutualNFO();};
		XmlHttpMFNFo.open("GET", requestUrl,  true);
		XmlHttpMFNFo.send(null);
	}
}

function getDataResponseMutualNFO()
{
    if(XmlHttpMFNFo.readyState == 4)
	{	
	    if(XmlHttpMFNFo.status == 200)
		{				
		    var NewTd = document.getElementById("NewTdNFO");
			var NewData = XmlHttpMFNFo.responseText;
						
			if(NewData != "")
				NewTd.innerHTML = NewData;				
			document.body.style.cursor = "auto";
		}
	}
}
