/* Javascript used by Content Management System */

<!--   hide this script from non-javascript-enabled browsers
// function that displays status bar message
var showMsg = navigator.userAgent != "Mozilla/4.0 (compatible; MSIE 4.0; Mac_PowerPC)";
function dmim(msgStr) {
  document.returnValue = false;
  if (showMsg) { 
    window.status = msgStr;
    document.returnValue = true;
  }
}

// open window
function openWin( windowURL, windowName, windowFeatures ) { 
	return window.open( windowURL, windowName, windowFeatures ) ; 
} 

// image preview	
function previewImg( windowURL, windowName, windowFeatures, textfield ) { 
	var image =  eval("document.editform." + textfield + ".value");
	var openURL = windowURL + "?Image=" + image;
	return window.open( openURL, windowName, windowFeatures ) ; 
} 

// stop hiding -->

// Qforms stuff 
/*  Must also include: <script src="includes/qforms/lib/qforms.js" type="text/javascript"></script> */
<!--//
	// set the path to the qForms directory
	qFormAPI.setLibraryPath("includes/qforms/lib/");
	// this loads all the default libraries
	qFormAPI.include("*");

//Test float fields to make sure they are proper floats (allows negative numbers)
function __IsNumericfloat()
{
// For foreign currencies, change the decimal to a comma on the next line:
var ValidChars = "01213456789.-";
var IsNumber = true;
var Char ;
var sText = this.value;
var numDecimals = 0;

for (i = 0; i < sText.length && IsNumber == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
//Checks for minus sign
if (Char == '-' && i > 0)
{
IsNumber = false;
}
//Checks to make sure there is only 1 decimal point in the number
// For foreign currencies, change the decimal to a comma on the next line:
if (Char == '.')
{
numDecimals = numDecimals + 1;
}
}

if (numDecimals > 1 || IsNumber == false)
{
this.error = "The field " +
this.description + " does not contain a valid number";
}
}

_addValidator("IsNumericfloat",__IsNumericfloat);

//-->


// Quicklist Cookies 
/*  add ID to quicklist */
<!--
	function includeInCookie(value) {
		var name = "bookmark";
		var d = new Date();
		d.setTime( d.getTime() + (15*24*60*60*1000));
		var expires = '; expires=' + d.toGMTString();
		var bookmark = readCookie("bookmark");
		if (!bookmark) bookmark = value;
		else {
			if (bookmark.indexOf(value) == -1) {
				bookmark = bookmark + "," + value;
			}
		}
		document.cookie = name + '=' + escape(bookmark)+ expires+'; path=/';
		alert ("This listing was added to your Quick List\n\nYou can view your Quick List by clicking on 'View Quick List' link.");
	}

	function readCookie(name) {
		var eq = name + "=";
		var ca = document.cookie.split(';');
		if (!ca.length) return null;
		for(var i=0;i<ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(eq) == 0) return unescape(c.substring(eq.length,c.length));
		}
		return null;
	}


	function removeFromCookie(property_id) {
					
		var name = "bookmark";
		var d = new Date();
		d.setTime( d.getTime() + (15*24*60*60*1000));
		var expires = '; expires=' + d.toGMTString();
					
		if (isNaN(property_id)) {
			if (property_id == "all") {
				var bookmark = "";
				document.cookie = name + '=' + escape(bookmark)+ expires;
			}
		}
		else {
			var bookmark = readCookie("bookmark");
			if (bookmark.length > 0) {
				if (bookmark.indexOf(property_id) > -1) {
					finalvar = bookmark.indexOf(property_id) + property_id.length + 1;
					var aux = "";
					aux = bookmark.substr(0, bookmark.indexOf(property_id));
					aux += bookmark.substr(finalvar);
					bookmark = aux;
				}
			}
	
			len = bookmark.length;
			len--;
			
			if (bookmark.lastIndexOf(",") == len) {
				bookmark = bookmark.substr(0, len);
			}
			
			document.cookie = name + '=' + escape(bookmark)+ expires;
			alert ("This listing was removed from your Quick List");
		}
			window.location.reload();
	}
				
// END - Cookie's functions ----
//-->

 
 
 

