﻿// 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 clockTimeoutID;
//Global Variables
var XmlHttp;
var XmlHttp2;
var XmlHttp3;
var XmlHttp4;
var XmlHttpTOP;
var XmlHttpNews;
var XmlHttptest;

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()
	{
if ( window.XMLHttpRequest )
 {
  // code for all new browsers
  XmlHttptest  = new XMLHttpRequest();
 }
 else if ( window.ActiveXObject )
 {
  // code for IE5 and IE6
  XmlHttptest  = new ActiveXObject('Microsoft.XMLHTTP');
 }
	}	
	

function CreateXmlHttp4()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttp4 = new ActiveXObject("Msxml2.XmlHttp");
		}
		catch(e)
		{
			try
			{
				XmlHttp4 = new ActiveXObject("Microsoft.XmlHttp");
			} 
			catch(oc)
			{
				XmlHttp4 = null;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if(!XmlHttp4 && typeof XmlHttpRequest != "undefined") 
		{
			XmlHttp4 = new XmlHttpRequest();
		}
	}
	
	function CreateXmlHttpNews()
	{
//Creating object of XmlHttp in IE
		if ( window.XMLHttpRequest )
 {
  // code for all new browsers
  XmlHttpNews  = new XMLHttpRequest();
 }
 else if ( window.ActiveXObject )
 {
  // code for IE5 and IE6
  XmlHttpNews  = new ActiveXObject('Microsoft.XMLHTTP');
 }

	
	}	
//For top performers data
function loadGLData(Period,Category,TopGl,typ)
{
//alert("as");


 if(typ == 'Top')
     {
      document.getElementById("tdtop").className="TabSelected";
	  document.getElementById("tdbottom").className="TabUNselectedwhite";
	 
	  
	
     }
     if(typ =='Bott')
     {
     document.getElementById("tdtop").className="TabUNselectedwhite";
	  document.getElementById("tdbottom").className="TabSelected";
	
	 
     }
	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+"&typ="+typ;

	
	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 loadCatRet(option)
	{		
		//alert(Period);
		var Type = document.getElementById("drptype").value;
		CreateXmlHttp1();
		document.body.style.cursor = "progress";
		
		
		var requestUrl = "AjaxCategoryData.aspx?option="+option + "&Type="+Type;
	//	alert(requestUrl);
		if(XmlHttptest)	
			{
					//alert("hi");
					XmlHttptest.onreadystatechange = function(){CatRetResponse();}; 
					XmlHttptest.open("GET", requestUrl,  true);
					XmlHttptest.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(XmlHttptest.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttptest.status == 200)
		{			
			var EquityId   = document.getElementById("EquityId");
          
			var strData = XmlHttptest.responseText;
			if(strData != "")
			{
				EquityId.innerHTML   = strData;
			}
			document.body.style.cursor = "auto";	
		}
		else
		{
			EquityId.innerHTML = "There was a problem retrieving data from the server.";
	
			document.body.style.cursor = "auto";
		}
	}
}


function CategoryCtrl(Type)
{
        
       // alert(Type);
    var option = document.getElementById("PeriodDropList").value;
		var requestUrl = "AjaxCategoryData.aspx?Type="+Type+"&option="+option;
	//alert(requestUrl);
		CreateXmlHttp4();
		document.body.style.cursor = "progress";
		if(XmlHttp4)	
			{
					XmlHttp4.onreadystatechange = function(){CatRetCtrlResponse();}; 
					XmlHttp4.open("GET", requestUrl,  true);
					XmlHttp4.send(null);
			}
}

function CatRetCtrlResponse()
{

	// To make sure receiving response data from server is completed
	if(XmlHttp4.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp4.status == 200)
		{			
			var EquityId   = document.getElementById("EquityId");
          
			var strData = XmlHttp4.responseText;
			if(strData != "")
			{
				EquityId.innerHTML   = strData;
			}
			document.body.style.cursor = "auto";	
		}
		else
		{
			EquityId.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 HomeMFNews()
{
  // alert(XmlHttpNews);
  var UserId= document.getElementById("inp_hid1").value;
		var requestUrl = "../MutualFund/AjaxHomeNews.aspx?timeStamp="+ new Date().getTime()+ "&UserId="+UserId;
	//alert(requestUrl);
		CreateXmlHttpNews();
		document.body.style.cursor = "progress";
		if(XmlHttpNews)	
			{
					XmlHttpNews.onreadystatechange = function(){HomeMFNewsResponse();}; 
					XmlHttpNews.open("GET", requestUrl,  true);
					XmlHttpNews.send(null);
			}
}

function HomeMFNewsResponse()
{

	// To make sure receiving response data from server is completed
	
	//alert(XmlHttpNews.readyState);
	if(XmlHttpNews.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpNews.status == 200)
		{			
			var HomeMFNewsTd   = document.getElementById("HomeMFNews");
        
			HomeMFNewsTd.innerHTML = XmlHttpNews.responseText;					
			document.body.style.cursor = "auto";	
		}
		else
		{
			HomeMFNewsTd.innerHTML = "There was a problem retrieving data from the server.";
	
			document.body.style.cursor = "auto";
		}
	}
}



/*MF new fundOffers*/

 function showDefaultSel(Option)
	{

			var strURL = window.location.href;
			var prdval="";
			
			if(strURL.indexOf("Period=less1yr")>=0)
			{
			prdval="less1yr";
			}
			if(strURL.indexOf("Period=gtreq1year")>=0)
			{
			prdval="gtreq1year";
			}
			if(strURL.indexOf("Period=All")>=0)
			{
			prdval="All";
			}
		
			
			
			
		 if(strURL.indexOf("Option=ENFO")>=0)
			Option ="ENFO";
		else if(strURL.indexOf("Option=FNFO")>=0)
			Option ="FNFO";
		else if(strURL.indexOf("Option=FMP")>=0)
		{
			Option = "FMP";
		}
		else
		{
		Option = "ENFO";
		}
			
		if(Option == 'ENFO')
			{
			    document.getElementById("maintabs").style.display = 'inline';
			    document.getElementById("tblFirst").style.display = 'inline';		
		        document.getElementById("tblSecond").style.display = 'none';
		        document.getElementById("tblThird").style.display = 'none';
		        //document.getElementById("ctl00_ContentPlaceHolder1_lblPage").style.display = 'inline'; //false//
		        document.getElementById("FMP").style.display = 'none'; //true//
		        
		    }
		    else if(Option=="FMP")
		    {
		  
		        document.getElementById("tblFirst").style.display = 'none';		
		        document.getElementById("tblSecond").style.display = 'none';
		        document.getElementById("tblThird").style.display = 'inline';
		        document.getElementById("maintabs").style.display = 'none';
		       // document.getElementById("ctl00_ContentPlaceHolder1_lblPage").style.display = 'none';//flase//
		        //chkrd(prdval);
		  
		        
		    }
	        else 
	        {   
	            document.getElementById("maintabs").style.display = 'inline';
	            document.getElementById("tblFirst").style.display = 'none';		
		        document.getElementById("tblSecond").style.display = 'inline';
		        document.getElementById("tblThird").style.display = 'none';
		       // document.getElementById("ctl00_ContentPlaceHolder1_lblPage").style.display = 'inline'; //false//
		          document.getElementById("FMP").style.display = 'none';
		
		    }
		    
   }
   
   function ShowData(exchgVal,Option)
    {	   
    
      document.location = "NewFundOffers.aspx?id=12&Option=" + Option; 
    }
 
 function loadMFData(Perfromance)
{
//alert("as");
	CreateXmlHttp()
	document.body.style.cursor = "progress";
	
	
	var requestUrl = "AjaxPerformanceData.aspx?status="+ Perfromance ;

	
	    document.location.href(requestUrl);

}	
 
 function loadTopGLData(Period,Category,TopGl)
{
//alert("as");
	CreateXmlHttp()
	document.body.style.cursor = "progress";
	var TopGl;
	if(Period=='')
		Period = "1YEAR";
	if(Category=='')	
		Category="ALL";
	
	var requestUrl = "performance.aspx?id=11&Period="+ Period +"&Category="+ Category +"&TB="+ TopGl;
    document.location.href(requestUrl);
	//alert(requestUrl);
//	if(XmlHttp)	{
//				XmlHttp.onreadystatechange = function(){TopGLResponse(TopGl)}
//				XmlHttp.open("GET", requestUrl,  true);
//				XmlHttp.send(null);
//			}
}	
	
	function TopGLResponse(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 LoadNFOUpdateExst(Option)
	{	
	
		CreateXmlHttpNFOExst();
		document.body.style.cursor = "progress";
		
		var requestUrl = "AjaxNFOUpdateDataExst.aspx?Option="+Option;
		
		if(XmlHttpNFOExst)	
			{
					
					XmlHttpNFOExst.onreadystatechange = function(){NFOUpdateResponseExst();}; 
					XmlHttpNFOExst.open("GET", requestUrl,  true);
					XmlHttpNFOExst.send(null);
			}
	}
	
	
	function NFOUpdateResponseExst()
{

	// To make sure receiving response data from server is completed
	if(XmlHttpNFOExst.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpNFOExst.status == 200)
		{	
		//alert("in respnse OK")	;	
			var NFOExstId   = document.getElementById("NFOExstId");
			
			var strData = XmlHttpNFOExst.responseText;
			//alert(strData);
			if(strData != "")
			{
			
				NFOExstId.innerHTML   = strData;
				

			}
			document.body.style.cursor = "auto";	
		}
		else
		{
			NFOExstId.innerHTML = "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
}


function CreateXmlHttpNFOExst()
{
	try
	{
		XmlHttpNFOExst = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpNFOExst = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpNFOExst = null;				
		}
	}
	if(!XmlHttpNFOExst && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpNFOExst = new XMLHttpRequest();
	}
}



 
 
 
 function LoadNFOUpdateForth(Option)
	{	
	
		CreateXmlHttpNFOForth();
		document.body.style.cursor = "progress";
		
		var requestUrl = "AjaxNFOUpdateDataForth.aspx?&Option="+Option;
		
		if(XmlHttpNFOForth)	
			{
					
					XmlHttpNFOForth.onreadystatechange = function(){NFOUpdateResponseForth();}; 
					XmlHttpNFOForth.open("GET", requestUrl,  true);
					XmlHttpNFOForth.send(null);
			}
	}
	
	
	function NFOUpdateResponseForth()
{

	// To make sure receiving response data from server is completed
	if(XmlHttpNFOForth.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpNFOForth.status == 200)
		{	
		//alert("in respnse OK")	;	
			var NFOForthId   = document.getElementById("NFOForthId");
			
			var strData = XmlHttpNFOForth.responseText;
			//alert(strData);
			if(strData != "")
			{
			
				NFOForthId.innerHTML   = strData;
				

			}
			document.body.style.cursor = "auto";	
		}
		else
		{
			NFOForthId.innerHTML = "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
}


function CreateXmlHttpNFOForth()
{
	try
	{
		XmlHttpNFOForth = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpNFOForth = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpNFOForth = null;				
		}
	}
	if(!XmlHttpNFOForth && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpNFOForth = new XMLHttpRequest();
	}
}


var url;
    var containerid="contentarea";
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""






function MFajaxpage(id,url, containerid,fincode)
{

//document.getElementById(containerid).innerHTML = "<table cellspacing=0 cellpadding=0 width=100%><tr><td height=60></td></tr><tr><td align=center><img src='../App_Themes/Common/images/loading.gif'></td></tr></table>";
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject)
{ // if IE
        try {
            page_request = new ActiveXObject("Msxml2.XMLHTTP")
            } 
        catch (e){
                try{
                    page_request = new ActiveXObject("Microsoft.XMLHTTP")
                }
                catch (e){}
                }
}
else
return false
page_request.onreadystatechange=function()
{
    MFloadpage(page_request, containerid)
}

if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}


function MFloadpage(page_request, containerid)
{
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
  //alert(page_request.responseText)
    document.getElementById(containerid).innerHTML=page_request.responseText
}

 function MFGetNewsDetail(secId,SubSecId,NewsID,opt)
	{
	     document.getElementById("divNews").style.display='inline';
		 var requestUrl = "../PopupNewsData.aspx?SecId="+ secId +"&SubSecId="+ SubSecId+"&NewsID="+NewsID+"&timeStamp="+new Date().getTime()+"opt="+opt;
		 MFajaxpage('1',requestUrl,'TdNews');
	}
	
