function getObject(name) {
	newObj=document.getElementById(name); return newObj;
}

function doFormSubmit(intID,formObj) {
	if(intID) {
		newObj=getObject("rid");
		if (newObj) {
			newObj.value=intID
			if (formObj){
				formObj.submit();
			} else {
				alert("Form object not found");
			}
		} else {
			alert("Hidden input for record ID not found");
		}
	} else {
		alert("Passed value unknown");
	}
}

function setWinStatus(sTxt) {
	window.defaultStatus=sTxt;
}

function setFocusFirstField(sID) {
	if(sID) {
		newObj=getObject(sID);
		if (newObj) {
			newObj.focus();
		} else {
			alert("Form object not found");
		}
	} else {
		alert("Passed value unknown");
	}
}


function popup(url, name, width, height, returnWin, statusBar)
{
var url = url || "";
var width = width || 500;
var name = name || "PixelDamV3";
var height = height || 600;
var left = (screen.width - width)/2;
var top = (screen.height - height)/2.1;
var win = window.open(url, name, 'left = ' + left + ', top = ' + top + ', toolbar = 0, scrollbars = 1, location = 0, status = ' + (statusBar ? 1 : 0) + ', statusmenubar = 0, resizable = 1, width=' + width + ', height=' + height);

if (returnWin) return win;
return false;
}


//Tells the check function whether to throw an error or not
var over = false;
function chars_left(sobjID) {
	//Current character count
	var current = document.getElementById(sobjID).value.length;
	//How many left?
	var chars_left = 140 - current;
	//Over the limit or not?
	if(chars_left < 0) {
		//Over the limit
		over = true;
		//Time for a warning
		document.getElementById('warning').innerHTML = "Exerpt has over 140 characters!";
	} else {
		//Reset
		over = false;
		//Clear any warnings
		document.getElementById('warning').innerHTML = "";
	}
	//Display the number of chars left.
	document.getElementById('left').innerHTML = chars_left;
}

function check() {
	if(over == true) {
		alert("Exerpt is to long, please shorten it.");
		return false;
	}
	else {
	//alert("Your message is short enough.");
		return true;
	}
}

function gotoDetail(gid) {
	top.location.href = "/project.asp?id="+gid;
}

function gotoForsale() {
	top.location.href = "/building.asp";
}

function gotoRESERVED() {
	top.location.href = "/reserved.asp";
}
function gotoBuild() {
	top.location.href = "/moonbuilding.asp";
}
