var xhrObj = false;

if (window.XMLHttpRequest) {
	xhrObj = new XMLHttpRequest() ;
}	else if (window.ActiveXObject) {
		xhrObj = new ActiveXObject("Microsoft.XMLHTTP");
}

function newWindow(xPage)
{
nw1_w=600;nw1_l=10
nw1_h=400;nw1_t=10
nw1_p="toolbar=yes,width="+nw1_w+",height="+nw1_h+",location=no,left="+nw1_l+",top="+nw1_t
nw1=window.open(xPage,"win1",nw1_p)
}
function real_eAddress (x_eAddress)
{
w_eAddress=x_eAddress.replace(/zzz.zz/,"org.uk");
w_eAddress=w_eAddress.replace(/£/,"@");
w_eAddress=w_eAddress.replace(/#/g,".");
w_aTag="<A href='mailto:"+w_eAddress+"'>"+w_eAddress+"</a>";
return(w_aTag);
}

function getData(dataSource, divID) 
  { 
	if(xhrObj) {
	  var obj = document.getElementById(divID); 
	  xhrObj.open("GET", dataSource, false); // false = sync !!!

	  xhrObj.onreadystatechange = function() 
	  { 
		if (xhrObj.readyState == 4 && 
		  xhrObj.status == 200) { 
			obj.innerHTML = xhrObj.responseText; 
		} 
	  } 

	  xhrObj.send(null); 
	}
}
function getDataNEW(dataSource, divID) 
  { 
	if(xhrObj) {
		var obj = document.getElementById(divID); 
		xhrObj.open("GET", dataSource, false); // false = sync !!!
		xhrObj.send(null); 
		if (xhrObj.readyState == 4 && 
			xhrObj.status == 200) { 
			obj.innerHTML = xhrObj.responseText; 
		} 
	}
}

function getPicture(year, picNo, divID) { 
	picData = "pics/pictureframe.php?picNo=" + picNo + "&year=" + year;
	
	if(xhrObj) {
		var obj = document.getElementById(divID); 
		xhrObj.open("GET", picData, false); // false = sync !!!
		xhrObj.send(null); 
		if (xhrObj.readyState == 4 && 
			xhrObj.status == 200) { 
			obj.innerHTML = xhrObj.responseText; 
		} 
	}
}
function toggleLayer( whichLayer, year, picNo ){
	var elem, vis;  
	
	if( document.getElementById ) // this is the way the standards work    
		elem = document.getElementById( whichLayer );  
	else if( document.all ) // this is the way old msie versions work      
		elem = document.all[whichLayer];  
			else if( document.layers ) // this is the way nn4 works    
				elem = document.layers[whichLayer];  
				
	vis = elem.style;  

// if the style.display value is blank we try to figure it out here  
	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
		vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  

	newDisplay = (vis.display==''||vis.display=='block')?'none':'block';
	
	if (newDisplay=='block'){
		getPicture(year, picNo, 'pictureFrame');
	}
	
	vis.display = newDisplay;
	

}