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 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();
	}
}


function SelectScheme(ig_,ig_a,ig_b)
	{
		
		var fund = document.getElementById("ctl12_drp_FundHouse");
		var category = document.getElementById("ctl12_drp_Category");
		var scheme = document.getElementById("ctl12_drp_Scheme");
		//alert(category.value);
		scheme.options[0] = new Option();
		scheme.options[0].text = "Loading.....";
		
		CreateXmlHttp();
		document.body.style.cursor = "progress";
		var requestUrl = "MF_SchemeData.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&Fund="+ fund.value +"&Category="+category.value;
		//alert(requestUrl);
		if(XmlHttp)	{
					XmlHttp.onreadystatechange = function(){getSchemeResp555(scheme)};
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
				}
	}
	
		
	//Called when response comes back from server Only For MF_SchemeData
function getSchemeResp555(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)
		{
			//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 = "";
					ig_.options[0].text = "Scheme is not available";			
			}
			document.body.style.cursor = "auto";	
		}
		else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "server is not ready";
					document.body.style.cursor = "auto";		
		}
	}
}	



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) +"'><span class=alpha id = spn"+String.fromCharCode(i)+">"+ String.fromCharCode(i) +"</span></a> <span class='Divider'> &nbsp; </span>";
				A2Z += "<a href='"+ redUrl_ +"&var='><span class=alpha id = spn>ALL</span></a>";
				//A2Z = A2Z.substring(0,A2Z.length -32)
				A2ZIndexId.innerHTML = A2Z;
				//MenuTextBoldRd
	}
	else
		A2ZIndexId.innerHTML = "";			
}

function SelectSchemee(ig_,ig_a,ig_b)
	{
		
		var fund = document.getElementById("ctl12_drp_FundHouse");
		var category = document.getElementById("ctl12_drp_Category");
		var scheme = document.getElementById("ctl12_drp_Scheme");
		
		scheme.options[0] = new Option();
		scheme.options[0].text = "Loading.....";
		
		CreateXmlHttp();
		document.body.style.cursor = "progress";
		var requestUrl = "MF_SchemeData.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&Fund="+ fund.value +"&Category="+category.value;
		//alert(requestUrl)
		if(XmlHttp)	{
					XmlHttp.onreadystatechange = function(){getSchemeResp555(scheme)};
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
				}
	}
	
	//Called when response comes back from server Only For MF_SchemeData
function getSchemeResp555(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)
		{
			//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 = "";
					ig_.options[0].text = "Scheme is not available";			
			}
			document.body.style.cursor = "auto";	
		}
		else {
					ig_.length = 0;
					ig_.options[0] = new Option();
					ig_.options[0].value = "";
					ig_.options[0].text = "server is not ready";
					document.body.style.cursor = "auto";
		}
	}
}	


function SelectScheme6(ig_,ig_a,ig_b)
	{

		var scheme = document.getElementById("_ctl12_drp_Scheme");		
		var TopHold=document.getElementById("Top10Hold");
		//alert(scheme.value )
		CreateXmlHttp();
		document.body.style.cursor = "progress";
		var requestUrl = "MF_SchemeData2.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&Scheme="+scheme.value;
		//alert(requestUrl);
		 if(XmlHttp)	
		 {
			XmlHttp.onreadystatechange = function(){getSchemeResp3(scheme)};
			XmlHttp.open("GET", requestUrl,  true);
			XmlHttp.send(null);
		}
	}
	
	function getSchemeResp3(ig_)
	{
		var TopHold=document.getElementById("Top10Hold");
		// To make sure receiving response data from server is completed
		if(XmlHttp.readyState == 1)
		{
		TopHold.innerHTML = "<img src='../images/loading1.gif'>";
		}
		else 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 availSchemes   = document.getElementById(ig_);
			
				TopHold.innerHTML = XmlHttp.responseText
				document.body.style.cursor = "auto";
			//	alert(TopHold.innerHTML);
			}			
		}
	}
	
	
	//For Loading News from NewsData.aspx Using AJAX
function GetNewsDet(secId,SrNo)
	{
		var currentDivObj = document.getElementById(SrNo);
		if(currentDivObj.style.display=='inline')
		{
				currentDivObj.style.display ='none';
				eval("document.IMG"+SrNo+".src = '../images/tickerplus1.gif'");
		}
		else
		{
				currentDivObj.style.display ='inline';
				eval("document.IMG"+SrNo+".src = '../images/tickerminus1.gif'");
				var tblObj=document.getElementById("NewsId").getElementsByTagName("td");
				var IdName;
				for(var i=1;i<tblObj.length;i++){
					IdName = tblObj[i].id;
					if(IdName)
						if(IdName!=SrNo){
							document.getElementById(IdName).style.display = "none";eval("document.IMG"+IdName+".src = '../images/tickerplus1.gif'");}}

				if(currentDivObj.innerHTML=="")
				{
					currentDivObj.innerHTML ="<img src=../images/loading1.gif>";
					CreateXmlHttp();
					document.body.style.cursor = "progress";
					var requestUrl = "NewsData.aspx?SecId="+ secId +"&SrNo="+ SrNo +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
					if(XmlHttp)	{
								XmlHttp.onreadystatechange = function(){getNewsDetResp(SrNo);};
								XmlHttp.open("GET", requestUrl,  true);
								XmlHttp.send(null);
							}
				}
			}	
	}
//Called when response comes back from server Only For NewsData
function getNewsDetResp(SrNo)
{
	// 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)
		{
			document.getElementById(SrNo).innerHTML = XmlHttp.responseText;
			document.body.style.cursor = "auto";
		}
		else
			document.getElementById(SrNo).innerHTML = "<img src='../images/loading1.gif'>";
	}
}

function showSnapChart(code,period)
{

	var period;
	var periodVal = period.substr(0,1);
	var period = period.substr(1,1)
	document.getElementById("SnapChart").src= "mfchart.aspx?Mfcode="+ code +"&Period="+ period +"&PeriodVal="+periodVal;
}

function showAssetChart(code,opt)
{
	var opt1;
	var code1;
	opt1 = opt;
	code1 = code;
	document.getElementById("AssetChart").src= "AssetChart.aspx?Mfcode="+ code1 +"&opt="+opt1;
}


