﻿// JScript File

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;
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 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 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();
		}
	}	
	

//For top performers data
function loadPerformData(Period,Category,TopGl)
{
//alert("as");
	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";
		}
	}
}	

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").className = 'TopINSEL';		
		        document.getElementById("tdDebt").className = 'TopIGLUnSN';
		        document.getElementById("tdHyb").className = 'TopIGLUnSN';
//				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").className = 'TopIGLUnSN';		
		        document.getElementById("tdHyb").className = 'TopIGLUnSN';
		        document.getElementById("tdDebt").className = 'TopINSEL';
//				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").className = 'TopIGLUnSN';		
		        document.getElementById("tdHyb").className = 'TopINSEL';
		        document.getElementById("tdDebt").className = 'TopIGLUnSN';
//				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 loadCatRet(Type,option)
	{		
		
		if(option=='1WEEKRET')
		{
		    document.getElementById("1W").className ="OptionSelected";
		    document.getElementById("1M").className ="OptionUnSelected"; 
		    document.getElementById("3M").className ="OptionUnSelected";
		    document.getElementById("1Y").className ="OptionUnSelected"; 
		    document.getElementById("3Y").className ="OptionUnSelected";
		}
		if(option=='1MONTHRET')
		{
		       document.getElementById("1W").className ="OptionUnSelected";
		    document.getElementById("1M").className ="OptionSelected"; 
		    document.getElementById("3M").className ="OptionUnSelected";
		    document.getElementById("1Y").className ="OptionUnSelected"; 
		    document.getElementById("3Y").className ="OptionUnSelected";
		}
		if(option=='3MONTHRET')
		{
		      document.getElementById("1W").className ="OptionUnSelected";
		    document.getElementById("1M").className ="OptionUnSelected"; 
		    document.getElementById("3M").className ="OptionSelected";
		    document.getElementById("1Y").className ="OptionUnSelected"; 
		    document.getElementById("3Y").className ="OptionUnSelected";
		}
		if(option=='1YEARRET')
		{
		       document.getElementById("1W").className ="OptionUnSelected";
		    document.getElementById("1M").className ="OptionUnSelected"; 
		    document.getElementById("3M").className ="OptionUnSelected";
		    document.getElementById("1Y").className ="OptionSelected"; 
		    document.getElementById("3Y").className ="OptionUnSelected";
		}
		if(option=='3YEARRET')
		{
		
		      document.getElementById("1W").className ="OptionUnSelected";
		    document.getElementById("1M").className ="OptionUnSelected"; 
		    document.getElementById("3M").className ="OptionUnSelected";
		    document.getElementById("1Y").className ="OptionUnSelected"; 
		    document.getElementById("3Y").className ="OptionSelected";
		}
		CreateXmlHttp1();
		document.body.style.cursor = "progress";
		
		var requestUrl = "AjaxCategoryData.aspx?Type="+Type+"&option="+option;
		
		if(XmlHttp1)	
			{
					
					XmlHttp1.onreadystatechange = function(){CatRetResponse();}; 
					XmlHttp1.open("GET", requestUrl,  true);
					XmlHttp1.send(null);
			}
			
	}	
	
	//Called when response comes back from server Only For Category Return
function CatRetResponse()
{
	// 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)
		{			
			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 ItemMouseOver(currentRow)
    {
        oRow = document.getElementById(currentRow);

            oRow.originalBackgroundColor = oRow.style.backgroundColor
            oRow.style.backgroundColor = '#e5f3fe';
            
    }

    function ItemMouseOut(currentRow)
    {
        oRow = document.getElementById(currentRow);

            oRow.style.backgroundColor = oRow.originalBackgroundColor;

    }
    
    
    function NFOUpdateCtrl(Option)
{

		
		
		if (Option=="ENFO")
		{
		       // document.getElementById("Existing").style.display = 'inline';
		        //document.getElementById("Forthcoming").style.display = 'none';
				document.getElementById("ImgCurrent").src="../App_Themes/CommonTheme/images/ExeNFOOn.gif";
				document.getElementById("ImgForthcomming").src="../App_Themes/CommonTheme/images/ForthNFOOff.gif";
//				document.getElementById("HBTD").src="../App_Themes/CommonTheme/images/hybridoff.gif";
				
				
				
					
		}
		else 
		{
		      //  document.getElementById("Forthcoming").style.display = 'inline';
		      //  document.getElementById("Existing").style.display = 'none';
    			document.getElementById("ImgCurrent").src="../App_Themes/CommonTheme/images/ExeNFOOff.gif";
				document.getElementById("ImgForthcomming").src="../App_Themes/CommonTheme/images/ForthNFOOn.gif";
//				document.getElementById("HBTD").src="../App_Themes/CommonTheme/images/hybridoff.gif";
				
		}
						
		LoadNFOUpdate(Option);
		
		
		
}


function LoadNFOUpdate(Option)
	{		
		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";
		}
	}
}
	
	
	
    function CreateXmlHttpPop()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttpPop= new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpPop = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpPop = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttpPop && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpPop = new XMLHttpRequest();
		}
	}
	
   function GetNewsDetail(secId,SubsecId,NewsID,opt)
	{
       // alert(requestUrl);
		var NewsWin = document.getElementById("divNews").style.display='inline';
		var currentDivObj;	
		
			currentDivObj = document.getElementById("TdNews");
			//alert(currentDivObj);
			currentDivObj.innerHTML ="<img src=../App_Themes/Common/images/ajax-loader.gif>"; 
		
		CreateXmlHttpPop();
		document.body.style.cursor = "progress";
		var requestUrl = "../PopupNewsData.aspx?SecId="+ secId +"&SubsecId="+ SubsecId+"&NewsID="+NewsID+"&timeStamp="+new Date().getTime()+"opt="+opt;
		//alert(requestUrl);
		
		if(XmlHttpPop)	{
					XmlHttpPop.onreadystatechange = function(){getDetailsResp();};
					XmlHttpPop.open("GET", requestUrl,  true);
					XmlHttpPop.send(null);					
				}
	}
	
	function getDetailsResp()
	{
		// To make sure receiving response data from server is completed
		if(XmlHttpPop.readyState == 4)
		{
			// To make sure valid response is received from the server, 200 means response received is OK
			if(XmlHttpPop.status == 200)
			{
				
				
					document.getElementById("TdNews").innerHTML = XmlHttpPop.responseText;
				
				document.body.style.cursor = "auto";
			}
			else
			{
				
					document.getElementById("NewsId").innerHTML = "<img src=../App_Themes/Common/images/ajax-loader.gif>";
				
			}
		}
	}
