File: /home/mykensington.co.uk/public_html/js/common.js
function newWindow(mypage, myname, w, h)
{
self.name = "main"; // names current window as "main"
var winl = (screen.width - w - 30);
var wint = (screen.height) / 10;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,menubar=no,toolbar=no,resizable';
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
function newFixedWindow(mypage, myname, w, h)
{
self.name = "main"; // names current window as "main"
var winl = (screen.width - w - 30);
var wint = (screen.height) / 10;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,menubar=no,toolbar=no,resizable=no';
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.blur(); }
}
function newFullWindow(mypage, myname, w, h)
{
win = null;
self.name = "main"; // names current window as "main"
var winl = (screen.width - w - 30);
var wint = (screen.height) / 10;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,location=yes,menubar=yes,toolbar=yes,resizable';
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
function newFullTrackingWindow(linkEl, linkName, w, h)
{
var s=s_gi('propertyfindercom');
s.tl(linkEl, 'o', linkName);
newFullWindow(linkEl.href, linkName, w, h);
}
function openParentUrl(mypage)
{
window.opener.location.href = mypage;
}
function openSameWindow(myURL){
window.opener.location.href=myURL;
}
function boxSetIdVisibility(boxId, id)
{
// Pass the id of a checkbox to control the visibility of the id element
// This method sets the unchecked status to display:hidden (renders white space)
if (document.getElementById(boxId).checked)
{
setClass(id, 'visible');
}
else
{
setClass(id, 'hidden');
}
}
function boxSetIdVisibility2(boxId, id)
{
// Pass the id of a checkbox to control the visibility of the id element
// This method sets the unchecked status to display:none (nothing is rendered)
if (document.getElementById(boxId).checked)
{
setClass(id, 'visible');
}
else
{
setClass(id, 'displayNone');
}
}
function radioActive(radioGroup)
{
if(radioGroup)
{
// Loop through the group
for (var i=0; i<radioGroup.length; i++)
{
// When we find the activated button, return the index
if (radioGroup[i].checked)
{
return radioGroup[i].value;
}
}
// If no button is activated, return -1
return -1
}
else
{
return false;
}
}
function setRadio(radioGroup, radioValue)
{
// Loop through the group
for (var i=0; i<radioGroup.length; i++)
{
var bChecked;
// When we find the named button, check it
if (radioGroup[i].value == radioValue)
{
bChecked = true;
}
else
{
bChecked = false;
}
radioGroup[i].checked = bChecked;
}
}
function checkBrowser(string)
{
// Returns true if the string passed in matches the user agent ('msie', 'opera', 'firefox' etc.)
var ua = navigator.userAgent.toLowerCase();
place = ua.indexOf(string) + 1;
return place;
}
function clearDefaultText(name, defaultText)
{
// Clears the default text from a form field
if(name)
{
var field = document.getElementById(name);
if(field && field.value == defaultText)
{
field.value = "";
}
}
}
/* Find DOM Function */
var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;
if (document.getElementById) {isID = 1; isDHTML = 1;}
else {
if (document.all) {isAll = 1; isDHTML = 1;}
else {
browserVersion = parseInt(navigator.appVersion);
if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
}}
function findDOM(objectID,withStyle) {
var el;
if (withStyle == 1) {
if (isID) {
if (el = document.getElementById(objectID)) { return el.style; }
else { return false; }
}
else {
if (isAll) { return (document.all[objectID].style); }
else {
if (isLayers) { return (document.layers[objectID]); }
};}
}
else {
if (isID) {
if (el = document.getElementById(objectID)) { return el; }
else { return false; }
}
else {
if (isAll) { return (document.all[objectID]); }
else {
if (isLayers) { return (document.layers[objectID]); }
};}
}
}
function setClass(objectID, newClass)
{
var obj = findDOM(objectID, 0);
obj.className = newClass;
}
function setVisibility(objectID, newVisibility)
{
var styleObj;
if (styleObj = findDOM(objectID, 1))
{
styleObj.visibility = newVisibility;
return true;
}
else
{
return false;
}
}
function setDisplay(objectID, newDisplay)
{
var styleObj;
if (styleObj = findDOM(objectID, 1))
{
styleObj.display = newDisplay;
return true;
}
else
{
return false;
}
}
function toggleDisplayBlock(objectID)
{
var styleObj;
if (styleObj = findDOM(objectID, 1))
{
var newDisplay;
if (styleObj.display == 'block')
{
newDisplay = 'none';
}
else
{
newDisplay = 'block';
}
styleObj.display = newDisplay;
}
}
function toggleClass(obj, class1, class2)
{
if (obj.className == class1)
{
obj.className = class2;
}
else if (obj.className == class2)
{
obj.className = class1;
}
}
/* SaveAs image function */
function saveImage(imageUrl)
{
document.saveFrame.location.href = imageUrl;
document.saveFrame.document.execCommand('SaveAs', false, imageUrl);
}
/* Event handlers */
function addEvent(id, event, func, useCapture)
{
var object;
if (object = findDOM(id, 0))
{
if (object.addEventListener)
{
object.addEventListener(event, func, useCapture);
return true;
}
else if (object.attachEvent)
{
return(object.attachEvent('on'+event, func));
}
else
{
// Go for brute force approach
if (event == 'click')
{
object.onclick = func;
}
else if (event == 'change')
{
object.onchange = func;
}
else if (event == 'focus')
{
object.onfocus = func;
}
else if (event == 'blur')
{
object.onblur = func;
}
else if (event == 'mouseover')
{
object.mouseover = func;
}
else if (event == 'mouseout')
{
object.mouseout = func;
}
else if (event == 'load')
{
object.onload = func;
}
else if (event == 'submit')
{
object.onsubmit = func;
}
else
{
return false;
}
}
}
else
{
return false;
}
}
function removeEvent(id, event, func, useCapture)
{
var object;
if (object = findDOM(id, 0))
{
if (object.removeEventListener)
{
object.removeEventListener(event, func, useCapture);
return(true);
}
else if (object.detachEvent)
{
return(object.detachEvent('on'+event, func));
}
else
{
return(false);
}
}
else
{
return false;
}
}
function addAllEvents(id, func)
{
addEvent(id, 'keypress', func, false);
addEvent(id, 'keydown', func, false);
addEvent(id, 'keyup', func, false);
addEvent(id, 'focus', func, false);
addEvent(id, 'blur', func, false);
addEvent(id, 'change', func, false);
addEvent(id, 'mouseover', func, false);
addEvent(id, 'mouseout', func, false);
}
/* Remove frame Link */
function breakOutFrame(frameSource)
{
top.location.href = parent.document.getElementById(frameSource).src;
}
var Debugger =
{
attach:function()
{
winprops = "height=400,width=400,scrollbars=yes,menubar=no,toolbar=no,resizable";
document._debugWindow = window.open("/debug.html", "debug", winprops);
this._attached = true;
},
println:function(str)
{
if(!this._attached)
{
return;
}
if(!str)
{
str = "";
}
document._debugWindow.document.getElementById('debug').innerHTML =
document._debugWindow.document.getElementById('debug').innerHTML + "<br />" + str;
},
clear:function()
{
if(!this._attached)
{
return;
}
document._debugWindow.document.getElementById('debug').innerHTML = "";
}
}
//Debugger.attach();