function toggleDisplay (theId,showIt) {
    if (showIt) {
        $(theId+'-hide').style.display = 'block';
        $(theId+'-show').style.display = 'none';
    } else {
        $(theId+'-hide').style.display = 'none';
        $(theId+'-show').style.display = 'block';
    }
    return false;
}

function toggleAnswer (theId) {
    $(theId).style.display = ($(theId).style.display != 'none') ? 'none' : 'block';
    return false;
}

var dstPreload = null;
var dstNo = 1;
var dstTotal = 5;
var dstTimer = null;
var dstBusy = false;

function cycleImages (wasClicked) {

    if (!dstBusy) {

        var thisDuration = (wasClicked) ? 250 : 750;
        dstBusy = true;
        clearTimeout(dstTimer);
        dstNo++;
        if (dstNo > dstTotal) dstNo = 1;
    
        dstPreload = new Image();
        $(dstPreload).addEvent('load',function(){
    
            $('dstfade').setStyle('opacity','0');
            var loadFx = new Fx.Tween('dstfade',{duration:thisDuration});
            $('dstfade').src = $('dstscreen').src;
            loadFx.set('opacity','1');
            $('dstscreen').src = this.src;        
            loadFx.start('opacity','0');
            setTimeout(function(){ dstBusy = false; },thisDuration);
    
        });
        dstPreload.src = '/images/software/delivery-status-touch-3/screen-0'+dstNo+'.jpg';
        dstTimer = setTimeout(cycleImages,5000);

    }

}

window.addEvent('load',function() {

    var thisguy = '';
    switch (Math.ceil(Math.random() * 5)) {
        case 1:
            thisguy = 'airplane';
            break;
        case 2:
            thisguy = 'birdie';
            break;
        case 3:
            thisguy = 'pengy';
            break;
        case 4:
            thisguy = 'robot';
            break;
        case 5:
            thisguy = ($('notefile-hero')) ? 'airplane' : 'sqwerl';
            break;
    }
    var newObject = new Element('div',{'id':thisguy});
    $('guy').adopt(newObject);
    
    if ($('dstscreen')) {
        var newImage = new Element('img',{
            'id': 'dstfade',
            'styles': { 'opacity': '0' }
        });
        newImage.inject('dstscreen','after');
        dstTimer = setTimeout(cycleImages,5000);
    }

    /* if ($('contact') && $('subject')) {
        $('subject').addEvent('change',function(){
            $('cmd').value = 'quickhelp';
            $('contact').submit();
            // use ajax instead!
        });        
    } */

});
