(function($){$.fn.fold=function(options){var ie55=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 5.5")!=-1);var ie6=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 6.0")!=-1);if(ie55||ie6){this.remove();return true;}
options=options||{};var defaults={directory:'',side:'bottomRight',turnImage:'img/misc/fold-nw.png',maxHeight:500,maxWidth:800,starting_width:80,starting_height:80,autoCurl:false};if(options.side=='right'&&!options.turnImage)defaults.turnImage='fold-sw.png';if(options.side=='bottomRight'&&!options.turnImage)defaults.turnImage='fold-nw.png';var options=$.extend(defaults,options);var turn_hideme=$('<div id="turn_hideme">');var turn_wrapper=$('<div id="turn_wrapper">');var turn_object=$('<div id="turn_object">');var img=$('<img id="turn_fold" src="'+(options.directory+'/'+options.turnImage)+'">');turn_object.css({width:options.starting_width,height:options.starting_height});if(options.side=='right')turn_wrapper.addClass('right');if(options.side=='bottomRight')turn_wrapper.addClass('bottomRight');this.wrap(turn_wrapper).wrap(turn_object).after(img).wrap(turn_hideme);turn_wrapper=$('#turn_wrapper');turn_object=$('#turn_object');if(!options.autoCurl){turn_object.resizable({aspectRatio:false,ratio:true,border:false,handles:'nw',maxWidth:options.maxWidth,maxHeight:options.maxHeight,stop:function(){var currentHeight=$(this).height();if(currentHeight==options.maxHeight){$("#target",this).css("z-index","9999");}else{$("#target",this).css("z-index","0");}},resize:function(){$("#target",this).css("z-index","0")}});}else{turn_wrapper.hover(function(){turn_object.stop().animate({width:options.maxHeight,height:options.maxHeight});},function(){turn_object.stop().animate({width:options.starting_height,height:options.starting_height});});}};})(jQuery);
