/*
 * jQuery Cycle Plugin (with Transition Definitions)
 * Examples and documentation at: http://jquery.malsup.com/cycle/
 * Copyright (c) 2007-2009 M. Alsup
 * Version: 2.63 (17-MAR-2009)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.2.6 or later
 *
 * Originally based on the work of:
 *	1) Matt Oakes
 *	2) Torsten Baldes (http://medienfreunde.com/lab/innerfade/)
 *	3) Benjamin Sterling (http://www.benjaminsterling.com/experiments/jqShuffle/)
 */
;(function($){var ver="2.63";if($.support==undefined){$.support={opacity:!($.browser.msie)};}function log(){if(window.console&&window.console.log){window.console.log("[cycle] "+Array.prototype.join.call(arguments," "));}}$.fn.cycle=function(options,arg2){var o={s:this.selector,c:this.context};if(this.length==0&&options!="stop"){if(!$.isReady&&o.s){log("DOM not ready, queuing slideshow");$(function(){$(o.s,o.c).cycle(options,arg2);});return this;}log("terminating; zero elements found by selector"+($.isReady?"":" (DOM not ready)"));return this;}return this.each(function(){options=handleArguments(this,options,arg2);if(options===false){return;}if(this.cycleTimeout){clearTimeout(this.cycleTimeout);}this.cycleTimeout=this.cyclePause=0;var $cont=$(this);var $slides=options.slideExpr?$(options.slideExpr,this):$cont.children();var els=$slides.get();if(els.length<2){log("terminating; too few slides: "+els.length);return;}var opts=buildOptions($cont,$slides,els,options,o);if(opts===false){return;}if(opts.timeout||opts.continuous){this.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev);},opts.continuous?10:opts.timeout+(opts.delay||0));}});};function handleArguments(cont,options,arg2){if(cont.cycleStop==undefined){cont.cycleStop=0;}if(options===undefined||options===null){options={};}if(options.constructor==String){switch(options){case"stop":cont.cycleStop++;if(cont.cycleTimeout){clearTimeout(cont.cycleTimeout);}cont.cycleTimeout=0;$(cont).removeData("cycle.opts");return false;case"pause":cont.cyclePause=1;return false;case"resume":cont.cyclePause=0;if(arg2===true){options=$(cont).data("cycle.opts");if(!options){log("options not found, can not resume");return false;}if(cont.cycleTimeout){clearTimeout(cont.cycleTimeout);cont.cycleTimeout=0;}go(options.elements,options,1,1);}return false;default:options={fx:options};}}else{if(options.constructor==Number){var num=options;options=$(cont).data("cycle.opts");if(!options){log("options not found, can not advance slide");return false;}if(num<0||num>=options.elements.length){log("invalid slide index: "+num);return false;}options.nextSlide=num;if(cont.cycleTimeout){clearTimeout(this.cycleTimeout);cont.cycleTimeout=0;}if(typeof arg2=="string"){options.oneTimeFx=arg2;}go(options.elements,options,1,num>=options.currSlide);return false;}}return options;}function removeFilter(el,opts){if(!$.support.opacity&&opts.cleartype&&el.style.filter){try{el.style.removeAttribute("filter");}catch(smother){}}}function buildOptions($cont,$slides,els,options,o){var opts=$.extend({},$.fn.cycle.defaults,options||{},$.metadata?$cont.metadata():$.meta?$cont.data():{});if(opts.autostop){opts.countdown=opts.autostopCount||els.length;}var cont=$cont[0];$cont.data("cycle.opts",opts);opts.$cont=$cont;opts.stopCount=cont.cycleStop;opts.elements=els;opts.before=opts.before?[opts.before]:[];opts.after=opts.after?[opts.after]:[];opts.after.unshift(function(){opts.busy=0;});if(!$.support.opacity&&opts.cleartype){opts.after.push(function(){removeFilter(this,opts);});}if(opts.continuous){opts.after.push(function(){go(els,opts,0,!opts.rev);});}saveOriginalOpts(opts);if(!$.support.opacity&&opts.cleartype&&!opts.cleartypeNoBg){clearTypeFix($slides);}if($cont.css("position")=="static"){$cont.css("position","relative");}if(opts.width){$cont.width(opts.width);}if(opts.height&&opts.height!="auto"){$cont.height(opts.height);}if(opts.startingSlide){opts.startingSlide=parseInt(opts.startingSlide);}if(opts.random){opts.randomMap=[];for(var i=0;i<els.length;i++){opts.randomMap.push(i);}opts.randomMap.sort(function(a,b){return Math.random()-0.5;});opts.randomIndex=0;opts.startingSlide=opts.randomMap[0];}else{if(opts.startingSlide>=els.length){opts.startingSlide=0;}}opts.currSlide=opts.startingSlide=opts.startingSlide||0;var first=opts.startingSlide;$slides.css({position:"absolute",top:0,left:0}).hide().each(function(i){var z=first?i>=first?els.length-(i-first):first-i:els.length-i;$(this).css("z-index",z);});$(els[first]).css("opacity",1).show();removeFilter(els[first],opts);if(opts.fit&&opts.width){$slides.width(opts.width);}if(opts.fit&&opts.height&&opts.height!="auto"){$slides.height(opts.height);}var reshape=opts.containerResize&&!$cont.innerHeight();if(reshape){var maxw=0,maxh=0;for(var i=0;i<els.length;i++){var $e=$(els[i]),e=$e[0],w=$e.outerWidth(),h=$e.outerHeight();if(!w){w=e.offsetWidth;}if(!h){h=e.offsetHeight;}maxw=w>maxw?w:maxw;maxh=h>maxh?h:maxh;}if(maxw>0&&maxh>0){$cont.css({width:maxw+"px",height:maxh+"px"});}}if(opts.pause){$cont.hover(function(){this.cyclePause++;},function(){this.cyclePause--;});}if(supportMultiTransitions(opts)===false){return false;}if(!opts.multiFx){var init=$.fn.cycle.transitions[opts.fx];if($.isFunction(init)){init($cont,$slides,opts);}else{if(opts.fx!="custom"&&!opts.multiFx){log("unknown transition: "+opts.fx,"; slideshow terminating");return false;}}}var requeue=false;options.requeueAttempts=options.requeueAttempts||0;$slides.each(function(){var $el=$(this);this.cycleH=(opts.fit&&opts.height)?opts.height:$el.height();this.cycleW=(opts.fit&&opts.width)?opts.width:$el.width();if($el.is("img")){var loadingIE=($.browser.msie&&this.cycleW==28&&this.cycleH==30&&!this.complete);var loadingOp=($.browser.opera&&this.cycleW==42&&this.cycleH==19&&!this.complete);var loadingOther=(this.cycleH==0&&this.cycleW==0&&!this.complete);if(loadingIE||loadingOp||loadingOther){if(o.s&&opts.requeueOnImageNotLoaded&&++options.requeueAttempts<100){log(options.requeueAttempts," - img slide not loaded, requeuing slideshow: ",this.src,this.cycleW,this.cycleH);setTimeout(function(){$(o.s,o.c).cycle(options);},opts.requeueTimeout);requeue=true;return false;}else{log("could not determine size of image: "+this.src,this.cycleW,this.cycleH);}}}return true;});if(requeue){return false;}opts.cssBefore=opts.cssBefore||{};opts.animIn=opts.animIn||{};opts.animOut=opts.animOut||{};$slides.not(":eq("+first+")").css(opts.cssBefore);if(opts.cssFirst){$($slides[first]).css(opts.cssFirst);}if(opts.timeout){opts.timeout=parseInt(opts.timeout);if(opts.speed.constructor==String){opts.speed=$.fx.speeds[opts.speed]||parseInt(opts.speed);}if(!opts.sync){opts.speed=opts.speed/2;}while((opts.timeout-opts.speed)<250){opts.timeout+=opts.speed;}}if(opts.easing){opts.easeIn=opts.easeOut=opts.easing;}if(!opts.speedIn){opts.speedIn=opts.speed;}if(!opts.speedOut){opts.speedOut=opts.speed;}opts.slideCount=els.length;opts.currSlide=opts.lastSlide=first;if(opts.random){opts.nextSlide=opts.currSlide;if(++opts.randomIndex==els.length){opts.randomIndex=0;}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{opts.nextSlide=opts.startingSlide>=(els.length-1)?0:opts.startingSlide+1;}var e0=$slides[first];if(opts.before.length){opts.before[0].apply(e0,[e0,e0,opts,true]);}if(opts.after.length>1){opts.after[1].apply(e0,[e0,e0,opts,true]);}if(opts.next){$(opts.next).click(function(){return advance(opts,opts.rev?-1:1);});}if(opts.prev){$(opts.prev).click(function(){return advance(opts,opts.rev?1:-1);});}if(opts.pager){buildPager(els,opts);}exposeAddSlide(opts,els);return opts;}function saveOriginalOpts(opts){opts.original={before:[],after:[]};opts.original.cssBefore=$.extend({},opts.cssBefore);opts.original.cssAfter=$.extend({},opts.cssAfter);opts.original.animIn=$.extend({},opts.animIn);opts.original.animOut=$.extend({},opts.animOut);$.each(opts.before,function(){opts.original.before.push(this);});$.each(opts.after,function(){opts.original.after.push(this);});}function supportMultiTransitions(opts){var txs=$.fn.cycle.transitions;if(opts.fx.indexOf(",")>0){opts.multiFx=true;opts.fxs=opts.fx.replace(/\s*/g,"").split(",");for(var i=0;i<opts.fxs.length;i++){var fx=opts.fxs[i];var tx=txs[fx];if(!tx||!txs.hasOwnProperty(fx)||!$.isFunction(tx)){log("discarding unknown transition: ",fx);opts.fxs.splice(i,1);i--;}}if(!opts.fxs.length){log("No valid transitions named; slideshow terminating.");return false;}}else{if(opts.fx=="all"){opts.multiFx=true;opts.fxs=[];for(p in txs){var tx=txs[p];if(txs.hasOwnProperty(p)&&$.isFunction(tx)){opts.fxs.push(p);}}}}if(opts.multiFx&&opts.randomizeEffects){var r1=Math.floor(Math.random()*20)+30;for(var i=0;i<r1;i++){var r2=Math.floor(Math.random()*opts.fxs.length);opts.fxs.push(opts.fxs.splice(r2,1)[0]);}log("randomized fx sequence: ",opts.fxs);}return true;}function exposeAddSlide(opts,els){opts.addSlide=function(newSlide,prepend){var $s=$(newSlide),s=$s[0];if(!opts.autostopCount){opts.countdown++;}els[prepend?"unshift":"push"](s);if(opts.els){opts.els[prepend?"unshift":"push"](s);}opts.slideCount=els.length;$s.css("position","absolute");$s[prepend?"prependTo":"appendTo"](opts.$cont);if(prepend){opts.currSlide++;opts.nextSlide++;}if(!$.support.opacity&&opts.cleartype&&!opts.cleartypeNoBg){clearTypeFix($s);}if(opts.fit&&opts.width){$s.width(opts.width);}if(opts.fit&&opts.height&&opts.height!="auto"){$slides.height(opts.height);}s.cycleH=(opts.fit&&opts.height)?opts.height:$s.height();s.cycleW=(opts.fit&&opts.width)?opts.width:$s.width();$s.css(opts.cssBefore);if(opts.pager){$.fn.cycle.createPagerAnchor(els.length-1,s,$(opts.pager),els,opts);}if($.isFunction(opts.onAddSlide)){opts.onAddSlide($s);}else{$s.hide();}};}$.fn.cycle.resetState=function(opts,fx){fx=fx||opts.fx;opts.before=[];opts.after=[];opts.cssBefore=$.extend({},opts.original.cssBefore);opts.cssAfter=$.extend({},opts.original.cssAfter);opts.animIn=$.extend({},opts.original.animIn);opts.animOut=$.extend({},opts.original.animOut);opts.fxFn=null;$.each(opts.original.before,function(){opts.before.push(this);});$.each(opts.original.after,function(){opts.after.push(this);});var init=$.fn.cycle.transitions[fx];if($.isFunction(init)){init(opts.$cont,$(opts.elements),opts);}};function go(els,opts,manual,fwd){if(manual&&opts.busy&&opts.manualTrump){$(els).stop(true,true);opts.busy=false;}if(opts.busy){return;}var p=opts.$cont[0],curr=els[opts.currSlide],next=els[opts.nextSlide];if(p.cycleStop!=opts.stopCount||p.cycleTimeout===0&&!manual){return;}if(!manual&&!p.cyclePause&&((opts.autostop&&(--opts.countdown<=0))||(opts.nowrap&&!opts.random&&opts.nextSlide<opts.currSlide))){if(opts.end){opts.end(opts);}return;}if(manual||!p.cyclePause){var fx=opts.fx;curr.cycleH=curr.cycleH||$(curr).height();curr.cycleW=curr.cycleW||$(curr).width();next.cycleH=next.cycleH||$(next).height();next.cycleW=next.cycleW||$(next).width();if(opts.multiFx){if(opts.lastFx==undefined||++opts.lastFx>=opts.fxs.length){opts.lastFx=0;}fx=opts.fxs[opts.lastFx];opts.currFx=fx;}if(opts.oneTimeFx){fx=opts.oneTimeFx;opts.oneTimeFx=null;}$.fn.cycle.resetState(opts,fx);if(opts.before.length){$.each(opts.before,function(i,o){if(p.cycleStop!=opts.stopCount){return;}o.apply(next,[curr,next,opts,fwd]);});}var after=function(){$.each(opts.after,function(i,o){if(p.cycleStop!=opts.stopCount){return;}o.apply(next,[curr,next,opts,fwd]);});};if(opts.nextSlide!=opts.currSlide){opts.busy=1;if(opts.fxFn){opts.fxFn(curr,next,opts,after,fwd);}else{if($.isFunction($.fn.cycle[opts.fx])){$.fn.cycle[opts.fx](curr,next,opts,after);}else{$.fn.cycle.custom(curr,next,opts,after,manual&&opts.fastOnEvent);}}}opts.lastSlide=opts.currSlide;if(opts.random){opts.currSlide=opts.nextSlide;if(++opts.randomIndex==els.length){opts.randomIndex=0;}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{var roll=(opts.nextSlide+1)==els.length;opts.nextSlide=roll?0:opts.nextSlide+1;opts.currSlide=roll?els.length-1:opts.nextSlide-1;}if(opts.pager){$.fn.cycle.updateActivePagerLink(opts.pager,opts.currSlide);}}var ms=0;if(opts.timeout&&!opts.continuous){ms=getTimeout(curr,next,opts,fwd);}else{if(opts.continuous&&p.cyclePause){ms=10;}}if(ms>0){p.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev);},ms);}}$.fn.cycle.updateActivePagerLink=function(pager,currSlide){$(pager).find("a").removeClass("activeSlide").filter("a:eq("+currSlide+")").addClass("activeSlide");};function getTimeout(curr,next,opts,fwd){if(opts.timeoutFn){var t=opts.timeoutFn(curr,next,opts,fwd);if(t!==false){return t;}}return opts.timeout;}$.fn.cycle.next=function(opts){advance(opts,opts.rev?-1:1);};$.fn.cycle.prev=function(opts){advance(opts,opts.rev?1:-1);};function advance(opts,val){var els=opts.elements;var p=opts.$cont[0],timeout=p.cycleTimeout;if(timeout){clearTimeout(timeout);p.cycleTimeout=0;}if(opts.random&&val<0){opts.randomIndex--;if(--opts.randomIndex==-2){opts.randomIndex=els.length-2;}else{if(opts.randomIndex==-1){opts.randomIndex=els.length-1;}}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{if(opts.random){if(++opts.randomIndex==els.length){opts.randomIndex=0;}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{opts.nextSlide=opts.currSlide+val;if(opts.nextSlide<0){if(opts.nowrap){return false;}opts.nextSlide=els.length-1;}else{if(opts.nextSlide>=els.length){if(opts.nowrap){return false;}opts.nextSlide=0;}}}}if($.isFunction(opts.prevNextClick)){opts.prevNextClick(val>0,opts.nextSlide,els[opts.nextSlide]);}go(els,opts,1,val>=0);return false;}function buildPager(els,opts){var $p=$(opts.pager);$.each(els,function(i,o){$.fn.cycle.createPagerAnchor(i,o,$p,els,opts);});$.fn.cycle.updateActivePagerLink(opts.pager,opts.startingSlide);}$.fn.cycle.createPagerAnchor=function(i,el,$p,els,opts){var a=($.isFunction(opts.pagerAnchorBuilder))?opts.pagerAnchorBuilder(i,el):'<a href="#">'+(i+1)+"</a>";if(!a){return;}var $a=$(a);if($a.parents("body").length==0){$a.appendTo($p);}$a.bind(opts.pagerEvent,function(){opts.nextSlide=i;var p=opts.$cont[0],timeout=p.cycleTimeout;if(timeout){clearTimeout(timeout);p.cycleTimeout=0;}if($.isFunction(opts.pagerClick)){opts.pagerClick(opts.nextSlide,els[opts.nextSlide]);}go(els,opts,1,opts.currSlide<i);return false;});if(opts.pauseOnPagerHover){$a.hover(function(){opts.$cont[0].cyclePause++;},function(){opts.$cont[0].cyclePause--;});}};$.fn.cycle.hopsFromLast=function(opts,fwd){var hops,l=opts.lastSlide,c=opts.currSlide;if(fwd){hops=c>l?c-l:opts.slideCount-l;}else{hops=c<l?l-c:l+opts.slideCount-c;}return hops;};function clearTypeFix($slides){function hex(s){s=parseInt(s).toString(16);return s.length<2?"0"+s:s;}function getBg(e){for(;e&&e.nodeName.toLowerCase()!="html";e=e.parentNode){var v=$.css(e,"background-color");if(v.indexOf("rgb")>=0){var rgb=v.match(/\d+/g);return"#"+hex(rgb[0])+hex(rgb[1])+hex(rgb[2]);}if(v&&v!="transparent"){return v;}}return"#ffffff";}$slides.each(function(){$(this).css("background-color",getBg(this));});}$.fn.cycle.commonReset=function(curr,next,opts,w,h,rev){$(opts.elements).not(curr).hide();opts.cssBefore.opacity=1;opts.cssBefore.display="block";if(w!==false&&next.cycleW>0){opts.cssBefore.width=next.cycleW;}if(h!==false&&next.cycleH>0){opts.cssBefore.height=next.cycleH;}opts.cssAfter=opts.cssAfter||{};opts.cssAfter.display="none";$(curr).css("zIndex",opts.slideCount+(rev===true?1:0));$(next).css("zIndex",opts.slideCount+(rev===true?0:1));};$.fn.cycle.custom=function(curr,next,opts,cb,speedOverride){var $l=$(curr),$n=$(next);var speedIn=opts.speedIn,speedOut=opts.speedOut,easeIn=opts.easeIn,easeOut=opts.easeOut;$n.css(opts.cssBefore);if(speedOverride){if(typeof speedOverride=="number"){speedIn=speedOut=speedOverride;}else{speedIn=speedOut=1;}easeIn=easeOut=null;}var fn=function(){$n.animate(opts.animIn,speedIn,easeIn,cb);};$l.animate(opts.animOut,speedOut,easeOut,function(){if(opts.cssAfter){$l.css(opts.cssAfter);}if(!opts.sync){fn();}});if(opts.sync){fn();}};$.fn.cycle.transitions={fade:function($cont,$slides,opts){$slides.not(":eq("+opts.currSlide+")").css("opacity",0);opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.cssBefore.opacity=0;});opts.animIn={opacity:1};opts.animOut={opacity:0};opts.cssBefore={top:0,left:0};}};$.fn.cycle.ver=function(){return ver;};$.fn.cycle.defaults={fx:"fade",timeout:4000,timeoutFn:null,continuous:0,speed:1000,speedIn:null,speedOut:null,next:null,prev:null,prevNextClick:null,pager:null,pagerClick:null,pagerEvent:"click",pagerAnchorBuilder:null,before:null,after:null,end:null,easing:null,easeIn:null,easeOut:null,shuffle:null,animIn:null,animOut:null,cssBefore:null,cssAfter:null,fxFn:null,height:"auto",startingSlide:0,sync:1,random:0,fit:0,containerResize:1,pause:0,pauseOnPagerHover:0,autostop:0,autostopCount:0,delay:0,slideExpr:null,cleartype:!$.support.opacity,nowrap:0,fastOnEvent:0,randomizeEffects:1,rev:0,manualTrump:true,requeueOnImageNotLoaded:true,requeueTimeout:250};})(jQuery);
/*
 * jQuery Cycle Plugin Transition Definitions
 * This script is a plugin for the jQuery Cycle Plugin
 * Examples and documentation at: http://malsup.com/jquery/cycle/
 * Copyright (c) 2007-2008 M. Alsup
 * Version:	 2.52
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
;(function($){$.fn.cycle.transitions.scrollUp=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var h=$cont.height();opts.cssBefore={top:h,left:0};opts.cssFirst={top:0};opts.animIn={top:0};opts.animOut={top:-h};};$.fn.cycle.transitions.scrollDown=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var h=$cont.height();opts.cssFirst={top:0};opts.cssBefore={top:-h,left:0};opts.animIn={top:0};opts.animOut={top:h};};$.fn.cycle.transitions.scrollLeft=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var w=$cont.width();opts.cssFirst={left:0};opts.cssBefore={left:w,top:0};opts.animIn={left:0};opts.animOut={left:0-w};};$.fn.cycle.transitions.scrollRight=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var w=$cont.width();opts.cssFirst={left:0};opts.cssBefore={left:-w,top:0};opts.animIn={left:0};opts.animOut={left:w};};$.fn.cycle.transitions.scrollHorz=function($cont,$slides,opts){$cont.css("overflow","hidden").width();opts.before.push(function(curr,next,opts,fwd){$.fn.cycle.commonReset(curr,next,opts);opts.cssBefore.left=fwd?(next.cycleW-1):(1-next.cycleW);opts.animOut.left=fwd?-curr.cycleW:curr.cycleW;});opts.cssFirst={left:0};opts.cssBefore={top:0};opts.animIn={left:0};opts.animOut={top:0};};$.fn.cycle.transitions.scrollVert=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push(function(curr,next,opts,fwd){$.fn.cycle.commonReset(curr,next,opts);opts.cssBefore.top=fwd?(1-next.cycleH):(next.cycleH-1);opts.animOut.top=fwd?curr.cycleH:-curr.cycleH;});opts.cssFirst={top:0};opts.cssBefore={left:0};opts.animIn={top:0};opts.animOut={left:0};};$.fn.cycle.transitions.slideX=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$(opts.elements).not(curr).hide();$.fn.cycle.commonReset(curr,next,opts,false,true);opts.animIn.width=next.cycleW;});opts.cssBefore={left:0,top:0,width:0};opts.animIn={width:"show"};opts.animOut={width:0};};$.fn.cycle.transitions.slideY=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$(opts.elements).not(curr).hide();$.fn.cycle.commonReset(curr,next,opts,true,false);opts.animIn.height=next.cycleH;});opts.cssBefore={left:0,top:0,height:0};opts.animIn={height:"show"};opts.animOut={height:0};};$.fn.cycle.transitions.shuffle=function($cont,$slides,opts){var w=$cont.css("overflow","visible").width();$slides.css({left:0,top:0});opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,true,true);});opts.speed=opts.speed/2;opts.random=0;opts.shuffle=opts.shuffle||{left:-w,top:15};opts.els=[];for(var i=0;i<$slides.length;i++){opts.els.push($slides[i]);}for(var i=0;i<opts.currSlide;i++){opts.els.push(opts.els.shift());}opts.fxFn=function(curr,next,opts,cb,fwd){var $el=fwd?$(curr):$(next);$(next).css(opts.cssBefore);var count=opts.slideCount;$el.animate(opts.shuffle,opts.speedIn,opts.easeIn,function(){var hops=$.fn.cycle.hopsFromLast(opts,fwd);for(var k=0;k<hops;k++){fwd?opts.els.push(opts.els.shift()):opts.els.unshift(opts.els.pop());}if(fwd){for(var i=0,len=opts.els.length;i<len;i++){$(opts.els[i]).css("z-index",len-i+count);}}else{var z=$(curr).css("z-index");$el.css("z-index",parseInt(z)+1+count);}$el.animate({left:0,top:0},opts.speedOut,opts.easeOut,function(){$(fwd?this:curr).hide();if(cb){cb();}});});};opts.cssBefore={display:"block",opacity:1,top:0,left:0};};$.fn.cycle.transitions.turnUp=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false);opts.cssBefore.top=next.cycleH;opts.animIn.height=next.cycleH;});opts.cssFirst={top:0};opts.cssBefore={left:0,height:0};opts.animIn={top:0};opts.animOut={height:0};};$.fn.cycle.transitions.turnDown=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false);opts.animIn.height=next.cycleH;opts.animOut.top=curr.cycleH;});opts.cssFirst={top:0};opts.cssBefore={left:0,top:0,height:0};opts.animOut={height:0};};$.fn.cycle.transitions.turnLeft=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true);opts.cssBefore.left=next.cycleW;opts.animIn.width=next.cycleW;});opts.cssBefore={top:0,width:0};opts.animIn={left:0};opts.animOut={width:0};};$.fn.cycle.transitions.turnRight=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true);opts.animIn.width=next.cycleW;opts.animOut.left=curr.cycleW;});opts.cssBefore={top:0,left:0,width:0};opts.animIn={left:0};opts.animOut={width:0};};$.fn.cycle.transitions.zoom=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,false,true);opts.cssBefore.top=next.cycleH/2;opts.cssBefore.left=next.cycleW/2;opts.animIn={top:0,left:0,width:next.cycleW,height:next.cycleH};opts.animOut={width:0,height:0,top:curr.cycleH/2,left:curr.cycleW/2};});opts.cssFirst={top:0,left:0};opts.cssBefore={width:0,height:0};};$.fn.cycle.transitions.fadeZoom=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,false);opts.cssBefore.left=next.cycleW/2;opts.cssBefore.top=next.cycleH/2;opts.animIn={top:0,left:0,width:next.cycleW,height:next.cycleH};});opts.cssBefore={width:0,height:0};opts.animOut={opacity:0};};$.fn.cycle.transitions.blindX=function($cont,$slides,opts){var w=$cont.css("overflow","hidden").width();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.animIn.width=next.cycleW;opts.animOut.left=curr.cycleW;});opts.cssBefore={left:w,top:0};opts.animIn={left:0};opts.animOut={left:w};};$.fn.cycle.transitions.blindY=function($cont,$slides,opts){var h=$cont.css("overflow","hidden").height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.animIn.height=next.cycleH;opts.animOut.top=curr.cycleH;});opts.cssBefore={top:h,left:0};opts.animIn={top:0};opts.animOut={top:h};};$.fn.cycle.transitions.blindZ=function($cont,$slides,opts){var h=$cont.css("overflow","hidden").height();var w=$cont.width();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.animIn.height=next.cycleH;opts.animOut.top=curr.cycleH;});opts.cssBefore={top:h,left:w};opts.animIn={top:0,left:0};opts.animOut={top:h,left:w};};$.fn.cycle.transitions.growX=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true);opts.cssBefore.left=this.cycleW/2;opts.animIn={left:0,width:this.cycleW};opts.animOut={left:0};});opts.cssBefore={width:0,top:0};};$.fn.cycle.transitions.growY=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false);opts.cssBefore.top=this.cycleH/2;opts.animIn={top:0,height:this.cycleH};opts.animOut={top:0};});opts.cssBefore={height:0,left:0};};$.fn.cycle.transitions.curtainX=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true,true);opts.cssBefore.left=next.cycleW/2;opts.animIn={left:0,width:this.cycleW};opts.animOut={left:curr.cycleW/2,width:0};});opts.cssBefore={top:0,width:0};};$.fn.cycle.transitions.curtainY=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false,true);opts.cssBefore.top=next.cycleH/2;opts.animIn={top:0,height:next.cycleH};opts.animOut={top:curr.cycleH/2,height:0};});opts.cssBefore={left:0,height:0};};$.fn.cycle.transitions.cover=function($cont,$slides,opts){var d=opts.direction||"left";var w=$cont.css("overflow","hidden").width();var h=$cont.height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);if(d=="right"){opts.cssBefore.left=-w;}else{if(d=="up"){opts.cssBefore.top=h;}else{if(d=="down"){opts.cssBefore.top=-h;}else{opts.cssBefore.left=w;}}}});opts.animIn={left:0,top:0};opts.animOut={opacity:1};opts.cssBefore={top:0,left:0};};$.fn.cycle.transitions.uncover=function($cont,$slides,opts){var d=opts.direction||"left";var w=$cont.css("overflow","hidden").width();var h=$cont.height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,true,true);if(d=="right"){opts.animOut.left=w;}else{if(d=="up"){opts.animOut.top=-h;}else{if(d=="down"){opts.animOut.top=h;}else{opts.animOut.left=-w;}}}});opts.animIn={left:0,top:0};opts.animOut={opacity:1};opts.cssBefore={top:0,left:0};};$.fn.cycle.transitions.toss=function($cont,$slides,opts){var w=$cont.css("overflow","visible").width();var h=$cont.height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,true,true);if(!opts.animOut.left&&!opts.animOut.top){opts.animOut={left:w*2,top:-h/2,opacity:0};}else{opts.animOut.opacity=0;}});opts.cssBefore={left:0,top:0};opts.animIn={left:0};};$.fn.cycle.transitions.wipe=function($cont,$slides,opts){var w=$cont.css("overflow","hidden").width();var h=$cont.height();opts.cssBefore=opts.cssBefore||{};var clip;if(opts.clip){if(/l2r/.test(opts.clip)){clip="rect(0px 0px "+h+"px 0px)";}else{if(/r2l/.test(opts.clip)){clip="rect(0px "+w+"px "+h+"px "+w+"px)";}else{if(/t2b/.test(opts.clip)){clip="rect(0px "+w+"px 0px 0px)";}else{if(/b2t/.test(opts.clip)){clip="rect("+h+"px "+w+"px "+h+"px 0px)";}else{if(/zoom/.test(opts.clip)){var t=parseInt(h/2);var l=parseInt(w/2);clip="rect("+t+"px "+l+"px "+t+"px "+l+"px)";}}}}}}opts.cssBefore.clip=opts.cssBefore.clip||clip||"rect(0px 0px 0px 0px)";var d=opts.cssBefore.clip.match(/(\d+)/g);var t=parseInt(d[0]),r=parseInt(d[1]),b=parseInt(d[2]),l=parseInt(d[3]);opts.before.push(function(curr,next,opts){if(curr==next){return;}var $curr=$(curr),$next=$(next);$.fn.cycle.commonReset(curr,next,opts,true,true,false);opts.cssAfter.display="block";var step=1,count=parseInt((opts.speedIn/13))-1;(function f(){var tt=t?t-parseInt(step*(t/count)):0;var ll=l?l-parseInt(step*(l/count)):0;var bb=b<h?b+parseInt(step*((h-b)/count||1)):h;var rr=r<w?r+parseInt(step*((w-r)/count||1)):w;$next.css({clip:"rect("+tt+"px "+rr+"px "+bb+"px "+ll+"px)"});(step++<=count)?setTimeout(f,13):$curr.css("display","none");})();});opts.cssBefore={display:"block",opacity:1,top:0,left:0};opts.animIn={left:0};opts.animOut={left:0};};})(jQuery);
/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
 * $Rev: 2447 $
 *
 * Version 2.1.1
 */
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);
/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @return    The object (aka "this") that called hoverIntent, and the event object
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
/*
 * jqModal - Minimalist Modaling with jQuery
 *   (http://dev.iceburg.net/jquery/jqModal/)
 *
 * Copyright (c) 2007,2008 Brice Burgess <bhb@iceburg.net>
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 * 
 * $Version: 03/01/2009 +r14
 */
(function($) {
$.fn.jqm=function(o){
var p={
overlay: 50,
overlayClass: 'jqmOverlay',
closeClass: 'jqmClose',
trigger: '.jqModal',
ajax: F,
ajaxText: '',
target: F,
modal: F,
toTop: F,
onShow: F,
onHide: F,
onLoad: F
};
return this.each(function(){if(this._jqm)return H[this._jqm].c=$.extend({},H[this._jqm].c,o);s++;this._jqm=s;
H[s]={c:$.extend(p,$.jqm.params,o),a:F,w:$(this).addClass('jqmID'+s),s:s};
if(p.trigger)$(this).jqmAddTrigger(p.trigger);
});};

$.fn.jqmAddClose=function(e){return hs(this,e,'jqmHide');};
$.fn.jqmAddTrigger=function(e){return hs(this,e,'jqmShow');};
$.fn.jqmShow=function(t){return this.each(function(){t=t||window.event;$.jqm.open(this._jqm,t);});};
$.fn.jqmHide=function(t){return this.each(function(){t=t||window.event;$.jqm.close(this._jqm,t)});};

$.jqm = {
hash:{},
open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(parseInt(h.w.css('z-index'))),z=(z>0)?z:3000,o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});if(h.a)return F;h.t=t;h.a=true;h.w.css('z-index',z);
 if(c.modal) {if(!A[0])L('bind');A.push(s);}
 else if(c.overlay > 0)h.w.jqmAddClose(o);
 else o=F;

 h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):F;
 if(ie6){$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in {Top:1,Left:1})o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}}

 if(c.ajax) {var r=c.target||h.w,u=c.ajax,r=(typeof r == 'string')?$(r,h.w):$(r),u=(u.substr(0,1) == '@')?$(t).attr(u.substring(1)):u;
  r.html(c.ajaxText).load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});}
 else if(cc)h.w.jqmAddClose($(cc,h.w));

 if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o);	
 (c.onShow)?c.onShow(h):h.w.show();e(h);return F;
},
close:function(s){var h=H[s];if(!h.a)return F;h.a=F;
 if(A[0]){A.pop();if(!A[0])L('unbind');}
 if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove();
 if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();} return F;
},
params:{}};
var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version == "6.0"),F=false,
i=$('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}),
e=function(h){if(ie6)if(h.o)h.o.html('<p style="width:100%;height:100%"/>').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i); f(h);},
f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(_){}},
L=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);},
m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r)f(h);return !r;},
hs=function(w,t,c){return w.each(function(){var s=this._jqm;$(t).each(function() {
 if(!this[c]){this[c]=[];$(this).click(function(){for(var i in {jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return F;});}this[c].push(s);});});};
})(jQuery);
/*
 * jqDnR - Minimalistic Drag'n'Resize for jQuery.
 *
 * Copyright (c) 2007 Brice Burgess <bhb@iceburg.net>, http://www.iceburg.net
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * $Version: 2007.08.19 +r2
 */

(function($){
$.fn.jqDrag=function(h){return i(this,h,'d');};
$.fn.jqResize=function(h){return i(this,h,'r');};
$.jqDnR={dnr:{},e:0,
drag:function(v){
 if(M.k == 'd')E.css({left:M.X+v.pageX-M.pX,top:M.Y+v.pageY-M.pY});
 else E.css({width:Math.max(v.pageX-M.pX+M.W,0),height:Math.max(v.pageY-M.pY+M.H,0)});
  return false;},
stop:function(){E.css('opacity',M.o);$().unbind('mousemove',J.drag).unbind('mouseup',J.stop);}
};
var J=$.jqDnR,M=J.dnr,E=J.e,
i=function(e,h,k){return e.each(function(){h=(h)?$(h,e):e;
 h.bind('mousedown',{e:e,k:k},function(v){var d=v.data,p={};E=d.e;
 // attempt utilization of dimensions plugin to fix IE issues
 if(E.css('position') != 'relative'){try{E.position(p);}catch(e){}}
 M={X:p.left||f('left')||0,Y:p.top||f('top')||0,W:f('width')||E[0].scrollWidth||0,H:f('height')||E[0].scrollHeight||0,pX:v.pageX,pY:v.pageY,k:d.k,o:E.css('opacity')};
 E.css({opacity:0.8});$().mousemove($.jqDnR.drag).mouseup($.jqDnR.stop);
 return false;
 });
});},
f=function(k){return parseInt(E.css(k))||false;};
})(jQuery);
/***********************************************************************
* YAV - Yet Another Validator  v1.3.7                                 *
* Copyright (C) 2005-2006-2007                                        *
* Author: Federico Crivellaro <f.crivellaro@gmail.com>                *
* WWW: http://yav.sourceforge.net                                     *
*                                                                     *
* This library is free software; you can redistribute it and/or       *
* modify it under the terms of the GNU Lesser General Public          *
* License as published by the Free Software Foundation; either        *
* version 2.1 of the License, or (at your option) any later version.  *
*                                                                     *
* This library is distributed in the hope that it will be useful,     *
* but WITHOUT ANY WARRANTY; without even the implied warranty of      *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   *
* Lesser General Public License for more details.                     *
*                                                                     *
* You should have received a copy of the GNU Lesser General Public    *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc.,59 Temple Place,Suite 330,Boston,MA 02111-1307 USA *
*                                                                     *
* last revision:  18 JUL 2007                                         *
***********************************************************************/
var undef;
var internalRules;
function performCheck(formName, strRules, alertType) {
var rules = makeRules(strRules);
internalRules = makeRules(strRules);
this.f = document.forms[formName];
if( !this.f ) {
debug('DEBUG: could not find form object ' + formName);
return null;
}
var errors = new Array();
var ix = 0;
if (rules.length) {
for(var i=0; i<rules.length; i++) {
var aRule = rules[i];
if (aRule!=null) {
highlight(getField(f, aRule.el), inputclassnormal);
}
}
} else {
if (rules!=null) {
highlight(getField(f, rules.el), inputclassnormal);
}
}
if (rules.length) {
for(var i=0; i<rules.length; i++) {
var aRule = rules[i];
var anErr = null;
if (aRule==null) {
} else if (aRule.ruleType=='pre-condition' || aRule.ruleType=='post-condition') {
} else if (aRule.ruleName=='implies') {
pre  = aRule.el;
post = aRule.comparisonValue;
var oldClassName = getField(f, rules[pre].el).className;
if ( checkRule(f, rules[pre])==null && checkRule(f, rules[post])!=null ) {
anErr = aRule.alertMsg;
} else if ( checkRule(f, rules[pre])!=null ) {
getField(f, rules[pre].el).className = oldClassName;
}
} else {
anErr = checkRule(f, aRule);
}
if ( anErr!=null ) {
errors[ix] = anErr;
ix++;
}
}//for
} else {
var myRule = rules;
err = checkRule(f, myRule);
if ( err!=null ) {
errors[0] = err;
}
}
return displayAlert(errors, alertType);
}
function checkKeyPress(ev, obj, strRules) {
var keyCode = null;
if ( getBrowser()=='msie' ) {
keyCode = window.event.keyCode;
} else if ( getBrowser()=='netscape' || getBrowser()=='firefox' ) {
keyCode = ev.which;
}
var rules = makeRules(strRules);
var keyAllowed = true;
if (rules.length) {
for(var i=0; i<rules.length; i++) {
var aRule = rules[i];
if (aRule.ruleName=='keypress' && aRule.el==obj.name) {
keyAllowed = isKeyAllowed(keyCode, aRule.comparisonValue);
break;
}
}
} else {
var aRule = rules;
if (aRule.ruleName=='keypress' && aRule.el==obj.name) {
keyAllowed = isKeyAllowed(keyCode, aRule.comparisonValue);
}
}
if (!keyAllowed) {
if ( getBrowser()=='msie' ) {
window.event.keyCode=0;
} else if ( getBrowser()=='netscape' || getBrowser()=='firefox' ) {
ev.preventDefault();
ev.stopPropagation();
ev.returnValue=false;
}
}
return false;
}
function displayAlert(messages, alertType) {
var retval =null;
if (alertType=='classic') {
retval = displayClassic(messages);
} else if (alertType=='innerHtml') {
retval = displayInnerHtml(messages);
}else if (alertType=='jsVar') {
retval = displayJsVar(messages);
} else {
debug('DEBUG: alert type ' + alertType + ' not supported');
}
return retval;
}
function displayClassic(messages) {
var str = '';
if ( messages!=null && messages.length>0 ) {
if (strTrim(HEADER_MSG).length > 0) {
str += HEADER_MSG + '\n\n';
}
for (var i=0; i<messages.length; i++) {
str += ' ' + messages[i] + '\n';
}
if (strTrim(FOOTER_MSG).length > 0) {
str += '\n' + FOOTER_MSG;
}
alert(str);
return false;
} else {
return true;
}
}
function displayInnerHtml(messages) {
if ( messages!=null && messages.length>0 ) {
var str = '';
if (strTrim(HEADER_MSG).length > 0) {
str += HEADER_MSG;
}
str += '<ul>';
for (var i=0; i<messages.length; i++) {
str += '<li>'+messages[i]+'</li>';
}
str += '</ul>';
if (strTrim(FOOTER_MSG).length > 0) {
str += FOOTER_MSG;
}
document.getElementById(errorsdiv).innerHTML = str;
document.getElementById(errorsdiv).className = innererror;
document.getElementById(errorsdiv).style.display = 'block';
return false;
} else {
document.getElementById(errorsdiv).innerHTML = '';
document.getElementById(errorsdiv).className = '';
document.getElementById(errorsdiv).style.display = 'none';
return true;
}
}
function displayJsVar(messages) {
document.getElementById(errorsdiv).className = '';
document.getElementById(errorsdiv).style.display = 'none';
if ( messages!=null && messages.length>0 ) {
var str = '';
str += '<script>var jsErrors;</script>';
document.getElementById(errorsdiv).innerHTML = str;
jsErrors = messages;
return false;
} else {
document.getElementById(errorsdiv).innerHTML = '<script>var jsErrors;</script>';
return true;
}
}
function rule(el, ruleName, comparisonValue, alertMsg, ruleType) {
if ( !checkArguments(arguments) ) {
return false;
}
tmp = el.split(':');
nameDisplayed = '';
if (tmp.length == 2) {
nameDisplayed = tmp[1];
el = tmp[0];
}
this.el = el;
this.nameDisplayed = nameDisplayed;
this.ruleName = ruleName;
this.comparisonValue = comparisonValue;
this.ruleType = ruleType;
if (alertMsg==undef || alertMsg==null) {
this.alertMsg = getDefaultMessage(el, nameDisplayed, ruleName, comparisonValue);
} else {
this.alertMsg = alertMsg;
}
}
function checkRule(f, myRule) {
retVal = null;
if (myRule != null) {
if (myRule.ruleName=='custom') {
var customFunction = ' retVal = ' + myRule.el;
eval(customFunction);
} else if (myRule.ruleName=='and') {
var op_1 = myRule.el;
var op_next = myRule.comparisonValue;
if ( checkRule(f, internalRules[op_1])!=null ) {
retVal = myRule.alertMsg;
if (myRule.ruleType=='pre-condition') {
highlight(getField(f, internalRules[op_1].el), inputclassnormal);
}
} else {
var op_k = op_next.split('-');
for(var k=0; k<op_k.length; k++) {
if ( checkRule(f, internalRules[op_k[k]])!=null ) {
retVal = myRule.alertMsg;
if (myRule.ruleType=='pre-condition') {
highlight(getField(f, internalRules[op_k[k]].el), inputclassnormal);
}
break;
}
}
}
} else if (myRule.ruleName=='or') {
var op_1 = myRule.el;
var op_next = myRule.comparisonValue;
var success = false;
if ( checkRule(f, internalRules[op_1])==null ) {
success = true;
} else {
if (myRule.ruleType=='pre-condition') {
highlight(getField(f, internalRules[op_1].el), inputclassnormal);
}
var op_k = op_next.split('-');
for(var k=0; k<op_k.length; k++) {
if ( checkRule(f, internalRules[op_k[k]])==null ) {
success = true;
break;
} else {
if (myRule.ruleType=='pre-condition') {
highlight(getField(f, internalRules[op_k[k]].el), inputclassnormal);
}
}
}
}
if (!success) {
retVal = myRule.alertMsg;
}
} else {
el = getField(f, myRule.el);
if (el == null) {
debug('DEBUG: could not find element ' + myRule.el);
return null;
}
var err = null;
if(el.type) {
if(el.type=='hidden'||el.type=='text'||el.type=='password'||el.type=='textarea') {
err = checkText(el, myRule);
} else if(el.type=='checkbox') {
err = checkCheckbox(el, myRule);
} else if(el.type=='select-one') {
err = checkSelOne(el, myRule);
} else if(el.type=='select-multiple') {
err = checkSelMul(el, myRule);
} else if(el.type=='radio') {
err = checkRadio(el, myRule);
} else {
debug('DEBUG: type '+ el.type +' not supported');
}
} else {
err = checkRadio(el, myRule);
}
retVal = err;
}
}
return retVal;
}
function checkArguments(args) {
if (args.length < 4) {
debug('DEBUG: rule requires four arguments at least');
return false;
} else if (args[0]==null || args[1]==null) {
debug('DEBUG: el and ruleName are required');
return false;
}
return true;
}
function checkRadio(el, myRule) {
var err = null;
if (myRule.ruleName=='required') {
var radios = el;
var found=false;
if (isNaN(radios.length) && radios.checked) {
found=true;
} else {
for(var j=0; j < radios.length; j++) {
if(radios[j].checked) {
found=true;
break;
}
}
}
if( !found ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
} else if (myRule.ruleName=='equal') {
var radios = el;
var found=false;
if (isNaN(radios.length) && radios.checked) {
if (radios.value==myRule.comparisonValue) {
found=true;
}
} else {
for(var j=0; j < radios.length; j++) {
if(radios[j].checked) {
if (radios[j].value==myRule.comparisonValue) {
found=true;
break;
}
}
}
}
if( !found ) {
err = myRule.alertMsg;
}
} else if (myRule.ruleName=='notequal') {
var radios = el;
var found=false;
if (isNaN(radios.length) && radios.checked) {
if (radios.value!=myRule.comparisonValue) {
found=true;
}
} else {
for(var j=0; j < radios.length; j++) {
if(radios[j].checked) {
if (radios[j].value!=myRule.comparisonValue) {
found=true;
break;
}
}
}
}
if( !found ) {
err = myRule.alertMsg;
}
} else {
debug('DEBUG: rule ' + myRule.ruleName + ' not supported for radio');
}
return err;
}
function checkText(el, myRule) {
err = null;
if (trimenabled) {
el.value = strTrim(el.value);
}
if (myRule.ruleName=='required') {
if ( el.value==null || el.value=='' ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
} else if (myRule.ruleName=='equal') {
err = checkEqual(el, myRule);
} else if (myRule.ruleName=='notequal') {
err = checkNotEqual(el, myRule);
} else if (myRule.ruleName=='numeric') {
reg = new RegExp("^[0-9]*$");
if ( !reg.test(el.value) ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
} else if (myRule.ruleName=='alphabetic') {
reg = new RegExp("^[A-Za-z]*$");
if ( !reg.test(el.value) ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
} else if (myRule.ruleName=='alphanumeric') {
reg = new RegExp("^[A-Za-z0-9]*$");
if ( !reg.test(el.value) ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
} else if (myRule.ruleName=='alnumhyphen') {
reg = new RegExp("^[A-Za-z0-9\-_]*$");
if ( !reg.test(el.value) ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
} else if (myRule.ruleName=='alnumhyphenat') {
reg = new RegExp("^[A-Za-z0-9\-_@]*$");
if ( !reg.test(el.value) ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
} else if (myRule.ruleName=='alphaspace') {
reg = new RegExp("^[A-Za-z0-9\-_ \n\r\t]*$");
if ( !reg.test(el.value) ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
} else if (myRule.ruleName=='email') {
reg = new RegExp("^(([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}){0,1}$");
if ( !reg.test(el.value) ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
} else if (myRule.ruleName=='maxlength') {
if ( isNaN(myRule.comparisonValue) ) {
debug('DEBUG: comparisonValue for rule ' + myRule.ruleName + ' not a number');
}else if ( el.value.length > myRule.comparisonValue ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
} else if (myRule.ruleName=='minlength') {
if ( isNaN(myRule.comparisonValue) ) {
debug('DEBUG: comparisonValue for rule ' + myRule.ruleName + ' not a number');
} else if ( el.value.length < myRule.comparisonValue ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
} else if (myRule.ruleName=='numrange') {
reg = new RegExp("^[-+]{0,1}[0-9]*[.]{0,1}[0-9]*$");
if ( !reg.test(unformatNumber(el.value)) ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
} else {
regRange = new RegExp("^[0-9]+-[0-9]+$");
if ( !regRange.test(myRule.comparisonValue) ) {
debug('DEBUG: comparisonValue for rule ' + myRule.ruleName + ' not in format number1-number2');
} else {
rangeVal = myRule.comparisonValue.split('-');
if (eval(unformatNumber(el.value))<eval(rangeVal[0]) || eval(unformatNumber(el.value))>eval(rangeVal[1])) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
}
}
} else if (myRule.ruleName=='regexp') {
reg = new RegExp(myRule.comparisonValue);
if ( !reg.test(el.value) ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
} else if (myRule.ruleName=='integer') {
err = checkInteger(el, myRule);
} else if (myRule.ruleName=='double') {
err = checkDouble(el, myRule);
} else if (myRule.ruleName=='date') {
err = checkDate(el, myRule);
} else if (myRule.ruleName=='date_lt') {
err = checkDateLessThan(el, myRule, false);
} else if (myRule.ruleName=='date_le') {
err = checkDateLessThan(el, myRule, true);
} else if (myRule.ruleName=='keypress') {
} else if (myRule.ruleName=='empty') {
if ( el.value!=null && el.value!='' ) {
highlight(el, inputclasserror);
err = myRule.alertMsg;
}
} else {
debug('DEBUG: rule ' + myRule.ruleName + ' not supported for ' + el.type);
}
return err;
}
function checkInteger(el, myRule) {
reg = new RegExp("^[-+]{0,1}[0-9]*$");
if ( !reg.test(el.value) ) {
highlight(el, inputclasserror);
return myRule.alertMsg;
}
}
function checkDouble(el, myRule) {
var sep = DECIMAL_SEP;
reg = new RegExp("^[-+]{0,1}[0-9]*[" + sep + "]{0,1}[0-9]*$");
if ( !reg.test(el.value) ) {
highlight(el, inputclasserror);
return myRule.alertMsg;
}
}
function checkDate(el, myRule) {
error = null;
if (el.value!='') {
var dateFormat = DATE_FORMAT;
ddReg = new RegExp("dd");
MMReg = new RegExp("MM");
yyyyReg = new RegExp("yyyy");
if ( !ddReg.test(dateFormat) || !MMReg.test(dateFormat) || !yyyyReg.test(dateFormat)  ) {
debug('DEBUG: locale format ' + dateFormat + ' not supported');
} else {
ddStart = dateFormat.indexOf('dd');
MMStart = dateFormat.indexOf('MM');
yyyyStart = dateFormat.indexOf('yyyy');
}
strReg = dateFormat.replace('dd','[0-9]{2}').replace('MM','[0-9]{2}').replace('yyyy','[0-9]{4}');
reg = new RegExp("^" + strReg + "$");
if ( !reg.test(el.value) ) {
highlight(el, inputclasserror);
error = myRule.alertMsg;
} else {
dd   = el.value.substring(ddStart, ddStart+2);
MM   = el.value.substring(MMStart, MMStart+2);
yyyy = el.value.substring(yyyyStart, yyyyStart+4);
if ( !checkddMMyyyy(dd, MM, yyyy) ) {
highlight(el, inputclasserror);
error = myRule.alertMsg;
}
}
}
return error;
}
function checkDateLessThan(el, myRule, isEqualAllowed) {
error = null;
var isDate = checkDate(el, myRule)==null ? true : false;
if ( isDate && el.value!='' ) {
var dateFormat = DATE_FORMAT;
ddStart = dateFormat.indexOf('dd');
MMStart = dateFormat.indexOf('MM');
yyyyStart = dateFormat.indexOf('yyyy');
dd   = el.value.substring(ddStart, ddStart+2);
MM   = el.value.substring(MMStart, MMStart+2);
yyyy = el.value.substring(yyyyStart, yyyyStart+4);
myDate = "" + yyyy + MM + dd;
strReg = dateFormat.replace('dd','[0-9]{2}').replace('MM','[0-9]{2}').replace('yyyy','[0-9]{4}');
reg = new RegExp("^" + strReg + "$");
var isMeta = myRule.comparisonValue.indexOf('$')==0
? true
: false;
var comparisonDate = '';
if (isMeta) {
toSplit = myRule.comparisonValue.substr(1);
tmp = toSplit.split(':');
if (tmp.length == 2) {
comparisonDate = this.getField(f, tmp[0]).value;
} else {
comparisonDate = this.getField(f, myRule.comparisonValue.substr(1)).value;
}
} else {
comparisonDate = myRule.comparisonValue;
}
if ( !reg.test(comparisonDate) ) {
highlight(el, inputclasserror);
error = myRule.alertMsg;
} else {
cdd   = comparisonDate.substring(ddStart, ddStart+2);
cMM   = comparisonDate.substring(MMStart, MMStart+2);
cyyyy = comparisonDate.substring(yyyyStart, yyyyStart+4);
cDate = "" + cyyyy + cMM + cdd;
if (isEqualAllowed) {
if ( !checkddMMyyyy(cdd, cMM, cyyyy) || myDate>cDate ) {
highlight(el, inputclasserror);
error = myRule.alertMsg;
}
} else {
if ( !checkddMMyyyy(cdd, cMM, cyyyy) || myDate>=cDate ) {
highlight(el, inputclasserror);
error = myRule.alertMsg;
}
}
}
} else {
if ( el.value!='' ) {
highlight(el, inputclasserror);
error = myRule.alertMsg;
}
}
return error;
}
function checkEqual(el, myRule) {
error = null;
var isMeta = myRule.comparisonValue.indexOf('$')==0
? true
: false;
var comparisonVal = '';
if (isMeta) {
toSplit = myRule.comparisonValue.substr(1);
tmp = toSplit.split(':');
if (tmp.length == 2) {
comparisonVal = this.getField(f, tmp[0]).value;
} else {
comparisonVal = this.getField(f, myRule.comparisonValue.substr(1)).value;
}
} else {
comparisonVal = myRule.comparisonValue;
}
if ( el.value!=comparisonVal ) {
highlight(el, inputclasserror);
error = myRule.alertMsg;
}
return error;
}
function checkNotEqual(el, myRule) {
error = null;
var isMeta = myRule.comparisonValue.indexOf('$')==0
? true
: false;
var comparisonVal = '';
if (isMeta) {
toSplit = myRule.comparisonValue.substr(1);
tmp = toSplit.split(':');
if (tmp.length == 2) {
comparisonVal = this.getField(f, tmp[0]).value;
} else {
comparisonVal = this.getField(f, myRule.comparisonValue.substr(1)).value;
}
} else {
comparisonVal = myRule.comparisonValue;
}
if ( el.value==comparisonVal ) {
highlight(el, inputclasserror);
error = myRule.alertMsg;
}
return error;
}
function checkddMMyyyy(dd, MM, yyyy) {
retVal = true;
if (    (dd > 31) || (MM > 12) ||
(dd==31 && (MM==2 || MM==4 || MM==6 || MM==9 || MM==11) ) ||
(dd >29 && MM==2) ||
(dd==29 && (MM==2) && ((yyyy%4 > 0) || (yyyy%4==0 && yyyy%100==0 && yyyy%400>0 )) )) {
retVal = false;
}
return retVal;
}
function checkCheckbox(el, myRule) {
if (myRule.ruleName=='required') {
if ( !el.checked ) {
highlight(el, inputclasserror);
return myRule.alertMsg;
}
} else if (myRule.ruleName=='equal') {
if ( !el.checked || el.value!=myRule.comparisonValue ) {
highlight(el, inputclasserror);
return myRule.alertMsg;
}
} else if (myRule.ruleName=='notequal') {
if ( !el.checked || el.value==myRule.comparisonValue ) {
highlight(el, inputclasserror);
return myRule.alertMsg;
}
} else {
debug('DEBUG: rule ' + myRule.ruleName + ' not supported for ' + el.type);
}
}
function checkSelOne(el, myRule) {
if (myRule.ruleName=='required') {
var found = false;
var inx = el.selectedIndex;
if(inx>=0 && el.options[inx].value) {
found = true;
}
if ( !found ) {
highlight(el, inputclasserror);
return myRule.alertMsg;
}
} else if (myRule.ruleName=='equal') {
var found = false;
var inx = el.selectedIndex;
if(inx>=0 && el.options[inx].value==myRule.comparisonValue) {
found = true;
}
if ( !found ) {
highlight(el, inputclasserror);
return myRule.alertMsg;
}
} else if (myRule.ruleName=='notequal') {
var found = false;
var inx = el.selectedIndex;
if(inx>=0 && el.options[inx].value!=myRule.comparisonValue) {
found = true;
}
if ( !found ) {
highlight(el, inputclasserror);
return myRule.alertMsg;
}
} else {
debug('DEBUG: rule ' + myRule.ruleName + ' not supported for ' + el.type);
}
}
function checkSelMul(el, myRule) {
if (myRule.ruleName=='required') {
var found = false;
opts = el.options;
for(var i=0; i<opts.length; i++) {
if(opts[i].selected && opts[i].value) {
found = true;
break;
}
}
if ( !found ) {
highlight(el, inputclasserror);
return myRule.alertMsg;
}
} else if (myRule.ruleName=='equal') {
var found = false;
opts = el.options;
for(var i=0; i<opts.length; i++) {
if(opts[i].selected && opts[i].value==myRule.comparisonValue) {
found = true;
break;
}
}
if ( !found ) {
highlight(el, inputclasserror);
return myRule.alertMsg;
}
} else if (myRule.ruleName=='notequal') {
var found = false;
opts = el.options;
for(var i=0; i<opts.length; i++) {
if(opts[i].selected && opts[i].value!=myRule.comparisonValue) {
found = true;
break;
}
}
if ( !found ) {
highlight(el, inputclasserror);
return myRule.alertMsg;
}
} else {
debug('DEBUG: rule ' + myRule.ruleName + ' not supported for ' + el.type);
}
}
function debug(msg) {
if (debugmode) {
alert(msg);
}
}
function strTrim(str) {
return str.replace(/^\s+/,'').replace(/\s+$/,'');
}
function makeRules(strRules) {
var rules=new Array();
if (strRules.length) {
for(var i=0; i<strRules.length; i++) {
rules[i] = splitRule(strRules[i]);
}
} else {
rules[0] = splitRule(strRules);
}
return rules;
}
function splitRule(strRule) {
var retval = null;
if (strRule!=undef) {
params = strRule.split('|');
switch (params.length) {
case 2:
retval = new rule(params[0], params[1], null, null, null);
break;
case 3:
if (threeParamRule(params[1])) {
retval = new rule(params[0], params[1], params[2], null, null);
} else if (params[2]=='pre-condition' || params[2]=='post-condition') {
retval = new rule(params[0], params[1], null, 'foo', params[2]);
} else {
retval = new rule(params[0], params[1], null, params[2], null);
}
break;
case 4:
if (threeParamRule(params[1]) && (params[3]=='pre-condition' || params[3]=='post-condition')) {
retval = new rule(params[0], params[1], params[2], 'foo', params[3]);
} else {
retval = new rule(params[0], params[1], params[2], params[3], null);
}
break;
default:
debug('DEBUG: wrong definition of rule');
}
}
return retval;
}
function threeParamRule(ruleName) {
return (ruleName=='equal' || ruleName=='notequal' || ruleName=='minlength' || ruleName=='maxlength' || ruleName=='date_lt' || ruleName=='date_le' || ruleName=='implies' || ruleName=='regexp' || ruleName=='numrange' || ruleName=='keypress' || ruleName=='and' || ruleName=='or')
? true
: false;
}
function highlight(el, clazz) {
if (el!=undef && inputhighlight) {
el.className = clazz;
}
}
function getDefaultMessage(el, nameDisplayed, ruleName, comparisonValue) {
if (nameDisplayed.length == 0) {
nameDisplayed = el;
}
var msg = DEFAULT_MSG;
if (ruleName=='required') {
msg = REQUIRED_MSG.replace('{1}', nameDisplayed);
} else if (ruleName=='minlength') {
msg = MINLENGTH_MSG.replace('{1}', nameDisplayed).replace('{2}', comparisonValue);
} else if (ruleName=='maxlength') {
msg = MAXLENGTH_MSG.replace('{1}', nameDisplayed).replace('{2}', comparisonValue);
} else if (ruleName=='numrange') {
msg = NUMRANGE_MSG.replace('{1}', nameDisplayed).replace('{2}', comparisonValue);
} else if (ruleName=='date') {
msg = DATE_MSG.replace('{1}', nameDisplayed);
} else if (ruleName=='numeric') {
msg = NUMERIC_MSG.replace('{1}', nameDisplayed);
} else if (ruleName=='integer') {
msg = INTEGER_MSG.replace('{1}', nameDisplayed);
} else if (ruleName=='double') {
msg = DOUBLE_MSG.replace('{1}', nameDisplayed);
} else if (ruleName=='equal') {
msg = EQUAL_MSG.replace('{1}', nameDisplayed).replace('{2}', getComparisonDisplayed(comparisonValue));
} else if (ruleName=='notequal') {
msg = NOTEQUAL_MSG.replace('{1}', nameDisplayed).replace('{2}', getComparisonDisplayed(comparisonValue));
} else if (ruleName=='alphabetic') {
msg = ALPHABETIC_MSG.replace('{1}', nameDisplayed);
} else if (ruleName=='alphanumeric') {
msg = ALPHANUMERIC_MSG.replace('{1}', nameDisplayed);
} else if (ruleName=='alnumhyphen') {
msg = ALNUMHYPHEN_MSG.replace('{1}', nameDisplayed);
} else if (ruleName=='alnumhyphenat') {
msg = ALNUMHYPHENAT_MSG.replace('{1}', nameDisplayed);
} else if (ruleName=='alphaspace') {
msg = ALPHASPACE_MSG.replace('{1}', nameDisplayed);
} else if (ruleName=='email') {
msg = EMAIL_MSG.replace('{1}', nameDisplayed);
} else if (ruleName=='regexp') {
msg = REGEXP_MSG.replace('{1}', nameDisplayed).replace('{2}', comparisonValue);
} else if (ruleName=='date_lt') {
msg = DATE_LT_MSG.replace('{1}', nameDisplayed).replace('{2}', getComparisonDisplayed(comparisonValue));
} else if (ruleName=='date_le') {
msg = DATE_LE_MSG.replace('{1}', nameDisplayed).replace('{2}', getComparisonDisplayed(comparisonValue));
} else if (ruleName=='empty') {
msg = EMPTY_MSG.replace('{1}', nameDisplayed);
}
return msg;
}
function getComparisonDisplayed(comparisonValue) {
comparisonDisplayed = comparisonValue;
if (comparisonValue.substring(0, 1)=='$') {
comparisonValue = comparisonValue.substring(1, comparisonValue.length);
tmp = comparisonValue.split(':');
if (tmp.length == 2) {
comparisonDisplayed = tmp[1];
} else {
comparisonDisplayed = comparisonValue;
}
}
return comparisonDisplayed;
}
function getBrowser() {
brs=navigator.userAgent.toLowerCase();
var retval;
if (brs.search(/msie\s(\d+(\.?\d)*)/)!=-1) {
retval='msie';
} else if (brs.search(/netscape[\/\s](\d+([\.-]\d)*)/)!=-1) {
retval='netscape';
} else if (brs.search(/firefox[\/\s](\d+([\.-]\d)*)/)!=-1) {
retval='firefox';
} else {
retval='unknown';
}
return retval;
}
function isKeyAllowed(keyCode, charsAllowed) {
retval = false;
var aCharCode;
if (keyCode==8) {
retval = true;
} else {
for(var i=0; i<charsAllowed.length; i++) {
aCharCode = charsAllowed.charCodeAt(i);
if (aCharCode==keyCode) {
retval = true;
break;
}
}
}
return retval;
}
function getField(formObj, fieldName){
var retval = null;
if (formObj.elements[fieldName]){
retval = formObj.elements[fieldName];
}else if (document.getElementById(fieldName)){
retval = document.getElementById(fieldName);
}
return retval;
}
function unformatNumber(viewValue){
var retval = viewValue.replace(THOUSAND_SEP, "");
retval = retval.replace(DECIMAL_SEP, ".");
return retval;
}

/*
 * jQuery.yav - Easy Form validation with YAV
 * 
 * Copyright (c) 2007 Jose Francisco Rives Lirola (http://letmehaveblog.blogspot.com)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-10-24 10:00:00 +0100 (wed, 24 oct 2007) $
 *
 * Version: 1.2.0
 * Requires: jQuery v1.2.1+ , YAV v1.4.0+ (http://yav.sourceforge.net/)
 */

jQuery.fn.extend({
	/**
	 * Integrates YAV form validation library as jQuery plugin
	 * adding accesibility, no intrusive, and standards compliant
	 * inline validation in web forms.
	 * 
	 * Setup a form object with YAV validation with no intrusive
	 * HTML code and minimal JS code. The errors messages are associated
	 * to each form field that generates the error, and they are shown
	 * in a position related to the field (after, before, in the parent...)
	 * for better accesibility and screen reader improve.
	 * 
	 * @example $("#myForm").yav();
	 * 
	 * @desc Setup a simple validation for the form with id #myForm using
	 * the default yav rules:
	 * "alnumhyphen","alnumhyphenat","alphabetic","alphanumeric","alphaspace",
	 * "date","date_le","date_lt","double","email","empty","equal","integer",
	 * "keypress","maxlength","minlength","notequal","numeric","numrange",
	 * "regexp" and "required".
	 * Set the proper rule in the class of the form field, the error message
	 * in the title attribute, and the param (if the rule requires it in the
	 * alt attribute as Map object:
	 * alt="{'params':'the param'}"
	 * or
	 * alt="{'params':['oneparam','twoparam',...]}"
	 * If the validation is ok then the form is submited (if the rest of form
	 * submit events handlers returns true), in other case shows the errors.
	 * Also you can set more than one rule using multiple classes (also you can
	 * use a CSS class normally) and the params must be as array of arrays (one
	 * array for each rule)
	 * class="equal maxlength another_css_class_not_rule" alt="{'params':[['one'],[10]]}"
	 * Alternatelly, because textarea and select fields has not alt attribute in
	 * W3C XHTML 1.0 standard, you can set the alt attribute inside the class attribute
	 * like this:  class="rule another_rule {'params':[['one'],[10]]}"
	 * 
	 * @before <form id="myForm" action="url_to_go" method="post|get">
	 * 	<label>Name: 
	 * 		<input type="text" id="name" name="name" class="alphaspace required" title="Please write only chars and spaces characters, this field is required"/>
	 *  </label>
	 * 	<label>Email: 
	 * 		<input type="email" id="email" name="email" title="Write a correct email address" />
	 * 	</label>
	 * 	<input type="submit" value="Send" />
	 * </form>
	 * 
	 * @after <form id="myForm" action="url_to_go" method="post|get">
	 * 	<label>Name: 
	 * 		<p class="error">Please write only chars and spaces characters, this field is required</p>
	 * 		<input type="text" id="name" name="name" class="alphaspace required" 
	 * 			title="Please write only chars and spaces characters, this field is required"/>
	 *  </label>
	 * 	<label>Email: 
	 * 		<p class="error">Write a correct email address</p>
	 * 		<input type="email" id="email" name="email" title="Write a correct email address" />
	 * 	</label>
	 * 	<input type="submit" value="Send" />
	 * </form>
	 * 
	 * @example $("#myForm").yav({
	 * 	"errorDiv":"TopError",
	 * 	"errorMessage":"Some errors are found, please correct them",
	 * 	"custom":{
	 * 		"myCustomRule1": function(returnvalue, param1, param2,...){
	 * 			if ($("textfield1").val() == param1){
	 * 				return null;
	 * 			}else{
	 * 				return returnvalue;
	 * 			}
	 * 		},
	 * 		"anotherCustomRule":....
	 * 	  }
	 * 	}
	 * );
	 * @desc You can set a top message showing a custom message (a default text is
	 * used if you can not set "errorMessage" param and the errorDiv is found). Also
	 * you can indicate another ID for the top message div (default is "errorDiv").
	 * If the validation process on submit is not OK then the errors are show and the
	 * page is scrolled to the top message.
	 * 
	 * In the "custom" param, you can set and indefinited number of custom rules. A custom
	 * rule, returns null id OK and returnvalue (allways the first param) if is not OK.
	 * The custom rule can have any number of params. You can use then, the custom rule
	 * name in the class of the field for the validation.
	 * 
	 * @before <form id="myForm" action="url_to_go" method="post|get">
	 * 	<label>Name: 
	 * 		<input type="text" id="name" name="name" class="myCustomRule1 required" title="Error message" 
	 * 			alt="{
	 * 				params:
	 * 					[
	 * 						['param1','param2'],
	 * 						['']
	 * 				]
	 * 			}"/>
	 *  </label>
	 * 	<input type="submit" value="Send" />
	 * </form>
	 * 
	 * @example $("#myForm").yav();
	 * @desc You can validate any field on event trigger using event parameter in alt attribute.
	 * This event parameter is one or a comma separated event list.
	 * 
	 * @before <form id="myForm" action="url_to_go" method="post|get">
	 * <label>Name: 
	 * 		<input type="text" id="name" name="name" class="required" title="Error message" 
	 * 			alt="{event:'blur, change'}"/>
	 *  </label>
	 * 	<input type="submit" value="Send" />
	 * </form>
	 * 
	 * @example $("#myForm").yav({
	 * 	"errorMessage":"Errors are found"
	 * },{
	 * 	"DATE_FORMAT":"MM/dd/yyyy",
	 * 	"inputclasserror":"fieldError"
	 * });
	 * 
	 * @desc A second Map (object) param in the plugin call you can set all the
	 * global variables for YAV config (you have not use yav-config.js file any more).
	 * 
	 * @example $("#myForm").yav({
	 * 	"onOk":function(form){
	 * 		//executes any code before submit (the validation has been OK)
	 * 		//This is a simple method for cancel the normal way of submit and
	 * 		//submit the validated data using AJAX calls
	 * 
	 * 		return true|false;  //if returns true form is submited, if false, form submit is cancelled
	 * 	},
	 * 	"onError":function(form){
	 * 		//executes any code if validation is not passed (the validation has been ERROR)
	 * 	}
	 * });
	 * 
	 * @desc In the first Map param, you have two more params ("onOk" and "onError"),
	 * these functions are called when the validation process is finished as passed or
	 * not passed. The function "onOk" is used by example, for AJAX submition of the 
	 * data and it not submit the form normally. "form" param is the reference of the 
	 * validated form.
	 * 
	 * @example $("#myForm").yav({
	 * 	"errorDiv": "mainError",
	 * 	"errorMessage": "There are errors in the form",
	 * 	"errorClass": "error",
	 * 	"errorTag": "p",
	 * 	"errorPosition": "before"
	 * });
	 * 
	 * @desc The rest of valid params for the plugin are: "errorDiv", the id of the
	 * div (normally on the top of the form) that shows that errors have been found.
	 * The text of the div "errorDiv" is setted with "errorMessage" param. If errorDiv
	 * is not found the first error gets the focus, in other case "errorDiv" gets the
	 * focus. "errorClass" is the CSS class for the errors messages, the messages are
	 * inside a tag "p" by default, you can set other tag if you want ("div","span",...)
	 * "errorPosition" sets the position of the message over the affected id, this position
	 * use the common jQuery transversing functions, example of valid values ("before",
	 * "after","parent().before","parent().after",...
	 * 
	 * @example $("#myForm").yav();
	 * 
	 * @before <form id="myForm" action="url_to_go" method="post|get">
	 * 	<label>Name: 
	 * 		<input type="text" id="name" name="name" class="numeric" title="Error message" 
	 * 			alt="{
	 * 				condition:{
	 * 					name:'first_and',
	 * 					type:'and',
	 * 					msg:'Checks Name and Email field'
	 * 				}
	 * 			}"/>
	 * 		<input type="text" id="email" name="email" class="alphabetic" title="Error message" 
	 * 			alt="{
	 * 				condition:{name:'first_and'}
	 * 			}"/>
	 *  </label>
	 * 	<input type="submit" value="Send" />
	 * </form>
	 * 
	 * @desc You have 3 rules, the first for the numeric field called "name", the second for the 
	 * alphabetic field called "email" and the third condition related the first and the second
	 * rule with a and rule, this conditional rule is passed if the first AND the second are passed.
	 * In the condition rule you set 'name' (an string for identify the condition rule), a 'type' of
	 * the condition, and the message to show the error. By default the message is show related with the
	 * ID of the first field of the rule (you don't need set all the condition params in the rest of the
	 * fields, only the 'name' identifier is necessary), if you want show the error message in other place,
	 * then set another param 'id' in the condition rule.
	 * {'condition':{'id':'another_id','name':'first_and','type':'and','msg':'Checks Name and Email field'}
	 * You can set three types of conditional rules 'and','or' and 'implies'. The validation dispatch
	 * an error if any of 3 before rules are not passed.
	 * 
	 * @example $("#myForm").yav();
	 * 
	 * @before <form id="myForm" action="url_to_go" method="post|get">
	 * 	<label>Name: 
	 * 		<input type="text" id="name" name="name" class="numeric" title="Error message" 
	 * 			alt="{
	 * 				require:'pre-condition',
	 * 				condition:{name:'first_and',type:'and',msg:'Checks Name and Email field'}
	 * 			}"/>
	 * 		<input type="text" id="email" name="email" class="alphabetic" title="Error message" 
	 * 			alt="{
	 * 				require:'pre-condition',
	 * 				condition:{'name':'first_and'}
	 * 			}"/>
	 *  </label>
	 * 	<input type="submit" value="Send" />
	 * </form>
	 * 
	 * @desc The 'require' param works only with condition rules. You can set this param to 'pre-condition'
	 * (in AND and OR rules) or 'post-condition' (for the final IMPLIES rule). If require param is set, then
	 * the origin rule doesn't dispatch an error if fails, but the condition rule works normally. In the example
	 * case, the numeric and alphabetic rule don't generate an error message but if the AND condition fail then
	 * the condition message is shown.
	 * 
	 * @example $("#myForm").yav();
	 * 
	 * @before <form id="myForm" action="url_to_go" method="post|get">
	 * 	<label>Name: 
	 * 		<input type="text" id="name" name="name" class="numeric" title="Error message" 
	 * 			alt="{
	 * 				require:'pre-condition',
	 * 				condition:[
	 * 					{
	 * 						name:'first_and',
	 * 						type:'and',
	 * 						require:'pre-condition'
	 *					},
	 * 					{
	 * 						name:'group_or',
	 * 						group:['first_and','second_and'],
	 * 						type:'or',
	 * 						msg:'You need validate the first group or the second almost'
	 * 					}
	 * 				]
	 * 			}"/>
	 * 		<input type="text" id="email" name="email" class="alphabetic" title="Error message" 
	 * 			alt="{
	 * 				require:'pre-condition',
	 * 				condition:{'name':'first_and'}
	 * 			}"/>
	 * 		<input type="text" id="name2" name="name2" class="numeric" title="Message" 
	 * 			alt="{
	 * 				require:'pre-condition',
	 * 				condition:{
	 * 					name:'second_and',
	 * 					type:'and',
	 * 					require:'pre-condition'
	 * 				}
	 * 			}"/>
	 * 		<input type="text" id="email2" name="email2" class="alphabetic" title="Message" 
	 * 			alt="{
	 * 				require:'pre-condition',
	 * 				condition:{'name':'second_and'}
	 * 			}"/>
	 *  </label>
	 * 	<input type="submit" value="Send" />
	 * </form>
	 * 
	 * @desc Multiple condition validation. You can write others 'condition's using an
	 * array of conditions. Alternately, you can express conditions over other conditions.
	 * By example, the this HTML code, you need express the conditions 
	 * ('name' AND 'email') OR ('name2' AND 'email2'), each AND condition is defined by a
	 * NAME identifier 'first_and' and 'second_and', in the OR condition you can write a new
	 * param 'group' as array of the name of the others conditions.
	 * Also you can write the 'require' param in each condition if you don't want generate
	 * error messages.
	 * 
	 * @name yav
	 * @param Map params The parameters list for the plugin (see the examples)
	 * @param Map yav_config The yav variables list (not requires yav-config.js file)
	 * 
	 * @type jQuery
	 * @return Object jQuery
	 * @cat Plugins/Integration/Forms
	 * @author SeViR · José Francisco Rives Lirola (http://letmehaveblog.blogspot.com | http://www.sevir.org/en/)
	 */
	yav:function(params,yav_config){
		var yavC = jQuery.extend({
			//yav config settings
			errorsdiv : "yavDiv",
			debugmode: false,
			DEFAULT_MSG : "",
			inputclassnormal : "i",
			inputhighlight : "h",
			inputclasserror : "c",
			trimenabled : true,
			RULE_SEP : "|",
			multipleclassname: true
		}, yav_config);
		
		var params = jQuery.extend({
			errorDiv : "errorDiv",
			errorMessage : "ERROR, please correct",
			errorClass : "error",
			errorTag : "p",
			errorPosition : "before",
			onError : "",
			onOk : ""
		}, params);
		
		//Extend the yav config and set the global settings
		for(var name in yavC){
			window[name]=yavC[name];
		}
		
		var yav_defRules = new Array(
			"alnumhyphen","alnumhyphenat","alphabetic","alphanumeric","alphaspace",
			"date","date_le","date_lt","double","email","empty","equal","integer",
			"keypress","maxlength","minlength","notequal","numeric","numrange",
			"regexp","required"
		);
		
		/*
		 * Creates YAV array rules from the form 
		 */
		function setRules(o){
			var rules = new Array();
			var conds = new Array();
			var str_rule = "";
			
			if (jQuery(o).is("form")){
				jQuery("input, textarea, select", o).each(function(){
					m = this.className.match(/\{.*\}/);
					if (m != null){
						$(this).attr("alt", m);
						this.className = this.className.replace(/\{.*\}/,"");
					}
					var f_alt = {};
					try{
						f_alt = eval("(" + $(this).attr("alt") + ")");
						f_alt = (typeof f_alt == "undefined")?{}:f_alt;
					}catch(e){}
					
					var the_rule = setRules(this);
					
					for (var j=0;j<the_rule.length;j++){
						try{
							var condition = f_alt.condition;
							var require_condition = f_alt.require;
							if (typeof condition != "undefined"){
								if (typeof condition.name != "undefined"){
									condition = [condition]; //converts object in array
								}
								var cond_index = "";
								for (var i=0; i < condition.length; i++){
									if (typeof conds[condition[i].name] != "undefined"){
										conds[condition[i].name].indexes.push(((cond_index == "")?cond_index = rules.push(the_rule[j]):cond_index) - 1);
										if (typeof require_condition != "undefined" && require_condition == "post-condition"){
											conds[condition[i].name].postcondition = conds[condition[i].name].indexes.length - 1;
										}
									}else{
										conds[condition[i].name] = {
											id:((typeof condition[i].id == "undefined")?this.id:condition[0].id),
											type:condition[i].type,
											msg:condition[i].msg,
											indexes: [((cond_index == "")?cond_index = rules.push(the_rule[j]):cond_index) - 1],
											require: ((typeof condition[i].require == "undefined")?null:condition[i].require),
											group: ((typeof condition[i].group != "undefined")?condition[i].group:null),
											postcondition: ((typeof require_condition != "undefined" && require_condition == "post-condition")?0:null)
										}
									alert(conds[condition[i].id]);
									}
								}
							}else{
								//doesn't check null value because if eval works this object has a rule
								rules.push(the_rule[j]);
							}
						}catch(e){
							if (the_rule[j] != null){
								rules.push(the_rule[j]);
							}
						}
					}
					
		            if (the_rule[0] != null && typeof(f_alt.event) != "undefined"){
		              this.yavrules = the_rule;
		              var yavhandler = function(){
		                resetMsgs();
		                var parent_form = $(this).parents("form");
		                if (!performCheck(parent_form[0].id, this.yavrules,'jsVar')){
		                  showErrors(parent_form[0]);
		                }
		              }
		              var fieldevents = f_alt.event.replace(" ","").split(",");
		              for (var e=0; e<fieldevents.length;e++){
		                $(this).bind(fieldevents[e], yavhandler);
		              }
		            }
				});
				
				//Sets the conds
				var conditional_rule = "";
				for (var name in conds){
					if (conds[name].group == null){						
						if (conds[name].postcondition != null){
							conds[name].indexes.push(conds[name].indexes[conds[name].postcondition]);
							conds[name].indexes.splice(conds[name].postcondition,1);
						}
						if (typeof conds[name].indexes  != "undefined"){
							conds[name].indexes = conds[name].indexes.reverse();
							conditional_rule = conds[name].indexes.pop() + "|" + 
											   conds[name].type + "|" + strParams(conds[name].indexes,"-") +
											   "|" + ((conds[name].require == null)?"{id:'"+conds[name].id+"',msg:'"+conds[name].msg+"'}":conds[name].require);
						}
						conds[name].rule_index = rules.push(conditional_rule) - 1;
					}
				}
				//Set the conds over conds (groups)
				for (var name in conds){
					if (conds[name].group != null){
						//get the first index
						conds[name].group = conds[name].group.reverse();
						conditional_rule = conds[conds[name].group.pop()].rule_index + "|" +
										   conds[name].type + "|";
						for (var i=0; i<conds[name].group.length;i++){
							conds[name].group[i] = conds[conds[name].group[i]].rule_index;
						}
						conditional_rule += strParams(conds[name].group,"-") + 
											"|" + ((conds[name].require == null)?"{id:'"+conds[name].id+"',msg:'"+conds[name].msg+"'}":conds[name].require);
						rules.push(conditional_rule);
					}	
				}
				
				return rules;
			}else{
				var arr_rules = new Array();
				var num_rules = 0;
				for(var i=0;i<yav_defRules.length;i++){
					if(jQuery(o).is("."+yav_defRules[i])){	
						try{
							str_rule = 
								createRule(o,yav_defRules[i],(jQuery(o).attr("title")),((typeof eval("("+jQuery(o).attr("alt")+")").params != "undefined" && typeof eval("("+jQuery(o).attr("alt")+")").params[0] == "object")?eval("("+jQuery(o).attr("alt")+")").params[num_rules]:eval("("+jQuery(o).attr("alt")+")").params),eval("("+jQuery(o).attr("alt")+")").require);
						}catch(e){
							str_rule =
								createRule(o,yav_defRules[i],(jQuery(o).attr("title")));
						}
						arr_rules.push(str_rule);
						num_rules++;
					}
				}
				var rulename;
				for(rulename in jQuery.yav_customfunctions){
					if(jQuery(o).is("."+rulename)){
						try{
							str_rule =
								createRule(o,"jQuery.yav_customfunctions."+rulename,(jQuery(o).attr("title")),((typeof eval("("+jQuery(o).attr("alt")+")").params[0] == "object")?eval("("+jQuery(o).attr("alt")+")").params[num_rules]:eval("("+jQuery(o).attr("alt")+")").params),eval("("+jQuery(o).attr("alt")+")").require);
						}catch(e){
							str_rule =
								createRule(o,"jQuery.yav_customfunctions."+rulename,(jQuery(o).attr("title")));
						}
						arr_rules.push(str_rule);
						num_rules++;
					}
				}
			}
			
			return ((arr_rules.length > 0)?arr_rules:[null]);
		}
		
		function createRule(o, rulename, text, rule_params, require){
			if (typeof rule_params != "undefined" && typeof rule_params != "object"){
				rule_params = [rule_params];
			}else if(typeof rule_params == "undefined"){
				rule_params = [];
			}
			if (rulename.indexOf("jQuery.yav") >= 0){
				return rulename+"({id:'" + o.id + "',msg:'" + text + "'"+((typeof(require) == "undefined")?"":",require:'"+require+"'") +"}"+
						((rule_params.length == 0)?"":",") + 
						strParams(rule_params, ",") +")|custom";
			}else{
				return o.id+"|"+rulename+"|" + ((rule_params.length > 0)?(strParams(rule_params,"-")+"|"):"") + ((typeof(require) == "undefined")?"{id:'"+o.id+"',msg:'"+text+"'}":require);
			}
		}
		
		function strParams(arrParam, separator){
			var str = "";
			for (var i=0;i<arrParam.length;i++){
				str += ((separator == "-")?"":"'") + arrParam[i] + ((separator == "-")?"":"'") + separator;
			}
			return str.substr(0, str.length -1);
		}
		
		function showErrors(o){
			var error_is_shown = new Array();
			jQuery(params.errorTag + "."+params.errorClass,o).remove();
			
			jQuery("#"+params.errorDiv).html(
				"<" + params.errorTag + " class='"+params.errorClass+"'>" + params.errorMessage + "</" + params.errorTag + ">"
			);
			
			//shows the errors
			for (var i=0; i<jsErrors.length;i++){
				objError = (typeof(jsErrors[i]) == "object")?jsErrors[i]:eval("("+ jsErrors[i] +")");
				if (typeof error_is_shown[objError.id] =="undefined" && typeof objError.require == "undefined"){
					error_is_shown[objError.id] = 1;
					evalText = "jQuery('#"+ objError.id +"')." + params.errorPosition + 
								"(\"" + 
								"<" + params.errorTag + " class='"+params.errorClass+"'>" + objError.msg + "</" + params.errorTag + ">"
								+ "\")";
					eval(evalText);
					jQuery("#"+objError.id).addClass(inputclasserror);
				}
			}
			
			if (jQuery("#"+params.errorDiv).size()>0){
				jQuery("#"+params.errorDiv)[0].scrollIntoView(true);	
			}
		}
		
		function resetMsgs(){
	      jQuery("#"+yavC.errorsdiv).remove();
	      jQuery("#"+params.errorDiv).html("");
	      jQuery(params.errorTag + "."+params.errorClass,this).remove();
	      jQuery("body").append("<div id='"+yavC.errorsdiv+"'></div>");
	      jQuery("."+yavC.inputclasserror).removeClass(yavC.inputclasserror);
		}
		
		//Extends the custom functions in jQuery Object
		jQuery.yav_customfunctions = params.custom;
		
		//creates the rules
		return this.each(function(){
	      	setRules(this);
			jQuery(this).bind("submit",function(){
				resetMsgs();
				var formRules = setRules(this);
				if (formRules.length == 0 || performCheck(this.id, formRules,'jsVar')){
					return ((typeof params.onOk == "function")?params.onOk(this):true);
				}else{
					showErrors(this);
					return ((typeof params.onError == "function")?params.onError(this):false);
				}
			});
		});
	}
});

if (typeof(deleteInline) == "function"){
  //Patches YAV > 1.4.0
  jQuery.deleteInline = deleteInline;
  deleteInline = function(msg){
    if(typeof(msg) == "string"){ return jQuery.deleteInline(msg); }else{ return msg; }
  }
}else{
  //Patches YAV for multiples classNames for YAV < 1.4.0
  function highlight(el, clazz) {}
}

//ceebox
/*
 * Ceebox 1.4.1 jQuery Plugin - Minimized via YUI compressor
 * Requires jQuery 1.3.2 and swfobject.jquery.js plugin to work
 * Code hosted on GitHub (http://github.com/catcubed/CeeBox) Please visit there for version history information
 * By Colin Fahrion (http://www.catcubed.com)
 * Inspiration for CeeBox comes from Thickbox (http://jquery.com/demo/thickbox/) and Videobox (http://videobox-lb.sourceforge.net/)
 * However, along the upgrade path CeeBox has morphed a long way from those roots.
 * Copyright (c) 2009 Colin Fahrion
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/

(function(a){a.ceebox={version:"1.4.1"};a.fn.ceebox=function(f){f=jQuery.extend({vidWidth:false,vidHeight:false,htmlWidth:false,htmlHeight:false},f);a(this).each(function(){if(a(this).is("a")||a(this).is("area")||a(this).is("input")){a(this).bind("click",function(){a.ceebox.show(this.title||this.name||this.t||"",this.href||this.alt,this.rel||false);a(this).blur();return false})}});a.ceebox.show=function(y,v,o){if(typeof document.body.style.maxHeight==="undefined"){a("html").css("overflow","hidden");if(a("#cee_HideSelect")===null){a("body").append("<iframe id='cee_HideSelect'></iframe>")}}if(a.browser.opera){a("body").append("<span style='line-height:0px;color:rgba(0,0,0,0)' rel='lame opera hack'>-</span>")}box=document.createElement("div");overlay=document.createElement("div");cee_closeBtn="<a href='#' id='cee_closeBtn' title='Close'>close</a>";a(overlay).attr("id","cee_overlay");a(box).attr("id","cee_box");(g())?a(overlay).addClass("cee_overlayMacFFBGHack"):a(overlay).addClass("cee_overlayBG");a("body").append("<div id='cee_load'></div>");a("#cee_load").show();var p=(v.indexOf("?")!==-1)?v.substr(0,v.indexOf("?")):v;urlString=/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$|\.swf$|\.htm$|\.html$|\.asp$|\.aspx$/;var A=p.toLowerCase().match(urlString);var x=(!f.vidWidth||!f.vidHeight)?d(o):[f.vidWidth,f.vidHeight];var w=(!f.htmlWidth||!f.htmlHeight)?d(o):[f.htmlWidth,f.htmlHeight];var z=[[(!v.match(/^http:+/)&&(o&&!o.match("iframe")))||(o&&o.match("ajax"))||false,"ajax"],[A==".jpg"||A==".jpeg"||A==".png"||A==".gif"||A==".bmp"||false,"image"],[v.match(/youtube\.com\/watch/i)||false,"youtube"],[v.match(/metacafe\.com\/watch/i)||false,"metacafe"],[v.match(/google\.com\/videoplay/i)||false,"google"],[v.match(/ifilm\.com\/video/i)||false,"ifilm"],[v.match(/vimeo\.com/i)||false,"vimeo"],[v.match(/dailymotion\.com/i)||false,"dailymotion"],[v.match(/facebook\.com\/video/i)||false,"facebook"]];var u=z.length;var q;do{if(z[u-1][0]){var q=z[u-1][1];break}}while(--u);switch(q){case"image":h(y,v,o);break;case"facebook":var n="http://www.facebook.com/v/"+v.split("v=")[1].split("&")[0];var s={wmode:"transparent",movie:n,allowFullScreen:"true",allowScriptAccess:"always",flashvars:{autoplay:true}};m(n,x,y,s);break;case"youtube":var n="http://www.youtube.com/v/"+v.split("v=")[1].split("&")[0]+"&hl=en&fs=1&autoplay=1";var s={wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always"};m(n,x,y,s);break;case"metacafe":var n="http://www.metacafe.com/fplayer/"+v.split("id=")[1].split("&")[0]+"/.swf";var s={wmode:"transparent"};m(n,x,y,s);break;case"google":n="http://video.google.com/googleplayer.swf?docId="+v.split("id=")[1].split("&")[0]+"&hl=en";s={wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always",flashvars:{autoplay:true,playerMode:"normal",fs:true}};m(n,x,y,s);break;case"ifilm":n="http://www.ifilm.com/efp";s={wmode:"transparent",flashvars:{flvbaseclip:v.split("id=")[1].split("&")[0]+"&"}};m(n,x,y,s);break;case"vimeo":n="http://www.vimeo.com/moogaloop.swf?clip_id="+v.split("/")[3]+"&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1";s={wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always"};m(n,x,y,s);break;case"dailymotion":n="http://www.dailymotion.com/swf/"+v.split("/")[4]+"&related=0&autoplay=1";s={allowFullScreen:"true",allowScriptAccess:"always"};m(n,x,y,s);case"ajax":j(y,v,o,w);break;default:i(y,v,o,w)}};function g(){var n=navigator.userAgent.toLowerCase();if(n.indexOf("mac")!=-1&&n.indexOf("firefox")!=-1){return true}}function d(q){var t=e();var n=t[0]-150;var p=t[1]-150;var o=new Array();if(q&&q.match(/[0-9]+/g)){var o=q.match(/[0-9]+/g);o[0]=(o[0])?o[0]*1:n;o[1]=(o[1])?o[1]*1:p}else{o=[n,p]}return o}function e(){var q=document.documentElement;var n=window.innerWidth||self.innerWidth||(q&&q.clientWidth)||document.body.clientWidth;var o=window.innerHeight||self.innerHeight||(q&&q.clientHeight)||document.body.clientHeight;var p=[n,o];return p}function h(z,q,n){if(n){var s=a("a[rel="+n+"]").get();var o=s.length;var p=o;var x="",w="";do{if(s[p-1].href==q){var v=p;break}}while(--p);var y="Image "+(p)+" sur "+(o);if(v>1){var w="<a href='#' id='cee_prev'>Previous</a>"}if(v<o){var x="<a href='#' id='cee_next'>Next</a>"}}else{var y="";var w="";var x=""}var u=new Image();u.onload=function(){u.onload=null;var F=e();var r=F[0]-150;var E=F[1]-150;var A=u.width;var D=u.height;if(A>r){A=r;D=D*(r/A)}if(D>E){A=A*(E/D);D=E}var t=A+30;l("<img id='cee_img' src='"+q+"' width='"+A+"' height='"+D+"' alt='"+z+"'/><div id='cee_nav' style='width:"+t+"px;height:"+D+"px'>"+w+x+"</div><div id='cee_cap'>"+z+"<div id='cee_count'>"+y+"</div></div>"+cee_closeBtn,A+30,D+60);if(w!=""){function C(){document.onkeydown=null;if(a(document).unbind("click",C)){a(document).unbind("click",C)}a("#cee_box").remove();a.ceebox.show(s[v-2].title,s[v-2].href,n);return false}a("#cee_prev").click(C)}if(x!=""){function B(){document.onkeydown=null;a("#cee_box").remove();a.ceebox.show(s[v].title,s[v].href,n);return false}a("#cee_next").click(B)}document.onkeydown=function(H){H=H||window.event;var G=H.keyCode||H.which;if(G==27){b()}else{if(G==190||G==39){if(x!=""){B()}}else{if(G==188||G==37){if(w!=""){C()}}}}}};u.src=q}function j(n,p,q,o){var s=[o[0],o[1]-5];if(a("#cee_box").css("display")!="block"){if(q&&q.match("modal")){a("#cee_overlay").unbind();l("<div id='cee_ajax' class='cee_modal' style='width:"+s[0]+"px;height:"+s[1]+"px;'></div>",o[0]+30,o[1]+40)}else{l("<div id='cee_title'><div id='cee_ajaxTitle'>"+n+"</div>"+cee_closeBtn+"</div><div id='cee_ajax' style='width:"+s[0]+"px;height:"+s[1]+"px'></div>",o[0]+30,o[1]+40)}}else{a("#cee_ajaxContent")[0].style.width=s[0]+"px";a("#cee_ajaxContent")[0].style.height=s[1]+"px";a("#cee_ajaxContent")[0].scrollTop=0;a("#cee_ajaxWindowTitle").html(caption)}if(q&&q.match(/#[a-z_A-Z1-9]+/)){targetId=q.match(/#[a-z_A-Z1-9]+/);a("#cee_ajax").load(p+" "+targetId)}else{a("#cee_ajax").load(p)}a("#cee_ajax a.ceebox").ceebox();k()}function i(o,q,s,p){var u=[p[0]+29,p[1]+12];a("#cee_iframe").remove();if(s&&s.match("modal")){a("#cee_overlay").unbind();var n="<iframe frameborder='0' hspace='0' src='"+q+"' id='cee_iframe' name='cee_iframe"+Math.round(Math.random()*1000)+"' onload='$.ceebox.showIframe()' style='width:"+u[0]+"px;height:"+u[1]+"px;'> </iframe>"}else{var n="<div id='cee_title'><div id='cee_ajaxTitle'>"+o+"</div>"+cee_closeBtn+"</div><iframe frameborder='0' hspace='0' src='"+q+"' id='cee_iframeContent' name='cee_iframeContent"+Math.round(Math.random()*1000)+"' onload='$.ceebox.showIframe()' style='width:"+u[0]+"px;height:"+u[1]+"px;' > </iframe>"}l(n,p[0]+30,p[1]+40);k()}a.ceebox.showIframe=function(){a("#cee_load").remove();a("#cee_window").css({display:"block"})};function b(){a("#cee_imgBtn").unbind("click");a("#cee_closeBtn").unbind("click");a("#cee_box").fadeOut("fast",function(){a("#cee_box,#cee_overlay,#cee_HideSelect").unbind().trigger("unload").remove()});a("#cee_load").remove();if(typeof document.body.style.maxHeight=="undefined"){a("body","html").css({height:"auto",width:"auto"});a("html").css("overflow","")}document.onkeydown=null;document.onkeyup=null;return false}function c(n,o){a("#cee_box").css({marginLeft:"-"+parseInt((n/2),10)+"px",width:n+"px"});if(!(jQuery.browser.msie&&jQuery.browser.version<7)){a("#cee_box").css({marginTop:"-"+parseInt((o/2),10)+"px"})}}function m(n,q,o,r){l("<div id='cee_vid'></div><div id='cee_cap'>"+o+"</div>"+cee_closeBtn,q[0]+30,q[1]+60);k();a("#cee_vid").flash({swf:n,width:q[0],height:q[1],params:r})}function k(){document.onkeyup=function(n){n=n||window.event;(n.keyCode==27||n.which==27)?b():false}}function l(p,n,o){if(a("#cee_overlay").size()==0){a(overlay).appendTo(a("body")).click(b)}a(box).appendTo("body").append(p);a("#cee_closeBtn").click(b);c(n,o);a("#cee_load").remove();a("#cee_box").css({display:"block"})}}})(jQuery);
function addEvent(event, elm, handler, bubble) {
	if (elm.addEventListener)
		elm.addEventListener(event, handler, bubble);
	else if (elm.attachEvent)
		elm.attachEvent("on"+event, handler);
}

function delEvent(event, elm, handler, bubble) {
	if (elm.removeEventListener)
		elm.removeEventListener(event, handler, bubble);
	else if (elm.detachEvent)
		elm.detachEvent("on"+event, handler);
}

function getObjectMethodClosure(object, method) {
	return function(arg) {
		return object[method](arg); 
	}
}
var element = getObjectMethodClosure(document, "createElement");
var txtNode = getObjectMethodClosure(document, "createTextNode");

/*
 * Slider
 */
function Slider2(id, orientation, resolution) {
	this.setSize = function (width, height) {
		this.width = width;
		this.height = height;
	}

	this.drag = function (event) {
		if (!event) var event = window.event;
		var deltaX=event.clientX - parseInt(sl.s.style.left);
		var deltaY=event.clientY - parseInt(sl.s.style.top);

		addEvent("mousemove", document, moveHandler, true);
		addEvent("mouseup", document, upHandler, true);

		function moveHandler(e) {
			var x; var y; var newvalue;
			if (!e) e=window.event;
	
			if (sl.orientation != "vertical") {
				x = e.clientX - deltaX;
				if (x<0) x=0;
				if (x>sl.width-10) x=sl.width-10;
				sl.s.style.left=(x) + "px";
				newvalue = parseInt(x/sl.width * sl.resolution);
			}
			else if (sl.orientation != "horizontal") {
				y = e.clientY - deltaY;
				if (y<0) y=0;
				if (y>sl.height-10) y=sl.height-10;
				sl.s.style.top=(y) + "px";
				newvalue = parseInt(y/sl.height * sl.resolution);
			}
			if (newvalue != sl.value) {
				sl.value = newvalue;
				sl.onChange(newvalue);
			}
		}
	
		function upHandler(e) {
			if (!e) e=window.event;
			delEvent("mouseup", document, upHandler, true);
			delEvent("mousemove", document, moveHandler, true);
		}
	}

	this.onChange = function (value) {
		/*alert(value);*/
	}
	
	this.setStart = function (value) {
		// Use only AFTER you defined onChange
		this.value = value;
		this.onChange(value);
		this.moveSlide(value);
	}
	
	this.moveSlide = function (value) {
		var length = this.height;
		var l;

		if (this.orientation == "horizontal")
			length = this.width;
			
		if (this.resolution < value)
			value = this.resolution;
		if (value < 0)
			value = 0;
		this.value = value;
		l = parseInt(length/this.resolution) * value;

		if (this.orientation == "horizontal")
			this.s.style.left=(l)+"px";
		else
			this.s.style.top=(l)+"px";
	}

	this.createSlider = function() {
		var rel = element("div");
		rel.style.display="none";
		rel.style.position = "relative";
		rel.setAttribute("id", this.id+"_slider");

		var bar = element("div");
		bar.style.position = "absolute";
		/*bar.style.backgroundColor = "#ccc";*/
		if (this.orientation == "horizontal") {
			bar.style.left = "0px";
			bar.style.top = (parseInt(this.height/2)-1)+"px";
			bar.style.width = (this.width)+"px";
			bar.style.height = "2px";
			rel.style.height = "2px";
		} else {
			bar.style.left = (parseInt(this.width/2)-1)+"px";
			bar.style.top = "0px";
			bar.style.width = "2px";
			bar.style.height = (this.height)+"px";
			rel.style.height = (this.height)+"px";
		}
		rel.appendChild(bar);
		
		// Set slider image as background element to fix IE quirk
		var img = element("div");
		img.style.backgroundImage='url("styles/images/scroller.gif")';
		img.style.backgroundRepeat="no-repeat";
		img.style.width="127px";
		img.style.height="19px";
		img.style.padding="0px";
		img.style.position = "absolute";
		img.style.left="0px";
		img.style.top="0px";

		img.onmousedown = this.drag;
		this.s = img;

		rel.appendChild(img);
		document.getElementById(this.id).appendChild(rel);
	}
	
	this.show = function() {
		this.s.parentNode.style.display="block";
	}

	// Initialize class
	this.id = id;
	this.orientation = "horizontal";
	this.resolution = 650;
	this.height = 19;
	this.width = 650;
	this.s = null;
	this.value=0;
	var sl = this;
	
	if (orientation != undefined && orientation == "vertical") {
		this.orientation = "vertical";
		this.setSize(10, 100);
	}
	if (resolution != undefined)
		this.resolution = resolution;
		
	this.createSlider();
}

function whereIs(myNode)
{
	originalNode = myNode;
	x = 0;
	y = 0;
	while (myNode.tagName != 'BODY')
	{
		x += myNode.offsetLeft;
		y += myNode.offsetTop;
		myNode = myNode.offsetParent;
	}
	originalNode.magicPositionX = x;
	originalNode.magicPositionY = y;
}

function FindX(obj){
	var x=0,y=0;
	while (obj!=null){
		x+=obj.offsetLeft-obj.scrollLeft;
		y+=obj.offsetTop-obj.scrollTop;
		obj=obj.offsetParent;
	}
	return x;
}

/*
 * Copyright (c) 2008 Threeformed Media (http://www.threeformed.com)
 * This is licensed under GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * 
 * 
 * *******
 * 
 * This plugin is derived in part from JScrollPane created by Kevin Luck(http://www.kelvinluck.com)
 * 
 * Copyright (c) 2006 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * 
 * See http://kelvinluck.com/assets/jquery/jScrollPane/
 * $Id: jScrollPane.js 3125 2007-09-06 20:39:42Z kelvin.luck $
 */

/**
 * Replace the default horizontal scroll bars on matched 
 * elements with a CSS styled veresion.  Very similar to the JScrollPane 
 * which does vertical scrolling, 2 features in particular have been added. 
 * 
 * 1) Intervals
 * 2) Resizing
 * 
 * 1) Intervals can be added by attaching a class type of "scroll-interval" to any 
 * element wrapped within the jscrollhorizontalpane context.  This provides
 * the following abilitiies: 
 * 			a) When dragging, it will snap to the closest element on release of dragger.
 * 			b) Mousewheel motions jump between intervals
 * 			c) Notches appear by default on the scrollbar, but can be overriden by css.
 * 
 * 2) Resizing Also occurs. When turned on, all widths are dealt in percentages, so on a 
 * screen refresh, the scroller will resize itself based on it's initial percentage.
 * There are a ton of different circumstances that need to be accounted for, and i'm sure 
 * it's not meeting some people's expected behaviour so let mek now about any problems or 
 * feature requests for that!  The resizing is done through the WResize plugin.
 * 
 *
 * @example jQuery(".scroll-pane").jScrollHorizontalPane();
 *
 * @name jScrollHorizontalPane
 * @type jQuery
 * @param Object	settings	hash with options, described below.
 *								scrollbarHeight	-	The height of the generated scrollbar in pixels
 *								scrollbarMargin	-	The amount of space to leave on the side of the scrollbar in pixels
 *								wheelSpeed		-	The speed the pane will scroll in response to the mouse wheel in pixels
 *								showArrows		-	Whether to display arrows for the user to scroll with
 *								arrowSize		-	The height of the arrow buttons if showArrows=true
 *								animateTo		-	Whether to animate when calling scrollTo and scrollBy
 *								dragMinWidth	-	The minimum width to allow the drag bar to be
 *								dragMaxWidth	-	The maximum width to allow the drag bar to be
 *								animateInterval	-	The interval in milliseconds to update an animating scrollHorizontalPane (default 100)
 *								animateStep		-	The amount to divide the remaining scroll distance by when animating (default 3)
 *								maintainPosition-	Whether you want the contents of the scroll pane to maintain it's position when you re-initialise it - so it doesn't scroll as you add more content (default true)
 *								resize			- 	Whether or not to have resizing turned on or not.
 * 								minimumWidth    - 	The minimum width to allow the jScrollHorizontalPane to be resized to.  Only effective when resize is on.
 * 								reset			-	When set to 'true' all the global properties will be reset.  This is useful for dynamic refreshes on the page.
 * @return jQuery
 * @cat Plugins/jScrollHorizontalPane
 * @author Threeformed Media ( www.threeformed.com, info@threeformed.com )
 * @version 1.0.0
 */

var _jscr_originalSizes = new Array();
var _jscr_differenceSizes = new Array();
var _jscr_previousWindowSize = new Array();
var _jscr_originalPercentages = new Array();
var _jscr_intervals = new Array();
var _jscr_trackInt = new Array();
var _jscr_originalPos = new Array();
var _jscr_globalProperties = new Array();

jQuery.jScrollHorizontalPane = {
	active : []
};

jQuery.fn.jScrollHorizontalPane = function(settings)
{
	settings = jQuery.extend(
		{
			scrollbarHeight : 10,
			scrollbarMargin : 5,
			wheelSpeed : 18,
			showArrows : false,
			arrowSize : 10,
			animateTo : false,
			dragMinWidth : 1,
			dragMaxWidth : 99999,
			animateInterval : 100,
			animateStep: 3,
			maintainPosition: true, 
			resize: true,
			minimumWidth: 200,
			reset: false
		}, settings
	);
	
	return this.each(
		function()
		{
			this.testProperty = 'blast';
			 
			if(settings.reset == true) {
				jQuery.fn.jScrollHorizontalPane.reset();
			}
			
			//This holds each one of the intervals, defaulting with one at the beginning.
			var $this = jQuery(this);			
			var mouseWheelNext = 0;
			var mouseWheelMove = false;
			var currentId = $this.attr('id');
			var previousWindow = _jscr_previousWindowSize[currentId];
			_jscr_originalPos[currentId] = -1;
			_jscr_globalProperties[currentId] = settings;
			_jscr_previousWindowSize[currentId] = $(window).width();
			
			//On initial load, set values needed for percentage resizing.
			if(_jscr_originalSizes[currentId] == undefined) {		

				//ie6 hack, since jquery width doesnt get the right value on an inproper refresh
				if((jQuery.browser.msie) && (parseInt(jQuery.browser.version) == 6)) {
					var outerWidth = parseInt($this.outerWidth()) - parseInt($this.offset().left);
					_jscr_differenceSizes[currentId] = $this.offset().left / $(window).width();
				} else {
					var outerWidth = $this.outerWidth();
					_jscr_differenceSizes[currentId] = $this.position().left / $(window).width();
				}

				percentageWidth = (outerWidth / $(window).width());			
				_jscr_originalPercentages[currentId] = percentageWidth;
				_jscr_originalSizes[currentId] = $(window).width();
			} else { 
				percentageWidth = _jscr_originalPercentages[currentId];
				diff = _jscr_differenceSizes[currentId] - (($this.offset().left + _jscr_originalPos[currentId])/ $(window).width());
				percentageWidth = percentageWidth + diff;
			}

			var halfIntervals = new Array();
			_jscr_intervals = new Array();
			halfIntervals[0] = 0;
			_jscr_intervals[0] = 0;
			margin = $this.position().left;
			offset = 1;
			
			if(margin < 0) {
				margin = 0;
			}
			
			//Handles interval code
			$(".scroll-interval", $this).each(
				function(i, elem) {
					pos = $(elem).position().left - margin;
					if(pos != 0) {
						_jscr_intervals[i+offset] = pos;
					} else { 
						offset--;
					}
				}
			);
				
			if(_jscr_intervals.length <= 1) { 
				_jscr_intervals = new Array();
			}

			if (jQuery(this).parent().is('.jScrollPaneContainer')) {
				var currentScrollPosition = settings.maintainPosition ? $this.offset({relativeTo:jQuery(this).parent()[0]}).left : 0;
				var $c = jQuery(this).parent();
				var paneWidth = $c.outerWidth();
				var paneHeight = $c.innerHeight();
				var rightPos = $this.offset().left + _jscr_originalPos[currentId] + paneWidth;
				
				if((previousWindow != $(window).width()) && ((rightPos > $(window).width()) || (previousWindow < $(window).width())) && (settings.resize == true)) {

					if($(window).width() >= _jscr_originalSizes[currentId]) {
						paneWidth = ($(window).width() *  percentageWidth);
					} else {
						//Give the outside edge a 10 px buffer margin
						paneWidth = $(window).width() - ($this.offset().left + _jscr_originalPos[currentId]) - 10;
					}

					if(paneWidth < settings.minimumWidth){
						paneWidth = settings.minimumWidth;
					}

					jQuery(this).parent().css(
									{ 
										'height':paneHeight+'px', 
										'width': paneWidth + 'px'
									}
								);
				}
				
				var trackWidth = paneWidth;

				if($c.unmousewheel) {
						
					if($.browser.opera) {
						$c.unbind("mousewheel", fn = function() { });	
					} else {
						$c.unmousewheel();
					}				
				}

				jQuery('>.jScrollPaneTrack, >.jScrollArrowLeft, >.jScrollArrowRight', $c).remove();
				$this.css({'left':0});
				_jscr_originalPos[currentId] = -1;
			} else {
				var currentScrollPosition = 0;
				this.originalPadding = $this.css('paddingTop') + ' ' + $this.css('paddingRight') + ' ' + $this.css('paddingBottom') + ' ' + $this.css('paddingLeft');
				this.originalSidePaddingTotal = (parseInt($this.css('paddingLeft')) || 0) + (parseInt($this.css('paddingRight')) || 0);
				var paneWidth = $this.outerWidth();
				var rightPos = $this.offset().left + _jscr_originalPos[currentId] + paneWidth;

				if((rightPos) > $(window).width()) { 
					paneWidth = $(window).width() *  percentageWidth; 
				}
				
				if(paneWidth < settings.minimumWidth){
					paneWidth = settings.minimumWidth;
				}
					
				var paneHeight = $this.innerHeight();
				var trackWidth = paneWidth;
				
				$this.wrap(
					jQuery('<div></div>').attr(
						{'className':'jScrollPaneContainer'}
					).css(
						{
							'height':paneHeight+'px', 
							'width':paneWidth+'px'
						}
					)
				);
				// deal with text size changes (if the jquery.em plugin is included)
				// and re-initialise the scrollPane so the track maintains the
				// correct size
				jQuery(document).bind(
					'emchange', 
					function(e, cur, prev)
					{
						$this.jScrollHorizontalPane(settings);
					}
				);
			}
			var p = this.originalSidePaddingTotal;
			
			$this.css(
				{
					'height': paneHeight - settings.scrollbarHeight - p + 'px',
					'width': 'auto',
					'paddingRight':settings.scrollbarMargin + 'px'
				}
			);

			var contentWidth = $this.outerWidth();

			//ie6 and 7, outside width does not always guarantee the full size of the div
			//is returned for outerWidth
			if($.browser.msie || $.browser.opera || $.browser.safari) {
				var ieWidth = 0;
				$this.children().each(function(i, elem) { if($(elem).outerWidth() > ieWidth) { ieWidth = $(elem).outerWidth();}});
				if(ieWidth > contentWidth) {
					contentWidth = ieWidth;
				}				
			}

			var percentInView = paneWidth / contentWidth;
			var trackIntervals = new Array();

			if (percentInView < 0.99) {
				var $container = $this.parent();

				$container.append(
					jQuery('<div></div>').attr({'className':'jScrollPaneTrack'}).css({'height':settings.scrollbarHeight+'px'}).append(
						jQuery('<div></div>').attr({'className':'jScrollPaneDrag'}).css({'height':settings.scrollbarHeight+'px'}).append(
							jQuery('<div></div>').attr({'className':'jScrollPaneDragLeft'}).css({'height':settings.scrollbarHeight+'px'}),
							jQuery('<div></div>').attr({'className':'jScrollPaneDragRight'}).css({'height':settings.scrollbarHeight+'px'})
						)
					)
				);
				
				var $track = jQuery('>.jScrollPaneTrack', $container);
			
				//Attach the intervals to the track
				for(inter in _jscr_intervals) { 
					
					if(settings.showArrows == true) { 
						scrollOffset = settings.arrowSize;
					} else { 
						scrollOffset = 0;
					}

					intervalTrackPos = _jscr_intervals[inter] / contentWidth * $track.width() - (scrollOffset);
					trackIntervals[inter] = intervalTrackPos;
					
					if(trackIntervals[inter - 1] != undefined) {
						halfIntervals[inter-1] = (trackIntervals[inter] + trackIntervals[inter-1]) / 2;
					}
				
					if(inter != 0) { 
						interObj = jQuery('<div>|</div>').attr({'className':'jScrollIntervalTrack'}).css({'left':intervalTrackPos + 'px'})
						$track.append(interObj);
					}
				}

				var $drag = jQuery('>.jScrollPaneTrack .jScrollPaneDrag', $container);
				
				if (settings.showArrows) {
			
					var currentArrowButton;
					var currentArrowDirection;
					var currentArrowInterval;
					var currentArrowInc;
					var whileArrowButtonDown = function()
					{
						if (currentArrowInc > 4 || currentArrowInc%4==0) {
							positionDrag(dragPosition + currentArrowDirection * mouseWheelMultiplier);
						}
						currentArrowInc ++;
					};
					var onArrowMouseUp = function(event)
					{
						jQuery('body').unbind('mouseup', onArrowMouseUp);
						currentArrowButton.removeClass('jScrollActiveArrowButton');
						clearInterval(currentArrowInterval);
						arrowUp = true;
						moveIntervals();
					};
					var onArrowMouseDown = function() {
						jQuery('body').bind('mouseup', onArrowMouseUp);
						currentArrowButton.addClass('jScrollActiveArrowButton');
						currentArrowInc = 0;
						whileArrowButtonDown();
						currentArrowInterval = setInterval(whileArrowButtonDown, 100);
					};
					$container
						.append(
							jQuery('<a></a>')
								.attr({'href':'javascript:;', 'className':'jScrollArrowLeft'})
								.css({'width':settings.arrowSize+'px'})
								.html('Scroll Left')
								.bind('mousedown', function()
								{
									currentArrowButton = jQuery(this);
									currentArrowDirection = -1;
									onArrowMouseDown();
									this.blur();
									return false;
								}),
							jQuery('<a></a>')
								.attr({'href':'javascript:;', 'className':'jScrollArrowRight'})
								.css({'width':settings.arrowSize+'px'})
								.html('Scroll Right')
								.bind('mousedown', function()
								{
									currentArrowButton = jQuery(this);
									currentArrowDirection = 1;
									onArrowMouseDown();
									this.blur();
									return false;
								})
						);
					if (settings.arrowSize) {
						trackWidth = paneWidth - settings.arrowSize - settings.arrowSize;
						$track
							.css({'width': trackWidth+'px', left:settings.arrowSize+'px'})
					} else {
						var leftArrowWidth = jQuery('>.jScrollArrowLeft', $container).width();
						settings.arrowSize = leftArrowWidth;
						trackWidth = paneWidth - leftArrowWidth - jQuery('>.jScrollArrowRight', $container).width();
						$track
							.css({'width': trackWidth +'px', left: leftArrowWidth+'px'})
					}
				}
				
				var $pane = jQuery(this).css({'position':'absolute', 'overflow':'visible'});
				
				var currentOffset;
				var maxX;
				var mouseWheelMultiplier;
				
				// store this in a seperate variable so we can keep track more accurately than just updating the css property..
				var dragPosition = 0;
				var dragMiddle = percentInView*paneWidth/2;
				
				// pos function borrowed from tooltip plugin and adapted...
				var getPos = function (event, c) {
					var p = c == 'X' ? 'Left' : 'Bottom';
					return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0;
				};
				
				var ignoreNativeDrag = function() {	return false; };
				var currentInterval = 0;
				var direction = 1;
				var arrowUp = false;
				var intervalMove = false;
				_jscr_trackInt[currentId] = -1;;
						
				var initDrag = function()
				{
					ceaseAnimation();
					currentOffset = $drag.offset(false);
					currentOffset.left -= dragPosition;
					maxX = trackWidth - $drag[0].offsetWidth;
					mouseWheelMultiplier = 2 * settings.wheelSpeed * maxX / contentWidth;
				};
				
				var onStartDrag = function(event)
				{
					initDrag();
					dragMiddle = getPos(event, 'X') - dragPosition - currentOffset.left;
					jQuery('body').bind('mouseup', onStopDrag).bind('mousemove', updateScroll);
					if (jQuery.browser.msie) {
						jQuery('body').bind('dragstart', ignoreNativeDrag).bind('selectstart', ignoreNativeDrag);
					}
					return false;
				};
				var onStopDrag = function()
				{
					jQuery('body').unbind('mouseup', onStopDrag).unbind('mousemove', updateScroll);
					dragMiddle = percentInView*paneWidth/2;
					moveIntervals();
					
					if (jQuery.browser.msie) {
						jQuery('body').unbind('dragstart', ignoreNativeDrag).unbind('selectstart', ignoreNativeDrag);
					}
				};
				var positionDrag = function(destX)
				{
					//Figure out if we need to adjust because of intervals.
					evaluateIntervals(dragPosition, destX);
					destX = destX < 0 ? 0 : (destX > maxX ? maxX : destX);
					dragPosition = destX;

					$drag.css({'left':destX +'px'});
					var p = destX / maxX;
					_jscr_originalPos[currentId] = (paneWidth-contentWidth) * p * -1;
					$pane.css({'left':((paneWidth-contentWidth)*p) + 'px'});
					$this.trigger('scroll');
				};
				
				var updateScroll = function(e)
				{
					positionDrag(getPos(e, 'X') - currentOffset.left - dragMiddle);
				};
				
				var evaluateIntervals = function(position, destX) { 
	
					if((intervalMove == false) && (mouseWheelMove != true)) { 
							_jscr_trackInt[currentId] = -1;
							halfInter = -1;
							
							smallInter = -1;
							bigInter = -1;
							
							endDragPos = destX + $drag.width();
							fullTrackWidth = $('.jScrollPaneTrack').width();

							for(inter in trackIntervals) { 
								if((endDragPos >= fullTrackWidth) && (endDragPos >= trackIntervals[inter])) {
									_jscr_trackInt[currentId] = inter;
								} else if(destX >= trackIntervals[inter]) {
									smallInter = inter;
								}	else { 
									bigInter = inter;
									break;
								}
								
							}

							if(_jscr_trackInt[currentId] == -1) {
								smallDistance = destX - trackIntervals[smallInter];
								largeDistance = trackIntervals[bigInter] - destX;
								
								if(smallDistance <= largeDistance) {
									_jscr_trackInt[currentId] = smallInter;
								} else { 
									_jscr_trackInt[currentId] = bigInter;
								}
							}
					} else { 
						intervalMove = false;
					}
	
				}
				
				var moveIntervals = function() { 
					if(_jscr_trackInt[currentId] != -1) { 
						//Catching arrow clicks
						if(arrowUp == true) { 
							if((direction == -1) && (_jscr_trackInt[currentId] != 0)) { 
								_jscr_trackInt[currentId] = currentInterval - 1;
							} else if((direction == 1) && (_jscr_trackInt[currentId] != (_jscr_intervals.length -1))) {
								_jscr_trackInt[currentId] = parseInt(currentInterval) + 1;
							}
							arrowUp = false;
						} 
						
						intervalMove = true;
						positionDrag(trackIntervals[_jscr_trackInt[currentId]]);
						currentInterval = _jscr_trackInt[currentId];
					}
				}
				
				var arrowSize = 0;
				
				if(settings.showArrows == true) {
					arrowSize = settings.arrowSize;
				} 
				
				var dragH = Math.max(Math.min(percentInView*(paneWidth-arrowSize*2), settings.dragMaxWidth), settings.dragMinWidth);
				
				$drag.css(
					{'width':dragH+'px'}
				).bind('mousedown', onStartDrag);
				
				var trackScrollInterval;
				var trackScrollInc;
				var trackScrollMousePos;
				var doTrackScroll = function()
				{
					if (trackScrollInc > 8 || trackScrollInc%4==0) {
						positionDrag((dragPosition - ((dragPosition - trackScrollMousePos) / 2)));
					}
					trackScrollInc ++;
				};
				var onStopTrackClick = function()
				{
					clearInterval(trackScrollInterval);
					moveIntervals();
					jQuery('body').unbind('mouseup', onStopTrackClick).unbind('mousemove', onTrackMouseMove);
				};
				var onTrackMouseMove = function(event)
				{
					trackScrollMousePos = getPos(event, 'X') - currentOffset.left - dragMiddle;
				};
				var onTrackClick = function(event)
				{
					initDrag();
					onTrackMouseMove(event);
					trackScrollInc = 0;
					jQuery('body').bind('mouseup', onStopTrackClick).bind('mousemove', onTrackMouseMove);
					trackScrollInterval = setInterval(doTrackScroll, 100);
					doTrackScroll();
				};
				
				$track.bind('mousedown', onTrackClick);
				
				// if the mousewheel plugin has been included then also react to the mousewheel
				if ($container.mousewheel) {

					$container.mousewheel (
						function (event, delta) {
							var movePos = -1;
							
							if($.browser.opera) {
								delta = event.wheelDelta / 120;	
							}

							//The following handles intervals with the mouse wheel
							if(trackIntervals.length > 1) {
								mouseWheelMove = true;
										
								//increase or decrease the interval we are currently on, depending
								//on the direction of the mouse wheel
								if(delta < 0) {
									_jscr_trackInt[currentId] = parseInt(_jscr_trackInt[currentId]) + 1;

									if((_jscr_trackInt[currentId]) >= trackIntervals.length - 1) {
										_jscr_trackInt[currentId] = trackIntervals.length - 1;
									}
									
									//If the next interval is beyond the dragWidth then recalculate.
									if((parseInt($drag.width())+ parseInt(trackIntervals[_jscr_trackInt[currentId]])) > parseInt($('.jScrollPaneTrack').width())) {
										movePos = parseInt($('.jScrollPaneTrack').width()) - $drag.width();
									}
									
								} else { 
									_jscr_trackInt[currentId] = parseInt(_jscr_trackInt[currentId]) - 1;
									if(_jscr_trackInt[currentId] < 0) {
										_jscr_trackInt[currentId] = 0;
									}
								}
							}

							initDrag();
							ceaseAnimation();
							var d = dragPosition;
							
							//when intervals are in use, mouseWheelMove is set to true
							if(mouseWheelMove == true) {
								if(movePos == -1) {
									positionDrag(trackIntervals[_jscr_trackInt[currentId]]);
								} else {
									positionDrag(movePos);
								}
							} else {
								positionDrag(dragPosition - delta * mouseWheelMultiplier);
							}
							
							moveIntervals();
							var dragOccured = d != dragPosition;
							mouseWheelMove = false;
							return !dragOccured;
						},
						false
					);					
				}
				var _animateToPosition;
				var _animateToInterval;
				function animateToPosition()
				{

					var diff = (_animateToPosition - dragPosition) / settings.animateStep;
					
					if ((diff > 1 || diff < -1) && ((dragPosition + diff + $drag.width()) < (paneWidth))) {
						positionDrag(dragPosition + diff);
					} else {
						positionDrag(_animateToPosition);
						ceaseAnimation();
					}
				}
				var ceaseAnimation = function()
				{
					if (_animateToInterval) {
						clearInterval(_animateToInterval);
						delete _animateToPosition;
					}
				};
				var scrollTo = function(pos, preventAni)
				{
					if (typeof pos == "string") {
						$e = jQuery(pos, this);

						if (!$e.length) return;
						pos = $e.position().left;
					}

					ceaseAnimation();
					var destDragPosition = -pos/(paneWidth-contentWidth) * maxX;
					if (!preventAni || settings.animateTo) {
						_animateToPosition = destDragPosition;
						_animateToInterval = setInterval(animateToPosition, settings.animateInterval);
		
					} else {
						positionDrag(destDragPosition);
					}	
				};
				$this[0].scrollTo = scrollTo;
				
				$this[0].scrollBy = function(delta)
				{
					var currentPos = -parseInt($pane.css('left')) || 0;
					scrollTo(currentPos + delta);
				};
				
				initDrag();
				
				scrollTo(-currentScrollPosition, true);
				
				jQuery.jScrollHorizontalPane.active.push($this[0]);

			} else {
				var scrollTo = function(pos, preventAni) {}
				$this[0].scrollTo = scrollTo;
				
				$this.css(
					{
						'height':paneHeight-this.originalSidePaddingTotal+'px',
						'width': paneWidth+'px',
						'padding':this.originalPadding
					}
				);
				// remove from active list?
			}
			
		}
	)
};

jQuery.fn.jScrollHorizontalPane.reset = function() {
	_jscr_originalSizes = new Array();
	_jscr_differenceSizes = new Array();
	_jscr_previousWindowSize = new Array();
	_jscr_originalPercentages = new Array();
	_jscr_intervals = new Array();
	_jscr_trackInt = new Array();
	_jscr_originalPos = new Array();
	_jscr_globalProperties = new Array();
}

// clean up the scrollTo expandos
jQuery(window)
	.bind('unload', function() {
		var els = jQuery.jScrollHorizontalPane.active; 
		for (var i=0; i<els.length; i++) {
			els[i].scrollTo = els[i].scrollBy = null;
		}
	}
);
	
	
/*   
=============================================================================== 
WResize is the jQuery plugin for fixing the IE window resize bug 
............................................................................... 
                                               Copyright 2007 / Andrea Ercolino 
------------------------------------------------------------------------------- 
LICENSE: http://www.opensource.org/licenses/mit-license.php 
WEBSITE: http://noteslog.com/ 

------------------------------------------------------------------------------- 
USAGE: (div is automatically resized when the window is resized)
------------------------------------------------------------------------------- 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" style="overflow:hidden;"> 
<head> 
<title> test window resize </title> 
 
<script type="text/javascript" src="http://jquery.com/src/jquery-latest.pack.js"></script> 
<script type="text/javascript" src="jquery.wresize.js"></script> 
 
 
<script type="text/javascript"> 
jQuery( function( $ )  
{ 
    function content_resize()  
    { 
        var w = $( window ); 
        var H = w.height(); 
        var W = w.width(); 
        $( '#content' ).css( {width: W-20, height: H-20} ); 
    } 
 
    $( window ).wresize( content_resize ); 
 
    content_resize(); 
} ); 
</script> 
 
</head> 

<body> 
  
<div id="content" style="border: 1px dashed silver; position:absolute; overflow:auto;"> 
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test  
</div> 
 
</body> 
</html>

=============================================================================== 
*/ 
 
( function( $ )  
{ 
 
	jQuery(function($) {
		$( window ).wresize(resizeScroller);
		
		function resizeScroller() {
		$('.scroll-pane').each(function(i, elem) { 	
			$(elem).jScrollHorizontalPane(_jscr_globalProperties[$(elem).attr('id')] );
		});
		}	
	});


    $.fn.wresize = function( f )  
    { 
        version = '1.1'; 
        wresize = {fired: false, width: 0}; 
 
        function resizeOnce()  
        { 
            if ( $.browser.msie ) 
            { 
                if ( ! wresize.fired ) 
                { 
                    wresize.fired = true; 
                } 
                else  
                { 
                    var version = parseInt( $.browser.version, 10 ); 
                    wresize.fired = false; 
                    if ( version < 7 ) 
                    { 
                        return false; 
                    } 
                    else if ( version == 7 ) 
                    { 
                        //a vertical resize is fired once, an horizontal resize twice 
                        var width = $( window ).width(); 
                        if ( width != wresize.width ) 
                        { 
                            wresize.width = width; 
                            return false; 
                        } 
                    } 
                } 
            }
 
            return true; 
        } 
 
        function handleWResize( e )  
        { 
			if ( resizeOnce() ) 
            { 
                return f.apply(this, [e]); 
            } 
        } 
 
        this.each( function()  
        { 
            if ( this == window ) 
            { 
                $( this ).resize( handleWResize ); 
            } 
            else 
            { 
                $( this ).resize( f ); 
            } 
        } ); 
 
        return this; 
    }; 
 
} ) ( jQuery );


/**
	main.js
	Georges Cubas 27/06/07
	scripts de l'administration
**/

jQuery.jQueryRandom = 0;
jQuery.extend(jQuery.expr[":"],
{
    random: function(a, i, m, r) {
        if (i == 0) {
            jQuery.jQueryRandom = Math.floor(Math.random() * r.length);
        };
        return i == jQuery.jQueryRandom;
    }
});

$.fn.infiniteCarousel = function () {

	function repeat(str, num) {
		return new Array( num + 1 ).join( str );
	}
  
	return this.each(function () {
		var $wrapper = $('> div', this).css('overflow', 'hidden'),
			$slider = $wrapper.find('> ul'),
			$items = $slider.find('> li'),
			$single = $items.filter(':first'),
			
			singleWidth = $single.outerWidth(), 
			visible = Math.ceil($wrapper.innerWidth() / singleWidth), // note: doesn't include padding or border
			currentPage = 1,
			pages = Math.ceil($items.length / visible);            


		// 1. Pad so that 'visible' number will always be seen, otherwise create empty items
		if (($items.length % visible) != 0) {
			$slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
			$items = $slider.find('> li');
		}

		// 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
		$items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
		$items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
		$items = $slider.find('> li'); // reselect
		
		// 3. Set the left position to the first 'real' item
		$wrapper.scrollLeft(singleWidth * visible);
		
		// 4. paging function
		function gotoPage(page) {
			var dir = page < currentPage ? -1 : 1,
				n = Math.abs(currentPage - page),
				left = singleWidth * dir * visible * n;
			$wrapper.filter(':not(:animated)').animate({
				scrollLeft : '+=' + left
			}, 500, function () {
				if (page == 0) {
					$wrapper.scrollLeft(singleWidth * visible * pages);
					page = pages;
				} else if (page > pages) {
					$wrapper.scrollLeft(singleWidth * visible);
					// reset back to start position
					page = 1;
				} 

				currentPage = page;
			});                
			
			return false;
		}
		
		$wrapper.after('<a class="arrow back">&lt;</a><a class="arrow forward">&gt;</a>');
		
		// 5. Bind to the forward and back buttons
		$('a.back', this).click(function () {
			return gotoPage(currentPage - 1);                
		});
		
		$('a.forward', this).click(function () {
			return gotoPage(currentPage + 1);
		});
		
		// create a public interface to move to a specific page
		$(this).bind('goto', function (event, page) {
			gotoPage(page);
		});
	});  
};

var currentTweet = null;
var TweetThisLink = {
	shorten : function() {
		var url = document.location.href;
		currentTweet = this;
		BitlyClient.shorten(url, "TweetThisLink.response");
	},

	response : function(data) {
		var bitly_link = null;
		for (var r in data.results) {
			bitly_link = data.results[r]["shortUrl"]; 
			break;
		}
		var tweet_title = document.title;
		$(currentTweet).attr("href", "http://twitter.com/home?status=" + encodeURIComponent(tweet_title + " " + bitly_link));
		$(currentTweet).attr("target", "_blank");
	}
}


$(document).ready(
	function () {
		// liens sociaux
		$(".maillink").attr("href", "mailto:votrecontact@example.com&subject=Millet%20:%20"+ encodeURIComponent(document.title) + "&body=" + encodeURIComponent(document.location.href));
		$(".viadeolink").attr("target", "_blank")
						.attr("href", "http://www.viadeo.com/shareit/share/?url=" + encodeURIComponent(document.location.href) + "&title=" + encodeURIComponent(document.title) + "&overview=" + encodeURIComponent(document.title) + "&urllanguage=fr&urlaffiliate=32003&encoding=UTF-8&urlpicture=http://www.viadeo.com/v_img8/shareit/viadeoflower.gif");
		$(".tweetlink").each(TweetThisLink.shorten);
		
        $('.infiniteCarousel').infiniteCarousel();
		$(".ceebox").ceebox();
		$('#content .bloc').each(
			function() {
				var bottom = this.offsetHeight + this.offsetTop;
				var lecontent = document.getElementById('content');
				if ( bottom > lecontent.offsetHeight)
					$('#content').css('height', bottom);
			}
		);

	/** liens **/
		$('a.externe, a[rel="external"]').click(
			function()
			{
				window.open($(this).attr('href'));
				return false;
			}
		);

		$('a.document').click(
			function()
			{
				window.open($(this).attr('href'));
				return false;
			}
		);


		$('body.porte a.voirAmbiance').unbind("click");
		$('body.porte a.voirAmbiance').click(
			function() {
				$('div.ambiance').SlideInUp('normal');
				$(this).hide();
				$('a.masquerAmbiance').show();
				return false;
			}
		);
		$('body.porte a.masquerAmbiance').click(
			function() {
				$('div.ambiance').SlideOutUp('normal');
				$(this).hide();
				$('a.voirAmbiance').show();
				return false;
			}
		);
		$('body.porte div.ambiance .masquer, body.porte div.ambiance').click(
			function() {
				$('div.ambiance').SlideOutUp('normal');
				$('a.masquerAmbiance').hide();
				$('a.voirAmbiance').show();
				return false;
			}
		);

		/*$('ul.liste_portes').jcarousel(
			{
				scroll : 1,
				visible : 1,
				initCallback: listePorte_initCallback,
				// This tells jCarousel NOT to autobuild prev/next buttons
				buttonNextHTML: null,
				buttonPrevHTML: null
			}
		);*/
		$('#portes_matiere').css('display', 'none');
		$('#portes_matiere').css('visibility', 'visible');

		$('div.menu-options').parents('div.bloc').css('z-index', 99);
		$('ul', 'div.menu-options').hide();
		$('div.menu-options').hoverIntent(
			{
				sensitivity: 99, // number = sensitivity threshold (must be 1 or higher)
				interval: 350, // number = milliseconds for onMouseOver polling interval
				over: function() {  // function = onMouseOver callback (required)
					$('ul', this).css('top', - parseInt($('ul', this).height()));
					$('ul', this).css('bottom', 'inherit');
					$('ul', this).SlideInDown('normal');
				},
				timeout: 750, // number = milliseconds delay before onMouseOut
				out: function() { // function = onMouseOut callback (required)
					$('ul', this).SlideOutDown('normal');
				}
			}
		);

		$('div.menu-deroulant div.hidden').hide();
		$('div.menu-deroulant').hoverIntent(
			{
				sensitivity: 99, // number = sensitivity threshold (must be 1 or higher)
				interval: 350, // number = milliseconds for onMouseOver polling interval
				over: function() {  // function = onMouseOver callback (required)
					$('div.hidden', this).css('top', - parseInt($('div.hidden', this).height()));
					$('div.hidden', this).css('bottom', 'inherit');
					$('div.hidden', this).show();
				},
				timeout: 750, // number = milliseconds delay before onMouseOut
				out: function() { // function = onMouseOut callback (required)
					$('div.hidden', this).hide();
				}
			}
		);

		$('#connect').click(
			function() {
				popin('popinConnect', 'index.php?action=ajaxGetConnexion');
				return false;
			}
		);

		$("a#lien_porteBois").append("<img src='medias/Image/accueil/ambiance-porte-bois.jpg' style='display : none; position:absolute; left:0; top:37px;'/>");
		$("a#lien_fenetreBois").append("<img src='medias/Image/accueil/ambiance-fenetre-bois.jpg' style='display : none; position:absolute; left:0; top:37px;'/>");
		$("a#lien_portePvc").append("<img src='medias/Image/accueil/ambiance-porte-pvc.jpg' style='display : none; position:absolute; left:0; top:37px;'/>");
		$("a#lien_fenetrePvc").append("<img src='medias/Image/accueil/ambiance-fenetre-pvc.jpg' style='display : none; position:absolute; left:0; top:37px;'/>");
		$("a#lien_porteAlu").append("<img src='medias/Image/accueil/ambiance-porte-alu.jpg' style='display : none; position:absolute; left:0; top:37px;'/>");
		$("a#lien_fenetreAlu").append("<img src='medias/Image/accueil/ambiance-fenetre-alu.jpg' style='display : none; position:absolute; left:0; top:37px;'/>");
		$("a#lien_porteAcier").append("<img src='medias/Image/accueil/ambiance-porte-acier.jpg' style='display : none; position:absolute; left:0; top:37px;'/>");
		$("a#lien_porteBois, a#lien_fenetreBois, a#lien_portePvc, a#lien_fenetrePvc, a#lien_porteAlu, a#lien_fenetreAlu, a#lien_porteAcier").hoverIntent({
			over : function() {
					$('img', this).css('z-index', 1000);
					$('img', this).show();
				},
			out : function() {
					$('img', this).hide();
				}
			}
		);
		$("a#lien_porteBois2").cycle();
		$("a#lien_portePVC2").cycle();
		$("a#lien_porteAlu2").cycle();
		$("a#lien_porteAcier2").cycle();

		// page recherche
		$('body.recherche h2').click(
			function() {
				$(this).parent().toggleClass("reduit");
			}
		);

		$('#formContact #in_type').change(
			function() {
				if ($(this).val() == 1)
				{
					$('#formContact .professionnel').hide();
					$('#formContact .particulier').show();
				}
				else
				{
					$('#formContact .particulier').hide();
					$('#formContact .professionnel').show();
				}
				$('#content .bloc').each(
					function() {
						var bottom = this.offsetHeight + this.offsetTop;
						var lecontent = document.getElementById('content');
						if ( bottom > lecontent.offsetHeight)
							$('#content').css('height', bottom);
					}
				);
			}
		);

		$('#formContact input[type=checkbox]').click(
			function() {
				if ($(this).is(':checked'))
					$('#formContact .'+ $(this).attr('id')).show();
				else
					$('#formContact .'+ $(this).attr('id')).hide();
				$('#content .bloc').each(
					function() {
						var bottom = this.offsetHeight + this.offsetTop;
						var lecontent = document.getElementById('content');
						if ( bottom > lecontent.offsetHeight)
							$('#content').css('height', bottom);
					}
				);
			}
		);
		
		$("#formContact").yav({
			errorTag:"span",
			custom: {				requiredPro: function(return_value){					var field_id = return_value.id;					if (($("#"+field_id).val() == "") && ($("#in_type").val() == "2")){						return return_value;					}else{						return null;					}
				},				requiredParticulier: function(return_value){					var field_id = return_value.id;					if (($("#"+field_id).val() == "") && ($("#in_type").val() == "1")){						return return_value;					}else{						return null;					}
				},				objetParticulier: function(return_value){
					if	(
							(
								!$("#bo_demandeInformationParticulier").is(":checked") &&
								!$("#bo_demandeDocumentationParticulier").is(":checked")/* &&
								!$("#bo_distributeurProche").is(":checked")*/
							) && ($("#in_type").val() == "1")
						)
					{						return return_value;					}else{						return null;					}
				},				objetPro: function(return_value){
					if	(
							(
								!$("#bo_demandeInformationProfessionnel").is(":checked") &&
								!$("#bo_demandeDocumentationProfessionnel").is(":checked") &&
								!$("#bo_demandeDevis").is(":checked")
							) && ($("#in_type").val() == "2")
						)
					{						return return_value;					}else{						return null;					}
				},				devisPro: function(return_value){
					if	(
							(
								($("#st_demandeDevis").val() == "") &&
								$("#bo_demandeDevis").is(":checked")
							) && ($("#in_type").val() == "2")
						)
					{						return return_value;					}else{						return null;					}
				},				informationPro: function(return_value){
					if	(
							(
								($("#st_demandeInformationProfessionnel").val() == "") &&
								$("#bo_demandeInformationProfessionnel").is(":checked")
							) && ($("#in_type").val() == "2")
						)
					{						return return_value;					}else{						return null;					}
				},				distributeurProche: function(return_value){
					if	(
							(
								($("#st_distributeurProche").val() == "") &&
								$("#bo_distributeurProche").is(":checked")
							) && ($("#in_type").val() == "1")
						)
					{						return return_value;					}else{						return null;					}
				},				informationParticulier: function(return_value){
					if	(
							(
								($("#st_demandeInformationParticulier").val() == "") &&
								$("#bo_demandeInformationParticulier").is(":checked")
							) && ($("#in_type").val() == "1")
						)
					{						return return_value;					}else{						return null;					}
				},				documentationParticulier: function(return_value){
					if	(
							$("#bo_demandeDocumentationParticulier").is(":checked")
							&& ($("#in_type").val() == "1")
						)
					{
						if ($('div.bo_demandeDocumentationParticulier input[type=checkbox]:checked').length > 0)
							return null;
						else
							return return_value;					}else{						return null;					}
				},				documentationPro: function(return_value){
					if	(
							$("#bo_demandeDocumentationProfessionnel").is(":checked")
							&& ($("#in_type").val() == "2")
						)
					{
						if ($('div.bo_demandeDocumentationProfessionnel input[type=checkbox]:checked').length > 0)
							return null;
						else
							return return_value;					}else{						return null;					}
				}			}
		});
	}
);

// liens de la liste des portes
function listePorte_initCallback(carousel) {
    $('.jcarousel-control a.position').click(
		function()
		{
			carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
			return false;
		}
	);

    $('.jcarousel-control a.mycarousel-next').click(
		function()
		{
			carousel.next();
			return false;
		}
	);

    $('.jcarousel-control a.mycarousel-prev').click(
		function()
		{
			carousel.prev();
			return false;
		}
	);
};

function listeItem_initCallback(carousel)
{
	carousel.buttonNext.html("&gt;");
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});

	carousel.buttonPrev.html("&lt;");
	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});

	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};

function popin(style, url)
{
	var currentTime = new Date()
	var id = "popin" + currentTime.getTime();
	$('body').append('<div class="popin ' + style + '" id="'+ id +'"><div class="popinTop"></div><div class="popinBody"><div style="text-align:center"><img src="medias/site/arbre.jpg" alt="" style="vertical-align:middle;" />Chargement en cours...</div></div><div class="popinBottom"></div></div>');
	$('#' + id)
		.jqm(
			{
				ajax: url,
				target: '.popinBody',
				onHide : function(hash) { hash.w.fadeOut('2000',function(){ hash.o.remove(); }); }
			})
		.jqmShow();
}

