
function Validation(obj1,obj2)
		{
	
			var FRmDate = document.getElementById(obj1).value.split('/');
			var ToDate = document.getElementById(obj2).value.split('/');
			var FVal = document.getElementById(obj1).value;
			var EVal = document.getElementById(obj2).value;
			sDay=FRmDate[0];
			sMonth=FRmDate[1];
			sYear=FRmDate[2];
			eDay=ToDate[0]
			eMonth=ToDate[1];
			eYear=ToDate[2];
			
			if(eval(sYear)%4==0 && eval(sMonth)==2 && eval(sDay)>29)
			{
				alert("Start Day can't be greater than 29");
				document.getElementById(obj1).focus();
				return false;
			}
			else if(eval(sMonth==2) && eval(sDay)>28)
			{
				alert("Start Day can't be greater than 28");
				document.getElementById(obj1).focus();
				return false;
			}
			else if((eval(sMonth)==4 || eval(sMonth)==6 || eval(sMonth)==9 || eval(sMonth==11)) && eval(sDay)>30)
			{
				alert("Start Day can't be greater than 30");
				document.getElementById(obj1).focus();
				return false;
			}
			else if(eval(eYear%4)==0 && eval(eMonth)==2 && eval(eDay)>29)
			{
				alert("End Day can't be greater than 29");
				document.getElementById(obj2).focus();
				return false;
			}
			else if(eval(eMonth)==2 && eval(eDay)>28)
			{
				alert("End Day can't be greater than 28");
				document.getElementById(obj2).focus();
				return false;
			}
			else if((eval(eMonth)==4 || eval(eMonth)==6 || eval(eMonth)==9 || eval(eMonth)==11) && eval(eDay)>30)
			{
				alert("End Day can't be greater than 30");
				document.getElementById(obj2).focus();
				return false;
			}
			else if(eval(sDay) > eval(eDay) && eval(sMonth)==eval(eMonth) && eval(sYear)==eval(eYear))
			{
				alert("Start date can't be greater than End date");
				document.getElementById(obj1).focus();
				return false;
			}	
			else if(eval(sYear)==eval(eYear))
			{
				if (eval(sMonth) > eval(eMonth))
				{
					alert("Start month can't be greater than To month")
					document.getElementById(obj1).focus();
					return false; 
				}
			}			
			else if(eval(sYear) > eval(eYear))
			{
				alert("Select proper year")
				document.getElementById(obj2).focus();
				return false; 
			}
			
	}		

function CategoryRet(Type)
{
	var Type;
	var EquityId = document.getElementById("CategoryRetCtrl1_EquityId");
	var DebtId  =  document.getElementById("CategoryRetCtrl1_DebtId");
	var BalancedId  =  document.getElementById("CategoryRetCtrl1_BalancedId");
		switch(Type)
		{
			case "EQUITY":
						document.ImgReturnTab.src = "../images/EquityOn.gif";
						EquityId.style.display = "inline";
						DebtId.style.display = "none";
						BalancedId.style.display = "none";				
						break;
			case "DEBT":
						document.ImgReturnTab.src = "../images/DebtOn.gif";
						EquityId.style.display = "none";
						DebtId.style.display = "inline";
						BalancedId.style.display = "none";							
						break;
			case "BALANCED":
						document.ImgReturnTab.src = "../images/BalancedOn.gif";
						EquityId.style.display = "none";
						DebtId.style.display = "none";
						BalancedId.style.display = "inline";							
						break;
		}
}

//Global Variables
var XmlHttp;

//Creating object of XMLHTTP For AJAX Method
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();
		}
	}


//For Loading ticker from MfTopGLData.aspx Using AJAX
function loadGLData(Period,Category,TopGl)
		{
		CreateXmlHttp();
		document.body.style.cursor = "progress";
		var TopGl;
		if(Period=='')
			Period = "1YEAR";
		if(Category=='')	
			Category="ALL";
		//var requestUrl = "MfTopGLData.aspx?Period="+ Period +"&Cat="+ Category +"&GL="+ TopGl;
		var requestUrl = "MFtopglData.aspx?Period="+ Period +"&Cat="+ Category +"&TopGl="+ TopGl;
		if(XmlHttp)	{
					XmlHttp.onreadystatechange = function(){GLResponse(TopGl)}
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
				}
	}
	
//For verifing ticker from MfTopGLData.aspx Using AJAX
function CheckUser(cin)
		{
		var CINid = document.getElementById("CIN");
		if(cin !="")
		{
		CreateXmlHttp();
		document.body.style.cursor = "progress";
		var requestUrl = "../admin/Regdata.aspx?cin="+cin;
		if(XmlHttp)	{
					XmlHttp.onreadystatechange = function(){RegDataResponse()}
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
				}
		}
		else
		{
		alert("Please Enter your CIN");
		CINid.focus();
		}
	}	
	//Called when response comes back from server Only For Ticker
function RegDataResponse()
{
	
	var ResultId = document.getElementById("ResultId1");
	ResultId.innerHTML="";
	var CINid = document.getElementById("CIN");
	var PasswordId = document.getElementById("Password");
	var RepasswordId = document.getElementById("Confirm_password");
	var MobileId = document.getElementById("Mobile");
	var EmailId = document.getElementById("Email");
	// 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 strRegData = XmlHttp.responseText
			if(strRegData!="invalid")
			{
				if(strRegData!="register")
				{			
					var strData = strRegData.split('|');
					CINid.value = strData[0];
					PasswordId.value = strData[1];
					RepasswordId.value = strData[1];
					MobileId.value = strData[2];
					EmailId.value = strData[3];
					if(MobileId.value=="")
					{
					ResultId.innerHTML = "Please enter your mobile number for getting sms service";
					MobileId.focus();			
					}
				}
				else
					ResultId.innerHTML = "Please Complete your Registration";
			}
			else
			{
			ResultId.innerHTML = "You are not a valid user";
			}
			
			document.body.style.cursor = "auto";
		}
		else
		{
			ResultId.innerHTML =  "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
}		 
	
function Register(mode)
		{	
	var ResultId = document.getElementById("ResultId");
	var CINid = document.getElementById("CIN").value;
	var PasswordId = document.getElementById("Password").value;
	var RepasswordId = document.getElementById("Confirm_password").value;
	var MobileId = document.getElementById("Mobile").value;
	var EmailId = document.getElementById("Email").value;Pass
	var Pass = document.getElementById("Pass").value;
	var CIN_No = document.getElementById("CIN_No").value;
		
		CreateXmlHttp();
		document.body.style.cursor = "progress";
		if(mode!="login")
		var requestUrl = "../admin/UpdateRegDetails.aspx?cin="+CINid+"&password="+PasswordId+"&Mobile="+MobileId+"&Email="+EmailId+"&mode="+mode;
		else
		var requestUrl = "../admin/UpdateRegDetails.aspx?cin="+CIN_No+"&password="+Pass+"&mode=login";
		
		if(XmlHttp)	{
					XmlHttp.onreadystatechange = function(){DataResponse()}
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
				}
		
		
	}	
	
	function DataResponse()
		{
		var Tabid =  document.getElementById('RegistForm');
		var cinno =  document.getElementById('CIN_No').value;
		var pass =  document.getElementById('pass').value;
		var loginformid =  document.getElementById('loginform');
		loginformid.style.display='inline'
		Tabid.style.display='none'
		// To make sure receiving response data from server is completed
		var ResultId = document.getElementById("ResultId");
		ResultId.innerHTML="";
		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 strRegData = XmlHttp.responseText
				if(strRegData=="loginvalid")
				window.location ="../res_demo.aspx?name="+cinno;
				else if(strRegData=="invalid")
				ResultId.innerHTML ="You CIN or Password is incorrect";
				else if(strRegData=="NOTVALID")
				ResultId.innerHTML ="Your are not a valid user";
				else if(strRegData=="Y")
				ResultId.innerHTML ="Your Details are updated";
				else
				ResultId.innerHTML ="Your Details are not updated.Try again";				
				document.body.style.cursor = "auto";
			}
			else
			{
				ResultId.innerHTML =  "There was a problem retrieving data from the server.";
				document.body.style.cursor = "auto";
			}
		}
		}	

//Called when response comes back from server Only For Ticker
function GLResponse(TopGl)
{
	// 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 GainerId = document.getElementById("GainerLoserCtrl1_GainerId");
			var LoserId  = document.getElementById("GainerLoserCtrl1_LoserId");
			var strGlData = XmlHttp.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 Loading ticker from CategoryRetData.aspx Using AJAX
function loadCatRet(Period)
	{
		CreateXmlHttp();
		document.body.style.cursor = "progress";
		if(Period=='')
			Period = "1YEAR";
		var requestUrl = "CategoryRetData.aspx?Period="+Period;
		if(XmlHttp)	{
					XmlHttp.onreadystatechange = CatRetResponse;
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.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(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{			
			var EquityId   = document.getElementById("CategoryRetCtrl1_EquityId");
			var DebtId     = document.getElementById("CategoryRetCtrl1_DebtId");
			var BalancedId = document.getElementById("CategoryRetCtrl1_BalancedId");
			//window.alert(XmlHttp.responseText);
			var strData = XmlHttp.responseText
			if(strData != "")
			{
				var arrDateSplit = strData.split("|");
				EquityId.innerHTML   = arrDateSplit[0];
				DebtId.innerHTML     = arrDateSplit[1];
				BalancedId.innerHTML = arrDateSplit[2];
			}
			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 winpopup(filepath)
{	
	
  	var w1=screen.width;
 	 w1-=300;
 	 var h1=screen.height;
 	 h1-=200;
	 var newWin=window.open(filepath,'win1','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=580,height=360,screenX=0,screenY=0,left=300,top=237');	
}
	
function ShowNews(secid,subsecid,sno)
{	
	fileName = "NewsDetail.aspx?sno="+ sno+"&secid="+ secid+"&subsecid="+ subsecid;
  	var w1=screen.width;
 	 w1-=300;
 	 var h1=screen.height;
 	 h1-=200;
	 var newWin=window.open(fileName,'win1','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=580,height=360,screenX=0,screenY=0,left=300,top=237');	
}
function empty()
{
if (document.getElementById("txtQuotes").value=="Enter Scrip Name/Code")
{
  	document.getElementById("txtQuotes").value="";
 }
}

function fill()
{
	var getquote=document.getElementById("txtQuotes").value;
	if (getquote=="")
	{
		document.getElementById("txtQuotes").value="Enter Scrip Name/Code";
	}
}

function ShowA2ZIndex(){
var A2ZIndexId = document.getElementById("A2ZIndex");
var DropId = document.getElementById("QuotesSearchCtrl_drpQuotes");
var DropValue;
if(DropId.value=="")
DropValue = "1";
else
DropValue = DropId.value;
if(A2ZIndexId.innerHTML==""){
	var A2Z="";
		for(i=65; i<=90; i++)
			A2Z += "<a href='ScripSearch.aspx?opt="+DropValue+"&schtxt="+ String.fromCharCode(i) +"'>"+ String.fromCharCode(i) +"</a> <span class='Divider'> | </span>";
			A2ZIndexId.innerHTML = A2Z;
}
else
	A2ZIndexId.innerHTML = "";
			
}



function ShowA2Z(redUrl_){
	var A2ZIndexId = document.getElementById("A2Z");
	if(A2ZIndexId.innerHTML==""){
		var A2Z="";
			for(i=65; i<=90; i++)
				A2Z += "<a href='"+ redUrl_ +"&var="+ String.fromCharCode(i) +"'>"+ String.fromCharCode(i) +"</a> <span class='Divider'> | </span>";
				A2Z = A2Z.substring(0,A2Z.length -32)
				A2ZIndexId.innerHTML = A2Z;
	}
	else
		A2ZIndexId.innerHTML = "";			
}


function ShownHide(val)
{
var Table1 = document.getElementById("Table1");
var Table2 = document.getElementById("Table2");
var Tab1 = document.getElementById("Tab1");
var Tab2 = document.getElementById("Tab2");
var edg1_ =document.getElementById("edg1_");
var edg2_ =document.getElementById("edg2_");
	
if(val =="1")
{
Table1.style.display = 'inline'
Table2.style.display = 'none'
Tab1.className = 'TableHeadY';
Tab2.className = 'TableHeadAsh';
edg1_.src="../images/Td_SPacer_right.gif";
edg2_.src="../images/Td_SPacer_right.gif";
}
else
{
Table1.style.display = 'none'
Table2.style.display = 'inline'
Tab1.className = 'TableHeadAsh';
Tab2.className = 'TableHeadY';
edg2_.src="../images/Td_SPacer_right.gif";
edg1_.src="../images/Td_SPacer_right.gif";
}
}




function ShownInst(val)
{

var Table1 = document.getElementById("FIIInvest");
var Table2 = document.getElementById("MfInvest");

var Tab1 = document.getElementById("Tab1");
var Tab2 = document.getElementById("Tab2");
var edg1_ =document.getElementById("edg1_");
var edg2_ =document.getElementById("edg2_");


if(val =="1")
{
Table1.style.display = 'inline';
Table2.style.display = 'none';
Tab1.className = 'TableHeadY';
Tab2.className = 'TableHeadAsh';
edg1_.src="../images/Td_SPacer_right.gif";
edg2_.src="../images/Td_SPacer_right.gif";
}
else
{
Table1.style.display = 'none';
Table2.style.display = 'inline';
Tab1.className = 'TableHeadAsh';
Tab2.className = 'TableHeadY';
edg2_.src="../images/Td_SPacer_right.gif";
edg1_.src="../images/Td_SPacer_right.gif";

}
}


function details(sno,secid,subsecid)
 {
	var wind_new;
	wind_new=window.open("newsdetail.aspx?sno="+sno+"&secid="+secid+"&subsecid="+subsecid+"", "DetailNews", "status = 1, height = 350, width =500, resizable = 0,scrollbars=1,left=200,top=200" )
	wind_new.focus();
 }
 function mfdetails(sno,secid,subsecid)
 {
	var wind_new;
	wind_new=window.open("../newsdetail.aspx?sno="+sno+"&secid="+secid+"&subsecid="+subsecid+"", "DetailNews", "status = 1, height = 350, width =500, resizable = 0,scrollbars=1,left=200,top=200" )
	wind_new.focus();
 }
 
 function WinPopup(StrUrl)
 {
 var newWin=window.open(StrUrl,'MyWindow2','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=1,copyhistory=no,width=530,height=300,screenX=0,screenY=0,left=210,top=200');	
 }


function ShowA2ZIndexAll(redUrl_){
	var A2ZIndexId = document.getElementById("A2ZIndex");
	if(A2ZIndexId.innerHTML==""){
		var A2Z="";
			for(i=65; i<=90; i++)
				A2Z += "<a href='"+ redUrl_ +"&var="+ String.fromCharCode(i) +"'>"+ String.fromCharCode(i) +"</a> <span class='Divider'> | </span>";
				A2Z = A2Z.substring(0,A2Z.length -32)
				A2ZIndexId.innerHTML = A2Z;
	}
	else
		A2ZIndexId.innerHTML = "";			
}

function showAssetChart(code,opt)
{
	var opt;
	document.getElementById("AssetChart").src= "AssetChart.asp?MFcode="+ code +"&opt="+opt;
}

function showSnapChart(code,period)
{
	var period;
	var periodVal = period.substr(0,1);
	var period = period.substr(1,1)
	document.getElementById("SnapChart").src= "mfchart.asp?MFcode="+ code +"&Period="+ period +"&PeriodVal="+periodVal;
}