function schcode()
{
	mfcode = new String();
	var flag,len1,scode,scode1,fname;
	if(document.navrec100.elements['scode'].value=="")
	{
		alert("no blanks please")
		flag="B";
	}
	else
	{
		scode=document.navrec100.scode.value
		if(fname="")
		{
			fname="snap";
		}
		len1=scode.length
		for(i=0;i<3;i++)
		{
			result=scode.charAt(i)
			if(scode==" ")
			{
				alert("no spaces allowed")
				flag=="B";
				break;
			}
			else
			{
				scode1=scode;	
			}
		}
	}
	
	if(scode!=" " && flag!="B")
	{
		fname=document.navrec100.fname.value
		document.navrec100.action="http://www.moneycontrol.com/mf/mfinfo/mfcodesearch.php?scode="+scode+"&scode1="+scode1+"&flag="+flag+"&fname="+fname;
		document.navrec100.submit();
	}
	else
	{
		document.navrec100.scode.focus();
	}
}

function sname()
{
	var flag,fname,tempvar;
	var lenc;
	var i=0;
	if(document.navrec100.AMCname.value =="")
	{
		alert("no blanks please")
		flag="false";
	}
	else
	{
		AMCname= new String(document.navrec100.AMCname.value);
		if(fname="")
		{
			fname="snap";
		}
		flag="true"
	}
	if(flag=="true")
	{
		fname=document.navrec100.fname.value
		document.navrec100.action="http://www.moneycontrol.com/mf/mf_info/mfsearch.php?AMCname="+escape(AMCname)+"&fname="+fname;
		document.navrec100.submit();
	}
	else
	{
		document.navrec100.AMCname.focus();
	}
}

function tocheck()
{
	if(document.navrec100.AMCname.value=="Scheme Name")
	{
		 alert("Please Enter Scheme Name")
		 return(false);
	}
	if(document.navrec100.AMCname.value.length<3)
	{
		 alert("Please enter minimum 3 characters to search")
		 return(false);
	}
	if(document.navrec100.AMCname.value!="")
	{
		if (document.navrec100.scode.value!="" && (document.navrec100.AMCname.value=="Scheme Name" || document.navrec100.AMCname.value==""))
		{
			schcode();
			return (true);
		}
		else
		{
			if (document.navrec100.AMCname.value!="" && (document.navrec100.scode.value=="Scheme Code" || document.navrec100.scode.value==""))
			{
				 sname();
				 return (true);
			}
			else
			{
				 alert("Please Enter Any One Field")
				 return(false);
			}
		}
	}	

	if(document.navrec100.AMCname.value=="")
	{
		alert("Please Enter Scheme Name")
		return(false);
	}
	return(true);
}

function returnfunc()
{
	imid=document.myform.imid.value;
	imffid=document.myform.imffid.value;
	imdesc=document.myform.imdesc.value;
	ffdesc=document.myform.ffdesc.value;
	firstdt=document.myform.firstdt.value;
	lastdt=document.myform.lastdt.value;
	fdt=document.myform.fdt.value;
	ldt=document.myform.ldt.value;
	
	myfromdt1=document.myform.fromdt1.value;
	myfromdt2=document.myform.fromdt2.value;
	myfromdt3=document.myform.fromdt3.value;

	mytodt1=document.myform.todt1.value;
	mytodt2=document.myform.todt2.value;
	mytodt3=document.myform.todt3.value;

	myfromdt=myfromdt3+""+myfromdt2+""+myfromdt1;
	mytodt=mytodt3+""+mytodt2+""+mytodt1;

	if(myfromdt2=="02")
	{
		rem = myfromdt3 % 4;
		if (rem != 0)
		{
			if (myfromdt1 > 28)
			{
				alert("Invalid From Date enterred");
				mytmpvar=document.myform.fromdt1;
				mytmpvar.focus();
				return false;
			}
		}
	}
	
	if(myfromdt2=="04" || myfromdt2=="06" || myfromdt2=="09" || myfromdt2=="11")
	{
		if(myfromdt1 > "30")
		{
			alert("Invalid From Date enterred");
			mytmpvar=document.myform.fromdt1;
			mytmpvar.focus();
			return false;
		}
	}

	if(mytodt2=="02")
	{
		rem = mytodt3 % 4;
		if (rem != 0)
		{
			if (mytodt1 > 28)
			{
				alert("Invalid To Date enterred");
				mytmpvar=document.myform.todt1;
				mytmpvar.focus();
				return false;
			}
		}
	}

	if(mytodt2=="04" || mytodt2=="06" || mytodt2=="09" || mytodt2=="11")
	{
		if(mytodt1 > "30")
		{
			alert("Invalid To Date enterred");
			mytmpvar=document.myform.todt1;
			mytmpvar.focus();
			return false;
		}
	}

	if(myfromdt > mytodt)
	{
		alert("From Date cannot be greater than To Date");
		mytmpvar=document.myform.todt1;
		mytmpvar.focus();
		return false;
	}

	if(myfromdt < fdt)
	{
		alert("Start Date cannot be before "+firstdt);
		mytmpvar=document.myform.fromdt1;
		mytmpvar.focus();
		return false;
	}

	if(mytodt > ldt)
	{
		alert("End Date cannot be greater than "+lastdt);
		mytmpvar=document.myform.fromdt1;
		mytmpvar.focus();
		return false;
	}

	document.myform.action="http://www.moneycontrol.com/mf/mf_info/returns.php?im_id="+imid+"&im_ffid="+imffid+"&im_desc="+imdesc+"&ff_desc="+ffdesc+"&retcalc=true&frdate="+myfromdt+"&todate="+mytodt;
}

function openrankmethod()
{
	popupwin1=window.open("http://www.moneycontrol.com/mf/rankmethod.php", "rankmethod", "toolbar=no,menubar=no,location=no,scrollbars=yes,titlebar=no,status=yes resizable=no,width=500,height=200,left=0,top=0");
}

function sel_amc()
{
	var now = new Date();
	var hour = now.getHours();
	var minute = now.getMinutes();
	document.amc.action="http://www.moneycontrol.com/india/mutualfunds/mutualfundreturns/"+hour+"/"+minute+"/returns";
	document.amc.submit();
	return true;
}

function jumpto(curobj)
{
	if(curobj.name=="fundfamily_frm")
	{
		if(document.getElementById("selMutFunFam").value=="")
		{
			alert("Please select a Fund Family");
			document.getElementById("selMutFunFam").focus();
			return false;
		}
		else
		{
			redir_url=document.getElementById("selMutFunFam").value;
		}
	}

	if(curobj.name=="fundclass_frm")
	{
		if(document.getElementById("selFundClass").value=="")
		{
			alert("Please select a Fund Class");
			document.getElementById("selFundClass").focus();
			return false;
		}
		else
		{
			redir_url=document.getElementById("selFundClass").value;
		}
	}

	if(curobj.name=="othcriteria_frm")
	{
		if(document.getElementById("criteria").value=="")
		{
			alert("Please select a Criteria");
			document.getElementById("criteria").focus();
			return false;
		}
		else
		{
			redir_url=document.getElementById("criteria").value;
		}
	}

	window.location = redir_url;
	return false;
}

function sel_easymf_form()
{
	var sel_value = document.selmf_easymf.selMutFunFam.value;
	if (sel_value=='')
	{
		alert("Please Select Fund Family")
		 return(false);
	}
	else
	{
	document.selmf_easymf.action=sel_value;
	document.selmf_easymf.submit();
	return true;
	}
}


function sel_easymf_form_2()
{
	var sel_value = document.selmf_easymf_2.selMutFunFam_2.value;
	if (sel_value=='')
	{
		alert("Please Select Fund Class")
		 return(false);
	}
	else
	{
	document.selmf_easymf_2.action=sel_value;
	document.selmf_easymf_2.submit();
	return true;
	}
}

function sel_easymf_form_3()
{
	var sel_value = document.selmf_easymf_3.criteria_3.value;
	if (sel_value=='')
	{
		alert("Please Select a Criteria")
		 return(false);
	}
	else
	{
	document.selmf_easymf_3.action=sel_value;
	document.selmf_easymf_3.submit();
	return true;
	}
}