<!--
/*
eg.
<tr onmouseover="setPointer(this, 3, 'over', '#CCCCCC', '#CCFFCC', '#FFCC99');" onmouseout="setPointer(this, 3, 'out', '#CCCCCC', '#CCFFCC', '#FFCC99');" onmousedown="setPointer(this, 3, 'click', '#CCCCCC', '#CCFFCC', '#FFCC99');">
*/

/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;


/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * theRow    		object    the table row
 * theRowNum 		interger  the row number
 * theAction 		string    the action calling this script (over, out or click)
 * theDefaultColor	string    the default background color
 * thePointerColor	string    the color to use for mouseover
 * theMarkColor		string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '') || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }
    if (theAction == 'over' || theAction == 'click') {
		theRow.style.cursor = 'hand';
	} else {
		theRow.style.cursor = 'pointer';
	}

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;

	// set the cell colours to the row colour
    for (c = 0; c < rowCellsCnt; c++) {
        theCells[c].setAttribute('bgcolor', theRow.getAttribute('bgcolor'), 0);
    }
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
    	// this is what is called for my browser
        currentColor = theCells[0].getAttribute('bgcolor');
        //currentColor = theRow.getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == '' || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase() && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
	} // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

function SetDefaultFocus(FormName) {
	var i;
	for ( i = 0; i < eval("document."+FormName+".elements.length"); i++ ) {
		if ( eval("document."+FormName+".elements[i].type") == "text" || eval("document."+FormName+".elements[i].type") == "password" ) {
			eval("document."+FormName+".elements[i].focus()");
			break;
		}
	}
}

function SubmitForm(formname) {
	var submitaction = 'document.' + formname + '.submit()';
	eval(submitaction);
}

function jsconfirmLink(theLink, sMessage, sURL) {
    var is_confirmed = confirm(sMessage);
    if (is_confirmed) {
        theLink.href = sURL;
    } else {
        theLink.href = "#";
    }
    return is_confirmed;
}

function ValidateChangePassword() {
	if ( document.passwordform.cx.value != document.passwordform.nx.value ) {
		alert("Password not confirmed");
		document.passwordform.cx.focus();
		document.passwordform.cx.select();
		return false;
	}
	if ( document.passwordform.cx.value == "" || document.passwordform.nx.value == "" ) {
		alert("You must enter a Password");
		document.passwordform.nx.focus();
		return false;
	}
	return true;
}
function ValidatePropertyForm() {
	if ( document.pageform.email.value == "" || document.pageform.email.value.indexOf("@") == -1 ) {
		alert("You must enter a valid email address");
		document.pageform.email.focus();
		document.pageform.email.select();
		return false;
	}
	if ( document.pageform.phone.value == "" ) {
		alert("You must enter a phone number");
		document.pageform.phone.focus();
		document.pageform.phone.select();
		return false;
	}
	if ( document.pageform.name.value == "" ) {
		alert("You must enter your name");
		document.pageform.name.focus();
		document.pageform.name.select();
		return false;
	}
	return true;
}

function NextImage(imagename) {
	ThisImage=document.getElementById("show");
	ThisImage.src=imagename;
}

function InHistory(address) {
	// determines if the address (URL) is in the browser's history
	var i;
	for ( i=0;i<history.length;i++ ) {
		if ( history[i].indexOf(address) != -1 ) {
			//alert('true');
			return true;
		}
	}
	//alert('false');
	return false;
}
function ChangeImage(img,w,h,caption) {
	var o = document.getElementById('main_image');
	o.src=img;
	o.width=w;
	o.height=h;
	document.getElementById('caption').innerHTML=caption;
}
function ReplaceRentImage(img,i) {
	var o = document.getElementById('image_'+i);
	o.src=img;
	o.width=193;
	o.height=145;
}

// -->