function newXMLHttpRequest()
{
	var xmlreq = false;

	if(window.XMLHttpRequest)
	{

	// Create XMLHttpRequest object in non-Microsoft browsers
	xmlreq = new XMLHttpRequest();
	
	}
	else if(window.ActiveXObject)
	{

		// Create XMLHttpRequest via MS ActiveX
    	try
    	{
		// Try to create XMLHttpRequest in later versions
		// of Internet Explorer

		xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
		
		}
		catch(e1)
		{

		// Failed to create required ActiveXObject

			try
			{
			// Try version supported by older versions of Internet Explorer
			
			xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
			
			}
			catch(e2)
			{

			// Unable to create an XMLHttpRequest with ActiveX
			}
    	}
	}

	return xmlreq;
}

function updateDiv(div,url)
{
	var div = document.getElementById(div);
	
	var req = newXMLHttpRequest();
	
	req.onreadystatechange = function()
	{
		if(req.readyState == 4)
		{
			// Check that a successful server response was received
			if(req.status == 200)
			{
				div.innerHTML = req.responseText;
				//alert(req.responseText);
			}
			else
			{
        		// An HTTP problem has occurred
        		alert("HTTP error: " + req.statusText);
      		}
		}
	}
	
	req.open("GET", url, true);
	req.send(null);
}

function showLayer(div)
{
	var div = document.getElementById(div);

	if(div.style.display == 'block')
	{
		div.style.display = 'none';
	}
	else
	{
		div.style.display = 'block';
		div.style.opacity = 0;
		div.style.filter = 'alpha(opacity=0)';
	}
	
	startFade(div);
}

function switchLayer(div,layerClass)
{	
	var collect = document.getElementsByTagName("DIV");
	
	var temp = new Array();
	
	for(var x = 0; x < collect.length; x++)
	{
		if(collect[x].className == layerClass)
		{
			temp.push(collect[x]);
		}
	}
	
	collect = temp;
	
	for(var x = 0; x < collect.length; x++)
	{
		if(collect[x].id == div)
		{
			collect[x].style.display = 'block';
			collect[x].style.opacity = 0;
			fader = collect[x];
		}
		else
		{
			collect[x].style.display = 'none';
		}
	}
	
	startFade(fader);
}

function startFade(div)
{
	fader = div;
	
	for(var x = 0; x < 11; x++)
	{
		setTimeout('fadeMe(' + x + ')',30*x);
	}
}

function fadeMe(value)
{	
	fader.style.opacity = value/10;
	fader.style.filter = 'alpha(opacity='+ (value * 10) +')';
}

function findParent(thenode,tag)
{
	// Keep bubbling up until we find the tag that we need
	var findp = thenode;
	while(findp.nodeName != tag)
	{
		findp = findp.parentNode;
	}
	
	return findp;
}

function setBox(box,theClass)
{
	box.value = "";
}

function next(div,classname)
{
	var div = document.getElementById(div);
	
	var collect = div.getElementsByTagName("DIV");
	
	var temp = new Array();
	
	for(var x = 0; x < collect.length; x++)
	{
		if(collect[x].className == classname)
		{
			temp.push(collect[x]);
		}
	}
	
	collect = temp;
	
	var current;
	
	for(var x = 0; x < collect.length; x++)
	{
		if(collect[x].style.display == 'block')
		{
			current = x;
		}
	}
	
	if((current + 1) < collect.length)
	{
		current += 1;
		
		for(var x = 0; x < collect.length; x++)
		{
			if(x == current)
			{
				collect[x].style.display = 'block';
			}
			else
			{
				collect[x].style.display = 'none';
			}
		}
	}
	else
	{
		current = 0;
		
		for(var x = 0; x < collect.length; x++)
		{
			if(x == current)
			{
				collect[x].style.display = 'block';
			}
			else
			{
				collect[x].style.display = 'none';
			}
		}
	}
}

function prev(div,classname)
{
	var div = document.getElementById(div);
	
	var collect = div.getElementsByTagName("DIV");
	
	var temp = new Array();
	
	for(var x = 0; x < collect.length; x++)
	{
		if(collect[x].className == classname)
		{
			temp.push(collect[x]);
		}
	}
	
	collect = temp;
	
	var current;
	
	for(var x = 0; x < collect.length; x++)
	{
		if(collect[x].style.display == 'block')
		{
			current = x;
		}
	}
	
	if((current - 1) < 0)
	{
		current = collect.length - 1;
		
		for(var x = 0; x < collect.length; x++)
		{
			if(x == current)
			{
				collect[x].style.display = 'block';
			}
			else
			{
				collect[x].style.display = 'none';
			}
		}
	}
	else
	{
		current -= 1;
		
		for(var x = 0; x < collect.length; x++)
		{
			if(x == current)
			{
				collect[x].style.display = 'block';
			}
			else
			{
				collect[x].style.display = 'none';
			}
		}
	}
}

window.onload = function(){ setTimeout('showLayer("bubble")',2000);}
