function trim(str) {
    while (str.charAt(0)==' ') str = str.substring(1, str.length);
    while (str.charAt(str.length - 1) == ' ') str = str.substring(0, str.length - 1);
    return str;
}

function emailFocus(o) {
    if (o.value == 'Type your e-mail') {
        o.value = '';
        o.style.color = 'Black';
    }
}
function emailBlur(o) {
    if (trim(o.value) == '') {
        o.value = 'Type your e-mail';
        o.style.color = 'Gray';
    }
}

function doSearch(frm) {
	return trim(frm.query.value) != '';
}

function WIRELogin() {
    window.location.href = '/login/';
}

var bImgs = new Array("0", "-224px", "-448px");
var bImgI = 0;
var pT = 5500;
var pF = 500;
function toggleBanner(t) {
    if (t) {
        bImgI += 1;
        if (bImgI >= bImgs.length) bImgI = 0;
        $('bannerImage').style.backgroundPosition = "0 " + bImgs[bImgI];
        Effect.Appear('bannerImage', {duration: pF/1000, from: 0, to: 1 });
        setTimeout('toggleBanner(false)', pT);
    } else {
        Effect.Fade('bannerImage', {duration: pF/1000, from: 1, to: 0 });
        setTimeout('toggleBanner(true)', pF);
    }
}

var subscribeTO = null;
function subscribe() {
    var o = $('email');
    if ((o.value != 'Type your e-mail') && (trim(o.value) != '')) {
        new Ajax.Updater('subscribeResult', 'subscribe.jsp', {parameters: {email: o.value}, onComplete: function() {
            var o = $('email');
            o.value = 'Type your e-mail';
            o.style.color = 'Gray';
            $("subscribeResult").show();
            if (subscribeTO != null) clearTimeout(subscribeTO);
            subscribeTO = setTimeout(function() {
                subscribeTO = null;
                Effect.Fade('subscribeResult', {duration: 2, from: 1, to: 0 });
            } , 7000);
        }});
    }
    return false;
}

