function setFormImgId(id)
{
	var imgid = new getObj('form_imgid_id');
	if (imgid.ready) {
		imgid.obj.value = id;
		//alert('Set to ' + id);
	}
	else {
		//alert('Could not find ' + id);
	}
}

function setFormMainImgId(id)
{
	var mainimgid = new getObj('form_mainimgid_id');
	if (mainimgid.ready) {
		var oldimg = new getObj('pimage_' + mainimgid.obj.value);
		if (oldimg.ready) {
			oldimg.style.background = "#FFFFFF";
		}
		var newimg = new getObj('pimage_' + id);
		if (newimg.ready) {
			newimg.style.background = "#3498CB";
			mainimgid.obj.value = id;
		}
		//alert('Set to ' + id);
	}
	else {
		//alert('Could not find ' + id);
	}
}

function swapimg(slot)
{
	var t = images[0];
	images[0] = images[slot];
	images[slot] = t;
	
	var imgt = new getObj('propertyimage' + slot);
	var imgm = new getObj('propertyimage');
	var imgp = new getObj('popupMainImageBody');
	if (imgt.ready && imgm.ready && imgp.ready) {
		imgm.obj.src = images[0][1].src;
		imgt.obj.src = images[slot][0].src;
		if (typeof images[0][2] == 'string') {
			var img = new Image();
			img.src = images[0][2];
			images[0][2] = img;
			images[0][2].onload = function() {
				var imgp = new getObj('popupMainImageBody');
				if (imgp.ready) {
					imgp.obj.innerHTML = "<a href=\"javascript: if (window.mainImageToggle) mainImageToggle();\"><img src=\"" + images[0][2].src + "\"  id=\"property_popupimage_img\"/></a>";
				}
			}
		}
		else {
			imgp.obj.innerHTML = "<a href=\"javascript: if (window.mainImageToggle) mainImageToggle();\"><img src=\"" + images[0][2].src + "\"  id=\"property_popupimage_img\"/></a>";
		}
	}
}

var mainImageVisible = false;

function mainImageToggle()
{
	var img = new getObj('popupMainImageContainer');
	if (img.ready) {
		if (mainImageVisible) {
			img.style.display = "none";
			mainImageVisible = false;
		}
		else {
			img.style.display = "block";
			mainImageVisible = true;
			if (typeof images[0][2] == 'string') {
				var img = new Image();
				img.src = images[0][2];
				images[0][2] = img;				
				var imgp = new getObj('popupMainImageBody');
				if (images[0][2].readyState && images[0][2].readyState == "complete" && imgp.ready) {
					imgp.obj.innerHTML = "<a href=\"javascript: if (window.mainImageToggle) mainImageToggle();\"><img src=\"" + images[0][2].src + "\" id=\"property_popupimage_img\" /></a>";
				}
				else {
					images[0][2].onload = function() {
						var imgp = new getObj('popupMainImageBody');
						if (imgp.ready) {
							imgp.obj.innerHTML = "<a href=\"javascript: if (window.mainImageToggle) mainImageToggle();\"><img src=\"" + images[0][2].src + "\" id=\"property_popupimage_img\" /></a>";
						}
					}
				}
			}
		}
	}
}

