//Global Variables
var XmlHttp1,XmlHttp;

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()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttp1 = new ActiveXObject("Msxml2.XmlHttp");
		}
		catch(e)
		{
			try
			{
				XmlHttp1 = new ActiveXObject("Microsoft.XmlHttp");
			} 
			catch(oc)
			{
				XmlHttp1 = null;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if(!XmlHttp1 && typeof XmlHttpRequest != "undefined") 
		{
			XmlHttp1 = new XmlHttpRequest();
		}
	}
	


//For Market commentry
function getMarketNews(subsecid)
	{
		CreateXmlHttp1();
		//document.body.style.cursor = "progress";
		
		if(subsecid!="")
		{
			for(var i=3;i<=6;i++)
			{
				document.getElementById("TD"+i).className ="tabhome1"; 
			}	
			document.getElementById("TD"+subsecid).className = "select";
		}
		
		var MktCom = document.getElementById("MktCom");
		
		MktCom.innerHTML ="<img src=../images/loading1.gif>";
		var requestUrl = "../GetMktCommentary.aspx?subsecid="+ subsecid+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();		
		
		if(subsecid==3) document.getElementById("MCMoreLink").href="http://www.ghallabhansali.com/ghalla-bhansali-markets/trend.asp?id=1";
		else if(subsecid==4) document.getElementById("MCMoreLink").href="http://www.ghallabhansali.com/ghalla-bhansali-markets/trend.asp?id=2";
		else if(subsecid==5) document.getElementById("MCMoreLink").href="http://www.ghallabhansali.com/ghalla-bhansali-markets/trend.asp?id=11";
		else if(subsecid==6) document.getElementById("MCMoreLink").href="http://www.ghallabhansali.com/ghalla-bhansali-markets/trend.asp?id=3";
		
    
		if(XmlHttp1)	
		{			
			XmlHttp1.onreadystatechange = function(){getNewsData(MktCom);};
			XmlHttp1.open("GET", requestUrl,  true);
			XmlHttp1.send(null);

		}
	}

	function getNewsData(id)
	{
	
		if(XmlHttp1.readyState == 4)
		{
		
			if(XmlHttp1.status == 200)
			{			
				id.innerHTML = XmlHttp1.responseText; 
			}
		}
	}
	
	//MF news
	
	function details(sno,secid,subsecid)
	{
	var wind_new;
	wind_new=window.open("../newsdetails.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 GetNewsDetails(secid,subsecid,sno)
	{	
		var newWin=window.open("../newsdetails.aspx?secid="+secid+"&subsecid="+subsecid+"&sno="+sno+"",'MyWindow2','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=580,height=470,screenX=0,screenY=0,left=210,top=200');	
	}	



//MF-Hist Nav

function CreateXmlHttpScheme()
{
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttpSch = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpSch = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpSch = null;	
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttpSch && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpSch = new XMLHttpRequest();
	}
}



function SelectScheme(id)
	{	
		var fund = document.getElementById("_ctl0_FundCat1_drp_FundHouse");
		var category = document.getElementById("_ctl0_FundCat1_drp_Category");
		var scheme = document.getElementById("_ctl0_FundCat1_drp_Scheme");
		var Period = document.getElementById("_ctl0_FundCat1_drp_Period");
		var Month =document.getElementById("_ctl0_FundCat1_MonthDrop");
		
		var requestUrl
		CreateXmlHttpScheme();
		document.body.style.cursor = "progress";

		 if(id=="5")
		{
			requestUrl = "../MutualFund/MF_SchemeData.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&Fund="+ fund.value +"&Category="+category.value+"&scheme="+scheme.value;

			if(XmlHttpSch)	{
				XmlHttpSch.onreadystatechange = function(){getSchemeResp(scheme)};
				XmlHttpSch.open("GET", requestUrl,  true);
				XmlHttpSch.send(null);
			}
		}
		
		
	}
	
	//Called when response comes back from server Only For MF_SchemeData
	function getSchemeResp(ig_)
	{
		// To make sure receiving response data from server is completed
		if(XmlHttpSch.readyState == 4)
		{
			// To make sure valid response is received from the server, 200 means response received is OK
			if(XmlHttpSch.status == 200)
			{
				var strData = XmlHttpSch.responseText

				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 ShowDerMFData(id)
	{
	switch(id)
		{
			case "MF":
				document.getElementById("MFData").innerHTML = "<b>&nbsp;Mutual Fund</b>";
				document.getElementById("DervData").innerHTML = "&nbsp;Derivative";	
				
				document.getElementById("MFData").className = "mfdertextsel";
				document.getElementById("DervData").className = "mfdertext";
				
				document.getElementById("tblMFNews").style.display = "inline";	
				document.getElementById("tblDerNews").style.display = "none";											
			break;
			
			case "DER":
				document.getElementById("MFData").innerHTML = "&nbsp;Mutual Fund";
				document.getElementById("DervData").innerHTML = "<b>&nbsp;Derivative</b>";	
				
				document.getElementById("MFData").className = "mfdertext";
				document.getElementById("DervData").className = "mfdertextsel";
				
				document.getElementById("tblMFNews").style.display = "none";	
				document.getElementById("tblDerNews").style.display = "inline";			
			break;
		}
	}
	