jQuery(function() {
         var wait=0;
         $(document).ready(function(){
                $('#td_logo').pngFix();
                sameHeight($(".sameHeight"));
                var galleryurl='/gallery.en.shtml';
                $("#slideshow").jCarouselLite({
                    auto: 4000,
                    speed: 1500,
                    visible:12,
                    beforeStart: function(a) {

                         if(window.location.pathname==galleryurl){
                             if(wait>0){
                                 wait=wait-1;
                             }else{
                                var li=a.children();
                                var temp =$(li[9]).attr('id');
                                var imgobject = ('#'+temp);
                                $().jumpintogallery($(imgobject));
                             }
                         }
                    }
                });
                $(".images a").click(function(e){
                    // stop normal link click
                    e.preventDefault();
                    var galleryurl='gallery.en.shtml';
                    window.location=galleryurl+'#'+this.id;
                    wait=1;
                    $().jumpintogallery(this);
                });
                $().jumpintogallery();


                /*$('#logo').crossSlide({
                  fade: 3
                }, [
                  {
                    src:  '/images/revolving/the-peak.jpg',
                    from: '100% 100% 1x',
                    to:   '100% 100% 1x',
                    time: 5
                  }, {
                    src:  '/images/revolving/3d.jpg',
                    from: '100% 90% 1x',
                    to:   '100% 30% 1.2x',
                    time: 5
                  }, {
                    src:  '/images/revolving/white-out.jpg',
                    from: '100% 50% 1x',
                    to:   '100% 0% 1x',
                    time: 5
                  }, {
                    src:  '/images/revolving/spa.jpg',
                    from: '100% 90% 1.2x',
                    to:   '70% 20% 0.93x',
                    time: 5
                  }

                ])*/;

                $('#logo').crossSlide({
                  sleep: 6.5,
                  fade: 1.5
                }, [
                  { src: '/images/revolving_sm/the_peak.jpg' },
                  { src: '/images/revolving_sm/white-out.jpg'  },
                  { src: '/images/revolving_sm/3d.jpg' },
                  { src: '/images/revolving_sm/spa.jpg' }
                ]);
         });
});



function sameHeight(all) {
    var max = 0;
    all.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > max) {
            max = thisHeight;
        }
    });
    all.height(max);
}
