// custom code
function popPrint(sPageName, sSubPageName, sID) {
	alert("feature coming");
}
function rollHome(bResidential, bOver) {
	oImage = document.getElementById("main").src;
	var sPath = oImage.substring(0, oImage.lastIndexOf('/')) + "/hdrimg_home";
	sPath = sPath + (bOver ? (bResidential ? "_r" : "_c" ) : "") + ".jpg";
	document.getElementById("main").src = sPath;
}
function rollBack(oThis, bOver) {
	oThis.style.backgroundColor = bOver ? "#ffffff" : "#e2e2e2";
}

// --------------------------------------------------------------------
// rollover code
roll = new csRoll();
function csRoll(overSuffix, outSuffix){
	this.overSuffix = "_over";
	this.outSuffix = "_out";
	this.images = new Object()
	this.initialized = false;
}
csRoll.prototype.over = function csRollOver(imgName) { if (this.initialized) this.images[imgName].over(); }
csRoll.prototype.out = function csRollOut(imgName) { if (this.initialized) this.images[imgName].out(); }
csRoll.prototype.init = csRollInit;
function csRollInit(){
	var imgs = document.getElementsByTagName("img");
	for(var i = 0; i < imgs.length; i++) this.mapImage(imgs[i]);
	this.initialized = true;
}
csRoll.prototype.mapImage = csRollMapImage;
function csRollMapImage(img){
	if(img.name.indexOf("_ROLL") != -1)
		this.images[img.name.substr(0,img.name.lastIndexOf("_"))] = new csRollImage(img, this.overSuffix, this.outSuffix);
}
function csRollImage(img, overSuffix, outSuffix){
	this.img = img;
	this.baseSuffix = this.img.src.substr(this.img.src.lastIndexOf("."));
	var baseSrc = this.img.src.substr(0,this.img.src.lastIndexOf("_"));
	this.overSrc = baseSrc + overSuffix + this.baseSuffix;
	this.outSrc = baseSrc + outSuffix + this.baseSuffix;
	this.preloadOver = new Image(); 
	this.preloadOver.src = this.overSrc; 
	this.preloadOut = new Image();
	this.preloadOut.src = this.outSrc;
}
csRollImage.prototype.over = function csRollImageOver() { this.img.src = this.preloadOver.src; }
csRollImage.prototype.out = function csRollImageOut() {	this.img.src = this.preloadOut.src; }

function popProperty(sPropertyURL) {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement &&
		( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	winProperty = new csWin(sPropertyURL, "MonumentRealtyPopup", myWidth, myHeight, 1, 1, 1, 1, 1, 1, 1, 1);
}
// form validation functions
function checkString(sFieldText, sFieldName, bFormOK, bBlankOK) {
	if (bFormOK) {
		if (hasScript(eval("document.frmThis." + sFieldName).value)) {
			alert(sFieldText + " contains illegal script text\nthat can cause problems with your information");
			eval("document.frmThis." + sFieldName).focus();
			return true;
		} else {
			if (!bBlankOK && isWhitespace(eval("document.frmThis." + sFieldName).value)) {
				alert(sFieldText + " is required");
				eval("document.frmThis." + sFieldName).focus();
				return true;
			} else {
				return false;
			}
		}
	}
	return false;
}
var sWhitespace = " \t\n\r";

function isEmpty(s){
	return ((s == null) || (s.length == 0))
}

function isWhitespace (s) {
	var i;
	if (isEmpty(s)) return true;
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (sWhitespace.indexOf(c) == -1) return false;
	}
	return true;
}
function hasScript (inString) {
	var tmpString = stripWhitespace(inString).toUpperCase();
	if (tmpString.indexOf("<" + "SCRIPT") != -1) return true;
	if (tmpString.indexOf("<" + "/" + "SCRIPT") != -1) return true;
	if (tmpString.indexOf("<" + "%") != -1) return true;
	if (tmpString.indexOf("%" + ">") != -1) return true;
	if (tmpString.indexOf("<" + "?") != -1) return true;
	if (tmpString.indexOf("php" + ">") != -1) return true;
	if (tmpString.indexOf("language=") != -1) return true;
	return false;
}
function stripWhitespace (s) {
	return stripCharsInBag (s, sWhitespace);
}
function stripCharsInBag (s, bag){
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}
function isInteger (s){
	var i;
	if (isEmpty(s))
		if (isInteger.arguments.length == 1) return defaultEmptyOK;
		else return (isInteger.arguments[1] == true);
	for (i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if (!isDigit(c)) return false;
	}
	return true;
}
function isDigit (c){
	return (((c >= "0") && (c <= "9")) || c == ".");
}
function csWin(popUrl,popName,w,h,scrollbars,x,y,toolbar,menubar,resizable,status,directories){
	this.popUrl = popUrl;
	this.popName = popName;
	this.w = w ? w : screen.width;
	this.h = h ? h : screen.height;
	this.scrollbars = scrollbars ? scrollbars : 0;
	this.toolbar = toolbar ? toolbar : 0;
	this.menubar = menubar ? menubar : 0;
	this.resizable = resizable ? resizable : 0;
	this.status = status ? status : 0;
	this.directories = directories ? directories : 0;
	var winl = x ? x : ((screen.width - this.w) / 2);
	var wint = y ? y : ((screen.height - this.h) / 2);
	if (wint < 0) wint = 1;
	if (winl < 0) winl = 0;
	this.popWin = window.open(
		this.popUrl,
		this.popName,
		"top=" + wint + "," +
		"left=" + winl + "," +
		"toolbar=" + this.toolbar.toString() + "," +
		"directories=" + this.directories.toString() + "," +
		"status=" + this.status.toString() + "," +
		"menubar=" + this.menubar.toString() + "," +
		"scrollbars=" + this.scrollbars.toString() + "," +
		"resizable=" + this.resizable.toString() + "," +
		"width=" + this.w.toString() + "," +
		"height=" + this.h.toString()
	);
}