/* For Mutual Fund Home Page - MF News */
function ShowHomeMFNews()
{
	var HomeNewsUrl = "../MutualFund/HomeNews.aspx";
	var ajax = new Ajax.Updater('HomeMFNews',HomeNewsUrl);
}

/* For Mutual Fund Home Page - Fund Performers */
function ShowBestWorst()
{
	var HomBestWorstUrl = "../MutualFund/BestWorstPer.aspx";
	var ajax = new Ajax.Updater('TDFundPer',HomBestWorstUrl);
}

function SelectScheme2(ig_,ig_a,ig_b)
{

	var fund = document.getElementById("_ctl0_Drp_FundHouse");
	var category = document.getElementById("_ctl0_Drp_FundCategory");
	//var scheme = document.getElementById("_ctl0_drp_Scheme");
	
	CreateXmlHttp();
	document.body.style.cursor = "progress";
	var requestUrl = "MF_CategoryData.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&Fund="+ fund.value;// +"&Category="+category.value;
	if(XmlHttp)	{
				XmlHttp.onreadystatechange = function(){getSchemeResp1(category)};
				XmlHttp.open("GET", requestUrl,  true);
				XmlHttp.send(null);
			}
}

function getSchemeResp1(ig_)
{
	
	// 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)
		{
			//alert(ig_)
			//var availSchemes   = document.getElementById(ig_);
			var strData = XmlHttp.responseText
			//alert(strData);
			if(strData != "") {	
				var arrSchm = strData.split("|");
				ig_.length = 0; 	
				for(i=0; i<arrSchm.length-1; i++) {	
					var strSchm = arrSchm[i];
					var arrSchmCode = strSchm.split("~");
					ig_.options[i] = new Option();
					ig_.options[i].value = arrSchmCode[0];
					ig_.options[i].text = arrSchmCode[1];
				}
			}
			else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					//ig_.options[0].value = "0";
					ig_.options[0].value = "";
					ig_.options[0].text = "No Categories available";			
			}
			document.body.style.cursor = "auto";
				
		}
		else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					//ig_.options[0].value = "0";
					ig_.options[0].value = "";
					ig_.options[0].text = "select category";
					document.body.style.cursor = "auto";		
		}
	}
}	
function GetBestWorst(val)
{
	if(val=='TOP')
	{	
		document.getElementById("TdBestPerf").style.display='inline';
		document.getElementById("TdWorstPerf").style.display='none';
		document.getElementById("TopData").style.display = 'inline';
		document.getElementById("BottomData").style.display = 'none';
	}
	else
	{
		document.getElementById("TdWorstPerf").style.display='inline';
		document.getElementById("TdBestPerf").style.display='none';
		document.getElementById("TopData").style.display = 'none';
		document.getElementById("BottomData").style.display = 'inline';
	}
}

function CreateXmlHttpTB()
{
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttpTB = new ActiveXObject("Msxml2.XmlHttp");
	}
	catch(e)
	{
		try
		{
			XmlHttpTB = new ActiveXObject("Microsoft.XmlHttp");
		} 
		catch(oc)
		{
			XmlHttpTB = null;	
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttpTB && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpTB = new XMLHttpRequest();
	}
}

function loadGLData(Period,Category,TopGl)
{
	CreateXmlHttpTB();
	document.body.style.cursor = "progress";
	
	var TopGl;
	if(Period=='')
		Period = "1YEAR";
	if(Category=='')
		Category="ALL";
	
	var requestUrl = "../MutualFund/MFTopGLData.aspx?Period="+ Period +"&Cat="+ Category +"&TopGl="+ TopGl;
	//alert(requestUrl);
	if(XmlHttpTB)	{
				XmlHttpTB.onreadystatechange = function(){GLResponse(TopGl)}
				XmlHttpTB.open("GET", requestUrl,  true);
				XmlHttpTB.send(null);
			}
}

function GLResponse(TopGl)
{
	// To make sure receiving response data from server is completed
	if(XmlHttpTB.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
	
		if(XmlHttpTB.status == 200)//TopBotPerformers
		{	
			var GainerId = document.getElementById("GainerId");
			var LoserId  = document.getElementById("LoserId");
			var strGlData = XmlHttpTB.responseText
			if(TopGl=='T')
				GainerId.innerHTML = strGlData;
			  else
				LoserId.innerHTML = strGlData;
				
			document.body.style.cursor = "auto";		
		}
		else
		{
			if(TopGl=='T')
				GainerId.innerHTML = "There was a problem retrieving data from the server.";
			else
				LoserId.innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}

/* For Mutual Fund Home Page - Category Returns */
function CatRetHome(category,period)
{
	var id;
	
	if(category=="")
	{
		if(navigator.userAgent.indexOf("MSIE")!=-1)
		{			
			if(document.getElementById("TDM1").className=="BWPerformerOn LeftPadd5 RightPadd5")
				category="EQUITY";
			else if(document.getElementById("TDM2").className=="BWPerformerOn LeftPadd5 RightPadd5")
				category="DEBT";
			else if(document.getElementById("TDM3").className=="BWPerformerOn LeftPadd5 RightPadd5")
				category="HYBRID";
			else
				category="EQUITY";
		}
		else
		{
			if(document.getElementById("TDM1").className=="BWPerformerOn LeftPadd5 RightPadd5")
				category="EQUITY";
			else if(document.getElementById("TDM2").className=="BWPerformerOn LeftPadd5 RightPadd5")
				category="DEBT";
			else if(document.getElementById("TDM3").className=="BWPerformerOn LeftPadd5 RightPadd5")
				category="DEBT";
			else
				category="EQUITY";
		}
	}
	
	if(category=="EQUITY")
		id="1";
	else if(category=="DEBT")
		id="2";
	else if(category=="HYBRID")
		id="3";
	
	if(navigator.userAgent.indexOf("MSIE")!=-1)
	{
		for(var j=1;j<=3;j++)
		{
			document.getElementById("TDM"+j).className="BWPerformerOff LeftPadd5 RightPadd5";				
			document.getElementById("TDM"+j).style.cursor="pointer";
		}
		document.getElementById("TDM"+id).className="BWPerformerOn LeftPadd5 RightPadd5";				
		document.getElementById("TDM"+id).style.cursor="default";		 
	}
	else
	{
		for(var j=1;j<=3;j++)
		{
			document.getElementById("TDM"+j).className="BWPerformerOff LeftPadd5 RightPadd5";				
			document.getElementById("TDM"+j).style.cursor="pointer";	
		}
		document.getElementById("TDM"+id).className="BWPerformerOn LeftPadd5 RightPadd5";				
		document.getElementById("TDM"+id).style.cursor="default";		 	
	}
	
	if(period=="")
		period=document.getElementById("catPeriod").value;
	
	var CatRetUrl = "../MutualFund/HomeCatRet.aspx?category="+category+"&period="+period;
	
	document.getElementById("CategoryData").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td align='center'><img src='../images/loadig1.gif'></td></tr></table>";
	var ajax = new Ajax.Updater('CategoryData',CatRetUrl);
}

/* For Mutual Fund Home Page - NFO */
function ShowHomeNFO()
{
	var HomeNFOUrl = "../MutualFund/HomeNFO.aspx";	
	var ajax = new Ajax.Updater('HomeNFO',HomeNFOUrl); 
}

function CreateXmlHttp()
{
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;	
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
	return XmlHttp;
}
/* MF Snapshot Begins */
function showTab()
{
	var opt = document.getElementById("Reptype").value
	var SummaryInfo = document.getElementById("SummaryInfo");
	var NavDet      = document.getElementById("NavDet");
	var PayOut      = document.getElementById("PayOut");
	var InvDet      = document.getElementById("InvDet");
	var Perform     = document.getElementById("Perform");
	var Ratio       = document.getElementById("Ratio");
	var AssetAlloc  = document.getElementById("AssetAlloc");
	var Holding     = document.getElementById("Holding");
	
	switch(opt)
	{
		case "A1":
				    SummaryInfo.style.display = "inline";
					NavDet.style.display = "inline";
					PayOut.style.display = "inline";
					InvDet.style.display = "inline";
					Perform.style.display = "inline";
					Ratio.style.display = "none";
					AssetAlloc.style.display = "inline";
					Holding.style.display = "inline";							
					break;
		
		case "N":
					SummaryInfo.style.display = "none";
					NavDet.style.display = "inline";
					PayOut.style.display = "none";
					InvDet.style.display = "none";
					Perform.style.display = "none";
					Ratio.style.display = "none";
					AssetAlloc.style.display = "none";
					Holding.style.display = "none";							
					break;
		case "L":
					SummaryInfo.style.display = "none";
					NavDet.style.display = "none";
					PayOut.style.display = "inline";
					InvDet.style.display = "none";
					Perform.style.display = "none";
					Ratio.style.display = "none";
					AssetAlloc.style.display = "none";
					Holding.style.display = "none";							
					break;
		case "I":
					SummaryInfo.style.display = "none";
					NavDet.style.display = "none";
					PayOut.style.display = "none";
					InvDet.style.display = "inline";
					Perform.style.display = "none";
					Ratio.style.display = "none";
					AssetAlloc.style.display = "none";
					Holding.style.display = "none";							
					break;
		case "P":
					SummaryInfo.style.display = "none";
					NavDet.style.display = "none";
					PayOut.style.display = "none";
					InvDet.style.display = "none";
					Perform.style.display = "inline";
					Ratio.style.display = "none";
					AssetAlloc.style.display = "none";
					Holding.style.display = "none";							
					break;
		case "R":
					SummaryInfo.style.display = "none";
					NavDet.style.display = "none";
					PayOut.style.display = "none";
					InvDet.style.display = "none";
					Perform.style.display = "none";
					Ratio.style.display = "none";
					AssetAlloc.style.display = "none";
					Holding.style.display = "none";							
					break;
		case "A":
					SummaryInfo.style.display = "none";
					NavDet.style.display = "none";
					PayOut.style.display = "none";
					InvDet.style.display = "none";
					Perform.style.display = "none";
					Ratio.style.display = "none";
					AssetAlloc.style.display = "inline";
					Holding.style.display = "none";							
					break;
		case "H":
					SummaryInfo.style.display = "none";
					NavDet.style.display = "none";
					PayOut.style.display = "none";
					InvDet.style.display = "none";
					Perform.style.display = "none";
					Ratio.style.display = "none";
					AssetAlloc.style.display = "none";
					Holding.style.display = "inline";							
					break;
		default : 
					SummaryInfo.style.display = "inline";
					NavDet.style.display = "none";
					PayOut.style.display = "none";
					InvDet.style.display = "none";
					Perform.style.display = "none";
					Ratio.style.display = "none";
					AssetAlloc.style.display = "none";
					Holding.style.display = "none";																																												
	}		
	return false;
}

function showSnapChart(code,period)
{	
	var period;
	
	var periodVal = period.substr(0,1);
	var period = period.substr(1,1)
	document.getElementById("SnapChart").src= "mfchart.aspx?schcode="+ code +"&Period="+ period +"&PeriodVal="+periodVal;
}
function showAssetChart(code,opt)
{
	var opt;
	document.getElementById("AssetChart").src= "AssetChart.aspx?schcode="+ code +"&opt="+opt;
}

/* For SIP Calculator */

//For Loading schemes from SipCalcSchData.aspx Using AJAX
function loadSipScheme(mf_code)
{	
	CreateXmlHttp();	
	document.body.style.cursor = "progress";
	if(mf_code=='')return false;
	var requestUrl = "SipCalcSchData.aspx?MF_Code="+ mf_code;	
	if(XmlHttp)	{
				XmlHttp.onreadystatechange = function(){sipSchResp()}
				XmlHttp.open("GET", requestUrl,  true);
				XmlHttp.send(null);
			}
}

//Called when response comes back from server Only For sip schemes
function sipSchResp()
{
	if(XmlHttp.readyState == 4)
	{
		if(XmlHttp.status == 200)
		{			
			var DrpScheme   = document.getElementById("SipCalcFrm_DrpScheme");
			var strData = XmlHttp.responseText			
			if(strData != "")
			{	
				if(strData!="NA") {
					var arrSchm = strData.split("|");
					
					var arrSCH_NAME   = eval(arrSchm[1]);
					arrMF_SCHCODE = eval(arrSchm[0]);
					arrMININVT    = eval(arrSchm[2]);

						DrpScheme.length = 0;
						DrpScheme.options[0] = new Option();
						DrpScheme.options[0].value = "";
						DrpScheme.options[0].text  = "Select Scheme..";						
						for(i=1; i<=arrMF_SCHCODE.length; i++) {	
							DrpScheme.options[i] = new Option();
							DrpScheme.options[i].value = arrMF_SCHCODE[i-1];
							DrpScheme.options[i].text  = arrSCH_NAME[i-1].replace(/#/g,"'");
						}
				}
				else
					fillSchDef("Scheme is not available");
			}
			else
				fillSchDef("Scheme is not available");
				document.body.style.cursor = "auto";
		}
		else
		{
			fillSchDef("server is not ready");
			document.body.style.cursor = "auto";
		}
	}
}

function fillSchDef(txt){
	var DrpScheme   = document.getElementById("SipCalcFrm_DrpScheme");
	DrpScheme.length = 0;
	DrpScheme.options[0] = new Option(); 
	DrpScheme.options[0].value = "";
	DrpScheme.options[0].text = txt;	
}

function MinSipAmt(schCode){
	document.body.style.cursor = "progress";
	var inv_Amnt  = document.getElementById("TxtInvstAmt");
	CreateXmlHttp();	
	var requestUrl = "SipStDtData.aspx?schCode="+ schCode;	
	if(XmlHttp)	{
				XmlHttp.onreadystatechange = function(){sipDtResp()}
				XmlHttp.open("GET", requestUrl,  true);
				XmlHttp.send(null);
			}
}

//Called when response comes back from server Only For sip Start Date
function sipDtResp()
{
	if(XmlHttp.readyState == 4)
	{
		if(XmlHttp.status == 200)
		{	
			var strData = XmlHttp.responseText
			if(strData != "")
			{	
				var stDy = document.getElementById("SipCalcFrm_drpStDay");
				var stMn = document.getElementById("SipCalcFrm_drpStMn");
				var stYr = document.getElementById("SipCalcFrm_drpStYr");
				
				var arrStr = strData.split("|");
				var arrDate = arrStr[0].split("-");
					for(i=0; i<stDy.length; i++)
						if(stDy.options[i].value==arrDate[0])stDy.options[i].selected = true;
					for(i=0; i<stMn.length; i++)
						if(stMn.options[i].value==arrDate[1])stMn.options[i].selected = true;
					for(i=0; i<stYr.length; i++){
						if(stYr.options[i].value==arrDate[2])stYr.options[i].selected = true;										
				}					
				SchTypeCode = arrStr[1];		
				selDy = stDy.options[stDy.selectedIndex].value;
				selMn = stMn.options[stMn.selectedIndex].value;
				selYr = stYr.options[stYr.selectedIndex].value;
			}
		}
	}
	document.body.style.cursor = "auto";
}

function SIP_Data()
{
	var tdate = new Date();
	var tday = tdate.getDate();
	var tmon = tdate.getMonth()+1;
	
	if(String(tday).length == 1)
	{
		tday = "0" + tday;
	}
	if(String(tmon).length == 1)
	{
		tmon = "0" + tmon;
	}
	//var today=(tdate.getMonth()+1) +"/"+ tdate.getDate() +"/"+ tdate.getFullYear();
	var today=(tmon) +"/"+ tday +"/"+ tdate.getFullYear();
	
	var SIPCALC    = document.getElementById("SIPCALC");
	SIPCALC.style.display='none';
	var sch_Code  = document.getElementById("SipCalcFrm_DrpScheme");
	var inv_Amnt  = document.getElementById("SipCalcFrm_TxtInvstAmt");
	
	var stday     = document.getElementById("SipCalcFrm_drpStDay");
    var drpStmonth= document.getElementById("SipCalcFrm_drpStMn");
    var drpStyear = document.getElementById("SipCalcFrm_drpStYr");
    
	var edday     = document.getElementById("SipCalcFrm_drpEdDay");    
	var drpEnmonth= document.getElementById("SipCalcFrm_drpEdMn");
	var drpEnyear = document.getElementById("SipCalcFrm_drpEdYr");
	
	var DrpAMC = document.getElementById("SipCalcFrm_DrpAMC");
	
	if(DrpAMC.value == "")
	{
		alert("Select a Fund")
		DrpAMC.focus();		
		return false;
	}
	
	if(sch_Code.value==""){
		alert("Select any Scheme");
		sch_Code.focus();
		return false;
	}

	if(drpStyear.value=="" || drpEnyear.value=="" || drpStmonth.value=="" || drpEnmonth.value=="")
	{
		alert("End Date should be Greater than Start Date")
		return false;
	}
	
	if(drpEnyear.value > tdate.getFullYear())
	{
		alert("End Date should not be greater than Current Date.")
		drpEnyear.focus()
		return false;
	}
	if(drpEnyear.value == tdate.getFullYear())
	{
		if (eval(drpEnmonth.value)> eval(tmon))
		{
			alert("End Date should not be greater than Current Date.")
			drpEnmonth.focus()
			return false;
		}
		else if(eval(drpEnmonth.value)== eval(tmon))
		{
			if(eval(edday.value) > eval(tday))
			{
				alert("End Date should not be greater than Current Date.")
				edday.focus()
				return false;
			}
		}
	}
	
	if(drpStyear.value > drpEnyear.value)
	{
		alert("End Date should be Greater than Start Date")
		drpStyear.focus()
		return false;
	}
	
	else if(drpStyear.value==drpEnyear.value)
	{
		if (eval(drpStmonth.value)> eval(drpEnmonth.value))
		{
			alert("End Date should be Greater than Start Date")
			drpStmonth.focus()
			return false;
		}
		else if(eval(drpStmonth.value)== eval(drpEnmonth.value))
		{
			if(eval(stday.value) > eval(edday.value))
			{
				alert("End Date should be Greater than Start Date")
				stday.focus()
				return false;
			}
		}
		/*if (eval(drpStmonth.value)>= eval(drpEnmonth.value))
		{
			if(eval(stday.value) > eval(edday.value))
			{
				alert("End Date should be Greater than Start Date")
				drpStmonth.focus()
				return false;
			}
		}*/
	}
	
	if(drpStmonth.value==02)
	{
		if(drpStyear.value%4==0)
		{
			if(stday.value>29)
			{
				alert("Day can't be greater than 29");
				stday.focus();
				return false;
			}
		}
		else
		{
			if(stday.value>28)
			{
				alert("Day can't be greater than 28");
				stday.focus();
				return false;
			}
		}
	}
	/*if(drpStyear.value%4==0 && drpStmonth.value==02 && stday.value>29)
	{
		alert("Day can't be greater than 29");
		stday.focus();
		return false;
	}
	else if(drpStmonth.value==02 && stday.value>28)
	{
		alert("Day can't be greater than 28");
		stday.focus();
		return false;
	}*/
	else if((drpStmonth.value==04 || drpStmonth.value==06 || drpStmonth.value==09 || drpStmonth.value==11) && stday.value>30)
	{
		alert("Day can't be greater than 30");
		stday.focus();
		return false;
	}
	
	if(drpEnmonth.value==02)
	{
		if(drpEnyear.value%4==0)
		{
			if(edday.value>29)
			{
				alert("Day can't be greater than 29");
				edday.focus();
				return false;
			}
		}
		else
		{
			if(edday.value>28)
			{
				alert("Day can't be greater than 28");
				edday.focus();
				return false;
			}
		}
	}
	/*else if(drpEnyear.value%4==0 && drpEnmonth.value==02 && edday.value>29)
	{
		alert("Day can't be greater than 29");
		edday.focus();
		return false;
	}
	else if(drpEnmonth.value==02 && edday.value>28)
	{
		alert("Day can't be greater than 28");
		edday.focus();
		return false;
	}*/
	else if((drpEnmonth.value==04 || drpEnmonth.value==06 || drpEnmonth.value==09 || drpEnmonth.value==11) && edday.value>30)
	{
		alert("Day can't be greater than 30");
		edday.focus();
		return false;
	}

	if(inv_Amnt.value == "")
	{
		alert("Enter Investment amount");
		inv_Amnt.focus();
		return false;
	}
	var SelAMC = DrpAMC.options[DrpAMC.selectedIndex].innerText || DrpAMC.options[DrpAMC.selectedIndex].textContent;

	if (SelAMC.indexOf("Reliance")> -1)
	{
		if (inv_Amnt.value < 100)
		{
			alert("Investment amount must be greater than 100")
			inv_Amnt.focus();
			return false;
		}
	}
	else
	{
		if (inv_Amnt.value < 500)
		{
			alert("Investment amount must be greater than or equal to 500")
			inv_Amnt.focus();
			return false;
		}
	}

	if(selYr == drpStyear.value && selMn == drpStmonth.value && stday.value < selDy)
	{
		alert("Start date can not be less than SIP start date.");
		stday.value = selDy;
		return false;
	}
	if(selYr == drpStyear.value && selMn > drpStmonth.value)
	{
		alert("Start date can not be less than SIP start date.");
		drpStmonth.value = selMn;
		return false;
	}
	if(selYr > drpStyear.value)
	{
		alert("Start date can not be less than SIP start date.");
		drpStyear.value = selYr;
		return false;
	}

	st_Date = drpStmonth.value +"/"+ stday.value +"/"+ drpStyear.value;
	ed_Date = drpEnmonth.value +"/"+ edday.value +"/"+ drpEnyear.value;

	/*if(ed_Date>today)
	{
		alert("End date should not be greater than current date");
		return false;
	}*/

	if(SchTypeCode==""){
		alert("This Scheme is not matching with our data..  Kindly Select another Scheme..!");
		sch_Code.focus();
		return false;
	}

	//for float value
	var invamtcast= new String();
	var invamtcast1= new String();
	var invamtcast2=new String();
	invamtcast=document.getElementById("SipCalcFrm_TxtInvstAmt").value;
	invamtcast1=invamtcast.substring(0,invamtcast.indexOf("."));

	if(invamtcast1!="")
	{
		if(invamtcast!=invamtcast1)
		{
			alert("Please enter valid investment amount");
			inv_Amnt.focus();
			return false;
		}
		else
			return true;
	}
	invamtcast2=invamtcast.substring(0,9);
	if(invamtcast.length>"9")
	{
		alert("Investment amount is not greater than " +invamtcast2);
		return false;
	}
	//end

	var SchmPlan = document.getElementById("SchmPlan");
	var InvAmount= document.getElementById("InvAmount");
	var InvPeriod= document.getElementById("InvPeriod");
	var SchemeName = document.getElementById("SchemeName");

	SchmPlan.innerHTML = sch_Code.options[sch_Code.selectedIndex].text;
	SchemeName.innerText = sch_Code.options[sch_Code.selectedIndex].text;
	InvAmount.innerHTML = inv_Amnt.value;
	InvPeriod.innerHTML = stday.value +"-"+ drpStmonth.options[drpStmonth.selectedIndex].text +"-"+ drpStyear.value +" To  "+ edday.value +"-"+ drpEnmonth.options[drpEnmonth.selectedIndex].text +"-"+ drpEnyear.value;
	InvPeriod.textContent = stday.value +"-"+ drpStmonth.options[drpStmonth.selectedIndex].text +"-"+ drpStyear.value +" To  "+ edday.value +"-"+ drpEnmonth.options[drpEnmonth.selectedIndex].text +"-"+ drpEnyear.value;
	document.body.style.cursor = "progress";
	CreateXmlHttp();
	var requestUrl = "SipCalcData.aspx?sch_Code="+ sch_Code.value +"&sch_Type="+ SchTypeCode +"&st_Date="+ st_Date +"&ed_Date="+ ed_Date +"&inv_Amnt="+inv_Amnt.value;

	if(XmlHttp){
				XmlHttp.onreadystatechange = function(){sipDataResp()}
				XmlHttp.open("GET", requestUrl,  true);
				XmlHttp.send(null);
			}
}
//Called when response comes back from server Only For sip data
function sipDataResp()
{
	if(XmlHttp.readyState == 4)
	{
		if(XmlHttp.status == 200)
		{			
			var SIPCALC    = document.getElementById("SIPCALC");
			var strData = XmlHttp.responseText
			if(strData != "NA")
			{	
				var Tot_InvAmt  = document.getElementById("Tot_InvAmt");
				var Tot_UnitBuy = document.getElementById("Tot_UnitBuy");
				var Inv_ValDate = document.getElementById("Inv_ValDate");
				var Inv_Val	    = document.getElementById("Inv_Val");
				var Return	    = document.getElementById("Return");
				var EntryLoad = document.getElementById("EntryLoad");
				var ExitLoad = document.getElementById("ExitLoad");				
				var TotMonth    = document.getElementById("TotMonth");
				var SIPTable    = document.getElementById("SIPTable");
				var arrStr = strData.split("|");
				
				SIPTable.innerHTML = arrStr[0];
				Tot_InvAmt.innerHTML = arrStr[1];
				Tot_UnitBuy.innerHTML = arrStr[2];
				Inv_ValDate.innerHTML = arrStr[3];
				Inv_Val.innerHTML = arrStr[4];
				Return.innerHTML = arrStr[5];					
				TotMonth.innerHTML = arrStr[8];
				EntryLoad.innerHTML = arrStr[9];
				ExitLoad.innerHTML = arrStr[10];
				SIPCALC.style.display='inline';
			}
			else {
				SIPCALC.style.display='inline';
				SIPCALC.innerHTML="There was a problem retrieving data from the server.";
			}
		}
	}
	document.body.style.cursor = "auto";
}

function SortCol(id,val,sortMode,mfcode1,Period)
{
	
		var url = "../MutualFund/MFFundProfile.aspx?id="+id+"&fund="+mfcode1+"&Period="+Period+"&Sortval="+val+"&sortMode1="+sortMode;
		document.getElementById('MFfundprofile').innerHTML = "<table cellpadding=0  cellspacing=0 border=0 width='100%'><tr><td align=center><img src='../images/loadig1.gif'></td></tr></table>";
		var ajax = new Ajax.Updater('MFfundprofile',url);
}

function FundProf_Paging(PageNo,Type,MFCode,DrpValue)
{
 
	var Prev=document.getElementById("MFPrev");
	var Next=document.getElementById("MFNext");
	var Last =document.getElementById("MFLast");
	
	//var StrUrl = "Addresses.aspx?sortMode1="+sortMode.value+"&Sortval="+Sortval1.value+"&PageNo="+0;
	
	var StrUrl = "MFFundProfile.aspx?MFCode="+MFCode+"&DrpValue="+DrpValue+"&Type="+Type+"&PageNo="+0;

	if(PageNo == "L")
	{
		var StrUrl = "MFFundProfile.aspx?MFCode="+MFCode+"&DrpValue="+DrpValue+"&Type="+Type+"&PageNo="+Last.value;
	}
	else if (PageNo =="P")
	{
		var StrUrl = "MFFundProfile.aspx?MFCode="+MFCode+"&DrpValue="+DrpValue+"&Type="+Type+"&PageNo="+Prev.value;
	}
	else if (PageNo =="N")
	{		
		var StrUrl = "MFFundProfile.aspx?MFCode="+MFCode+"&DrpValue="+DrpValue+"&Type="+Type+"&PageNo="+Next.value;
	}
	
	document.getElementById('MfFundProfile').innerHTML = "<table cellpadding=0  cellspacing=0 border=0 width='100%'><tr><td align=center><img src='../images/loadig1.gif'></td></tr></table>";	
	var ajax = new Ajax.Updater('MfFundProfile',StrUrl);
}
function ChkNum(evt)
{	
	var k=(evt.which)? evt.which : evt.keyCode; 
	return (k > 31 && (k < 43 || k > 57))  ? false : true;	 	
}

