/*
 * script.js
 * Common script functions
 *
 * $Id: $
 *
 * Copyright (c) 2006-2008 AMC World Technologies GmbH
 * Fischerinsel 1, D-10179 Berlin, Deutschland
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information of AMC World
 * Technologies GmbH ("Confidential Information"). You shall not disclose such
 * Confidential Information and shall use it only in accordance with the terms
 * of the license agreement you entered into with AMC World Technologies GmbH.
 */


//-- Functions ----------------------------------

/**
 * Loads a new image into the picture viewer.
 *
 * @param[in] filePath  [string] the path to the image to load
 * @param[in] altText   [string] the alternative text to set for the image
 * @param[in] titleText [string] the title text to set for the image
 */
function changeImg(filePath, altText, titleText) {
    var img = getElem("image");
    img.src = filePath;
    if (altText) img.alt = altText;
    if (titleText) img.title = titleText;
    else if (altText) img.title = altText;
}

/**
 * Gets the element with the given ID from the current document. The element is
 * retrieved for different types of browsers.
 *
 * @param[in] id  [string] the ID of the desired element
 * @return        [object] the element; @c null if an error occurred
 */
function getElem(id) {
    if (document.getElementById) {
        return document.getElementById(id);
    } else if (document.all) {
        return document.all[id];
    } else {
        return null;
    }
}

/**
 * Called if the checkbox "I agree" has toggled.
 *
 * @param[in] ctrl  [object] the checkbox "I agree"
 */
function onChangeIAgree(ctrl) {
    var f = document.forms["mailform"];
    f.elements["formtype_mail"].disabled = !ctrl.checked;
}

/**
 * Called if the pages for reservation and buy of furnitures has to initialize.
 */
function onInitReservationBuyPage() {
    document.forms["mailform"].elements["formtype_mail"].disabled = true;
}
