var nbsp = "\240";

function verify_email (field) {
    var email;
	
// Check that the email address doesn't have 2 @ signs, a .., a @., a 
// .@ or begin or end with a .
// Allow only letters, numbers, dashes, underscores and dots and make
// sure the address ends in 2-4 letters after a period.

    email = field.value;
    
    if ((email.search (/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) != -1) || 
        (email.search (/^\w([\w\.-])*@\w([\w\.-])*\.[a-zA-Z]{2,4}$/) == -1)) {
        alert ("Invalid E-mail address");
        field.focus();
        return false;
    }  

    return true;
}

function get_cookie (field) {
    var cookie = document.cookie;
    var i = cookie.indexOf (field + "=");
    var j;

    if (i < 0)  return "";
    
    i = i + field.length + 1;
    j = cookie.indexOf (";", i);
    if (j < 0)  j = cookie.length + 1;
    
    return unescape(cookie.substr (i, j - i));
}

function delete_cookie (cname) {
    document.cookie = cname + "=deleted; path=/; expires=Fri, 02-Jan-1970 00:00:00 GMT";
}

function set_fontsize (n, e) {
    if (n == 0) {
        var c = get_cookie ("fontsize");
        if (c == "")  c = 100;
        document.body.style.fontSize = c + "%";
    } else {
        var now = new Date();
        var fs = document.body.style.fontSize;

        if (fs == "")  fs = "100%";
        fs = (fs.substr(0, fs.length - 1) - 0) + (n * 10);
        if (fs < 50) fs = 50;
        document.body.style.fontSize = fs + "%";
    
        now.setFullYear(now.getFullYear() + 10);
        document.cookie = "fontsize=" + fs + "; path=/; expires=" + now.toGMTString();
    }

    if (arguments.length == 2) {
        var pos = 0;
        do {
            pos = pos + e.offsetTop;
        } while (e = e.offsetParent);
        window.scrollTo (0, pos);
    }
}

function show_search_options (o, b) {
    var t = document.getElementById('searchoptstab' + o);
    var i = document.getElementById('searchoptsimg' + o);

    if (t.style.visibility == "") {
         t.style.visibility = 'hidden';
         i.src = b + "images/searchopts-o.gif";
    } else {
         t.style.visibility = '';
         i.src = b + "images/searchopts-c.gif";
    }
}

function atomz_submit (f) {
    if (f["sp-q"].value.replace (/ /g, "") == "") {
        f["sp-q"].value = "Enter words to search for";
        return false;
    }
    return true;
}
