function getXMLHTTP() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else {
		if (window.Ajax_XMLHttpRequestProgID) {
			return new ActiveXObject(window.Ajax_XMLHttpRequestProgID);
		} else {
			var progIDs = ["Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
			for (var i = 0; i < progIDs.length; ++i) {
				var progID = progIDs[i];
				try {
					var x = new ActiveXObject(progID);
					window.Ajax_XMLHttpRequestProgID = progID;
					return x;
				} catch (e) {
				}
			}
		}
	}
	return null;
}

function setContent(url, symbol)
{
	var xmlhttp=getXMLHTTP();
	xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4)
			{
				try{
					document.getElementById(symbol).innerHTML = xmlhttp.responseText;	
				}catch (e){
					}
			}
		}
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}

function _genRightNav(symbol)
{
	setContent("link/" + symbol + ".ashx", symbol);
}
function _genRightNavExt(symbol, ticker)
{
	setContent("link/" + symbol + ".ashx?tickers=" + ticker, symbol);
}

function winOpen(url,width,height) {
	    //Incoming width and height are formatted for IE on windows platform.		
		if ((navigator.appVersion.indexOf("Mac") != -1) && (navigator.appName == "Microsoft Internet Explorer")) {
		    height = height * .892;
			window.open(url,'macie','menubar=no,resizable=yes,status=no,width='+width+',height='+height); }
		if ((navigator.appVersion.indexOf("Mac") != -1) && (navigator.appName == "Netscape")) {
		    height = height * .941;
			window.open(url,'macNN','menubar=no,resizable=yes,status=no,width='+width+',height='+height); }		
		if ((navigator.appVersion.indexOf("Win") != -1) && (navigator.appName == "Netscape")) {
		    height = height * 1.059;
			window.open(url,'NN','menubar=no,resizable=yes,status=no,width='+width+',height='+height); }
		if ((navigator.appVersion.indexOf("Win") != -1) && (navigator.appName == "Microsoft Internet Explorer")) {
			window.open(url,'IE','menubar=no,resizable=yes,width='+width+',height='+height); }	
}

//Henry add xml request functions
function _requesRightNav(symbol, titleid,ticker)
{
    var url=ticker?"link/" + symbol + ".ashx?tickers=" + ticker:"link/" + symbol + ".ashx";
    var callback=function(data)
    {
         if($(data).find("premcontent").length>0 && $(data).find("premcontent").text()=="true")
         {
            $('#'+titleid).html('<div class="menu_close"></div><img src="http://im.morningstar.com/im/premIcon.gif" width="11" height="10" border="0"/><img src="http://im.morningstar.com/im/dot_clear.gif" width="5" height="10" border="0"/>'+$(data).find("title").text());
         }
         else
         {
            $('#'+titleid).html('<div class="menu_close"></div>'+$(data).find("title").text());
         }
         var symbolHtml='';
         $(data).find("data").find("link").each(
            function()
            {
                symbolHtml+='<a class="arow_b2a atext_b2" href="'+$(this).find("href").text()+'">'+$(this).find("value").text()+'</a>';
            }
         );
         $('#'+symbol).html(symbolHtml);
    }
     $.ajax({ type: "GET", url: url, dataType: "xml", timeout:100000, success: callback,error:null});
    
}