function emailUs() {    displayModalDialog('Email Us','email.php','600px', '400px');}function emailUsPrefix(prefix) {    displayModalDialog('Email Us',prefix+'email.php','600px', '400px');}function emailFay() {    displayModalDialog('Email Fay Chen','email-fay.php','600px', '400px');}function emailRichard() {    displayModalDialog('Email Richard Shepherd','email-richard.php','600px', '400px');}function showLogin() {    document.getElementById("login").style.display = "";}function hideLogin() {    document.getElementById("login").style.display = "none";}var dialogID = 0;var x = 150;var y = 80;var dialogIDs = [];function displayModalDialog(title, src, width, height) {    if (!width || width == '') width = "500px";    if (!height || height == '') height = "400px";    var id = "dialog_" + dialogID;    dialogID++;    dialogIDs[dialogIDs.length] = id;    var modalContainer = document.createElement('div');    modalContainer.className = "modalContainer";    modalContainer.id = id;    modalContainer.style.width = width;    // position it in the center of the screen    modalContainer.style.left = x + "px";    modalContainer.style.top = y + "px";    x += 50;    y += 50;    var modalWindow = document.createElement('div');    modalWindow.className = "modalWindow";    var close = document.createElement('a');    close.className = 'close';    close.setAttribute('href', "javascript:closeModalDialog('" + id + "');");    close.innerHTML = "<img src='sitelayout/close.png' />";    var maximise = document.createElement('a');    maximise.className = 'close';    maximise.setAttribute('id', id + "_a");    maximise.setAttribute('href', "javascript:maximiseModalDialog('" + id + "');");    maximise.innerHTML = "<img src='sitelayout/maximise.png' />";    var modalTitle = document.createElement('div');    modalTitle.className = 'modalTitle';    modalTitle.innerHTML = title;    //modalTitle.setAttribute("onmousedown", "dragStart(event, '" + id + "')");    modalTitle.onmousedown = new Function("dragStart(event, '" + id + "')");    var iframe = document.createElement('iframe');    iframe.className = 'modalFrame';    iframe.setAttribute('src', src);    iframe.setAttribute('frameborder', 0);    iframe.setAttribute('id', id + "_iframe");    iframe.style.height = height;    iframe.style.width = width;    iframe.src = src;    modalWindow.appendChild(close);    modalWindow.appendChild(maximise);    modalWindow.appendChild(modalTitle);    modalWindow.appendChild(iframe);    modalContainer.appendChild(modalWindow);    document.body.appendChild(modalContainer);}function maximiseModalDialog(id) {    var object = document.getElementById(id);    var iframe = document.getElementById(id + "_iframe");    var a = document.getElementById(id + "_a");    var minX = 28;    var minY = 48;    var oldLeft = object.style.left;    var oldTop = object.style.top;    var oldWidth = object.style.width;    var oldHeight = iframe.style.height;    object.style.left = minX + "px";    object.style.top = minY + "px";    var clientHeight = document.body.clientHeight - minY;    if (window.innerHeight && window.innerHeight > clientHeight) {        clientHeight = window.innerHeight - minY;    }    var width = document.body.clientWidth - minX;    var height = clientHeight - minY;    object.style.width = width + "px";    iframe.style.height = height + "px";    a.setAttribute("href","javascript:minimiseModalDialog('" + oldLeft + "','" + oldTop + "','" + oldWidth + "','" + oldHeight + "','" + id + "');");}function minimiseModalDialog(left, top, width, height, id) {    var object = document.getElementById(id);    var iframe = document.getElementById(id + "_iframe");    var a = document.getElementById(id + "_a");    object.style.left = left;    object.style.top = top;    object.style.width = width;    iframe.style.height = height;    a.setAttribute('href', "javascript:maximiseModalDialog('" + id + "');");}function closeModalDialog(id) {    if (!id || id == '') {        // only option is to close all modal dialogs        for (var i = 0; i < dialogIDs.length; i++) {            closeModalDialog(dialogIDs[i]);        }        // reset the array        dialogIDs = [];    } else {        var object = document.getElementById(id);        object.style.display = 'none';        document.body.removeChild(object);    }}function fadeBubble() {    var feedbackLink = document.getElementById("feedbackLink");    // make the bubble appear beneaet the feedback link    var position = getPosition(feedbackLink);    var bubble = document.getElementById("bubble");    if (bubble) {        bubble.style.left = (position.x - 25)  + 'px';        bubble.style.top = (position.y + 17) + 'px';        fadeIn("bubble", 0);        setTimeout("fadeOut('bubble', 100)", 5000);    }}function getPosition(obj) {    var curleft = 0;    var curtop = 0;    if (obj.offsetParent) {        do {            curleft += obj.offsetLeft;            curtop += obj.offsetTop;        } while (obj = obj.offsetParent);    }    return {        x: curleft,        y: curtop    };}function setOpacity(elem, alpha) {    elem.style.opacity = alpha * 0.01;    elem.style.filter = 'alpha(opacity=' + alpha + ')';}function fadeIn(elemID, alpha) {    var elem = document.getElementById(elemID);    if (elem) {        if (alpha < 100) {            setOpacity(elem, alpha);            elem.style.display = '';            setTimeout("fadeIn('" + elemID + "'," + (alpha + 1) + ")",10);        }    }}function onMessage(message) {// don't do anything    }function fadeOut(elemID, alpha) {    var elem = document.getElementById(elemID);    if (elem) {        if (alpha > 0) {            setOpacity(elem, alpha);            setTimeout("fadeOut('" + elemID + "'," + (alpha - 1) + ")",10);        } else {            elem.parentNode.removeChild(elem);        }    }}
