// Panel Sliding Functions

function SlidePanelClose(panelID, height) {
	var panel = document.getElementById(panelID).cells[0];
	var newHeight = height - 20;
	
	if (panel.style.height.replace("px", "") > 20) {
		panel.style.height = (newHeight < 0 ? 0 : newHeight);
		setTimeout("SlidePanelClose('" + panelID + "', " + (newHeight) + ")", 10);
	}
	else {
		panel.style.height = 20;
		panel.style.display = "none";
	}		
}

function SlidePanelOpen(panelID, height, maxHeight) {
	var panel = document.getElementById(panelID).cells[0];
	var newHeight = (height == 0 ? panel.clientHeight : height) + 20;
	
	if (newHeight < (maxHeight+20)) {
		panel.style.height = (newHeight < 0 ? 0 : newHeight);
		setTimeout("SlidePanelOpen('" + panelID + "', " + (newHeight) + "," + maxHeight + ")", 10);
	}
}

function TogglePanel(container, symbol, gameID, TradeTicketID, TradeID) {
	var displayTR = document.getElementById(container.id + "_HP");
	
	
	if (displayTR.cells[0].style.display == "none") {
		if ((navigator.userAgent.toLowerCase().indexOf("gecko") > -1) ||
			(navigator.userAgent.toLowerCase().indexOf("opera") > -1))
		{
			displayTR.cells[0].style.display = "table-cell";
		}
		else {
			displayTR.cells[0].style.display = "inline";
		}
			
		if (displayTR.cells[0].innerHTML.indexOf("Loading...") > -1) {
			//SendQuery(displayTR, symbol, gameID, TradeTicketID, TradeID);
		}
		else	
			SlidePanelOpen(displayTR.id, 0, 165);
	}
	else
		SlidePanelClose(displayTR.id, 100);
}

// Panel Sliding Functions End

// Ajax Functions

function Initialize() {
    /*try {
        req=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) {
        try {
            req=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(oc) {
            req=null;
        }
    }

    if(!req&&typeof XMLHttpRequest!="undefined") {
        req=new XMLHttpRequest();
    }
	*/
}

function SendQuery(Container, symbol, gameID, TradeTicketID, TradeID) {
	var req;
	/*
	try {
        req=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) {
        try {
            req=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(oc) {
            req=null;
        }
    }

    if(!req&&typeof XMLHttpRequest!="undefined") {
        req=new XMLHttpRequest();
    }
    
    var url = "http://simulator.investopedia.com/MyPortfolio/AJAX/GetPortDetails.aspx?Symbol=" + symbol + "&GameID=" + gameID + "&TradeTicketID=" + TradeTicketID + "&TradeID=" + TradeID;
	
    if(req!=null) {
        req.onreadystatechange = 
			function() {
				if (req.readyState == 4) {
					if (req.status == 200) {
						Container.cells[0].innerHTML = req.responseText;          
						SlidePanelOpen(Container.id, 1, 165);
					}
				else
					Container.innerHTML = "There was a problem retrieving data: " + req.statusText;
				}
			}
			
			
        req.open("GET", url, true);
        req.send(null);
    }
	*/
}