$(document).ready(function(){
    $("input#searchbox").labelify({labelledClass: "inputtip"});
    setTimeout(function(){
        var rssfeeds = $('#rssboxes').height();
        $('.rssbox').each(function(){ 
            $(this).height(rssfeeds);
        });
        var contentheight = $('#contentarea').height();
        var subnavheight = $('#subnav').height();
        $('#sidebar').height(contentheight);
        $('#sidecontent').height(contentheight - subnavheight -20);
        $("#searchsubmit").replaceWith('<a href="#" id="searchsubmit">Go</a>');
        $("#searchsubmit").click(function () {
          $("#searchform").submit();
          return false;
        });
        $("#nlsubmit").replaceWith('<p class="buttonlinks"><a href="#" id="nlsubmit"><span>Submit</span></a></p>');
        $("#nlsubmit").click(function () {
          $("#newsletterform").submit();
          return false;
        });
        $('#signinform').hide();
        $('a.signin').click(function () {
            $("#signinform").slideToggle("normal");
            return false;
        });
        $("#wlpeLoginButton").replaceWith('<p class="buttonlinks"><a href="#" id="wlpeLoginButton"><span>Login</span></a></p>');
        $("#wlpeLoginButton").click(function () {
          $("#wlpeLoginForm").submit();
          return false;
        });
/*
        FLIR.init( new FLIRStyle( { inheritStyle:true } ) )
        $("#whatwhyhow-questions a").each(function(){ 
            FLIR.replace(this, new FLIRStyle({ resizeBox: false }));
            $(this).css({ visibility: 'visible' });
        });
        $("#whatwhyhow-answers h2").each(function(){ 
            FLIR.replace(this, new FLIRStyle({ mode: 'wrap' }));
            $(this).css({ visibility: 'visible' });
        });
        $("#downloadlink a").each(function(){ 
            FLIR.replace(this, new FLIRStyle({ resizeBox: false }));
            $(this).css({ visibility: 'visible' });
        });
*/
    },250);
    $("input#searchbox").labelify({labelledClass: "inputtip"});
    
    $('#whatwhyhow-questions').localScroll({
        target:'#whatwhyhow-answers'
    });
    $("#whatwhyhow-questions a").click(function(event){
        event.preventDefault();
        $('#whatwhyhow-arrow').animate({ top: $(this).attr("rel") } );
    });
    $('.mim a.thumb').click(function(){
        var mimImage = $(this).attr('href') + ' .mim-image'
        $(mimImage).html('<img src="'+$(this).attr('rel')+'" alt="'+$(this+' img').attr('alt')+'" />');
    });
    $('.mim a.thumb').fancyZoom({scaleImg: true, closeOnClick: true, directory: '/templates/joomlavi/js/images', width: 700, height: 600});
});

