var xmlHttp

// Debug
function dynamicPhoto(str)
{ 
	xmlHttp=getAJAXHandler();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="/js/_galleryPhotoServer2.cfm";
	url=url+"?picid="+str;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	function stateChanged() 
	{ 
		if (xmlHttp.readyState==4)
		{ 
			getElementWithID(photodiv).innerHTML=xmlHttp.responseText;
			if(photodiv == 'photoa'){ photodiv = 'photob'; }
			else { photodiv = 'photoa'; }
			// alert('content:'+trim(xmlHttp.responseText)+'Next Profile div: '+profilediv);
			//alert('PID: '+str+' NewPicture: '+newPicture);
			if (newPicture != 0) {
			   getstyle("prof"+newPicture).visibility = "visible";
			}
			//alert('Visible');
			if (document.getElementById("thumb"+currentPicture).className == "thumb last curr"){
				document.getElementById("thumb"+currentPicture).className = "thumb last";
			}else{
				document.getElementById("thumb"+currentPicture).className = "thumb";
			}
			if (newPicture != 0) {
			   if (document.getElementById("thumb"+newPicture).className == "thumb last"){
				   document.getElementById("thumb"+newPicture).className = "thumb last curr";
			   }else{
				   document.getElementById("thumb"+newPicture).className = "thumb curr";
			   } 
			}
			//alert('preanimate');
			if(!firstclick)animate();
		}
	}
}

function getAJAXHandler()
{
	var ajaxHandler = false;
	try	//Good browsers
	{		ajaxHandler = new XMLHttpRequest();		}
	catch(e1)
	{
		try	//Some versions of IE
		{			ajaxHandler = new ActiveXObject("Msxml2.XMLHTTP");		}
		catch(e2)
		{	
			try	//Some other versions of IE
			{				ajaxHandler = new ActiveXObject("Microsoft.XMLHTTP");			}
			catch(e3)	//No dice?  What a drag.
			{				return false;			}
		}
	}
	return ajaxHandler;
}

function getElementWithID(id)
{
	var elementPtr = false;
	if (document.getElementById)
		elementPtr = document.getElementById(id);
	else if (document.all)
		elementPtr = document.all[id];
	else if (document.layers)
		elementPtr = document.layers[id];
	return elementPtr;
}

function toggleDisplay(id)
{
	var box = getElementWithID(id);
	if(box == null)
	{
		alert(id + " not found in page");
		return false;
	}
	if(box.style.display.toLowerCase() == "none")
		box.style.display = "block";
	else
		box.style.display = "none";
	return false;
}

function setDisplay(id, flag)
{
	var box = getElementWithID(id);
	if(box == null)
	{
		alert(id + " not found in page");
		return false;
	}
	//Ensure that flag is a valid value
	flag = flag.toLowerCase();
	switch(flag)
	{
		case 'none':
		case 'block':
		case 'inline':
			break;

		default:
			flag = 'none';
			break;
	}
	box.style.display = flag;
	return false;
}

function toggleVisibility(id)		{	return toggleDisplay(id);	}
function setVisibility(id, flag)	{	return setDisplay(id, flag);	}
