/**
 * JS Library modules
 **/
 
/* FancyBox - Copyright (c) 2008 - 2010 Janis Skarnelis, Dual licensed under the MIT and GPL licenses */
 (function(b){var m,u,x,g,D,i,z,A,B,p=0,e={},q=[],n=0,c={},j=[],E=null,s=new Image,G=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,S=/[^\.]\.(swf)\s*$/i,H,I=1,k,l,h=false,y=b.extend(b("<div/>")[0],{prop:0}),v=0,O=!b.support.opacity&&!window.XMLHttpRequest,J=function(){u.hide();s.onerror=s.onload=null;E&&E.abort();m.empty()},P=function(){b.fancybox('<p id="fancybox_error">The requested content cannot be loaded.<br />Please try again later.</p>',{scrolling:"no",padding:20,transitionIn:"none",transitionOut:"none"})},K=function(){return[b(window).width(),b(window).height(),b(document).scrollLeft(),b(document).scrollTop()]},T=function(){var a=K(),d={},f=c.margin,o=c.autoScale,t=(20+f)*2,w=(20+f)*2,r=c.padding*2;if(c.width.toString().indexOf("%")>-1){d.width=a[0]*parseFloat(c.width)/100-40;o=false}else d.width=c.width+r;if(c.height.toString().indexOf("%")>-1){d.height=a[1]*parseFloat(c.height)/100-40;o=false}else d.height=c.height+r;if(o&&(d.width>a[0]-t||d.height>a[1]-w))if(e.type=="image"||e.type=="swf"){t+=r;w+=r;o=Math.min(Math.min(a[0]-t,c.width)/c.width,Math.min(a[1]-w,c.height)/c.height);d.width=Math.round(o*(d.width-r))+r;d.height=Math.round(o*(d.height-r))+r}else{d.width=Math.min(d.width,a[0]-t);d.height=Math.min(d.height,a[1]-w)}d.top=a[3]+(a[1]-(d.height+40))*0.5;d.left=a[2]+(a[0]-(d.width+40))*0.5;if(c.autoScale===false){d.top=Math.max(a[3]+f,d.top);d.left=Math.max(a[2]+f,d.left)}return d},U=function(a){if(a&&a.length)switch(c.titlePosition){case "inside":return a;case "over":return'<span id="fancybox-title-over">'+a+"</span>";default:return'<span id="fancybox-title-wrap"><span id="fancybox-title-left"></span><span id="fancybox-title-main">'+a+'</span><span id="fancybox-title-right"></span></span>'}return false},V=function(){var a=c.title,d=l.width-c.padding*2,f="fancybox-title-"+c.titlePosition;b("#fancybox-title").remove();v=0;if(c.titleShow!==false){a=b.isFunction(c.titleFormat)?c.titleFormat(a,j,n,c):U(a);if(!(!a||a==="")){b('<div id="fancybox-title" class="'+f+'" />').css({width:d,paddingLeft:c.padding,paddingRight:c.padding}).html(a).appendTo("body");switch(c.titlePosition){case "inside":v=b("#fancybox-title").outerHeight(true)-c.padding;l.height+=v;break;case "over":b("#fancybox-title").css("bottom",c.padding);break;default:b("#fancybox-title").css("bottom",b("#fancybox-title").outerHeight(true)*-1);break}b("#fancybox-title").appendTo(D).hide()}}},W=function(){b(document).unbind("keydown.fb").bind("keydown.fb",function(a){if(a.keyCode==27&&c.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if(a.keyCode==37){a.preventDefault();b.fancybox.prev()}else if(a.keyCode==39){a.preventDefault();b.fancybox.next()}});if(b.fn.mousewheel){g.unbind("mousewheel.fb");j.length>1&&g.bind("mousewheel.fb",function(a,d){a.preventDefault();h||d===0||(d>0?b.fancybox.prev():b.fancybox.next())})}if(c.showNavArrows){if(c.cyclic&&j.length>1||n!==0)A.show();if(c.cyclic&&j.length>1||n!=j.length-1)B.show()}},X=function(){var a,d;if(j.length-1>n){a=j[n+1].href;if(typeof a!=="undefined"&&a.match(G)){d=new Image;d.src=a}}if(n>0){a=j[n-1].href;if(typeof a!=="undefined"&&a.match(G)){d=new Image;d.src=a}}},L=function(){i.css("overflow",c.scrolling=="auto"?c.type=="image"||c.type=="iframe"||c.type=="swf"?"hidden":"auto":c.scrolling=="yes"?"auto":"visible");if(!b.support.opacity){i.get(0).style.removeAttribute("filter");g.get(0).style.removeAttribute("filter")}b("#fancybox-title").show();c.hideOnContentClick&&i.one("click",b.fancybox.close);c.hideOnOverlayClick&&x.one("click",b.fancybox.close);c.showCloseButton&&z.show();W();b(window).bind("resize.fb",b.fancybox.center);c.centerOnScroll?b(window).bind("scroll.fb",b.fancybox.center):b(window).unbind("scroll.fb");b.isFunction(c.onComplete)&&c.onComplete(j,n,c);h=false;X()},M=function(a){var d=Math.round(k.width+(l.width-k.width)*a),f=Math.round(k.height+(l.height-k.height)*a),o=Math.round(k.top+(l.top-k.top)*a),t=Math.round(k.left+(l.left-k.left)*a);g.css({width:d+"px",height:f+"px",top:o+"px",left:t+"px"});d=Math.max(d-c.padding*2,0);f=Math.max(f-(c.padding*2+v*a),0);i.css({width:d+"px",height:f+"px"});if(typeof l.opacity!=="undefined")g.css("opacity",a<0.5?0.5:a)},Y=function(a){var d=a.offset();d.top+=parseFloat(a.css("paddingTop"))||0;d.left+=parseFloat(a.css("paddingLeft"))||0;d.top+=parseFloat(a.css("border-top-width"))||0;d.left+=parseFloat(a.css("border-left-width"))||0;d.width=a.width();d.height=a.height();return d},Q=function(){var a=e.orig?b(e.orig):false,d={};if(a&&a.length){a=Y(a);d={width:a.width+c.padding*2,height:a.height+c.padding*2,top:a.top-c.padding-20,left:a.left-c.padding-20}}else{a=K();d={width:1,height:1,top:a[3]+a[1]*0.5,left:a[2]+a[0]*0.5}}return d},N=function(){u.hide();if(g.is(":visible")&&b.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){b.event.trigger("fancybox-cancel");h=false;return}j=q;n=p;c=e;i.get(0).scrollTop=0;i.get(0).scrollLeft=0;if(c.overlayShow){O&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});x.css({"background-color":c.overlayColor,opacity:c.overlayOpacity}).unbind().show()}l=T();V();if(g.is(":visible")){b(z.add(A).add(B)).hide();var a=g.position(),d;k={top:a.top,left:a.left,width:g.width(),height:g.height()};d=k.width==l.width&&k.height==l.height;i.fadeOut(c.changeFade,function(){var f=function(){i.html(m.contents()).fadeIn(c.changeFade,L)};b.event.trigger("fancybox-change");i.empty().css("overflow","hidden");if(d){i.css({top:c.padding,left:c.padding,width:Math.max(l.width-c.padding*2,1),height:Math.max(l.height-c.padding*2-v,1)});f()}else{i.css({top:c.padding,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*2,1)});y.prop=0;b(y).animate({prop:1},{duration:c.changeSpeed,easing:c.easingChange,step:M,complete:f})}})}else{g.css("opacity",1);if(c.transitionIn=="elastic"){k=Q();i.css({top:c.padding,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*2,1)}).html(m.contents());g.css(k).show();if(c.opacity)l.opacity=0;y.prop=0;b(y).animate({prop:1},{duration:c.speedIn,easing:c.easingIn,step:M,complete:L})}else{i.css({top:c.padding,left:c.padding,width:Math.max(l.width-c.padding*2,1),height:Math.max(l.height-c.padding*2-v,1)}).html(m.contents());g.css(l).fadeIn(c.transitionIn=="none"?0:c.speedIn,L)}}},F=function(){m.width(e.width);m.height(e.height);if(e.width=="auto")e.width=m.width();if(e.height=="auto")e.height=m.height();N()},Z=function(){h=true;e.width=s.width;e.height=s.height;b("<img />").attr({id:"fancybox-img",src:s.src,alt:e.title}).appendTo(m);N()},C=function(){J();var a=q[p],d,f,o,t,w;e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));o=a.title||b(a).title||e.title||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(o===""&&e.orig)o=e.orig.attr("alt");d=a.nodeName&&/^(?:javascript|#)/i.test(a.href)?e.href||null:e.href||a.href||null;if(e.type){f=e.type;if(!d)d=e.content}else if(e.content)f="html";else if(d)if(d.match(G))f="image";else if(d.match(S))f="swf";else if(b(a).hasClass("iframe"))f="iframe";else if(d.match(/#/)){a=d.substr(d.indexOf("#"));f=b(a).length>0?"inline":"ajax"}else f="ajax";else f="inline";e.type=f;e.href=d;e.title=o;if(e.autoDimensions&&e.type!=="iframe"&&e.type!=="swf"){e.width="auto";e.height="auto"}if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=false;e.enableEscapeButton=false;e.showCloseButton=false}if(b.isFunction(e.onStart))if(e.onStart(q,p,e)===false){h=false;return}m.css("padding",20+e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(i.children())});switch(f){case "html":m.html(e.content);F();break;case "inline":b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(i.children())}).bind("fancybox-cancel",function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();s=new Image;s.onerror=function(){P()};s.onload=function(){s.onerror=null;s.onload=null;Z()};s.src=d;break;case "swf":t='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+d+'"></param>';w="";b.each(e.swf,function(r,R){t+='<param name="'+r+'" value="'+R+'"></param>';w+=" "+r+'="'+R+'"'});t+='<embed src="'+d+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+w+"></embed></object>";m.html(t);F();break;case "ajax":a=d.split("#",2);f=e.ajax.data||{};if(a.length>1){d=a[0];if(typeof f=="string")f+="&selector="+a[1];else f.selector=a[1]}h=false;b.fancybox.showActivity();E=b.ajax(b.extend(e.ajax,{url:d,data:f,error:P,success:function(r){if(E.status==200){m.html(r);F()}}}));break;case "iframe":b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" scrolling="'+e.scrolling+'" src="'+e.href+'"></iframe>').appendTo(m);N();break}},$=function(){if(u.is(":visible")){b("div",u).css("top",I*-40+"px");I=(I+1)%12}else clearInterval(H)},aa=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),u=b('<div id="fancybox-loading"><div></div></div>'),x=b('<div id="fancybox-overlay"></div>'),g=b('<div id="fancybox-wrap"></div>'));if(!b.support.opacity){g.addClass("fancybox-ie");u.addClass("fancybox-ie")}D=b('<div id="fancybox-outer"></div>').append('<div class="fancy-bg" id="fancy-bg-n"></div><div class="fancy-bg" id="fancy-bg-ne"></div><div class="fancy-bg" id="fancy-bg-e"></div><div class="fancy-bg" id="fancy-bg-se"></div><div class="fancy-bg" id="fancy-bg-s"></div><div class="fancy-bg" id="fancy-bg-sw"></div><div class="fancy-bg" id="fancy-bg-w"></div><div class="fancy-bg" id="fancy-bg-nw"></div>').appendTo(g);D.append(i=b('<div id="fancybox-inner"></div>'),z=b('<a id="fancybox-close"></a>'),A=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),B=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));z.click(b.fancybox.close);u.click(b.fancybox.cancel);A.click(function(a){a.preventDefault();b.fancybox.prev()});B.click(function(a){a.preventDefault();b.fancybox.next()});if(O){x.get(0).style.setExpression("height","document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'");u.get(0).style.setExpression("top","(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'");D.prepend('<iframe id="fancybox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>')}}};b.fn.fancybox=function(a){b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(d){d.preventDefault();if(!h){h=true;b(this).blur();q=[];p=0;d=b(this).attr("rel")||"";if(!d||d==""||d==="nofollow")q.push(this);else{q=b("a[rel="+d+"], area[rel="+d+"]");p=q.index(this)}C();return false}});return this};b.fancybox=function(a,d){if(!h){h=true;d=typeof d!=="undefined"?d:{};q=[];p=d.index||0;if(b.isArray(a)){for(var f=0,o=a.length;f<o;f++)if(typeof a[f]=="object")b(a[f]).data("fancybox",b.extend({},d,a[f]));else a[f]=b({}).data("fancybox",b.extend({content:a[f]},d));q=jQuery.merge(q,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},d,a));else a=b({}).data("fancybox",b.extend({content:a},d));q.push(a)}if(p>q.length||p<0)p=0;C()}};b.fancybox.showActivity=function(){clearInterval(H);u.show();H=setInterval($,66)};b.fancybox.hideActivity=function(){u.hide()};b.fancybox.next=function(){return b.fancybox.pos(n+1)};b.fancybox.prev=function(){return b.fancybox.pos(n-1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a,10);if(a>-1&&j.length>a){p=a;C()}if(c.cyclic&&j.length>1&&a<0){p=j.length-1;C()}if(c.cyclic&&j.length>1&&a>=j.length){p=0;C()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");J();e&&b.isFunction(e.onCancel)&&e.onCancel(q,p,e);h=false}};b.fancybox.close=function(){function a(){x.fadeOut("fast");g.hide();b.event.trigger("fancybox-cleanup");i.empty();b.isFunction(c.onClosed)&&c.onClosed(j,n,c);j=e=[];n=p=0;c=e={};h=false}if(!(h||g.is(":hidden"))){h=true;if(c&&b.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){h=false;return}J();b(z.add(A).add(B)).hide();b("#fancybox-title").remove();g.add(i).add(x).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");i.css("overflow","hidden");if(c.transitionOut=="elastic"){k=Q();var d=g.position();l={top:d.top,left:d.left,width:g.width(),height:g.height()};if(c.opacity)l.opacity=1;y.prop=1;b(y).animate({prop:0},{duration:c.speedOut,easing:c.easingOut,step:M,complete:a})}else g.fadeOut(c.transitionOut=="none"?0:c.speedOut,a)}};b.fancybox.resize=function(){var a,d;if(!(h||g.is(":hidden"))){h=true;a=i.wrapInner("<div style='overflow:auto'></div>").children();d=a.height();g.css({height:d+c.padding*2+v});i.css({height:d});a.replaceWith(a.children());b.fancybox.center()}};b.fancybox.center=function(){h=true;var a=K(),d=c.margin,f={};f.top=a[3]+(a[1]-(g.height()-v+40))*0.5;f.left=a[2]+(a[0]-(g.width()+40))*0.5;f.top=Math.max(a[3]+d,f.top);f.left=Math.max(a[2]+d,f.left);g.css(f);h=false};b.fn.fancybox.defaults={padding:10,margin:20,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.3,overlayColor:"#666",titleShow:true,titlePosition:"outside",titleFormat:null,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing",easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,onStart:null,onCancel:null,onComplete:null,onCleanup:null,onClosed:null};b(document).ready(function(){aa()})})(jQuery);

/* CUFON script - Copyright (c) 2010 Simo Kinnunen., Licensed under the MIT license. */
 var Cufon = (function() {var api = function() {return api.replace.apply(null, arguments);};var DOM = api.DOM = {ready: (function() {var complete = false, readyStatus = { loaded: 1, complete: 1 };var queue = [], perform = function() {if (complete) return;complete = true;for (var fn; fn = queue.shift(); fn());};if (document.addEventListener) {document.addEventListener('DOMContentLoaded', perform, false);window.addEventListener('pageshow', perform, false);}if (!window.opera && document.readyState) (function() {readyStatus[document.readyState] ? perform() : setTimeout(arguments.callee, 10);})();if (document.readyState && document.createStyleSheet) (function() {try {document.body.doScroll('left');perform();}catch (e) {setTimeout(arguments.callee, 1);}})();addEvent(window, 'load', perform);return function(listener) {if (!arguments.length) perform();else complete ? listener() : queue.push(listener);};})(),root: function() {return document.documentElement || document.body;}};var CSS = api.CSS = {Size: function(value, base) {this.value = parseFloat(value);this.unit = String(value).match(/[a-z%]*$/)[0] || 'px';this.convert = function(value) {return value / base * this.value;};this.convertFrom = function(value) {return value / this.value * base;};this.toString = function() {return this.value + this.unit;};},addClass: function(el, className) {var current = el.className;el.className = current + (current && ' ') + className;return el;},color: cached(function(value) {var parsed = {};parsed.color = value.replace(/^rgba\((.*?),\s*([\d.]+)\)/, function($0, $1, $2) {parsed.opacity = parseFloat($2);return 'rgb(' + $1 + ')';});return parsed;}),fontStretch: cached(function(value) {if (typeof value == 'number') return value;if (/%$/.test(value)) return parseFloat(value) / 100;return {'ultra-condensed': 0.5,'extra-condensed': 0.625,condensed: 0.75,'semi-condensed': 0.875,'semi-expanded': 1.125,expanded: 1.25,'extra-expanded': 1.5,'ultra-expanded': 2}[value] || 1;}),getStyle: function(el) {var view = document.defaultView;if (view && view.getComputedStyle) return new Style(view.getComputedStyle(el, null));if (el.currentStyle) return new Style(el.currentStyle);return new Style(el.style);},gradient: cached(function(value) {var gradient = {id: value,type: value.match(/^-([a-z]+)-gradient\(/)[1],stops: []}, colors = value.substr(value.indexOf('(')).match(/([\d.]+=)?(#[a-f0-9]+|[a-z]+\(.*?\)|[a-z]+)/ig);for (var i = 0, l = colors.length, stop; i < l; ++i) {stop = colors[i].split('=', 2).reverse();gradient.stops.push([ stop[1] || i / (l - 1), stop[0] ]);}return gradient;}),quotedList: cached(function(value) {var list = [], re = /\s*((["'])([\s\S]*?[^\\])\2|[^,]+)\s*/g, match;while (match = re.exec(value)) list.push(match[3] || match[1]);return list;}),recognizesMedia: cached(function(media) {var el = document.createElement('style'), sheet, container, supported;el.type = 'text/css';el.media = media;try {el.appendChild(document.createTextNode('/**/'));} catch (e) {}container = elementsByTagName('head')[0];container.insertBefore(el, container.firstChild);sheet = (el.sheet || el.styleSheet);supported = sheet && !sheet.disabled;container.removeChild(el);return supported;}),removeClass: function(el, className) {var re = RegExp('(?:^|\\s+)' + className +  '(?=\\s|$)', 'g');el.className = el.className.replace(re, '');return el;},supports: function(property, value) {var checker = document.createElement('span').style;if (checker[property] === undefined) return false;checker[property] = value;return checker[property] === value;},textAlign: function(word, style, position, wordCount) {if (style.get('textAlign') == 'right') {if (position > 0) word = ' ' + word;}else if (position < wordCount - 1) word += ' ';return word;},textShadow: cached(function(value) {if (value == 'none') return null;var shadows = [], currentShadow = {}, result, offCount = 0;var re = /(#[a-f0-9]+|[a-z]+\(.*?\)|[a-z]+)|(-?[\d.]+[a-z%]*)|,/ig;while (result = re.exec(value)) {if (result[0] == ',') {shadows.push(currentShadow);currentShadow = {};offCount = 0;}else if (result[1]) {currentShadow.color = result[1];}else {currentShadow[[ 'offX', 'offY', 'blur' ][offCount++]] = result[2];}}shadows.push(currentShadow);return shadows;}),textTransform: (function() {var map = {uppercase: function(s) {return s.toUpperCase();},lowercase: function(s) {return s.toLowerCase();},capitalize: function(s) {return s.replace(/(?:^|\s)./g, function($0) {return $0.toUpperCase();});}};return function(text, style) {var transform = map[style.get('textTransform')];return transform ? transform(text) : text;};})(),whiteSpace: (function() {var ignore = {inline: 1,'inline-block': 1,'run-in': 1};var wsStart = /^\s+/, wsEnd = /\s+$/;return function(text, style, node, previousElement, simple) {if (simple) return text.replace(wsStart, '').replace(wsEnd, '');if (previousElement) {if (previousElement.nodeName.toLowerCase() == 'br') {text = text.replace(wsStart, '');}}if (ignore[style.get('display')]) return text;if (!node.previousSibling) text = text.replace(wsStart, '');if (!node.nextSibling) text = text.replace(wsEnd, '');return text;};})()};CSS.ready = (function() {var complete = !CSS.recognizesMedia('all'), hasLayout = false;var queue = [], perform = function() {complete = true;for (var fn; fn = queue.shift(); fn());};var links = elementsByTagName('link'), styles = elementsByTagName('style');function isContainerReady(el) {return el.disabled || isSheetReady(el.sheet, el.media || 'screen');}function isSheetReady(sheet, media) {if (!CSS.recognizesMedia(media || 'all')) return true;if (!sheet || sheet.disabled) return false;try {var rules = sheet.cssRules, rule;if (rules) {search: for (var i = 0, l = rules.length; rule = rules[i], i < l; ++i) {switch (rule.type) {case 2:break;case 3:if (!isSheetReady(rule.styleSheet, rule.media.mediaText)) return false;break;default:break search;}}}}catch (e) {}return true;}function allStylesLoaded() {if (document.createStyleSheet) return true;var el, i;for (i = 0; el = links[i]; ++i) {if (el.rel.toLowerCase() == 'stylesheet' && !isContainerReady(el)) return false;}for (i = 0; el = styles[i]; ++i) {if (!isContainerReady(el)) return false;}return true;}DOM.ready(function() {if (!hasLayout) hasLayout = CSS.getStyle(document.body).isUsable();if (complete || (hasLayout && allStylesLoaded())) perform();else setTimeout(arguments.callee, 10);});return function(listener) {if (complete) listener();else queue.push(listener);};})();function Font(data) {var face = this.face = data.face, wordSeparators = {'\u0020': 1,'\u00a0': 1,'\u3000': 1};this.glyphs = (function(glyphs) {var key, fallbacks = {'\u2011': '\u002d','\u00ad': '\u2011'};for (key in fallbacks) {if (!hasOwnProperty(fallbacks, key)) continue;if (!glyphs[key]) glyphs[key] = glyphs[fallbacks[key]];}return glyphs;})(data.glyphs);this.w = data.w;this.baseSize = parseInt(face['units-per-em'], 10);this.family = face['font-family'].toLowerCase();this.weight = face['font-weight'];this.style = face['font-style'] || 'normal';this.viewBox = (function () {var parts = face.bbox.split(/\s+/);var box = {minX: parseInt(parts[0], 10),minY: parseInt(parts[1], 10),maxX: parseInt(parts[2], 10),maxY: parseInt(parts[3], 10)};box.width = box.maxX - box.minX;box.height = box.maxY - box.minY;box.toString = function() {return [ this.minX, this.minY, this.width, this.height ].join(' ');};return box;})();this.ascent = -parseInt(face.ascent, 10);this.descent = -parseInt(face.descent, 10);this.height = -this.ascent + this.descent;this.spacing = function(chars, letterSpacing, wordSpacing) {var glyphs = this.glyphs, glyph,kerning, k,jumps = [],width = 0, w,i = -1, j = -1, chr;while (chr = chars[++i]) {glyph = glyphs[chr] || this.missingGlyph;if (!glyph) continue;if (kerning) {width -= k = kerning[chr] || 0;jumps[j] -= k;}w = glyph.w;if (isNaN(w)) w = +this.w;if (w > 0) {w += letterSpacing;if (wordSeparators[chr]) w += wordSpacing;}width += jumps[++j] = ~~w;kerning = glyph.k;}jumps.total = width;return jumps;};}function FontFamily() {var styles = {}, mapping = {oblique: 'italic',italic: 'oblique'};this.add = function(font) {(styles[font.style] || (styles[font.style] = {}))[font.weight] = font;};this.get = function(style, weight) {var weights = styles[style] || styles[mapping[style]]|| styles.normal || styles.italic || styles.oblique;if (!weights) return null;weight = {normal: 400,bold: 700}[weight] || parseInt(weight, 10);if (weights[weight]) return weights[weight];var up = {1: 1,99: 0}[weight % 100], alts = [], min, max;if (up === undefined) up = weight > 400;if (weight == 500) weight = 400;for (var alt in weights) {if (!hasOwnProperty(weights, alt)) continue;alt = parseInt(alt, 10);if (!min || alt < min) min = alt;if (!max || alt > max) max = alt;alts.push(alt);}if (weight < min) weight = min;if (weight > max) weight = max;alts.sort(function(a, b) {return (up? (a >= weight && b >= weight) ? a < b : a > b: (a <= weight && b <= weight) ? a > b : a < b) ? -1 : 1;});return weights[alts[0]];};}function HoverHandler() {function contains(node, anotherNode) {try {if (node.contains) return node.contains(anotherNode);return node.compareDocumentPosition(anotherNode) & 16;}catch(e) {}return false;}function onOverOut(e) {var related = e.relatedTarget;if (related && contains(this, related)) return;trigger(this, e.type == 'mouseover');}function onEnterLeave(e) {trigger(this, e.type == 'mouseenter');}function trigger(el, hoverState) {setTimeout(function() {var options = sharedStorage.get(el).options;api.replace(el, hoverState ? merge(options, options.hover) : options, true);}, 10);}this.attach = function(el) {if (el.onmouseenter === undefined) {addEvent(el, 'mouseover', onOverOut);addEvent(el, 'mouseout', onOverOut);}else {addEvent(el, 'mouseenter', onEnterLeave);addEvent(el, 'mouseleave', onEnterLeave);}};}function ReplaceHistory() {var list = [], map = {};function filter(keys) {var values = [], key;for (var i = 0; key = keys[i]; ++i) values[i] = list[map[key]];return values;}this.add = function(key, args) {map[key] = list.push(args) - 1;};this.repeat = function() {var snapshot = arguments.length ? filter(arguments) : list, args;for (var i = 0; args = snapshot[i++];) api.replace(args[0], args[1], true);};}function Storage() {var map = {}, at = 0;function identify(el) {return el.cufid || (el.cufid = ++at);}this.get = function(el) {var id = identify(el);return map[id] || (map[id] = {});};}function Style(style) {var custom = {}, sizes = {};this.extend = function(styles) {for (var property in styles) {if (hasOwnProperty(styles, property)) custom[property] = styles[property];}return this;};this.get = function(property) {return custom[property] != undefined ? custom[property] : style[property];};this.getSize = function(property, base) {return sizes[property] || (sizes[property] = new CSS.Size(this.get(property), base));};this.isUsable = function() {return !!style;};}function addEvent(el, type, listener) {if (el.addEventListener) {el.addEventListener(type, listener, false);}else if (el.attachEvent) {el.attachEvent('on' + type, function() {return listener.call(el, window.event);});}}function attach(el, options) {var storage = sharedStorage.get(el);if (storage.options) return el;if (options.hover && options.hoverables[el.nodeName.toLowerCase()]) {hoverHandler.attach(el);}storage.options = options;return el;}function cached(fun) {var cache = {};return function(key) {if (!hasOwnProperty(cache, key)) cache[key] = fun.apply(null, arguments);return cache[key];};}function getFont(el, style) {var families = CSS.quotedList(style.get('fontFamily').toLowerCase()), family;for (var i = 0; family = families[i]; ++i) {if (fonts[family]) return fonts[family].get(style.get('fontStyle'), style.get('fontWeight'));}return null;}function elementsByTagName(query) {return document.getElementsByTagName(query);}function hasOwnProperty(obj, property) {return obj.hasOwnProperty(property);}function merge() {var merged = {}, arg, key;for (var i = 0, l = arguments.length; arg = arguments[i], i < l; ++i) {for (key in arg) {if (hasOwnProperty(arg, key)) merged[key] = arg[key];}}return merged;}function process(font, text, style, options, node, el) {var fragment = document.createDocumentFragment(), processed;if (text === '') return fragment;var separate = options.separate;var parts = text.split(separators[separate]), needsAligning = (separate == 'words');if (needsAligning && HAS_BROKEN_REGEXP) {if (/^\s/.test(text)) parts.unshift('');if (/\s$/.test(text)) parts.push('');}for (var i = 0, l = parts.length; i < l; ++i) {processed = engines[options.engine](font,needsAligning ? CSS.textAlign(parts[i], style, i, l) : parts[i],style, options, node, el, i < l - 1);if (processed) fragment.appendChild(processed);}return fragment;}function replaceElement(el, options) {var name = el.nodeName.toLowerCase();if (options.ignore[name]) return;if (options.ignoreClass && options.ignoreClass.test(el.className)) return;if (options.onBeforeReplace) options.onBeforeReplace(el, options);var replace = !options.textless[name], simple = (options.trim === 'simple');var style = CSS.getStyle(attach(el, options)).extend(options);if (parseFloat(style.get('fontSize')) === 0) return;var font = getFont(el, style), node, type, next, anchor, text, lastElement;var isShy = options.softHyphens, anyShy = false, pos, shy, reShy = /\u00ad/g;var modifyText = options.modifyText;if (!font) return;for (node = el.firstChild; node; node = next) {type = node.nodeType;next = node.nextSibling;if (replace && type == 3) {if (isShy && el.nodeName.toLowerCase() != TAG_SHY) {pos = node.data.indexOf('\u00ad');if (pos >= 0) {node.splitText(pos);next = node.nextSibling;next.deleteData(0, 1);shy = document.createElement(TAG_SHY);shy.appendChild(document.createTextNode('\u00ad'));el.insertBefore(shy, next);next = shy;anyShy = true;}}if (anchor) {anchor.appendData(node.data);el.removeChild(node);}else anchor = node;if (next) continue;}if (anchor) {text = anchor.data;if (!isShy) text = text.replace(reShy, '');text = CSS.whiteSpace(text, style, anchor, lastElement, simple);if (modifyText) text = modifyText(text, anchor, el, options);el.replaceChild(process(font, text, style, options, node, el), anchor);anchor = null;}if (type == 1) {if (node.firstChild) {if (node.nodeName.toLowerCase() == 'cufon') {engines[options.engine](font, null, style, options, node, el);}else arguments.callee(node, options);}lastElement = node;}}if (isShy && anyShy) {updateShy(el);if (!trackingShy) addEvent(window, 'resize', updateShyOnResize);trackingShy = true;}if (options.onAfterReplace) options.onAfterReplace(el, options);}function updateShy(context) {var shys, shy, parent, glue, newGlue, next, prev, i;shys = context.getElementsByTagName(TAG_SHY);for (i = 0; shy = shys[i]; ++i) {shy.className = C_SHY_DISABLED;glue = parent = shy.parentNode;if (glue.nodeName.toLowerCase() != TAG_GLUE) {newGlue = document.createElement(TAG_GLUE);newGlue.appendChild(shy.previousSibling);parent.insertBefore(newGlue, shy);newGlue.appendChild(shy);}else {glue = glue.parentNode;if (glue.nodeName.toLowerCase() == TAG_GLUE) {parent = glue.parentNode;while (glue.firstChild) {parent.insertBefore(glue.firstChild, glue);}parent.removeChild(glue);}}}for (i = 0; shy = shys[i]; ++i) {shy.className = '';glue = shy.parentNode;parent = glue.parentNode;next = glue.nextSibling || parent.nextSibling;prev = (next.nodeName.toLowerCase() == TAG_GLUE) ? glue : shy.previousSibling;if (prev.offsetTop >= next.offsetTop) {shy.className = C_SHY_DISABLED;if (prev.offsetTop < next.offsetTop) {newGlue = document.createElement(TAG_GLUE);parent.insertBefore(newGlue, glue);newGlue.appendChild(glue);newGlue.appendChild(next);}}}}function updateShyOnResize() {if (ignoreResize) return;CSS.addClass(DOM.root(), C_VIEWPORT_RESIZING);clearTimeout(shyTimer);shyTimer = setTimeout(function() {ignoreResize = true;CSS.removeClass(DOM.root(), C_VIEWPORT_RESIZING);updateShy(document);ignoreResize = false;}, 100);}var HAS_BROKEN_REGEXP = ' '.split(/\s+/).length == 0;var TAG_GLUE = 'cufonglue';var TAG_SHY = 'cufonshy';var C_SHY_DISABLED = 'cufon-shy-disabled';var C_VIEWPORT_RESIZING = 'cufon-viewport-resizing';var sharedStorage = new Storage();var hoverHandler = new HoverHandler();var replaceHistory = new ReplaceHistory();var initialized = false;var trackingShy = false;var shyTimer;var ignoreResize = false;var engines = {}, fonts = {}, defaultOptions = {autoDetect: false,engine: null,forceHitArea: false,hover: false,hoverables: {a: true},ignore: {applet: 1,canvas: 1,col: 1,colgroup: 1,head: 1,iframe: 1,map: 1,noscript: 1,optgroup: 1,option: 1,script: 1,select: 1,style: 1,textarea: 1,title: 1,pre: 1},ignoreClass: null,modifyText: null,onAfterReplace: null,onBeforeReplace: null,printable: true,selector: (window.Sizzle||	(window.jQuery && function(query) { return jQuery(query); })||	(window.dojo && dojo.query)||	(window.glow && glow.dom && glow.dom.get)||	(window.Ext && Ext.query)||	(window.YAHOO && YAHOO.util && YAHOO.util.Selector && YAHOO.util.Selector.query)||	(window.$$ && function(query) { return $$(query); })||	(window.$ && function(query) { return $(query); })||	(document.querySelectorAll && function(query) { return document.querySelectorAll(query); })||	elementsByTagName),separate: 'words',softHyphens: true,textless: {dl: 1,html: 1,ol: 1,table: 1,tbody: 1,thead: 1,tfoot: 1,tr: 1,ul: 1},textShadow: 'none',trim: 'advanced'};var separators = {words: /\s/.test('\u00a0') ? /[^\S\u00a0]+/ : /\s+/,characters: '',none: /^/};api.now = function() {DOM.ready();return api;};api.refresh = function() {replaceHistory.repeat.apply(replaceHistory, arguments);return api;};api.registerEngine = function(id, engine) {if (!engine) return api;engines[id] = engine;return api.set('engine', id);};api.registerFont = function(data) {if (!data) return api;var font = new Font(data), family = font.family;if (!fonts[family]) fonts[family] = new FontFamily();fonts[family].add(font);return api.set('fontFamily', '"' + family + '"');};api.replace = function(elements, options, ignoreHistory) {options = merge(defaultOptions, options);if (!options.engine) return api;if (!initialized) {CSS.addClass(DOM.root(), 'cufon-active cufon-loading');CSS.ready(function() {CSS.addClass(CSS.removeClass(DOM.root(), 'cufon-loading'), 'cufon-ready');});initialized = true;}if (options.hover) options.forceHitArea = true;if (options.autoDetect) delete options.fontFamily;if (typeof options.ignoreClass == 'string') {options.ignoreClass = new RegExp('(?:^|\\s)(?:' + options.ignoreClass.replace(/\s+/, '|') + ')(?:\\s|$)');}if (typeof options.textShadow == 'string') {options.textShadow = CSS.textShadow(options.textShadow);}if (typeof options.color == 'string' && /^-/.test(options.color)) {options.textGradient = CSS.gradient(options.color);}else delete options.textGradient;if (!ignoreHistory) replaceHistory.add(elements, arguments);if (elements.nodeType || typeof elements == 'string') elements = [ elements ];CSS.ready(function() {for (var i = 0, l = elements.length; i < l; ++i) {var el = elements[i];if (typeof el == 'string') api.replace(options.selector(el), options, true);else replaceElement(el, options);}});return api;};api.set = function(option, value) {defaultOptions[option] = value;return api;};return api;})();Cufon.registerEngine('vml', (function() {var ns = document.namespaces;if (!ns) return;ns.add('cvml', 'urn:schemas-microsoft-com:vml');ns = null;var check = document.createElement('cvml:shape');check.style.behavior = 'url(#default#VML)';if (!check.coordsize) return;check = null;var HAS_BROKEN_LINEHEIGHT = (document.documentMode || 0) < 8;document.write(('<style type="text/css">' +'cufoncanvas{text-indent:0;}' +'@media screen{' +'cvml\\:shape,cvml\\:rect,cvml\\:fill,cvml\\:shadow{behavior:url(#default#VML);display:block;antialias:true;position:absolute;}' +'cufoncanvas{position:absolute;text-align:left;}' +'cufon{display:inline-block;position:relative;vertical-align:' +(HAS_BROKEN_LINEHEIGHT? 'middle': 'text-bottom') +';}' +'cufon cufontext{position:absolute;left:-10000in;font-size:1px;text-align:left;}' +'cufonshy.cufon-shy-disabled,.cufon-viewport-resizing cufonshy{display:none;}' +'cufonglue{white-space:nowrap;display:inline-block;}' +'.cufon-viewport-resizing cufonglue{white-space:normal;}' +'a cufon{cursor:pointer}' +'}' +'@media print{' +'cufon cufoncanvas{display:none;}' +'}' +'</style>').replace(/;/g, '!important;'));function getFontSizeInPixels(el, value) {return getSizeInPixels(el, /(?:em|ex|%)$|^[a-z-]+$/i.test(value) ? '1em' : value);}function getSizeInPixels(el, value) {if (!isNaN(value) || /px$/i.test(value)) return parseFloat(value);var style = el.style.left, runtimeStyle = el.runtimeStyle.left;el.runtimeStyle.left = el.currentStyle.left;el.style.left = value.replace('%', 'em');var result = el.style.pixelLeft;el.style.left = style;el.runtimeStyle.left = runtimeStyle;return result;}function getSpacingValue(el, style, size, property) {var key = 'computed' + property, value = style[key];if (isNaN(value)) {value = style.get(property);style[key] = value = (value == 'normal') ? 0 : ~~size.convertFrom(getSizeInPixels(el, value));}return value;}var fills = {};function gradientFill(gradient) {var id = gradient.id;if (!fills[id]) {var stops = gradient.stops, fill = document.createElement('cvml:fill'), colors = [];fill.type = 'gradient';fill.angle = 180;fill.focus = '0';fill.method = 'none';fill.color = stops[0][1];for (var j = 1, k = stops.length - 1; j < k; ++j) {colors.push(stops[j][0] * 100 + '% ' + stops[j][1]);}fill.colors = colors.join(',');fill.color2 = stops[k][1];fills[id] = fill;}return fills[id];}return function(font, text, style, options, node, el, hasNext) {var redraw = (text === null);if (redraw) text = node.alt;var viewBox = font.viewBox;var size = style.computedFontSize || (style.computedFontSize = new Cufon.CSS.Size(getFontSizeInPixels(el, style.get('fontSize')) + 'px', font.baseSize));var wrapper, canvas;if (redraw) {wrapper = node;canvas = node.firstChild;}else {wrapper = document.createElement('cufon');wrapper.className = 'cufon cufon-vml';wrapper.alt = text;canvas = document.createElement('cufoncanvas');wrapper.appendChild(canvas);if (options.printable) {var print = document.createElement('cufontext');print.appendChild(document.createTextNode(text));wrapper.appendChild(print);}if (!hasNext) wrapper.appendChild(document.createElement('cvml:shape'));}var wStyle = wrapper.style;var cStyle = canvas.style;var height = size.convert(viewBox.height), roundedHeight = Math.ceil(height);var roundingFactor = roundedHeight / height;var stretchFactor = roundingFactor * Cufon.CSS.fontStretch(style.get('fontStretch'));var minX = viewBox.minX, minY = viewBox.minY;cStyle.height = roundedHeight;cStyle.top = Math.round(size.convert(minY - font.ascent));cStyle.left = Math.round(size.convert(minX));wStyle.height = size.convert(font.height) + 'px';var color = style.get('color');var chars = Cufon.CSS.textTransform(text, style).split('');var jumps = font.spacing(chars,getSpacingValue(el, style, size, 'letterSpacing'),getSpacingValue(el, style, size, 'wordSpacing'));if (!jumps.length) return null;var width = jumps.total;var fullWidth = -minX + width + (viewBox.width - jumps[jumps.length - 1]);var shapeWidth = size.convert(fullWidth * stretchFactor), roundedShapeWidth = Math.round(shapeWidth);var coordSize = fullWidth + ',' + viewBox.height, coordOrigin;var stretch = 'r' + coordSize + 'ns';var fill = options.textGradient && gradientFill(options.textGradient);var glyphs = font.glyphs, offsetX = 0;var shadows = options.textShadow;var i = -1, j = 0, chr;while (chr = chars[++i]) {var glyph = glyphs[chars[i]] || font.missingGlyph, shape;if (!glyph) continue;if (redraw) {shape = canvas.childNodes[j];while (shape.firstChild) shape.removeChild(shape.firstChild);}else {shape = document.createElement('cvml:shape');canvas.appendChild(shape);}shape.stroked = 'f';shape.coordsize = coordSize;shape.coordorigin = coordOrigin = (minX - offsetX) + ',' + minY;shape.path = (glyph.d ? 'm' + glyph.d + 'xe' : '') + 'm' + coordOrigin + stretch;shape.fillcolor = color;if (fill) shape.appendChild(fill.cloneNode(false));var sStyle = shape.style;sStyle.width = roundedShapeWidth;sStyle.height = roundedHeight;if (shadows) {var shadow1 = shadows[0], shadow2 = shadows[1];var color1 = Cufon.CSS.color(shadow1.color), color2;var shadow = document.createElement('cvml:shadow');shadow.on = 't';shadow.color = color1.color;shadow.offset = shadow1.offX + ',' + shadow1.offY;if (shadow2) {color2 = Cufon.CSS.color(shadow2.color);shadow.type = 'double';shadow.color2 = color2.color;shadow.offset2 = shadow2.offX + ',' + shadow2.offY;}shadow.opacity = color1.opacity || (color2 && color2.opacity) || 1;shape.appendChild(shadow);}offsetX += jumps[j++];}var cover = shape.nextSibling, coverFill, vStyle;if (options.forceHitArea) {if (!cover) {cover = document.createElement('cvml:rect');cover.stroked = 'f';cover.className = 'cufon-vml-cover';coverFill = document.createElement('cvml:fill');coverFill.opacity = 0;cover.appendChild(coverFill);canvas.appendChild(cover);}vStyle = cover.style;vStyle.width = roundedShapeWidth;vStyle.height = roundedHeight;}else if (cover) canvas.removeChild(cover);wStyle.width = Math.max(Math.ceil(size.convert(width * stretchFactor)), 0);if (HAS_BROKEN_LINEHEIGHT) {var yAdjust = style.computedYAdjust;if (yAdjust === undefined) {var lineHeight = style.get('lineHeight');if (lineHeight == 'normal') lineHeight = '1em';else if (!isNaN(lineHeight)) lineHeight += 'em';style.computedYAdjust = yAdjust = 0.5 * (getSizeInPixels(el, lineHeight) - parseFloat(wStyle.height));}if (yAdjust) {wStyle.marginTop = Math.ceil(yAdjust) + 'px';wStyle.marginBottom = yAdjust + 'px';}}return wrapper;};})());Cufon.registerEngine('canvas', (function() {var check = document.createElement('canvas');if (!check || !check.getContext || !check.getContext.apply) return;check = null;var HAS_INLINE_BLOCK = Cufon.CSS.supports('display', 'inline-block');var HAS_BROKEN_LINEHEIGHT = !HAS_INLINE_BLOCK && (document.compatMode == 'BackCompat' || /frameset|transitional/i.test(document.doctype.publicId));var styleSheet = document.createElement('style');styleSheet.type = 'text/css';styleSheet.appendChild(document.createTextNode(('cufon{text-indent:0;}' +'@media screen,projection{' +'cufon{display:inline;display:inline-block;position:relative;vertical-align:middle;' +(HAS_BROKEN_LINEHEIGHT? '': 'font-size:1px;line-height:1px;') +'}cufon cufontext{display:-moz-inline-box;display:inline-block;width:0;height:0;text-align:left;text-indent:-10000in;}' +(HAS_INLINE_BLOCK? 'cufon canvas{position:relative;}': 'cufon canvas{position:absolute;}') +'cufonshy.cufon-shy-disabled,.cufon-viewport-resizing cufonshy{display:none;}' +'cufonglue{white-space:nowrap;display:inline-block;}' +'.cufon-viewport-resizing cufonglue{white-space:normal;}' +'}' +'@media print{' +'cufon{padding:0;}' +'cufon canvas{display:none;}' +'}').replace(/;/g, '!important;')));document.getElementsByTagName('head')[0].appendChild(styleSheet);function generateFromVML(path, context) {var atX = 0, atY = 0;var code = [], re = /([mrvxe])([^a-z]*)/g, match;generate: for (var i = 0; match = re.exec(path); ++i) {var c = match[2].split(',');switch (match[1]) {case 'v':code[i] = { m: 'bezierCurveTo', a: [ atX + ~~c[0], atY + ~~c[1], atX + ~~c[2], atY + ~~c[3], atX += ~~c[4], atY += ~~c[5] ] };break;case 'r':code[i] = { m: 'lineTo', a: [ atX += ~~c[0], atY += ~~c[1] ] };break;case 'm':code[i] = { m: 'moveTo', a: [ atX = ~~c[0], atY = ~~c[1] ] };break;case 'x':code[i] = { m: 'closePath' };break;case 'e':break generate;}context[code[i].m].apply(context, code[i].a);}return code;}function interpret(code, context) {for (var i = 0, l = code.length; i < l; ++i) {var line = code[i];context[line.m].apply(context, line.a);}}return function(font, text, style, options, node, el) {var redraw = (text === null);if (redraw) text = node.getAttribute('alt');var viewBox = font.viewBox;var size = style.getSize('fontSize', font.baseSize);var expandTop = 0, expandRight = 0, expandBottom = 0, expandLeft = 0;var shadows = options.textShadow, shadowOffsets = [];if (shadows) {for (var i = shadows.length; i--;) {var shadow = shadows[i];var x = size.convertFrom(parseFloat(shadow.offX));var y = size.convertFrom(parseFloat(shadow.offY));shadowOffsets[i] = [ x, y ];if (y < expandTop) expandTop = y;if (x > expandRight) expandRight = x;if (y > expandBottom) expandBottom = y;if (x < expandLeft) expandLeft = x;}}var chars = Cufon.CSS.textTransform(text, style).split('');var jumps = font.spacing(chars,~~size.convertFrom(parseFloat(style.get('letterSpacing')) || 0),~~size.convertFrom(parseFloat(style.get('wordSpacing')) || 0));if (!jumps.length) return null;var width = jumps.total;expandRight += viewBox.width - jumps[jumps.length - 1];expandLeft += viewBox.minX;var wrapper, canvas;if (redraw) {wrapper = node;canvas = node.firstChild;}else {wrapper = document.createElement('cufon');wrapper.className = 'cufon cufon-canvas';wrapper.setAttribute('alt', text);canvas = document.createElement('canvas');wrapper.appendChild(canvas);if (options.printable) {var print = document.createElement('cufontext');print.appendChild(document.createTextNode(text));wrapper.appendChild(print);}}var wStyle = wrapper.style;var cStyle = canvas.style;var height = size.convert(viewBox.height);var roundedHeight = Math.ceil(height);var roundingFactor = roundedHeight / height;var stretchFactor = roundingFactor * Cufon.CSS.fontStretch(style.get('fontStretch'));var stretchedWidth = width * stretchFactor;var canvasWidth = Math.ceil(size.convert(stretchedWidth + expandRight - expandLeft));var canvasHeight = Math.ceil(size.convert(viewBox.height - expandTop + expandBottom));canvas.width = canvasWidth;canvas.height = canvasHeight;cStyle.width = canvasWidth + 'px';cStyle.height = canvasHeight + 'px';expandTop += viewBox.minY;cStyle.top = Math.round(size.convert(expandTop - font.ascent)) + 'px';cStyle.left = Math.round(size.convert(expandLeft)) + 'px';var wrapperWidth = Math.max(Math.ceil(size.convert(stretchedWidth)), 0) + 'px';if (HAS_INLINE_BLOCK) {wStyle.width = wrapperWidth;wStyle.height = size.convert(font.height) + 'px';}else {wStyle.paddingLeft = wrapperWidth;wStyle.paddingBottom = (size.convert(font.height) - 1) + 'px';}var g = canvas.getContext('2d'), scale = height / viewBox.height;g.scale(scale, scale * roundingFactor);g.translate(-expandLeft, -expandTop);g.save();function renderText() {var glyphs = font.glyphs, glyph, i = -1, j = -1, chr;g.scale(stretchFactor, 1);while (chr = chars[++i]) {var glyph = glyphs[chars[i]] || font.missingGlyph;if (!glyph) continue;if (glyph.d) {g.beginPath();if (glyph.code) interpret(glyph.code, g);else glyph.code = generateFromVML('m' + glyph.d, g);g.fill();}g.translate(jumps[++j], 0);}g.restore();}if (shadows) {for (var i = shadows.length; i--;) {var shadow = shadows[i];g.save();g.fillStyle = shadow.color;g.translate.apply(g, shadowOffsets[i]);renderText();}}var gradient = options.textGradient;if (gradient) {var stops = gradient.stops, fill = g.createLinearGradient(0, viewBox.minY, 0, viewBox.maxY);for (var i = 0, l = stops.length; i < l; ++i) {fill.addColorStop.apply(fill, stops[i]);}g.fillStyle = fill;}else g.fillStyle = style.get('color');renderText();return wrapper;};})());

/* Tooltips */
 this.tooltip = function(){/* CONFIG */xOffset = -20;yOffset = 20;/* IMG TOOLTIP */jQuery(".tooltip").hover(function(e){this.t = this.title;this.title = "";jQuery("body").append("<p id='tooltip'>"+ this.t +"</p>");jQuery("#tooltip").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px").fadeIn("fast");},function(){this.title = this.t;jQuery("#tooltip").remove();});jQuery(".tooltip").mousemove(function(e){jQuery("#tooltip").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px");});};jQuery.noConflict(); jQuery(document).ready(function(){tooltip();});

/* TableDnD plug-in for JQuery, Copyright (c) Denis Howlett <denish@isocra.com> - Licensed like jQuery, see http://docs.jquery.com/License. */
jQuery.tableDnD = {
    currentTable : null,
    dragObject: null,
    mouseOffset: null,
    oldY: 0,

    build: function(options) {

        // Set up the defaults if any
        this.each(function() {
            // This is bound to each matching table, set up the defaults and override with user options
            this.tableDnDConfig = jQuery.extend({
                onDragStyle: null,
                onDropStyle: null,
				// Add in the default class for whileDragging
				onDragClass: "tDnD_whileDrag",
                onDrop: null,
                onDragStart: null,
                scrollAmount: 5,
				// The regular expression to use to trim row IDs
                serializeRegexp: /[^\-_]*$/, 
				// If you want to specify another parameter name instead of the table ID
                serializeParamName: null, 
                // If you give the name of a class here, then only Cells with this class will be draggable
                dragHandle: null 
            }, options || {});
            // Now make the rows draggable
            jQuery.tableDnD.makeDraggable(this);
        });

        // Now we need to capture the mouse up and mouse move event. We can use bind so that we don't interfere with other event handlers
        jQuery(document)
            .bind('mousemove', jQuery.tableDnD.mousemove)
            .bind('mouseup', jQuery.tableDnD.mouseup);

        // Don't break the chain
        return this;
    },

    /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
    makeDraggable: function(table) {
        var config = table.tableDnDConfig;
		if (table.tableDnDConfig.dragHandle) {
			// We only need to add the event to the specified cells
			var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table);
			cells.each(function() {
				// The cell is bound to "this"
                jQuery(this).mousedown(function(ev) {
                    jQuery.tableDnD.dragObject = this.parentNode;
                    jQuery.tableDnD.currentTable = table;
                    jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
                    if (config.onDragStart) {
                        // Call the onDrop method if there is one
                        config.onDragStart(table, this);
                    }
                    return false;
                });
			})
		} else {
			// For backwards compatibility, we add the event to the whole row - get all the rows as a wrapped set
	        var rows = jQuery("tr", table);
	        rows.each(function() {
				// Iterate through each row, the row is bound to "this"
				var row = jQuery(this);
				if (! row.hasClass("nodrag")) {
	                row.mousedown(function(ev) {
	                    if (ev.target.tagName == "TD") {
	                        jQuery.tableDnD.dragObject = this;
	                        jQuery.tableDnD.currentTable = table;
	                        jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
	                        if (config.onDragStart) {
	                            // Call the onDrop method if there is one
	                            config.onDragStart(table, this);
	                        }
	                        return false;
	                    }
	                // Store the tableDnD object
                    }).css("cursor", "move"); 
				}
			});
		}
	},

	updateTables: function() {
		this.each(function() {
			// this is now bound to each matching table
			if (this.tableDnDConfig) {
				jQuery.tableDnD.makeDraggable(this);
			}
		})
	},

    /** Get the mouse coordinates from the event (allowing for browser differences) */
    mouseCoords: function(ev){
        if(ev.pageX || ev.pageY){
            return {x:ev.pageX, y:ev.pageY};
        }
        return {
            x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
            y:ev.clientY + document.body.scrollTop  - document.body.clientTop
        };
    },

    /** Given a target element and a mouse event, get the mouse offset from that element. To do this we need the element's position and the mouse position */
    getMouseOffset: function(target, ev) {
        ev = ev || window.event;

        var docPos    = this.getPosition(target);
        var mousePos  = this.mouseCoords(ev);
        return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
    },

    /** Get the position of an element by going up the DOM tree and adding up all the offsets */
    getPosition: function(e){
        var left = 0;
        var top  = 0;
        /** Safari fix -- thanks to Luis Chato for this! */
        if (e.offsetHeight == 0) {
            // a table cell
            e = e.firstChild; 
        }

        while (e.offsetParent){
            left += e.offsetLeft;
            top  += e.offsetTop;
            e     = e.offsetParent;
        }

        left += e.offsetLeft;
        top  += e.offsetTop;

        return {x:left, y:top};
    },

    mousemove: function(ev) {
        if (jQuery.tableDnD.dragObject == null) {
            return;
        }

        var dragObj = jQuery(jQuery.tableDnD.dragObject);
        var config = jQuery.tableDnD.currentTable.tableDnDConfig;
        var mousePos = jQuery.tableDnD.mouseCoords(ev);
        var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
        //auto scroll the window
	    var yOffset = window.pageYOffset;
	 	if (document.all) {
	        // Windows version: yOffset=document.body.scrollTop;
	        if (typeof document.compatMode != 'undefined' &&
	             document.compatMode != 'BackCompat') {
	           yOffset = document.documentElement.scrollTop;
	        }
	        else if (typeof document.body != 'undefined') {
	           yOffset=document.body.scrollTop;
	        }

	    }
		    
		if (mousePos.y-yOffset < config.scrollAmount) {
	    	window.scrollBy(0, -config.scrollAmount);
	    } else {
            var windowHeight = window.innerHeight ? window.innerHeight
                    : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
            if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
                window.scrollBy(0, config.scrollAmount);
            }
        }


        if (y != jQuery.tableDnD.oldY) {
            // work out if we're going up or down...
            var movingDown = y > jQuery.tableDnD.oldY;
            // update the old value
            jQuery.tableDnD.oldY = y;
            // update the style to show we're dragging
			if (config.onDragClass) {
				dragObj.addClass(config.onDragClass);
			} else {
	            dragObj.css(config.onDragStyle);
			}
            // If we're over a row then move the dragged row to there so that the user sees the effect dynamically
            var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y);
            if (currentRow) {
                // TODO worry about what happens when there are multiple TBODIES
                if (movingDown && jQuery.tableDnD.dragObject != currentRow) {
                    jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling);
                } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) {
                    jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow);
                }
            }
        }

        return false;
    },

    /** We're only worried about the y position really, because we can only move rows up and down */
    findDropTargetRow: function(draggedRow, y) {
        var rows = jQuery.tableDnD.currentTable.rows;
        for (var i=0; i<rows.length; i++) {
            var row = rows[i];
            var rowY    = this.getPosition(row).y;
            var rowHeight = parseInt(row.offsetHeight)/2;
            if (row.offsetHeight == 0) {
                rowY = this.getPosition(row.firstChild).y;
                rowHeight = parseInt(row.firstChild.offsetHeight)/2;
            }
            // Because we always have to insert before, we need to offset the height a bit
            if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) {
                // that's the row we're over - If it's the same as the current row, ignore it
				if (row == draggedRow) {return null;}
                var config = jQuery.tableDnD.currentTable.tableDnDConfig;
                if (config.onAllowDrop) {
                    if (config.onAllowDrop(draggedRow, row)) {
                        return row;
                    } else {
                        return null;
                    }
                } else {
					// If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
                    var nodrop = jQuery(row).hasClass("nodrop");
                    if (! nodrop) {
                        return row;
                    } else {
                        return null;
                    }
                }
                return row;
            }
        }
        return null;
    },

    mouseup: function(e) {
        if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) {
            var droppedRow = jQuery.tableDnD.dragObject;
            var config = jQuery.tableDnD.currentTable.tableDnDConfig;
            // If we have a dragObject, then we need to release it, the row will already have been moved to the right place so we just reset stuff
			if (config.onDragClass) {
	            jQuery(droppedRow).removeClass(config.onDragClass);
			} else {
	            jQuery(droppedRow).css(config.onDropStyle);
			}
            jQuery.tableDnD.dragObject   = null;
            if (config.onDrop) {
                // Call the onDrop method if there is one
                config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
            }
            // let go of the table too
            jQuery.tableDnD.currentTable = null; 
        }
    },

    serialize: function() {
        if (jQuery.tableDnD.currentTable) {
            return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable);
        } else {
            return "Error: No Table id set, you need to set an id on your table and every row";
        }
    },

	serializeTable: function(table) {
        var result = "";
        var tableId = table.id;
        var rows = table.rows;
        for (var i=0; i<rows.length; i++) {
            if (result.length > 0) result += "&";
            var rowId = rows[i].id;
            if (rowId && rowId && table.tableDnDConfig && table.tableDnDConfig.serializeRegexp) {
                rowId = rowId.match(table.tableDnDConfig.serializeRegexp)[0];
            }

            result += tableId + '[]=' + rowId;
        }
        return result;
	},

	serializeTables: function() {
        var result = "";
        this.each(function() {
			// this is now bound to each matching table
			result += jQuery.tableDnD.serializeTable(this);
		});
        return result;
    }

};

jQuery.fn.extend(
	{
		tableDnD : jQuery.tableDnD.build,
		tableDnDUpdate : jQuery.tableDnD.updateTables,
		tableDnDSerialize: jQuery.tableDnD.serializeTables
	}
);

