/* QuickFlip jQuery Plugin
 * Author  :   Jon Raasch 
 * Website :   http://jonraasch.com/blog/quickflip-jquery-plugin
 * Contact :   jr@jonraasch.com
 * Version :   0.1
 * Copyright (c)2008 Jon Raasch. All rights reserved.
 * Released under FreeBSD License, see readme.txt
 * Do not remove the above copyright notice or text
 */

var quickFlip={wrappers:[],newPanel:[],oldPanel:[],speed:[100,100],createFlip:function(b,c,e){var a="";for(z=0;z<2;z++)a+='<div class="'+(z==0?"flipColLeft":"flipColRight")+'" style="width: '+e+"px; height: "+b.height+"; "+(z==0?"right":"left")+": "+b.halfwidth+'px;"><div class="'+b.classNames[c]+'">'+b.panels[c].html()+"</div></div>";return a},flip:function(b,c,e){var a=quickFlip.wrappers[b],d=a.panels.length>c+1?c+1:0;quickFlip.newPanel=Array(b,d);quickFlip.oldPanel=Array(b,c);var k=quickFlip.createFlip(a,
c,a.halfwidth),l=quickFlip.createFlip(a,d,0);a.panels[c].hide();a.wrapper.append(k);var f=$(".flipColLeft, .flipColRight",a.wrapper),g=0,h=0,i=typeof a.speed=="undefined"?quickFlip.speed:a.speed;f.animate({width:0},i[0],function(){if(g){f.remove();a.wrapper.append(l);var j=$(".flipColLeft, .flipColRight",a.wrapper);j.animate({width:a.halfwidth},i[1],function(){if(h){j.remove();a.panels[d].show();switch(e){case -1:quickFlip.flip(b,d,-1);break;case 1:if($.browser.msie){typeof quickFlip.reattachEvents==
"function"&&quickFlip.reattachEvents();quickFlip.attachHandlers($(".clickFlip",a.panels[d]),b,d)}break;default:quickFlip.flip(b,d,e-1);break}}else h++})}else g++})},attachHandlers:function(b,c,e){b.click(function(a){a.preventDefault();quickFlip.flip(c,e,1)})},init:function(){quickFlip.wrappers=[];$(".quickFlip").each(function(b){var c=$(this),e={wrapper:c,halfwidth:parseInt(parseInt(c.css("width"))/2),height:c.css("height"),classNames:[],panels:[]};c.children(".quickFlipPanel").each(function(a){var d=
$(this);e.panels.push(d);e.classNames.push(d[0].className);quickFlip.attachHandlers($(".clickFlip",d),b,a);a&&d.hide()});quickFlip.wrappers.push(e)})}};$(function(){quickFlip.init()});
