pageLoaded = false;
function enlarge(srcOfTheImage){
	var enlargepicwindow = window.open('enlargepic.asp?url='+escape(srcOfTheImage),'enlargepicwindow','width=100,height=10,status,scrollbars,resizable');
	enlargepicwindow.focus();
	return false;
}
function buttonToggle(whichButtonToggle,statusButtonToggle){
	currentSrcButtonToggle = whichButtonToggle.src;
	if (statusButtonToggle){
		whichButtonToggle.src = currentSrcButtonToggle.replace('.gif','-over.gif');
	}else{
		whichButtonToggle.src = currentSrcButtonToggle.replace('-over.gif','.gif');
	}
}
function changeDate(which){
	//alert(which.id+' wordt '+which.options[which.selectedIndex].value);
	ajaxRun('changeDate.asp',changeDateReturn,'POST','stock='+parseInt(which.parentNode.parentNode.title)+'&propertyid=<% = propertyId %>&oldpropertyvalueid='+parseInt(which.id)+'&newpropertyvalueid='+parseInt(which.options[which.selectedIndex].value),false,true);
}
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 += tempStr;
		//2
		tempStr = txt.substring(txt.indexOf('<td'),txt.indexOf('</td>')+5);
		txt = txt.replace(tempStr,'');
		cellStr += tempStr;
		//3
		tempStr = txt.substring(txt.indexOf('<td'),txt.indexOf('</td>')+5);
		txt = txt.replace(tempStr,'');
		cellStr += tempStr;
		//4th image
		tempStr = txt.substring(txt.indexOf('<td'),txt.indexOf('</td>')+5);
		txt = txt.replace(tempStr,'');
		cellStr += tempStr;
		//links should open in a new window, damnit
		while (cellStr.indexOf('<a href=') > 0){
			cellStr = cellStr.replace('<a href=','<a target="_blank" href=');
		}
		cellStr = '<table><tr>' + cellStr + '</tr></table>';
		document.getElementById('photos'+whose).innerHTML = cellStr;
		return;
	}
}
function photosbasReturn(xmlObj){
	photosReturn(xmlObj,'bas');
}
function photosjoeriReturn(xmlObj){
	photosReturn(xmlObj,'joeri');
}
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);
	}
}
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 chooseLanguage(){
	//alert(document.getElementById('chooseLanguageDiv'));
	//alert(chooseLanguageDiv);
	chooseLanguageDiv.style.display = 'block';
	chooseLanguageDiv.focus();
}
function epost(who){
	monkeytail='@';
	if (who=='Bas'){
		document.location.href='mailto:bas'+monkeytail+'nonstockphoto.com?subject=Nonstockphoto';
	}else{
		document.location.href='mailto:joeri'+monkeytail+'nonstockphoto.com?subject=Nonstockphoto';
	}
}