/*** USING JQUERY *************************************************************/

/**
 * We must resolve the $ conflict with jQuery.  We reassign $ to $jQuery$ instead.
 * See: http://docs.jquery.com/Using_jQuery_with_Other_Libraries
 */
//var $jQuery$ = jQuery.noConflict();

//$jQuery$(document).ready(function(){
//    $jQuery$("#joomlaMessages").fadeOut(0).fadeIn(1000);
//
//    $jQuery$("#closeJoomlaMessage").click(function(){
//
//        // Animate to left
////        $jQuery$("#joomlaMessages").animate({
////            //            opacity: 0.05,
////            left: "+=10px"
////        }, 500).animate({
////            //            opacity: 0.25,
////            left: "-5000px"
////        }, 1000).fadeOut(0);
//
//        // Animate to top
//        var height = $jQuery$("#joomlaMessages").css('height');
//        height = height.replace("px", "");
//        height = parseInt(height) + 50;
////        height = 200;
//        height = "-" + height;
//        //alert(height);
//        $jQuery$("#joomlaMessages").animate({
//            opacity: 0.05,
//            top: height
//        }, 1500).fadeOut(0);
//    });
//
//    //$jQuery$("#joomlaMessages").fadeOut(800).fadeIn(800).fadeOut(400).fadeIn(400)
//    //.fadeOut(400).fadeIn(400);
//
//    //$jQuery$("#joomlaMessages").css('display', 'none');
//});

/*** USING MOOTOOLS ***********************************************************/

/**
 * 1. Comment out the Hide link in
 */

var tmjmosmsg,fx;
function pload(){
    // Hide button if there is one.
    $$('#closeJoomlaMessage').setStyle('display', 'none');

    // if the joomlaMessagesContent element has content, we want to show.  Since
    // it's style is 'display: none;' by default, we change it to block so that
    // it'll show up as a block.
    var ele = $('joomlaMessagesContent');
    var value = ele.innerHTML;
    if (!value.match(/^\s*$/))
        $$('#joomlaMessages').setStyle('display', 'block');

    


    tmjmosmsg=$$('#joomlaMessages');
    if($type(tmjmosmsg[0])=='element'){
        var el=tmjmosmsg[0];
        el.setStyle('overflow','hidden');
        var h=el.getSize().size.y;

        fx = new Fx.Styles(el, {
            duration:900,
            wait:false
        });
        //scrol to message
        winScroller = new Fx.Scroll(window);
        winScroller.toElement($('page'));
        //delayed start, then remove the html element upon completion

        (function(){
            fx.start({
                'margin-top':-1*h.toInt(),
                opacity:0
            }).chain(function(){
                el.remove();
            });
        }).delay(2500);
    }
};

window.addEvent('load',function(){
        pload();
    }
);
