var requestUrl='getcontent.aspx';
var xmlHttp;
var levContent;

function LoadContent(level, id) {
	var url = requestUrl + '?id' + level + '=' + id;
	levContent = level;
	xmlHttp = GetXmlHttpObject(stateChangeHandler);
	if (xmlHttp != null)
	{
		if (level == 2)
		{
			document.getElementById('SecondContent').innerHTML = 'Wait...';
			document.getElementById('ThirdContent').innerHTML = '';
			var coll = document.getElementById('FirstContent').getElementsByTagName('li');
			for(i = 0; i < coll.length; i++)
			{
				coll[i].className = '';
			}
			document.getElementById('First' + id).className = 'active';
		}
		else {
			if (level == 3)
			{
				document.getElementById('ThirdContent').innerHTML = 'Wait...';
				var coll = document.getElementById('SecondContent').getElementsByTagName('li');
				for(i = 0; i < coll.length; i++)
				{
					coll[i].className = '';
				}
				document.getElementById('Second' + id).className = 'active';
			}
		}
	    xmlHttp_Get(xmlHttp, url); 
	    return false;
	}
	else
	{
		return true;
	}
}

function stateChangeHandler() 
{ 
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete'){ 
        var str = xmlHttp.responseText; 
        var controlId;
        if (levContent == 2)
        {
			controlId = 'Second';
			document.getElementById('ThirdContent').innerHTML = '';
		}
		else
		{
			if (levContent == 3)
			{
				controlId = 'Third';
			}
		}
		if (controlId != '')
		{
			document.getElementById(controlId + 'Content').innerHTML = str; 
		}
    } 
}

function xmlHttp_Get(xmlhttp, url) { 
    xmlhttp.open('GET', url, true); 
    xmlhttp.send(null); 
} 

function GetXmlHttpObject(handler) {
	var objXmlHttp = null;
	try {
		objXmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
		objXmlHttp.onreadystatechange = handler;
		}
	catch (e1) {
		try {
			objXmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
			objXmlHttp.onreadystatechange = handler;
			}
		catch (e2) {
			try {
				objXmlHttp = new XMLHttpRequest();
				objXmlHttp.onload = handler;
				objXmlHttp.onerror = handler;
				}
			catch (e3) {
				objXmlHttp = null;
				}
			}
		}
	return objXmlHttp;
}

