/* Copyright (c) 2010 Christian Pfeiffer (christian.pfeiffer.k@gmail.com || http://www.fancydesign.de)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Project: jQuery Pageswitch Plugin
 * Last Change: 2010-11-22
 * Version: 1.00
 * 
 */
 
 
j$('head').append('<style type="text/css">#wrapper{display:none;}</style>');

j$(function(){
    j$('#wrapper').fadeIn(1000);
}); 

(function(j$){
    j$.fn.pageswitch = function(options) {
        var defaults = {
            url:'default',
            event:'click',
            target:'#wrapper',
            properties: { opacity: 0 },
            options:{ duration: 750, easing: "linear", queue: true }
        };

        var options = j$.extend(defaults, options);

        return this.each(function() {
            if(options.url == 'default') var target = j$(this).attr('href');
            else var target = options.url;

            j$(this).bind(options.event, function() {
                options.options.complete = function() { window.location.replace(target) };
                j$(options.target).animate(options.properties, options.options);
                return false;
            });
          });
     };
})(jQuery);

j$(document).ready(function() {
    j$('#global a').pageswitch();

    // フルパスは横スライド
//     j$('#example a:eq(1)').pageswitch({
//         // select the second a-tag
//         url:        'index.html',
//         // overwrites the a-href
//         properties: { marginLeft: -j$('body').width() },
//         // manipulates the margin of the target    
//         options:     { duration: 1000 }        // sets the duration of animation
//     });
});

