/*
 * FancyBox - jQuery Plugin
 * Simple and fancy lightbox alternative
 *
 * Examples and documentation at: http://fancybox.net
 * 
 * Copyright (c) 2008 - 2010 Janis Skarnelis
 * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
 * 
 * Version: 1.3.4 (11/11/2010)
 * Requires: jQuery v1.3+
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
;(function(b){var m,t,u,f,D,j,E,n,z,A,q=0,e={},o=[],p=0,d={},l=[],G=null,v=new Image,J=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,W=/[^\.]\.(swf)\s*$/i,K,L=1,y=0,s="",r,i,h=false,B=b.extend(b("<div/>")[0],{prop:0}),M=b.browser.msie&&b.browser.version<7&&!window.XMLHttpRequest,N=function(){t.hide();v.onerror=v.onload=null;G&&G.abort();m.empty()},O=function(){if(false===e.onError(o,q,e)){t.hide();h=false}else{e.titleShow=false;e.width="auto";e.height="auto";m.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');
F()}},I=function(){var a=o[q],c,g,k,C,P,w;N();e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));w=e.onStart(o,q,e);if(w===false)h=false;else{if(typeof w=="object")e=b.extend(e,w);k=e.title||(a.nodeName?b(a).attr("title"):a.title)||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(k===""&&e.orig&&e.titleFromAlt)k=e.orig.attr("alt");c=e.href||(a.nodeName?b(a).attr("href"):a.href)||null;if(/^(?:javascript)/i.test(c)||
c=="#")c=null;if(e.type){g=e.type;if(!c)c=e.content}else if(e.content)g="html";else if(c)g=c.match(J)?"image":c.match(W)?"swf":b(a).hasClass("iframe")?"iframe":c.indexOf("#")===0?"inline":"ajax";if(g){if(g=="inline"){a=c.substr(c.indexOf("#"));g=b(a).length>0?"inline":"ajax"}e.type=g;e.href=c;e.title=k;if(e.autoDimensions)if(e.type=="html"||e.type=="inline"||e.type=="ajax"){e.width="auto";e.height="auto"}else e.autoDimensions=false;if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=
false;e.enableEscapeButton=false;e.showCloseButton=false}e.padding=parseInt(e.padding,10);e.margin=parseInt(e.margin,10);m.css("padding",e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(j.children())});switch(g){case "html":m.html(e.content);F();break;case "inline":if(b(a).parent().is("#fancybox-content")===true){h=false;break}b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(j.children())}).bind("fancybox-cancel",
function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();v=new Image;v.onerror=function(){O()};v.onload=function(){h=true;v.onerror=v.onload=null;e.width=v.width;e.height=v.height;b("<img />").attr({id:"fancybox-img",src:v.src,alt:e.title}).appendTo(m);Q()};v.src=c;break;case "swf":e.scrolling="no";C='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+c+
'"></param>';P="";b.each(e.swf,function(x,H){C+='<param name="'+x+'" value="'+H+'"></param>';P+=" "+x+'="'+H+'"'});C+='<embed src="'+c+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+P+"></embed></object>";m.html(C);F();break;case "ajax":h=false;b.fancybox.showActivity();e.ajax.win=e.ajax.success;G=b.ajax(b.extend({},e.ajax,{url:c,data:e.ajax.data||{},error:function(x){x.status>0&&O()},success:function(x,H,R){if((typeof R=="object"?R:G).status==200){if(typeof e.ajax.win==
"function"){w=e.ajax.win(c,x,H,R);if(w===false){t.hide();return}else if(typeof w=="string"||typeof w=="object")x=w}m.html(x);F()}}}));break;case "iframe":Q()}}else O()}},F=function(){var a=e.width,c=e.height;a=a.toString().indexOf("%")>-1?parseInt((b(window).width()-e.margin*2)*parseFloat(a)/100,10)+"px":a=="auto"?"auto":a+"px";c=c.toString().indexOf("%")>-1?parseInt((b(window).height()-e.margin*2)*parseFloat(c)/100,10)+"px":c=="auto"?"auto":c+"px";m.wrapInner('<div style="width:'+a+";height:"+c+
";overflow: "+(e.scrolling=="auto"?"auto":e.scrolling=="yes"?"scroll":"hidden")+';position:relative;"></div>');e.width=m.width();e.height=m.height();Q()},Q=function(){var a,c;t.hide();if(f.is(":visible")&&false===d.onCleanup(l,p,d)){b.event.trigger("fancybox-cancel");h=false}else{h=true;b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");f.is(":visible")&&d.titlePosition!=="outside"&&f.css("height",f.height());l=o;p=q;d=e;if(d.overlayShow){u.css({"background-color":d.overlayColor,
opacity:d.overlayOpacity,cursor:d.hideOnOverlayClick?"pointer":"auto",height:b(document).height()});if(!u.is(":visible")){M&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});u.show()}}else u.hide();i=X();s=d.title||"";y=0;n.empty().removeAttr("style").removeClass();if(d.titleShow!==false){if(b.isFunction(d.titleFormat))a=d.titleFormat(s,l,p,d);else a=s&&s.length?
d.titlePosition=="float"?'<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+s+'</td><td id="fancybox-title-float-right"></td></tr></table>':'<div id="fancybox-title-'+d.titlePosition+'">'+s+"</div>":false;s=a;if(!(!s||s==="")){n.addClass("fancybox-title-"+d.titlePosition).html(s).appendTo("body").show();switch(d.titlePosition){case "inside":n.css({width:i.width-d.padding*2,marginLeft:d.padding,marginRight:d.padding});
y=n.outerHeight(true);n.appendTo(D);i.height+=y;break;case "over":n.css({marginLeft:d.padding,width:i.width-d.padding*2,bottom:d.padding}).appendTo(D);break;case "float":n.css("left",parseInt((n.width()-i.width-40)/2,10)*-1).appendTo(f);break;default:n.css({width:i.width-d.padding*2,paddingLeft:d.padding,paddingRight:d.padding}).appendTo(f)}}}n.hide();if(f.is(":visible")){b(E.add(z).add(A)).hide();a=f.position();r={top:a.top,left:a.left,width:f.width(),height:f.height()};c=r.width==i.width&&r.height==
i.height;j.fadeTo(d.changeFade,0.3,function(){var g=function(){j.html(m.contents()).fadeTo(d.changeFade,1,S)};b.event.trigger("fancybox-change");j.empty().removeAttr("filter").css({"border-width":d.padding,width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2});if(c)g();else{B.prop=0;b(B).animate({prop:1},{duration:d.changeSpeed,easing:d.easingChange,step:T,complete:g})}})}else{f.removeAttr("style");j.css("border-width",d.padding);if(d.transitionIn=="elastic"){r=V();j.html(m.contents());
f.show();if(d.opacity)i.opacity=0;B.prop=0;b(B).animate({prop:1},{duration:d.speedIn,easing:d.easingIn,step:T,complete:S})}else{d.titlePosition=="inside"&&y>0&&n.show();j.css({width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2}).html(m.contents());f.css(i).fadeIn(d.transitionIn=="none"?0:d.speedIn,S)}}}},Y=function(){if(d.enableEscapeButton||d.enableKeyboardNav)b(document).bind("keydown.fb",function(a){if(a.keyCode==27&&d.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if((a.keyCode==
37||a.keyCode==39)&&d.enableKeyboardNav&&a.target.tagName!=="INPUT"&&a.target.tagName!=="TEXTAREA"&&a.target.tagName!=="SELECT"){a.preventDefault();b.fancybox[a.keyCode==37?"prev":"next"]()}});if(d.showNavArrows){if(d.cyclic&&l.length>1||p!==0)z.show();if(d.cyclic&&l.length>1||p!=l.length-1)A.show()}else{z.hide();A.hide()}},S=function(){if(!b.support.opacity){j.get(0).style.removeAttribute("filter");f.get(0).style.removeAttribute("filter")}e.autoDimensions&&j.css("height","auto");f.css("height","auto");
s&&s.length&&n.show();d.showCloseButton&&E.show();Y();d.hideOnContentClick&&j.bind("click",b.fancybox.close);d.hideOnOverlayClick&&u.bind("click",b.fancybox.close);b(window).bind("resize.fb",b.fancybox.resize);d.centerOnScroll&&b(window).bind("scroll.fb",b.fancybox.center);if(d.type=="iframe")b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" '+(b.browser.msie?'allowtransparency="true""':"")+' scrolling="'+e.scrolling+'" src="'+d.href+'"></iframe>').appendTo(j);
f.show();h=false;b.fancybox.center();d.onComplete(l,p,d);var a,c;if(l.length-1>p){a=l[p+1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}if(p>0){a=l[p-1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}},T=function(a){var c={width:parseInt(r.width+(i.width-r.width)*a,10),height:parseInt(r.height+(i.height-r.height)*a,10),top:parseInt(r.top+(i.top-r.top)*a,10),left:parseInt(r.left+(i.left-r.left)*a,10)};if(typeof i.opacity!=="undefined")c.opacity=a<0.5?0.5:a;f.css(c);
j.css({width:c.width-d.padding*2,height:c.height-y*a-d.padding*2})},U=function(){return[b(window).width()-d.margin*2,b(window).height()-d.margin*2,b(document).scrollLeft()+d.margin,b(document).scrollTop()+d.margin]},X=function(){var a=U(),c={},g=d.autoScale,k=d.padding*2;c.width=d.width.toString().indexOf("%")>-1?parseInt(a[0]*parseFloat(d.width)/100,10):d.width+k;c.height=d.height.toString().indexOf("%")>-1?parseInt(a[1]*parseFloat(d.height)/100,10):d.height+k;if(g&&(c.width>a[0]||c.height>a[1]))if(e.type==
"image"||e.type=="swf"){g=d.width/d.height;if(c.width>a[0]){c.width=a[0];c.height=parseInt((c.width-k)/g+k,10)}if(c.height>a[1]){c.height=a[1];c.width=parseInt((c.height-k)*g+k,10)}}else{c.width=Math.min(c.width,a[0]);c.height=Math.min(c.height,a[1])}c.top=parseInt(Math.max(a[3]-20,a[3]+(a[1]-c.height-40)*0.5),10);c.left=parseInt(Math.max(a[2]-20,a[2]+(a[0]-c.width-40)*0.5),10);return c},V=function(){var a=e.orig?b(e.orig):false,c={};if(a&&a.length){c=a.offset();c.top+=parseInt(a.css("paddingTop"),
10)||0;c.left+=parseInt(a.css("paddingLeft"),10)||0;c.top+=parseInt(a.css("border-top-width"),10)||0;c.left+=parseInt(a.css("border-left-width"),10)||0;c.width=a.width();c.height=a.height();c={width:c.width+d.padding*2,height:c.height+d.padding*2,top:c.top-d.padding-20,left:c.left-d.padding-20}}else{a=U();c={width:d.padding*2,height:d.padding*2,top:parseInt(a[3]+a[1]*0.5,10),left:parseInt(a[2]+a[0]*0.5,10)}}return c},Z=function(){if(t.is(":visible")){b("div",t).css("top",L*-40+"px");L=(L+1)%12}else clearInterval(K)};
b.fn.fancybox=function(a){if(!b(this).length)return this;b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(c){c.preventDefault();if(!h){h=true;b(this).blur();o=[];q=0;c=b(this).attr("rel")||"";if(!c||c==""||c==="nofollow")o.push(this);else{o=b("a[rel="+c+"], area[rel="+c+"]");q=o.index(this)}I()}});return this};b.fancybox=function(a,c){var g;if(!h){h=true;g=typeof c!=="undefined"?c:{};o=[];q=parseInt(g.index,10)||0;if(b.isArray(a)){for(var k=
0,C=a.length;k<C;k++)if(typeof a[k]=="object")b(a[k]).data("fancybox",b.extend({},g,a[k]));else a[k]=b({}).data("fancybox",b.extend({content:a[k]},g));o=jQuery.merge(o,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},g,a));else a=b({}).data("fancybox",b.extend({content:a},g));o.push(a)}if(q>o.length||q<0)q=0;I()}};b.fancybox.showActivity=function(){clearInterval(K);t.show();K=setInterval(Z,66)};b.fancybox.hideActivity=function(){t.hide()};b.fancybox.next=function(){return b.fancybox.pos(p+
1)};b.fancybox.prev=function(){return b.fancybox.pos(p-1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a);o=l;if(a>-1&&a<l.length){q=a;I()}else if(d.cyclic&&l.length>1){q=a>=l.length?0:l.length-1;I()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");N();e.onCancel(o,q,e);h=false}};b.fancybox.close=function(){function a(){u.fadeOut("fast");n.empty().hide();f.hide();b.event.trigger("fancybox-cleanup");j.empty();d.onClosed(l,p,d);l=e=[];p=q=0;d=e={};h=false}if(!(h||f.is(":hidden"))){h=
true;if(d&&false===d.onCleanup(l,p,d))h=false;else{N();b(E.add(z).add(A)).hide();b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");j.find("iframe").attr("src",M&&/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank");d.titlePosition!=="inside"&&n.empty();f.stop();if(d.transitionOut=="elastic"){r=V();var c=f.position();i={top:c.top,left:c.left,width:f.width(),height:f.height()};if(d.opacity)i.opacity=1;n.empty().hide();B.prop=1;
b(B).animate({prop:0},{duration:d.speedOut,easing:d.easingOut,step:T,complete:a})}else f.fadeOut(d.transitionOut=="none"?0:d.speedOut,a)}}};b.fancybox.resize=function(){u.is(":visible")&&u.css("height",b(document).height());b.fancybox.center(true)};b.fancybox.center=function(a){var c,g;if(!h){g=a===true?1:0;c=U();!g&&(f.width()>c[0]||f.height()>c[1])||f.stop().animate({top:parseInt(Math.max(c[3]-20,c[3]+(c[1]-j.height()-40)*0.5-d.padding)),left:parseInt(Math.max(c[2]-20,c[2]+(c[0]-j.width()-40)*0.5-
d.padding))},typeof a=="number"?a:200)}};b.fancybox.init=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),t=b('<div id="fancybox-loading"><div></div></div>'),u=b('<div id="fancybox-overlay"></div>'),f=b('<div id="fancybox-wrap"></div>'));D=b('<div id="fancybox-outer"></div>').append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>').appendTo(f);
D.append(j=b('<div id="fancybox-content"></div>'),E=b('<a id="fancybox-close"></a>'),n=b('<div id="fancybox-title"></div>'),z=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),A=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));E.click(b.fancybox.close);t.click(b.fancybox.cancel);z.click(function(a){a.preventDefault();b.fancybox.prev()});A.click(function(a){a.preventDefault();b.fancybox.next()});
b.fn.mousewheel&&f.bind("mousewheel.fb",function(a,c){if(h)a.preventDefault();else if(b(a.target).get(0).clientHeight==0||b(a.target).get(0).scrollHeight===b(a.target).get(0).clientHeight){a.preventDefault();b.fancybox[c>0?"prev":"next"]()}});b.support.opacity||f.addClass("fancybox-ie");if(M){t.addClass("fancybox-ie6");f.addClass("fancybox-ie6");b('<iframe id="fancybox-hide-sel-frame" src="'+(/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank")+'" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(D)}}};
b.fn.fancybox.defaults={padding:10,margin:40,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:"#777",titleShow:true,titlePosition:"float",titleFormat:null,titleFromAlt:false,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing",
easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};b(document).ready(function(){b.fancybox.init()})})(jQuery);

/**
 * jQuery.timers - Timer abstractions for jQuery
 * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
 * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
 * Date: 2009/10/16
 *
 * @author Blair Mitchelmore
 * @version 1.2
 *
 **/
jQuery.fn.extend({everyTime:function(interval,label,fn,times){return this.each(function(){jQuery.timer.add(this,interval,label,fn,times);});},oneTime:function(interval,label,fn){return this.each(function(){jQuery.timer.add(this,interval,label,fn,1);});},stopTime:function(label,fn){return this.each(function(){jQuery.timer.remove(this,label,fn);});}});jQuery.extend({timer:{global:[],guid:1,dataKey:"jQuery.timer",regex:/^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,powers:{'ms':1,'cs':10,'ds':100,'s':1000,'das':10000,'hs':100000,'ks':1000000},timeParse:function(value){if(value==undefined||value==null)
return null;var result=this.regex.exec(jQuery.trim(value.toString()));if(result[2]){var num=parseFloat(result[1]);var mult=this.powers[result[2]]||1;return num*mult;}else{return value;}},add:function(element,interval,label,fn,times){var counter=0;if(jQuery.isFunction(label)){if(!times)
times=fn;fn=label;label=interval;}
interval=jQuery.timer.timeParse(interval);if(typeof interval!='number'||isNaN(interval)||interval<0)
return;if(typeof times!='number'||isNaN(times)||times<0)
times=0;times=times||0;var timers=jQuery.data(element,this.dataKey)||jQuery.data(element,this.dataKey,{});if(!timers[label])
timers[label]={};fn.timerID=fn.timerID||this.guid++;var handler=function(){if((++counter>times&times!==0)||fn.call(element,counter)===false)
jQuery.timer.remove(element,label,fn);};handler.timerID=fn.timerID;if(!timers[label][fn.timerID])
timers[label][fn.timerID]=window.setInterval(handler,interval);this.global.push(element);},remove:function(element,label,fn){var timers=jQuery.data(element,this.dataKey),ret;if(timers){if(!label){for(label in timers)
this.remove(element,label,fn);}else if(timers[label]){if(fn){if(fn.timerID){window.clearInterval(timers[label][fn.timerID]);delete timers[label][fn.timerID];}}else{for(var fn in timers[label]){window.clearInterval(timers[label][fn]);delete timers[label][fn];}}
for(ret in timers[label])break;if(!ret){ret=null;delete timers[label];}}
for(ret in timers)break;if(!ret)
jQuery.removeData(element,this.dataKey);}}}});jQuery(window).bind("unload",function(){jQuery.each(jQuery.timer.global,function(index,item){jQuery.timer.remove(item);});});

/**
 * jquery.placeholder
 * http://mths.be/placeholder v1.8.5 by @mathias
 **/
(function(g,a,$){var f='placeholder' in a.createElement('input'),b='placeholder' in a.createElement('textarea');if(f&&b){$.fn.placeholder=function(){return this};$.fn.placeholder.input=$.fn.placeholder.textarea=true}else{$.fn.placeholder=function(){return this.filter((f?'textarea':':input')+'[placeholder]').bind('focus.placeholder',c).bind('blur.placeholder',e).trigger('blur.placeholder').end()};$.fn.placeholder.input=f;$.fn.placeholder.textarea=b;$(function(){$('form').bind('submit.placeholder',function(){var h=$('.placeholder',this).each(c);setTimeout(function(){h.each(e)},10)})});$(g).bind('unload.placeholder',function(){$('.placeholder').val('')})}function d(i){var h={},j=/^jQuery\d+$/;$.each(i.attributes,function(l,k){if(k.specified&&!j.test(k.name)){h[k.name]=k.value}});return h}function c(){var h=$(this);if(h.val()===h.attr('placeholder')&&h.hasClass('placeholder')){if(h.data('placeholder-password')){h.hide().next().show().focus().attr('id',h.removeAttr('id').data('placeholder-id'))}else{h.val('').removeClass('placeholder')}}}function e(){var l,k=$(this),h=k,j=this.id;if(k.val()===''){if(k.is(':password')){if(!k.data('placeholder-textinput')){try{l=k.clone().attr({type:'text'})}catch(i){l=$('<input>').attr($.extend(d(this),{type:'text'}))}l.removeAttr('name').data('placeholder-password',true).data('placeholder-id',j).bind('focus.placeholder',c);k.data('placeholder-textinput',l).data('placeholder-id',j).before(l)}k=k.removeAttr('id').hide().prev().attr('id',j).show()}k.addClass('placeholder').val(k.attr('placeholder'))}else{k.removeClass('placeholder')}}}(this,document,jQuery));

/**
 * jquery.pajinate.js - version 0.4
 * A jQuery plugin for paginating through any number of DOM elements
 * 
 * Copyright (c) 2010, Wes Nolte (http://wesnolte.com)
 * Liscensed under the MIT License (MIT-LICENSE.txt)
 * http://www.opensource.org/licenses/mit-license.php
 * Created: 2010-04-16 | Updated: 2010-04-26
 *
 * Modified goto function to add the page number in the location hash - glegault@lesaffranchis.ca
 **/
;(function($){$.fn.pajinate=function(options){var current_page='current_page';var items_per_page='items_per_page';var meta;var defaults={item_container_id:'.content',items_per_page:10,nav_panel_id:'.page_navigation',num_page_links_to_display:20,start_page:0,wrap_around:false,nav_label_first:'First',nav_label_prev:'Prev',nav_label_next:'Next',nav_label_last:'Last',show_first_last:true};var options=$.extend(defaults,options);var $item_container;var $page_container;var $items;var $nav_panels;var total_page_no_links;return this.each(function(){$page_container=$(this);$item_container=$(this).find(options.item_container_id);$items=$page_container.find(options.item_container_id).children();meta=$page_container;meta.data(current_page,0);meta.data(items_per_page,options.items_per_page);var total_items=$item_container.children().size();var number_of_pages=Math.ceil(total_items/options.items_per_page);var more='<span class="ellipse more">...</span>';var less='<span class="ellipse less">...</span>';var first=!options.show_first_last?'':'<a class="first_link" href="">'+options.nav_label_first+'</a>';var last=!options.show_first_last?'':'<a class="last_link" href="">'+options.nav_label_last+'</a>';var navigation_html=first;navigation_html+='<a class="previous_link" href="">'+options.nav_label_prev+'</a>'+less;var current_link=0;while(number_of_pages>current_link){navigation_html+='<a class="page_link" href="" longdesc="'+current_link+'">'+(current_link+1)+'</a>';current_link++}navigation_html+=more+'<a class="next_link" href="">'+options.nav_label_next+'</a>';navigation_html+=last;$nav_panels=$page_container.find(options.nav_panel_id);$nav_panels.html(navigation_html).each(function(){$(this).find('.page_link:first').addClass('first');$(this).find('.page_link:last').addClass('last')});$nav_panels.children('.ellipse').hide();$nav_panels.find('.previous_link').next().next().addClass('active_page');$items.hide();$items.slice(0,meta.data(items_per_page)).show();total_page_no_links=$page_container.children(options.nav_panel_id+':first').children('.page_link').size();options.num_page_links_to_display=Math.min(options.num_page_links_to_display,total_page_no_links);$nav_panels.children('.page_link').hide();$nav_panels.each(function(){$(this).children('.page_link').slice(0,options.num_page_links_to_display).show()});$page_container.find('.first_link').click(function(e){e.preventDefault();movePageNumbersRight($(this),0);goto(0)});$page_container.find('.last_link').click(function(e){e.preventDefault();var lastPage=total_page_no_links-1;movePageNumbersLeft($(this),lastPage);goto(lastPage)});$page_container.find('.previous_link').click(function(e){e.preventDefault();showPrevPage($(this))});$page_container.find('.next_link').click(function(e){e.preventDefault();showNextPage($(this))});$page_container.find('.page_link').click(function(e){e.preventDefault();goto($(this).attr('longdesc'))});goto(parseInt(options.start_page));toggleMoreLess();if(!options.wrap_around)tagNextPrev()});function showPrevPage(e){new_page=parseInt(meta.data(current_page))-1;if($(e).siblings('.active_page').prev('.page_link').length==true){movePageNumbersRight(e,new_page);goto(new_page)}else if(options.wrap_around){goto(total_page_no_links-1)}};function showNextPage(e){new_page=parseInt(meta.data(current_page))+1;if($(e).siblings('.active_page').next('.page_link').length==true){movePageNumbersLeft(e,new_page);goto(new_page)}else if(options.wrap_around){goto(0)}};function goto(page_num){var ipp=parseInt(meta.data(items_per_page));var isLastPage=false;start_from=page_num*ipp;end_on=start_from+ipp;$items.hide().slice(start_from,end_on).show();$page_container.find(options.nav_panel_id).children('.page_link[longdesc='+page_num+']').addClass('active_page').siblings('.active_page').removeClass('active_page');meta.data(current_page,page_num);toggleMoreLess();tagNextPrev();window.location.hash=page_num;};function movePageNumbersLeft(e,new_p){var new_page=new_p;var $current_active_link=$(e).siblings('.active_page');if($current_active_link.siblings('.page_link[longdesc='+new_page+']').css('display')=='none'){$nav_panels.each(function(){$(this).children('.page_link').hide().slice(parseInt(new_page-options.num_page_links_to_display+1),new_page+1).show()})}}function movePageNumbersRight(e,new_p){var new_page=new_p;var $current_active_link=$(e).siblings('.active_page');if($current_active_link.siblings('.page_link[longdesc='+new_page+']').css('display')=='none'){$nav_panels.each(function(){$(this).children('.page_link').hide().slice(new_page,new_page+parseInt(options.num_page_links_to_display)).show()})}}function toggleMoreLess(){if(!$nav_panels.children('.page_link:visible').hasClass('last')){$nav_panels.children('.more').show()}else{$nav_panels.children('.more').hide()}if(!$nav_panels.children('.page_link:visible').hasClass('first')){$nav_panels.children('.less').show()}else{$nav_panels.children('.less').hide()}}function tagNextPrev(){if($nav_panels.children('.last').hasClass('active_page')){$nav_panels.children('.next_link').add('.last_link').addClass('no_more')}else{$nav_panels.children('.next_link').add('.last_link').removeClass('no_more')}if($nav_panels.children('.first').hasClass('active_page')){$nav_panels.children('.previous_link').add('.first_link').addClass('no_more')}else{$nav_panels.children('.previous_link').add('.first_link').removeClass('no_more')}}}})(jQuery);


/**
 * jquery.slider
 * Gabriel Legault glegault@lesaffranchis.ca
 **/
(function($) {
	$.fn.slider = function(options) {
		var opts = $.extend({}, $.fn.slider.defaults, options);
		var $container = null;
		var $items = null;
		var $controls = null;
		var wrapper_width = 0;
		var anim_ready = true;
		return this.each(function() {
			// Set basic references
			$container = $(this);
			$items = $container.find(opts.item_selector);
			// Check if we need the slider
			if($items.length < 2)
			{
				return;
			}
			// Add controls
			$container.append('<div class="controls"><a href="#" class="prev"></a><ul></ul><a href="#" class="next"></a></div>');
			$controls = $container.find('div.controls');
			$items.each(function(){
				$controls.find('ul').append('<li><a href="#" class="item"></a></li>');
			});
			$controls.css({'margin-left': -($controls.width() / 2) + 'px'});
			// Wrap items
			$items.wrapAll('<div class="wrapper" />');
			$container = $container.find('.wrapper');
			wrapper_width = $container.width();
			$items.css({left: wrapper_width + opts.item_margin});
			// Animate to first slide
			next();
			// Manage clicks
			$controls.find('a').click(function(e){
				e.preventDefault();
				var $this = $(this);
				$this.blur();
				if(anim_ready)
				{
					if($this.hasClass('prev'))
					{
						next({dir: 'prev'});
					}
					else if($this.hasClass('next'))
					{
						next();
					}
					else if($this.hasClass('item'))
					{
						next({pos: $this.parents('li').index()});
					}
				}
			});
		}); // END .each()
		
		function next()
		{
			var args = arguments;
			var $current = $items.filter('.active');
			var cur_index = $current.index();
			var $next = null;
			var start_pos = wrapper_width + opts.item_margin;
			
			if($current.length == 0)
			{
				$next = $items.filter(':first');
			}
			else if(args.length > 0 && args[0].pos != undefined)
			{
				if(cur_index == args[0].pos)
				{
					return;
				}
				$next = $items.filter(':eq('+args[0].pos+')');
			}
			else if(args.length > 0 && args[0].dir == 'prev')
			{
				$next = $current.prev(opts.item_selector);
				if($next.length == 0)
				{
					$next = $items.filter(':last');
				}
				start_pos = -(wrapper_width + opts.item_margin);
			}
			else
			{
				$next = $current.next(opts.item_selector);
				if($next.length == 0)
				{
					$next = $items.filter(':first');
				}
			}
			$items.removeClass('last_active');
			$current.removeClass('active').addClass('last_active');
			var current_height = $current.height();
			var next_height = $next.height();
			$next.css({left: start_pos+'px'});
			anim_ready = false;
			// adapt height then animate
			if(next_height > current_height)
			{
				$container.animate({
					height: next_height+'px'
				}, opts.speed, function() {
					$next.addClass('active').animate({
						left: '0px'
					}, opts.speed, function(){
						uglyIE7Fix();
						anim_ready = true;
					});
					$current.animate({
						left: -start_pos+'px'
					}, opts.speed);
				});
			}
			// animate then adapt height
			else
			{
				$next.addClass('active').animate({
					left: '0px'
				}, opts.speed, function() {
					$container.animate({
						height: next_height+'px'
					}, opts.speed, function(){
						uglyIE7Fix();
						anim_ready = true;
					});
				});
				$current.animate({
					left: -start_pos+'px'
				}, opts.speed);
			}
			// Select control index
			$controls.find('ul li a').removeClass('active');
			$controls.find('ul li:eq('+$next.index()+') a').addClass('active');
		} // END next()
		
		function uglyIE7Fix()
		{
			if($.browser.msie && $.browser.version < 8) {
				var current = parseInt($controls.css('bottom'));
				$controls.css({bottom: (current + 10) + 'px'});
				$controls.css({bottom: current+'px'});
			}
		}
	}
	$.fn.slider.defaults = {
		item_selector: '',
		speed: 500,  // Transition speed
		delay: 5000, // Delay between slice change
		item_margin: 40
	}
})(jQuery);


/**
 * jquery.fader
 * Gabriel Legault glegault@lesaffranchis.ca
 * Dependancies: jquery.timers
 **/
(function($) {
	$.fn.fader = function(options) {
		var opts = $.extend({}, $.fn.fader.defaults, options);
		var $container = null;
		var $items = null;
		var $controls = null;
		var wrapper_width = 0;
		var anim_ready = true;
		return this.each(function() {
			// Set basic references
			$container = $(this);
			$items = $container.find(opts.item_selector);
			// Check if we need the fader
			if($items.length < 2)
			{
				return;
			}
			$container.append('<div class="controls"><a href="#" class="prev"></a><ul></ul><a href="#" class="next"></a></div>');
			$controls = $container.find('div.controls');
			$items.each(function(){
				$controls.find('ul').append('<li><a href="#" class="item"></a></li>');
			});
			$controls.css({'margin-left': -($controls.width() / 2) + 'px'});
			
			$items.hide();
			$items.filter(':first').stop().addClass('active').fadeTo(opts.speed, 1, function(){
				if(typeof(is_ie) != 'undefined' && is_ie)
				{
					this.style.removeAttribute('filter');
				}
			});
			$controls.find('ul li:first a').addClass('active');
			
			// Start timer and stop it when the windows loses focus
			var active = true;
			$container.everyTime(opts.delay, 'slide', function() {
				next();
			});
			$(window).blur(function(){
				if(active)
				{
					active = false;
					$container.stopTime('slide');
				}
			});
			$(window).focus(function(){
				if(!active)
				{
					active = true;
					$container.everyTime(opts.delay, 'slide', function() {
						next();
					});
				}
			});
			
			$controls.find('a').click(function(e){
				e.preventDefault();
				var $this = $(this);
				$this.blur();
				if(anim_ready)
				{
					$container.stopTime('slide');
					if($this.hasClass('prev'))
					{
						next({dir: 'prev'});
					}
					else if($this.hasClass('next'))
					{
						next();
					}
					else if($this.hasClass('item'))
					{
						next({pos: $this.parents('li').index()});
					}
					$container.everyTime(opts.delay, 'slide', function() {
						next();
					});
				}
			});
		}); // END .each()
		function next()
		{
			var args = arguments;
			var $current = $items.filter('.active');
			var cur_index = $current.index();
			var $next = null;
			
			if(args.length > 0 && args[0].pos != undefined)
			{
				if(cur_index == args[0].pos)
				{
					return;
				}
				$next = $items.filter(':eq('+args[0].pos+')');
			}
			else if(args.length > 0 && args[0].dir == 'prev')
			{
				$next = $current.prev(opts.item_selector);
				if($next.length == 0)
				{
					$next = $items.filter(':last');
				}
			}
			else
			{
				$next = $current.next(opts.item_selector);
				if($next.length == 0)
				{
					$next = $items.filter(':first');
				}
			}
			
			anim_ready = false;
			
			$items.removeClass('last_active');
			$current.removeClass('active').addClass('last_active');
			$next.addClass('active').stop().fadeTo(opts.speed, 1, function(){
				anim_ready = true;
				$current.stop().fadeTo(0, 0);
				if(typeof(is_ie) != 'undefined' && is_ie)
				{
					this.style.removeAttribute('filter');
				}
			});
			
			$controls.find('ul li a').removeClass('active');
			$controls.find('ul li:eq('+$next.index()+') a').addClass('active');
		}
	}
	$.fn.fader.defaults = {
		item_selector: '',
		speed: 500,  // Transition speed
		delay: 5000 // Delay between slice change
	}
})(jQuery);

/**
 * jquery.checkbox
 * Gabriel Legault glegault@lesaffranchis.ca
 **/
(function($) {
	$.fn.checkbox = function(options) {
		var opts = $.extend({}, $.fn.checkbox.defaults, options);
		return this.each(function() {
			var $this = $(this);
			if($this.is('input[type=checkbox]'))
			{
				$this.hide();
				var cbx_id  = $this.attr('id');
				$this.after('<div class="fs_checkbox '+cbx_id+'"></div>');
				var $checkbox = $this.siblings('div.fs_checkbox.'+cbx_id);
				if($this.is(':checked'))
				{
					$checkbox.addClass('fs_checked');
				}
				
				$checkbox.click(function(e){
					e.preventDefault();
					if($checkbox.hasClass('fs_checked'))
					{
						$checkbox.removeClass('fs_checked');
						$this.removeAttr('checked');
					}
					else
					{
						$checkbox.addClass('fs_checked');
						$this.attr('checked', 'checked');
					}
					
				});
			}
		});
	}
})(jQuery);


/**
 * jquery.dropdown
 * Gabriel Legault glegault@lesaffranchis.ca
 **/
(function($) {
	$.fn.dropdown = function(options) {
		var opts = $.extend({}, $.fn.dropdown.defaults, options);
		return this.each(function() {
			var $this = $(this);
			if($this.is('select'))
			{
				$this.hide();
				var sel_id  = $this.attr('id');
				$this.after('<div class="fs_select '+sel_id+'"><span class="fs_selected"></span><ul class="fs_dropdown"></ul></div>');
				var $select = $this.siblings('div.fs_select.'+sel_id);
				var $list = $select.find('ul');
				$list.hide();
				$select
					.data('id', $this.attr('id'))
					.mouseleave(function () {
						$list.hide();
						$select.removeClass('fs_opened');
					})
					.click(function (e) {
						e.stopPropagation();
						$list.show();
						$select.addClass('fs_opened');
					});
				$this.find('option').each(function () {
					var $current = $(this);
					$list.append('<li>' + $current.text() + '</li>');
					var $new_li = $list.find('li:last');
					$new_li.data('value', $current.attr('value'));
					if ($current.attr('selected')) {
						$select.find('span.fs_selected').text($current.text());
					}
				});
				$list.find('li').click(function (e) {
					e.stopPropagation();
					var $current = $(this);
					$this.find('option').removeAttr('selected');
					$this.find('option[value=' + $current.data('value') + ']').attr('selected', 'selected').trigger('click');
					$this.trigger('change');
					$select.find('span.fs_selected').text($current.text());
					$list.hide();
					$select.removeClass('fs_opened');
				});
			}
		});
	}
})(jQuery);

/**
 * jquery.textreplacer
 * Gabriel Legault glegault@lesaffranchis.ca
 **/
(function($) {
	$.fn.textreplacer = function(options) {
		var opts = $.extend({}, $.fn.textreplacer.defaults, options);
		var full_height = 0;
		var short_height = 0;
		return this.each(function() {
		
			var $container = $(this);
			var $full = $container.find('div.full');
			var $short = $container.find('div.short');
			
			if($full.length > 0 && $short.length > 0)
			{
				$full.show();
				$short.show();
				full_height = $full.height() + 18; // 18 est la hauteur de mon bouton, pour les cas ou le bouton - se retrouve tout seul sur la dernière ligne...
				short_height = $short.outerHeight();
				$full.hide();
				
				$short.find('p:last').append('<a href="#" class="more">+</a>');
				$full.find('p:last').append('<a href="#" class="less">-</a>');
				$short.find('a.more').click(function(e){
					e.preventDefault();
					$short.hide();
					$full.css({height: short_height + 'px'}).show().animate({height: full_height + 'px'}, 500);
				});
				$full.find('a.less').click(function(e){
					e.preventDefault();
					$full.animate({height: short_height + 'px'}, 500, function(){$full.hide();$short.show();})
				});
			}
		});
	}
})(jQuery);

/**
 * jquery.listexpander
 * Gabriel Legault glegault@lesaffranchis.ca
 **/
(function($) {
	$.fn.listexpander = function(options) {
		var opts = $.extend({}, $.fn.listexpander.defaults, options);
		return this.each(function() {
			var $big_list = $(this);
			var classes = $big_list.attr('class');
			var $container = $big_list.parent();
			while((group = $big_list.find('li:lt('+opts.row_length+')').remove()).length){
				$container.append('<ul class="'+classes+'" />');
				$big_list.siblings('ul:last').append(group);
			}
			$big_list.remove();
			
			
			$container.append('\n\
				<div id="'+opts.info_id+'">\n\
					<h3>Nom du diffusé</h3>\n\
					<div class="info">\n\
						<div class="description"></div>\n\
						<div class="contact"></div>\n\
						<div class="clear"></div>\n\
						<a href="#" class="website" target="_blank">Site Internet</a>\n\
						<a href="#" class="tools" target="_blank">Outils pédagogiques</a>\n\
					</div>\n\
					<a href="#" class="close"></a>\n\
				</div>');
			
			var $info = $('#'+opts.info_id).hide();
			
			$container.find('ul.'+classes+'>li').click(function(){
				var $this = $(this);
				
				if($this.hasClass('active'))
				{
					$info.slideUp(opts.speed, function(){
						$this.removeClass('active');
					});
					return;
				}
				
				$info.slideUp(opts.speed, function(){
					$container.find('li.active').removeClass('active');
					$this.addClass('active');
					var this_id = $this.attr('id');
					$this.attr('id', '__');
					window.location.hash = this_id;
					$this.attr('id', this_id);
					
					// Move info box to the correct position
					$this.parent().after($info);
					
					// Put new content in the info box
					$info.find('h3').html($this.find('strong').html());
					$info.find('div.description').html($this.find('div.description').html());
					$info.find('div.contact').html($this.find('div.contact').html());
					
					var $this_website = $this.find('a.website');
					var $info_website = $info.find('a.website');
					if($this_website.length > 0)
					{
						$info_website.attr('href', $this_website.attr('href'));
						$info_website.show();
					}
					else
					{
						$info_website.hide();
					}
					
					var $this_tools = $this.find('a.tools');
					var $info_tools = $info.find('a.tools');
					if($this_tools.length > 0)
					{
						$info_tools.attr('href', $this_tools.attr('href'));
						$info_tools.show();
					}
					else
					{
						$info_tools.hide();
					}
					
					// Show new content
					$info.slideDown(opts.speed, function(){
						$('html, body').stop().animate({
							scrollTop: $(window.location.hash).offset().top
						}, 500);
					});
				});
			});
			
			$info.find('a.close').click(function(e){
				e.preventDefault();
				$info.slideUp(opts.speed, function(){
					$container.find('li.active').removeClass('active');
				});
			});
			
			if(window.location.hash) {
				$(window.location.hash).click();
			}
		});
	}
	$.fn.listexpander.defaults = {
		row_length: 5,
		info_id: 'diffusion_info',
		info_pos_offset: 139,
		info_margin: 18,
		speed: 500
	}
})(jQuery);


/**
 * jquery.booklist
 * Gabriel Legault glegault@lesaffranchis.ca
 **/
(function($) {
	$.fn.booklist = function(options) {
		var opts = $.extend({}, $.fn.booklist.defaults, options);
		return this.each(function() {
			var $this = $(this);
			if(opts.pagination == 'slider')
			{
				splitList($this.find('ul.'+opts.list_class));
				$this.slider({item_selector: 'ul.'+opts.list_class});
				popInfo($this);
			}
			else if(opts.pagination == 'pajinate')
			{
				popInfo($this);
				addPagination($this);
			}
			else
			{
				popInfo($this);
			}
		});
		function addPagination($this)
		{
			var item_count = $this.find('ul.'+opts.list_class + ' li').length;
			if(item_count <= opts.page_length)
			{
				return;
			}
			$this.append('<div class="pagination"></div>');
			
			var start_page = 0;
			var hash_start = parseInt(escape(window.location.hash.replace( /^#/, '')));
			if(hash_start >= 0)
			{
				start_page = hash_start;
			}
			
			$this.pajinate({
				items_per_page: opts.page_length,
				item_container_id: '.book_list',
				nav_panel_id: '.pagination',
				num_page_links_to_display: 10,
				nav_label_prev: 'Précédent',
				nav_label_next: 'Suivant',
				show_first_last: false,
				start_page: start_page
			});
		}
		function splitList($this)
		{
			if($this.is('ul'))
			{
				var $parent = $this.parent();
				while((group = $this.find('li:lt('+opts.page_length+')').remove()).length){
					$parent.find('ul.'+opts.list_class+':last').after('<ul class="'+opts.list_class+'" />');
					$parent.find('ul.'+opts.list_class+':last').append(group);
				}
				$this.remove();
			}
		}
		function popInfo($this)
		{
			$this.append('<div class="'+opts.info_popin_class+'">'+opts.popin_content+'</div>');
			var $popin = $this.find('div.'+opts.info_popin_class).hide();
			$popin.hover(
				function(){
					showPopIn();
				},
				function(){
					hidePopIn();
				}
			);
			$this.find('ul.'+opts.list_class+' > li a').hover(
				function(){
					var $current = $(this);
					var content = {
						'h4 strong': $current.find('strong').html(),
						'h4 em': $current.find('em').html(),
						'div.description': $current.siblings('div.description').html()
					};
					// Calculate popin position
					var book_pos = $current.position();
					var pos_left = book_pos.left + opts.popin_offset_x;
					var pos_top = book_pos.top + opts.popin_offset_y;
					updatePopIn(content, pos_left, pos_top);
					showPopIn();
				},
				function(){
					hidePopIn();
				}
			);
			function updatePopIn(content, pos_left, pos_top)
			{
				$.each(content, function(selector, value){
					$popin.find(selector).html(value);
				});
				$popin.css({
					left: pos_left + 'px',
					top: pos_top + 'px'
				});
			}
			function showPopIn()
			{
				$popin.show();
				$popin.stop().fadeTo(100,1);
			}
			function hidePopIn()
			{
				$popin.stop().fadeTo(100,0, function(){
					$popin.hide();
				});
			}
		} // popInfo()
	}
	$.fn.booklist.defaults = {
		list_class: 'book_list',
		pagination: 'none',
		page_length: 4,
		info_popin_class: 'book_info',
		popin_content: '<h4><strong></strong><em></em></h4><div class="description"></div><div class="arrow"></div>',
		popin_offset_x: 0,
		popin_offset_y: 0
	}
})(jQuery);



var flammarion = {
	init: function() {
		$('a[href=#]').click(function(e){
			e.preventDefault();
		});
		$('input, textarea').placeholder();
		
		$("#popin_send_friend").find("a.submit").click (
			function  (e)
			{
				$parent = $(this).parent();
				var strTo = $parent.find("#txt_to").val();
				var strFrom = $parent.find("#txt_from").val();
				var strMessage = $parent.find("#txt_msg").val();
				
				var bValid = true;
				
				showErrorMsg($parent.find("#txt_to"), "");
				showErrorMsg($parent.find("#txt_from"), "");
				
				if (strTo == "")
				{
					showErrorMsg($parent.find("#txt_to"), "Vous devez inscrire un courriel.");
					bValid = false;
				}
				else if (!validateEmail(strTo))
				{
					showErrorMsg($parent.find("#txt_to"), "Le courriel n'est pas valide.");
					bValid = false;
				}
				
				if (strFrom == "")
				{
					showErrorMsg($parent.find("#txt_from"), "Vous devez inscrire un courriel.");
					bValid = false;
				}
				else if (!validateEmail(strFrom))
				{
					showErrorMsg($parent.find("#txt_from"), "Le courriel n'est pas valide.");
					bValid = false;
				}
				
				
				if (bValid)
				{
					$strData = $parent.serialize();
					
					var strURL = $parent.attr("action");
				
					$.ajax (
					{
						url:strURL,
						data:$strData
					});
				
					$.fancybox.close();
				}
			}
		);
		
		$("#submit").click (
			function (e)
			{
				e.preventDefault();
				
				var strPlaceholder = $("#txt_search").attr("placeholder");
				var strRecherche = $("#txt_search").val();
				
				if (strPlaceholder == strRecherche) 
					strRecherche = "";
					
				window.location = "recherche_" + PLA.Simplify(strRecherche) ;
			}
		);
		
		$("#txt_search").keypress(
			function (e)
			{
				if (e.which == 13)
				{
					e.preventDefault();
					
					var strRecherche = $("#txt_search").val();
					var strPlaceholder = $("#txt_search").attr("placeholder");
					
					if (strPlaceholder == strRecherche) 
						strRecherche = "";
					
					window.location = "recherche_" + PLA.Simplify(strRecherche);
				}
			}
		);
		
		var $book_share = $('#book_share');
		if($book_share.length > 0)
		{
			$book_share.find('li.email a').fancybox({
				type: 'inline',
				href: '#popin_send_friend',
				overlayOpacity:	0.8,
				overlayColor: '#000',
				padding: 0,
				margin: 0
			});
		}
	},
	submenu: {
		init: function() {
			var $container = $('#book_buy > ul > li');
			$container
				.click(function(e){
					$(this).find('ul').show();
				})
				.mouseleave(function(){
					$(this).find('ul').hide();
				});
		}
	}, // END submenu
	selectAuthorRange: function(select_selector, item_selector) {
		$(select_selector).change(function(){
			var range = $(this).find('option:selected').val();
			
			if(range == '')
			{
				$('#authors').find(item_selector).show();
			}
			else
			{
				var strStartLetter = range.substr(0,1);
				var strEndLetter = range.substr(2,1);
			
				$('#authors').find(item_selector).hide();
				while (strStartLetter <= strEndLetter)
				{
					$('#authors').find(item_selector+'.'+strStartLetter).show();
					strStartLetter = String.fromCharCode(strStartLetter.charCodeAt(0) + 1);
					
				}
				
			}
		});
	},
	selectCompanyRange: function() {
		$('#sel_alpha').change(function()
		{
			
			var strRange = $(this).val().replace("-", "");
			if (strRange == "")
				return;
				
			$(this).parents('form').attr("action", "diffusion_" + strRange);
			$(this).parents('form').submit();
		});
	}
};

var PLA = 
{
	Simplify : function (_strText) 
	{
		_strText = _strText.replace(/ /g,'%20');
		_strText = _strText.replace(new RegExp("\\s", 'g'),"");
		_strText = _strText.replace(new RegExp("æ", 'g'),"ae");
		_strText = _strText.replace(new RegExp("ç", 'g'),"c");
		_strText = _strText.replace(new RegExp("[ìíîï]", 'g'),"i");
		_strText = _strText.replace(new RegExp("ñ", 'g'),"n");                            
		_strText = _strText.replace(new RegExp("[òóôõö]", 'g'),"o");
		_strText = _strText.replace(new RegExp("œ", 'g'),"oe");
		_strText = _strText.replace(new RegExp("[ùúûü]", 'g'),"u");
		_strText = _strText.replace(new RegExp("[ýÿ]", 'g'),"y");
		_strText = _strText.replace("?", "");
		_strText = _strText.replace("+", "");
		_strText = _strText.replace("!", "");
		_strText = _strText.replace("...", "");
		_strText = _strText.replace("/", "_");
		_strText = _strText.replace("\\", "_");
		_strText = _strText.replace("'", "_");
		_strText = _strText.replace(new RegExp(String.fromCharCode(233) , "g"), "e"); //é
		_strText = _strText.replace(new RegExp(String.fromCharCode(232), "g"), "e"); //è
		_strText = _strText.replace(new RegExp(String.fromCharCode(234), "g"), "e"); //ê
		_strText = _strText.replace(new RegExp(String.fromCharCode(235), "g"), "e"); //ë
		_strText = _strText.replace(new RegExp(String.fromCharCode(224), "g"), "a"); //à
		_strText = _strText.replace(new RegExp(String.fromCharCode(226), "g"), "a"); //â
		_strText = _strText.replace(new RegExp(String.fromCharCode(233), "g"), "i"); //î
	
		return _strText;			
	}
 
}

function showErrorMsg($input, msg)
{
	
	if($input.prev().is('div.error'))
	{
		
		if (msg != "")
		{
			
			$input.prev().find('p').text(msg);
		}
		else
		{
			
			$input.prev().remove();
		}
	}
	else
	{
		if (msg != "")
		{
			
			$input.before('<div class="error"><p>'+msg+'</p><span class="arrow"></span></div>');
		}
	}
}

function validateEmail(email) 
{ 
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	return re.test(email);
}
