/*
 *  Generic JavaScript utilities for Ouneva Group
 *  Copyright (c) 2007 by Tero Niemi (Gofort & Part.)
 *
 *  http://www.gofort.fi/
 *
 *  All worldwide rights reserved.
 */

/*** utils **********************************************************/
var isModernBrowser = (document && document.getElementById);

function isSpace(c) {
    return (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f')
}

function trim(s) {
    while (isSpace(s.substring(0, 1))) s = s.substring(1, s.length);
    while (isSpace(s.substring(s.length-1, s.length))) s = s.substring(0, s.length-1);
    return s;
}

function setClass(i, cls) {
    if (isModernBrowser) {
        document.getElementById(i).className = cls;
    }
}
/*** /utils *********************************************************/

/*** header menu hover **********************************************/
function hoverOn(i) {
    setClass(i + '_top', 'hover');
}

function hoverOff(i) {
    setClass(i + '_top', '');
}
/*** /header menu hover *********************************************/

/*** quick search ***************************************************/
function searchFocus() {
    if (isModernBrowser) {
        document.getElementById('quicksearch').focus();
    }
}

function searchOn() {
    if (isModernBrowser) {
        setClass('quicksearch', '');
        if (document.getElementById('quicksearch').value == searchProposal) {
            document.getElementById('quicksearch').value = '';
        }
    }
}

function searchOff() {
    if (isModernBrowser) {
        setClass('quicksearch', 'blur');
        if (trim(document.getElementById('quicksearch').value) == '') {
            document.getElementById('quicksearch').value = searchProposal;
        }
    }
}

function searchValidate() {
    if (isModernBrowser) {
        if (trim(document.getElementById('quicksearch').value) == ''
            || document.getElementById('quicksearch').value == searchProposal) {
            return false;
        } else {
            return true;
        }
    }
}
/*** /quick search **************************************************/

/*** EOF ***/
