pageLoaded = false;
function photosReturn(xmlObj,whose){
	if (xmlObj.readyState == 4){
		txt = xmlObj.responseText;
//		if (txt == ''){
//			document.location.reload();
//		}else if (txt.length < 2000){
//			alert(txt);//.substr(2000,10000));
//		}else{
//			alert(txt.substr(2000,10000));
//		}
		//get everything between '<td' and '</td>'
		cellStr = '';
		tempStr = txt.substring(txt.indexOf('<td'),txt.indexOf('</td>')+5);
		txt = txt.replace(tempStr,'');
		cellStr += ReplaceAll(tempStr,'td','div');
		//2
		tempStr = txt.substring(txt.indexOf('<td'),txt.indexOf('</td>')+5);
		txt = txt.replace(tempStr,'');
		cellStr += ReplaceAll(tempStr,'td','div');
		//3
		tempStr = txt.substring(txt.indexOf('<td'),txt.indexOf('</td>')+5);
		txt = txt.replace(tempStr,'');
		cellStr += ReplaceAll(tempStr,'td','div');

		document.getElementById('photos'+whose).innerHTML = cellStr;
		return;
	}
}
function photosbasReturn(xmlObj){
	photosReturn(xmlObj,'bas');
}
function photosjoeriReturn(xmlObj){
	photosReturn(xmlObj,'joeri');
}
function ReplaceAll(ReplaceAllIn,ReplaceAllWhat,ReplaceAllWith){
	if (ReplaceAllWith.indexOf(ReplaceAllWhat) != -1){
		alert('ReplaceAll function can\'t work.');
	}else{
		while (ReplaceAllIn.indexOf(ReplaceAllWhat) > 0){
			ReplaceAllIn = ReplaceAllIn.replace(ReplaceAllWhat,ReplaceAllWith);
		}
	}
	return ReplaceAllIn;
}

function onBodyLoad(){
	pageLoaded = true;
	if (document.getElementById('photosjoeri')){ //load some of joeri's photos from flickr
		ajaxRun('scripts/getflickrthumbs.asp',photosjoeriReturn,'POST','photographer=joeri',false,true);
	}
	if (document.getElementById('photosbas')){ //load some of bas's photos from flickr
		ajaxRun('scripts/getflickrthumbs.asp',photosbasReturn,'POST','photographer=bas',false,true);
	}
}
