﻿/// <reference path="jquery-1.3.2.min-vsdoc.js" />
/*
* Naxma coporate web site
*
* Copyright © 2009 naxma-Software http://www.naxma.com
* All rights reserved.
*
*/

var $j = jQuery.noConflict();

var naxmaSite = {

    version: "1.0",

    // nNapTime in 1/1000 seconds
    sleep: function(nNapTime) {
        nNapTime += new Date().getTime();
        while (new Date().getTime() < nNapTime) { /* zzZZzz */ }
    },

    initTeaser: function() {

        var imagesToWaitFor = $j("#slider img").length;

        if (imagesToWaitFor > 0) {
            
            // Preload ajax image
            var img = new Image;
            img.src = $j("#ajax img").attr('src');

            $j("#ajax").animate({ opacity: "show" }, "slow");
        }

        $j("#slider img").each(function() {

            if (this.complete)
                initImage();
            else
                $j(this).unbind().bind('load', initImage);

            function initImage() {
                if (--imagesToWaitFor <= 0) {
                    $j("#slider").easySlider({
                        auto: true,
                        continuous: true
                    });

                    $j("#ajax").stop().animate({ opacity: "hide" }, "slow");
                }
            }
        });
    }
}

$j(function() {
    // Init facybox anchors
    $j("a.fancy").fancybox({
        'overlayShow': true,
        'zoomSpeedIn': 600,
        'zoomSpeedOut': 500,
        'easingIn': 'easeOutBack',
        'easingOut': 'easeInBack'
    });

    // Init lavamenu
    $j('#lavaMenu').lavaLamp({
        fx: 'easeOutBack',
        speed: 800
    });

    naxmaSite.initTeaser();
});
