// JavaScript Document
/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 9/11/2008
 * @author Ariel Flesler
 * @version 1.4
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(h){var m=h.scrollTo=function(b,c,g){h(window).scrollTo(b,c,g)};m.defaults={axis:'y',duration:1};m.window=function(b){return h(window).scrollable()};h.fn.scrollable=function(){return this.map(function(){var b=this.parentWindow||this.defaultView,c=this.nodeName=='#document'?b.frameElement||b:this,g=c.contentDocument||(c.contentWindow||c).document,i=c.setInterval;return c.nodeName=='IFRAME'||i&&h.browser.safari?g.body:i?g.documentElement:this})};h.fn.scrollTo=function(r,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};a=h.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=h(k),d=r,l,e={},p=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(d)){d=n(d);break}d=h(d,this);case'object':if(d.is||d.style)l=(d=h(d)).offset()}h.each(a.axis.split(''),function(b,c){var g=c=='x'?'Left':'Top',i=g.toLowerCase(),f='scroll'+g,s=k[f],t=c=='x'?'Width':'Height',v=t.toLowerCase();if(l){e[f]=l[i]+(p?0:s-o.offset()[i]);if(a.margin){e[f]-=parseInt(d.css('margin'+g))||0;e[f]-=parseInt(d.css('border'+g+'Width'))||0}e[f]+=a.offset[i]||0;if(a.over[i])e[f]+=d[v]()*a.over[i]}else e[f]=d[i];if(/^\d+$/.test(e[f]))e[f]=e[f]<=0?0:Math.min(e[f],u(t));if(!b&&a.queue){if(s!=e[f])q(a.onAfterFirst);delete e[f]}});q(a.onAfter);function q(b){o.animate(e,j,a.easing,b&&function(){b.call(this,r,a)})};function u(b){var c='scroll'+b,g=k.ownerDocument;return p?Math.max(g.documentElement[c],g.body[c]):k[c]}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);


// JavaScript Document
(function($) {
 
/**
 * A page loading progress object. Initialized by passing a "loader" element in
 * which the loading progress will be displayed by a
 * <div><span>[dynamicPercentage]</span>%</div>
 *
 * e.g. Insert <div id="loader"></div> inside your page.tpl.php (or html...)
 *      then follow usage :)
 *
 * Usage:
 *    $('#loader').loader({options});
 *
 * Options:
 *    'wrapper': $(document.body),
 *        The element in which we check for the images to load
 *    'container': $('#container'),
 *        Container for your content which will get hidden then faded-in when
 *        the page has finished loading
 *    'loadingClass': 'loading',
 *        CSS class added to the loader and container for extra theming
 *    'callback': function(){}
 *        Callback function that gets called after $('#container') finished
 *        fading in
 *
 *
 * Version: 1.2 (30/04/2009)
 * Requires: jQuery v1.2.6+
 * Copyright (c) 2009 Vincent Gariepy
 * Dual licensed under the MIT (en.wikipedia.org/wiki/MIT_License)
 * and GPL (en.wikipedia.org/wiki/GNU_General_Public_License) licenses
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 
 */
 
  $.fn.loader = function(options) {
    return $.fn.loader.init(this, options);
  };
 
  $.fn.loader.init = function(loader, options) {
 
    if ($(loader).length <= 0) { return false; }
 
    var settings = {
      'wrapper': $(document.body),
      'container': $('#container'),
      'loadingClass': 'loading',
      'callback': function(){}
    };
    if (options) $.extend(settings, options);
 
    var $percent = $('<span>0</span>');
    var $loadel = $('<div></div>').text('%').prepend($percent);
    var $loader = $(loader).append($loadel);
 
    var $wrapper = $(settings.wrapper);
    var $container = $(settings.container);
 
    imgLoaded = 0;
    imgTotal = $('img:visible', $wrapper).length;
 
    if (imgTotal <= 0) { initLoaded(); return false; }
 
    // We can go ahead now, hide the content in $container and attach
    // behaviors
    $container.hide();
 
    $(loader).addClass(settings.loadingClass);
    $wrapper.addClass(settings.loadingClass).css('cursor','wait');
 
    $('img:visible', $wrapper).each(function(img){
      $(this).load(function(e){
        imgLoaded++;
        var percentLoaded = parseInt((parseInt(imgLoaded) * 100) / parseInt(imgTotal));
        $percent.text(percentLoaded);
        if (imgLoaded == imgTotal) {
          initLoaded();
        }
      });
    });
 
    initLoaded = function() {
      $container.fadeIn('normal',function() {
        $loader.removeClass(settings.loadingClass).stop().fadeOut('normal');
        $wrapper.removeClass(settings.loadingClass).css('cursor','auto');
        if (typeof(settings.callback) == 'function') $(settings.callback({'loaded': true}));
        if ($.browser.msie) {
          fixIEfilter(this);
        }
      });
    };
 
    // Force initLoaded() when images don't fire .load()
    $(window).load( function() {
      $percent.text('100');
      initLoaded();
    });
 
    return loader;
  };
 
  // Replace with your own fading/IE filters solution if you like, otherwise
  // its needed
  fixIEfilter = function(els) {
    $(els).each(function(i){
      if ($(this).length > 0) {
        if (this.style.filter && this.style.removeAttribute) {
          this.style.removeAttribute('filter');
        }
      }
    });
  };
 
})(jQuery);