/* http://z3ext.net/@@/jquery.i18n.js */
/*
 * jQuery i18n plugin
 * @requires jQuery v1.1 or later
 *
 * Examples at: http://recurser.com/articles/2008/02/21/jquery-i18n-translation-plugin/
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Based on 'javascript i18n that almost doesn't suck' by markos
 * http://markos.gaivo.net/blog/?p=100
 *
 * Revision: $Id$
 * Version: 1.0.0  Feb-10-2008
 */
 (function($) {
/**
 * i18n provides a mechanism for translating strings using a jscript dictionary.
 *
 */


/*
 * i18n property list
 */
$.i18n = {

/**
 * setDictionary()
 * Initialise the dictionary and translate nodes
 *
 * @param property_list i18n_dict : The dictionary to use for translation
 */
  setDictionary: function(i18n_dictionary) {
    i18n_dict = i18n_dictionary;
  },

/**
 * _()
 * The actual translation function. Looks the given string up in the
 * dictionary and returns the translation if one exists. If a translation
 * is not found, returns the original word
 *
 * @param string str : The string to translate
 * @param property_list params : params for using printf() on the string
 * @return string : Translated word
 *
 */
  _: function (str, params) {
    var transl = str;
    if (i18n_dict&& i18n_dict[str]) {
      transl = i18n_dict[str];
    }
    return this.printf(transl, params);
  },

/**
 * toEntity()
 * Change non-ASCII characters to entity representation
 *
 * @param string str : The string to transform
 * @return string result : Original string with non-ASCII content converted to entities
 *
 */
  toEntity: function (str) {
    var result = '';
    for (var i=0;i<str.length; i++) {
      if (str.charCodeAt(i) > 128)
        result += "&#"+str.charCodeAt(i)+";";
      else
        result += str.charAt(i);
    }
    return result;
  },

/**
 * stripStr()
 *
 * @param string str : The string to strip
 * @return string result : Stripped string
 *
 */
   stripStr: function(str) {
    return str.replace(/^\s*/, "").replace(/\s*$/, "");
  },

/**
 * stripStrML()
 *
 * @param string str : The multi-line string to strip
 * @return string result : Stripped string
 *
 */
  stripStrML: function(str) {
    // Split because m flag doesn't exist before JS1.5 and we need to
    // strip newlines anyway
    var parts = str.split('\n');
    for (var i=0; i<parts.length; i++)
      parts[i] = stripStr(parts[i]);

    // Don't join with empty strings, because it "concats" words
    // And strip again
    return stripStr(parts.join(" "));
  },

/*
 * printf()
 * C-printf like function, which substitutes %s with parameters
 * given in list. %%s is used to escape %s.
 *
 * Doesn't work in IE5.0 (splice)
 *
 * @param string S : string to perform printf on.
 * @param string L : Array of arguments for printf()
 */
  printf: function(S, L) {
    if (!L) return S;

    var nS = "";
    var tS = S.split("%s");

    for(var i=0; i<L.length; i++) {
      if (tS[i].lastIndexOf('%') == tS[i].length-1 && i != L.length-1)
        tS[i] += "s"+tS.splice(i+1,1)[0];
      nS += tS[i] + L[i];
    }
    return nS + tS[tS.length-1];
  }

};


})(jQuery);

/* http://z3ext.net/@@/jquery.lightbox.js */
(function($){if(!$.browser.safari&&typeof window.console!=='undefined'&&typeof window.console.log==='function'){$.log=window.console.log}
else{$.log=function(){}}
$.params_to_json=$.params_to_json|| function(params){params=String(params);params=params.substring(params.indexOf('?')+1);params=params.replace(/\+/g,'%20');if(params.substring(0,1)==='{'&&params.substring(params.length-1)==='}'){return eval(decodeURIComponent(params))}
params=params.split(/\&|\&amp\;/);var json={};for(var i=0,n=params.length;i<n;++i){var param=params[i]||null;if(param===null){continue}
param=param.split('=');if(param===null){continue}
var key=param[0]||null;if(key===null){continue}
if(typeof param[1]==='undefined'){continue}
var value=param[1];key=decodeURIComponent(key);value=decodeURIComponent(value);try{value=eval(value)} catch(e){}
var keys=key.split('.');if(keys.length===1){json[key]=value}
else{var path='';for(ii in keys){key=keys[ii];path+='.'+key;eval('json'+path+' = json'+path+' || {}')}
eval('json'+path+' = value')}}
return json};$.LightboxClass=function(){this.construct()};$.fn.lightbox=function(options){$.Lightbox=$.Lightbox||new $.LightboxClass();if($.Lightbox.ie6&&!$.Lightbox.ie6_support){return this}
options=$.extend({start:false,events:true},options);var group=$(this);if(options.events){$(group).unbind().click(function(){var obj=$(this);if(!$.Lightbox.init($(obj)[0],group)){return false}
if(!$.Lightbox.start()){return false}
return false});$(group).addClass('lightbox-enabled')}
if(options.start){var obj=$(this);if(!$.Lightbox.init($(obj)[0],group)){return this}
if(!$.Lightbox.start()){return this}}
return this};$.extend($.LightboxClass.prototype,{images:{list:[],image:false,prev: function(image){if(typeof image==='undefined'){image=this.active();if(!image){return image}}
if(this.first(image)){return false}
return this.get(image.index-1)},next: function(image){if(typeof image==='undefined'){image=this.active();if(!image){return image}}
if(this.last(image)){return false}
return this.get(image.index+1)},first: function(image){if(typeof image==='undefined'){return this.get(0)}
return image.index===0},last: function(image){if(typeof image==='undefined'){return this.get(this.size()-1)}
return image.index===this.size()-1},single: function(){return this.size()===1},size: function(){return this.list.length},empty: function(){return this.size()===0},clear: function(){this.list=[];this.image=false},active: function(image){if(typeof image==='undefined'){return this.image}
if(image!==false){image=this.get(image);if(!image){return image}}
this.image=image;return true},add: function(obj){if(obj[0]){for(var i=0;i<obj.length;i++){this.add(obj[i])}
return true}
var image=this.create(obj);if(!image){return image}
image.index=this.size();this.list.push(image);return true},create: function(obj){var image={src:'',title:'Untitled',description:'',name:'',index:-1,color:null,width:null,height:null,image:true};if(obj.image){image.src=obj.src||image.src;image.title=obj.title||image.title;image.description=obj.description||image.description;image.name=obj.name||image.name;image.color=obj.color||image.color;image.width=obj.width||image.width;image.height=obj.height||image.height;image.index=obj.index||image.index}
else if(obj.tagName){obj=$(obj);if(obj.attr('src')||obj.attr('href')){image.src=obj.attr('src')||obj.attr('href');image.title=obj.attr('title')||obj.attr('alt')||image.title;image.name=obj.attr('name')||'';image.color=obj.css('backgroundColor');var s=image.title.indexOf(': ');if(s>0){image.description=image.title.substring(s+2)||image.description;image.title=image.title.substring(0,s)||image.title}}
else{image=false}}
else{image=false}
if(!image){$.log('ERROR','We dont know what we have:',obj);return false}
return image},get: function(image){if(typeof image==='undefined'||image===null){return this.active()}
else
if(typeof image==='number'){image=this.list[image]||false}
else{image=this.create(image);if(!image){return false}
var f=false;for(var i=0;i<this.size();i++){var c=this.list[i];if(c.src===image.src&&c.title===image.title&&c.description===image.description){f=c}}
image=f}
if(!image){$.log('ERROR','The desired image doesn\'t exist: ',image,this.list);return false}
return image},debug: function(){return $.Lightbox.debug(arguments)}},constructed:false,src:null,baseurl:null,files:{js:{lightbox:'js/jquery.lightbox.js',colorBlend:'js/jquery.color.js'},css:{lightbox:'css/jquery.lightbox.css'},images:{prev:'images/prev.gif',next:'images/next.gif',blank:'images/blank.gif',loading:'images/loading.gif'}},text:{image:'Image',of:'of',close:'Close X',closeInfo:'You can also click anywhere outside the image to close.',download:'Direct link to download the image.',help:{close:'Click to close',interact:'Hover to interact'},about:{text:'jQuery Lightbox Plugin (balupton edition)',title:'Licenced under the GNU Affero General Public License.',link:'http://jquery.com/plugins/project/jquerylightbox_bal'}},keys:{close:'c',prev:'p',next:'n'},handlers:{show:null},opacity:0.9,padding:null,speed:400,rel:'lightbox',auto_relify:true,auto_scroll:'follow',auto_resize:true,ie6:null,ie6_support:true,ie6_upgrade:true,colorBlend:null,download_link:true,show_linkback:true,show_info:'auto',show_extended_info:'auto',options:['auto_scroll','auto_resize','download_link','show_info','show_extended_info','ie6_support','ie6_upgrade','colorBlend','baseurl','files','text','show_linkback','keys','opacity','padding','speed','rel','auto_relify'],construct: function(options){var initial=typeof this.constructed==='undefined'||this.constructed===false;this.constructed=true;var domReady=initial;options=$.extend({},options);if(initial&&(typeof options.files==='undefined')){this.src=$('script[src*='+this.files.js.lightbox+']:first').attr('src');if(!this.src){domReady=false}
else{this.baseurl=this.src.substring(0,this.src.indexOf(this.files.js.lightbox));var me=this;$.each(this.files, function(group,val){$.each(this, function(file,val){me.files[group][file]=me.baseurl+val})});delete me;options=$.extend(options,$.params_to_json(this.src))}}
else
if(typeof options.files==='object'){var me=this;$.each(options.files, function(group,val){$.each(this, function(file,val){this[file]=me.baseurl+val})});delete me}
else{domReady=false}
for(i in this.options){var name=this.options[i];if((typeof options[name]==='object')&&(typeof this[name]==='object')){this[name]=$.extend(this[name],options[name])}
else if(typeof options[name]!=='undefined'){this[name]=options[name]}}
if(initial&&navigator.userAgent.indexOf('MSIE 6')>=0){this.ie6=true}
else{this.ie6=false}
if(domReady||typeof options.download_link!=='undefined'||typeof options.colorBlend!=='undefined'||typeof options.files==='object'||typeof options.text==='object'||typeof options.show_linkback!=='undefined'||typeof options.scroll_with!=='undefined'){$(function(){$.Lightbox.domReady()})}
return true},domReady: function(){var bodyEl=document.getElementsByTagName($.browser.safari?'head':'body')[0];var stylesheets=this.files.css;var scripts=this.files.js;if(this.ie6&&this.ie6_upgrade){scripts.ie6='http://www.savethedevelopers.org/say.no.to.ie.6.js'}
if(this.colorBlend===true&&typeof $.colorBlend==='undefined'){this.colorBlend=true}
else{this.colorBlend=typeof $.colorBlend!=='undefined';delete scripts.colorBlend}
for(stylesheet in stylesheets){var linkEl=document.createElement('link');linkEl.type='text/css';linkEl.rel='stylesheet';linkEl.media='screen';linkEl.href=stylesheets[stylesheet];linkEl.id='lightbox-stylesheet-'+stylesheet.replace(/[^a-zA-Z0-9]/g,'');$('#'+linkEl.id).remove();bodyEl.appendChild(linkEl)}
for(script in scripts){var scriptEl=document.createElement('script');scriptEl.type='text/javascript';scriptEl.src=scripts[script];scriptEl.id='lightbox-script-'+script.replace(/[^a-zA-Z0-9]/g,'');$('#'+scriptEl.id).remove();bodyEl.appendChild(scriptEl)}
delete scripts;delete stylesheets;delete bodyEl;$('#lightbox,#lightbox-overlay').remove();$('body').append('<div id="lightbox-overlay"><div id="lightbox-overlay-text">'+(this.show_linkback?'<p><span id="lightbox-overlay-text-about"><a href="#" title="'+this.text.about.title+'">'+this.text.about.text+'</a></span></p><p>&nbsp;</p>':'')+'<p><span id="lightbox-overlay-text-close">'+this.text.help.close+'</span><br/>&nbsp;<span id="lightbox-overlay-text-interact">'+this.text.help.interact+'</span></p></div></div><div id="lightbox"><div id="lightbox-imageBox"><div id="lightbox-imageContainer"><img id="lightbox-image" /><div id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+this.files.images.loading+'" /></a></div></div></div><div id="lightbox-infoBox"><div id="lightbox-infoContainer"><div id="lightbox-infoHeader"><span id="lightbox-caption">'+(this.download_link?'<a href="#" title="'+this.text.download+'" id="lightbox-caption-title"></a>':'<span id="lightbox-caption-title"></span>')+'<span id="lightbox-caption-seperator"></span><span id="lightbox-caption-description"></span></span></div><div id="lightbox-infoFooter"><span id="lightbox-currentNumber"></span><span id="lightbox-close"><a href="#" id="lightbox-close-button" title="'+this.text.closeInfo+'">'+this.text.close+'</a></span></div><div id="lightbox-infoContainer-clear"></div></div></div></div>');this.resizeBoxes();this.repositionBoxes();$('#lightbox,#lightbox-overlay,#lightbox-overlay-text-interact').hide();if(this.ie6&&this.ie6_support){$('#lightbox-overlay').css({position:'absolute',top:'0px',left:'0px'})}
$.each(this.files.images, function(){var preloader=new Image();preloader.onload=function(){preloader.onload=null;preloader=null};preloader.src=this});$(window).unbind().resize(function(){$.Lightbox.resizeBoxes('resized')});if(this.scroll==='follow'){$(window).scroll(function(){$.Lightbox.repositionBoxes()})}
$('#lightbox-nav-btnPrev').unbind().hover(function(){$(this).css({'background':'url('+$.Lightbox.files.images.prev+') left 45% no-repeat'})},function(){$(this).css({'background':'transparent url('+$.Lightbox.files.images.blank+') no-repeat'})}).click(function(){$.Lightbox.showImage($.Lightbox.images.prev());return false});$('#lightbox-nav-btnNext').unbind().hover(function(){$(this).css({'background':'url('+$.Lightbox.files.images.next+') right 45% no-repeat'})},function(){$(this).css({'background':'transparent url('+$.Lightbox.files.images.blank+') no-repeat'})}).click(function(){$.Lightbox.showImage($.Lightbox.images.next());return false});if(this.show_linkback){$('#lightbox-overlay-text-about a').click(function(){window.open($.Lightbox.text.about.link);return false})}
$('#lightbox-overlay-text-close').unbind().hover(
function(){$('#lightbox-overlay-text-interact').fadeIn()},
function(){$('#lightbox-overlay-text-interact').fadeOut()});$('#lightbox-caption-title').click(function(e){window.location=$(e.target).attr('href');return false});$('#lightbox-overlay, #lightbox, #lightbox-loading-link, #lightbox-btnClose').unbind().click(function(){$.Lightbox.finish();return false});if(this.auto_relify){this.relify()}
return true},relify: function(){var groups={};var groups_n=0;var orig_rel=this.rel;$.each($('[@rel*='+orig_rel+']'), function(index,obj){var rel=$(obj).attr('rel');if(rel===orig_rel){rel=groups_n}
if(typeof groups[rel]==='undefined'){groups[rel]=[];groups_n++}
groups[rel].push(obj)});$.each(groups, function(index,group){$(group).lightbox()});return true},init: function(image,images){if(typeof images==='undefined'){images=image;image=0}
this.images.clear();if(!this.images.add(images)){return false}
if(this.images.empty()){$.log('WARNING','Lightbox started, but no images: ',image,images);return false}
if(!this.images.active(image)){return false}
return true},start: function(){this.visible=true;if(this.scroll==='disable'){$(document.body).css('overflow','hidden')}
$('embed, object, select').css('visibility','hidden');this.resizeBoxes('general');this.repositionBoxes({'speed':0});$('#lightbox-infoFooter').hide();$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-infoBox').hide();$('#lightbox-overlay').css('opacity',this.opacity).fadeIn(400, function(){$('#lightbox').fadeIn(300);if(!$.Lightbox.showImage($.Lightbox.images.active())){$.Lightbox.finish();return false}});return true},finish: function(){$('#lightbox').hide();$('#lightbox-overlay').fadeOut(function(){$('#lightbox-overlay').hide()});$('embed, object, select').css({'visibility':'visible'});this.images.active(false);if(this.scroll==='disable'){$(document.body).css('overflow','visible')}
this.visible=false},resizeBoxes: function(type){if(type!=='transition'){var $body=$(this.ie6?document.body:document);$('#lightbox-overlay').css({width:$body.width(),height:$body.height()});delete $body}
switch(type){case 'general':return true;break;case 'resized':if(this.auto_resize===false){this.repositionBoxes({'nHeight':nHeight,'speed':this.speed});return true}
case 'transition':default:break}
var image=this.images.active();if(!image||!image.width||!this.visible){$.log('WARNING','A resize occured while no image or no lightbox...');return false}
var iWidth=image.width;var iHeight=image.height;var wWidth=$(window).width();var wHeight=$(window).height();if(this.auto_resize!==false){var maxWidth=Math.floor(wWidth*(4/5));var maxHeight=Math.floor(wHeight*(4/5));var resizeRatio;while(iWidth>maxWidth||iHeight>maxHeight){if(iWidth>maxWidth){resizeRatio=maxWidth/iWidth;iWidth=maxWidth;iHeight=Math.floor(iHeight*resizeRatio)}
if(iHeight>maxHeight){resizeRatio=maxHeight/iHeight;iHeight=maxHeight;iWidth=Math.floor(iWidth*resizeRatio)}}}
var cWidth=$('#lightbox-imageBox').width();var cHeight=$('#lightbox-imageBox').height();var nWidth=(iWidth+(this.padding * 2));var nHeight=(iHeight+(this.padding * 2));var dWidth=cWidth-nWidth;var dHeight=cHeight-nHeight;$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css('height',nHeight);$('#lightbox-infoBox').css('width',nWidth);if(type==='transition'){if(dWidth===0&&dHeight===0){this.pause(this.speed/3);this.showImage(null,3)}
else{$('#lightbox-image').width(iWidth).height(iHeight);$('#lightbox-imageBox').animate({width:nWidth,height:nHeight},this.speed, function(){$.Lightbox.showImage(null,3)})}}
else{$('#lightbox-image').animate({width:iWidth,height:iHeight},this.speed);$('#lightbox-imageBox').animate({width:nWidth,height:nHeight},this.speed)}
this.repositionBoxes({'nHeight':nHeight,'speed':this.speed});return true},repositioning:false,reposition_failsafe:false,repositionBoxes: function(options){if(this.repositioning){this.reposition_failsafe=true;return null}
this.repositioning=true;options=$.extend({},options);options.callback=options.callback||null;options.speed=options.speed||'slow';var pageScroll=this.getPageScroll();var nHeight=options.nHeight||parseInt($('#lightbox').height(),10);var nTop=pageScroll.yScroll+($(window).height()-nHeight)/2.5;var nLeft=pageScroll.xScroll;var css={left:nLeft,top:nTop};if(options.speed){$('#lightbox').animate(css,'slow', function(){if($.Lightbox.reposition_failsafe){$.Lightbox.repositioning=$.Lightbox.reposition_failsafe=false;$.Lightbox.repositionBoxes(options)}
else{$.Lightbox.repositioning=false;if(options.callback){options.callback()}}})}
else{$('#lightbox').css(css);if(this.reposition_failsafe){this.repositioning=this.reposition_failsafe=false;this.repositionBoxes(options)}
else{this.repositioning=false}}
return true},visible:false,showImage: function(image,step){image=this.images.get(image);if(!image){return image}
step=step||1;var skipped_step_1=step>1&&this.images.active().src!==image.src;var skipped_step_2=step>2&&$('#lightbox-image').attr('src')!==image.src;if(skipped_step_1||skipped_step_2){$.log('We wanted to skip a few steps: ',image,step,skipped_step_1,skipped_step_2);step=1}
switch(step){case 1:this.KeyboardNav_Disable();$('#lightbox-loading').show();$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-infoBox').hide();$('#lightbox-imageBox').unbind();if(!this.images.active(image)){return false}
if(image.width&&image.height){this.showImage(null,2)}
else{var preloader=new Image();preloader.onload=function(){image.width=preloader.width;image.height=preloader.height;$.Lightbox.showImage(null,2);preloader.onload=null;preloader=null};preloader.src=image.src}
break;case 2:$('#lightbox-image').attr('src',image.src);if(typeof this.padding==='undefined'||this.padding===null||isNaN(this.padding)){this.padding=parseInt($('#lightbox-imageContainer').css('padding-left'),10)||parseInt($('#lightbox-imageContainer').css('padding'),10)||0}
if(this.colorBlend){$('#lightbox-overlay').animate({'backgroundColor':image.color},this.speed*2);$('#lightbox-imageBox').css('borderColor',image.color)}
this.resizeBoxes('transition');break;case 3:$('#lightbox-loading').hide();$('#lightbox-image').fadeIn(this.speed*1.5, function(){$.Lightbox.showImage(null,4)});this.preloadNeighbours();if(this.handlers.show!==null){this.handlers.show(image)}
break;case 4:var $title=$('#lightbox-caption-title').html(image.title||'Untitled');if(this.download_link){$title.attr('href',this.download_link?image.src:'')}
delete $title;$('#lightbox-caption-seperator').html(image.description?': ':'');$('#lightbox-caption-description').html(image.description||'&nbsp;');if(this.images.size()>1){$('#lightbox-currentNumber').html(this.text.image+'&nbsp;'+(image.index+1)+'&nbsp;'+this.text.of+'&nbsp;'+this.images.size())} else{$('#lightbox-currentNumber').html('&nbsp;')}
$('#lightbox-imageBox').unbind('mouseover').mouseover(function(){$('#lightbox-infoBox').slideDown('fast')});$('#lightbox-infoBox').unbind('mouseover').mouseover(function(){$('#lightbox-infoFooter').slideDown('fast')});if(this.show_extended_info===true){$('#lightbox-imageBox').trigger('mouseover');$('#lightbox-infoBox').trigger('mouseover')}
else if(this.show_info===true){$('#lightbox-imageBox').trigger('mouseover')}
$('#lightbox-nav-btnPrev, #lightbox-nav-btnNext').css({'background':'transparent url('+this.files.images.blank+') no-repeat'});if(!this.images.first(image)){$('#lightbox-nav-btnPrev').show()}
if(!this.images.last(image)){$('#lightbox-nav-btnNext').show()}
$('#lightbox-nav').show();this.KeyboardNav_Enable();break;default:$.log('ERROR','Don\'t know what to do: ',image,step);return this.showImage(image,1)}
return true},preloadNeighbours: function(){if(this.images.single()||this.images.empty()){return true}
var image=this.images.active();if(!image){return image}
var prev=this.images.prev(image);var objNext;if(prev){objNext=new Image();objNext.src=prev.src}
var next=this.images.next(image);if(next){objNext=new Image();objNext.src=next.src}},KeyboardNav_Enable: function(){$(document).keydown(function(objEvent){$.Lightbox.KeyboardNav_Action(objEvent)})},KeyboardNav_Disable: function(){$(document).unbind()},KeyboardNav_Action: function(objEvent){objEvent=objEvent||window.event;var keycode=objEvent.keyCode;var escapeKey=objEvent.DOM_VK_ESCAPE||27;var key=String.fromCharCode(keycode).toLowerCase();if(key===this.keys.close||keycode===escapeKey){return $.Lightbox.finish()}
if(key===this.keys.prev||keycode===37){return $.Lightbox.showImage($.Lightbox.images.prev())}
if(key===this.keys.next||keycode===39){return $.Lightbox.showImage($.Lightbox.images.next())}
return true},getPageScroll: function(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset} else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft} else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft}
var arrayPageScroll={'xScroll':xScroll,'yScroll':yScroll};return arrayPageScroll},pause: function(ms){var date=new Date();var curDate=null;do{curDate=new Date()}
while(curDate-date<ms)}});if(typeof $.Lightbox==='undefined'){$.Lightbox=new $.LightboxClass()}})(jQuery);

/* http://z3ext.net/@@/jquery.multifile.js */
;if(window.jQuery)(function($){$.fn.MultiFile=function(options){if(this.length==0) return this;if(typeof arguments[0]=='string'){if(this.length>1){var args=arguments;return this.each(function(){$.fn.MultiFile.apply($(this),args)})};$.fn.MultiFile[arguments[0]].apply(this,$.makeArray(arguments).slice(1)||[]);return this};var options=$.extend({},$.fn.MultiFile.options,options||{});$('form').not('MultiFile-intercepted').addClass('MultiFile-intercepted').submit($.fn.MultiFile.disableEmpty);if($.fn.MultiFile.options.autoIntercept){$.fn.MultiFile.intercept($.fn.MultiFile.options.autoIntercept);$.fn.MultiFile.options.autoIntercept=null};this.not('.MultiFile-applied').addClass('MultiFile-applied').each(function(){window.MultiFile=(window.MultiFile||0)+1;var group_count=window.MultiFile;var MultiFile={e:this,E:$(this),clone:$(this).clone()};if(typeof options=='number') options={max:options};var o=$.extend({},$.fn.MultiFile.options,options||{},($.metadata?MultiFile.E.metadata():($.meta?MultiFile.E.data():null))||{},{});if(!(o.max>0)){o.max=MultiFile.E.attr('maxlength');if(!(o.max>0)){o.max=(String(MultiFile.e.className.match(/\b(max|limit)\-([0-9]+)\b/gi)||['']).match(/[0-9]+/gi)||[''])[0];if(!(o.max>0)) o.max=-1;else o.max=String(o.max).match(/[0-9]+/gi)[0]}};o.max=new Number(o.max);o.accept=o.accept||MultiFile.E.attr('accept')||'';if(!o.accept){o.accept=(MultiFile.e.className.match(/\b(accept\-[\w\|]+)\b/gi))||'';o.accept=new String(o.accept).replace(/^(accept|ext)\-/i,'')};$.extend(MultiFile,o||{});MultiFile.STRING=$.extend({},$.fn.MultiFile.options.STRING,MultiFile.STRING);$.extend(MultiFile,{n:0,slaves:[],files:[],instanceKey:MultiFile.e.id||'MultiFile'+String(group_count),generateID: function(z){return MultiFile.instanceKey+(z>0?'_F'+String(z):'')},trigger: function(event,element){var handler=MultiFile[event],value=$(element).attr('value');if(handler){var returnValue=handler(element,value,MultiFile);if(returnValue!=null) return returnValue}
return true}});if(String(MultiFile.accept).length>1){MultiFile.accept=MultiFile.accept.replace(/\W+/g,'|').replace(/^\W|\W$/g,'');MultiFile.rxAccept=new RegExp('\\.('+(MultiFile.accept?MultiFile.accept:'')+')$','gi')};MultiFile.wrapID=MultiFile.instanceKey+'_wrap';MultiFile.E.wrap('<div class="MultiFile-wrap" id="'+MultiFile.wrapID+'"></div>');MultiFile.wrapper=$('#'+MultiFile.wrapID+'');MultiFile.e.name=MultiFile.e.name||'file'+group_count+'[]';if(!MultiFile.list){MultiFile.wrapper.append('<div class="MultiFile-list" id="'+MultiFile.wrapID+'_list"></div>');MultiFile.list=$('#'+MultiFile.wrapID+'_list')};MultiFile.list=$(MultiFile.list);MultiFile.addSlave=function(slave,slave_count){MultiFile.n++;slave.MultiFile=MultiFile;if(slave_count>0) slave.id=slave.name='';if(slave_count>0) slave.id=MultiFile.generateID(slave_count);slave.name=String(MultiFile.namePattern.replace(/\$name/gi,$(MultiFile.clone).attr('name')).replace(/\$id/gi,$(MultiFile.clone).attr('id')).replace(/\$g/gi,group_count).replace(/\$i/gi,slave_count));if((MultiFile.max>0)&&((MultiFile.n-1)>(MultiFile.max)))
slave.disabled=true;MultiFile.current=MultiFile.slaves[slave_count]=slave;slave=$(slave);slave.val('').attr('value','')[0].value='';slave.addClass('MultiFile-applied');slave.change(function(){$(this).blur();if(!MultiFile.trigger('onFileSelect',this,MultiFile)) return false;var ERROR='',v=String(this.value||'');if(MultiFile.accept&&v&&!v.match(MultiFile.rxAccept))
ERROR=MultiFile.STRING.denied.replace('$ext',String(v.match(/\.\w{1,4}$/gi)));for(var f in MultiFile.slaves)
if(MultiFile.slaves[f]&&MultiFile.slaves[f]!=this)
if(MultiFile.slaves[f].value==v)
ERROR=MultiFile.STRING.duplicate.replace('$file',v.match(/[^\/\\]+$/gi));var newEle=$(MultiFile.clone).clone();newEle.addClass('MultiFile');if(ERROR!=''){MultiFile.error(ERROR);MultiFile.n--;MultiFile.addSlave(newEle[0],slave_count);slave.parent().prepend(newEle);slave.remove();return false};$(this).css({position:'absolute',top:'-3000px'});slave.after(newEle);MultiFile.addToList(this,slave_count);MultiFile.addSlave(newEle[0],slave_count+1);if(!MultiFile.trigger('afterFileSelect',this,MultiFile)) return false});$(slave).data('MultiFile',MultiFile)};MultiFile.addToList=function(slave,slave_count){if(!MultiFile.trigger('onFileAppend',slave,MultiFile)) return false;var
r=$('<div class="MultiFile-label"></div>'),v=String(slave.value||''),a=$('<span class="MultiFile-title" title="'+MultiFile.STRING.selected.replace('$file',v)+'">'+MultiFile.STRING.file.replace('$file',v.match(/[^\/\\]+$/gi)[0])+'</span>'),b=$('<a class="MultiFile-remove" href="#'+MultiFile.wrapID+'">'+MultiFile.STRING.remove+'</a>');MultiFile.list.append(r.append(b,' ',a));b.click(function(){if(!MultiFile.trigger('onFileRemove',slave,MultiFile)) return false;MultiFile.n--;MultiFile.current.disabled=false;MultiFile.slaves[slave_count]=null;$(slave).remove();$(this).parent().remove();$(MultiFile.current).css({position:'',top:''});$(MultiFile.current).reset().val('').attr('value','')[0].value='';if(!MultiFile.trigger('afterFileRemove',slave,MultiFile)) return false;return false});if(!MultiFile.trigger('afterFileAppend',slave,MultiFile)) return false};if(!MultiFile.MultiFile) MultiFile.addSlave(MultiFile.e,0);MultiFile.n++;MultiFile.E.data('MultiFile',MultiFile)})};$.extend($.fn.MultiFile,{reset: function(){var settings=$(this).data('MultiFile');if(settings) settings.list.find('a.MultiFile-remove').click();return $(this)},disableEmpty: function(klass){klass=(typeof(klass)=='string'?klass:'')||'mfD';var o=[];$('input:file.MultiFile').each(function(){if($(this).val()=='') o[o.length]=this});return $(o).each(function(){this.disabled=true}).addClass(klass)},reEnableEmpty: function(klass){klass=(typeof(klass)=='string'?klass:'')||'mfD';return $('input:file.'+klass).removeClass(klass).each(function(){this.disabled=false})},intercepted:{},intercept: function(methods,context,args){var method,value;args=args||[];if(args.constructor.toString().indexOf("Array")<0) args=[args];if(typeof(methods)=='function'){$.fn.MultiFile.disableEmpty();value=methods.apply(context||window,args);setTimeout(function(){$.fn.MultiFile.reEnableEmpty()},1000);return value};if(methods.constructor.toString().indexOf("Array")<0) methods=[methods];for(var i=0;i<methods.length;i++){method=methods[i]+'';if(method)(function(method){$.fn.MultiFile.intercepted[method]=$.fn[method]|| function(){};$.fn[method]=function(){$.fn.MultiFile.disableEmpty();value=$.fn.MultiFile.intercepted[method].apply(this,arguments);setTimeout(function(){$.fn.MultiFile.reEnableEmpty()},1000);return value}})(method)}}});$.fn.MultiFile.options={accept:'',max:-1,namePattern:'$name',STRING:{remove:'x',denied:'You cannot select a $ext file.\nTry again...',file:'$file',selected:'File selected: $file',duplicate:'This file has already been selected:\n$file'},autoIntercept:['submit','ajaxSubmit','ajaxForm','validate'],error: function(s){alert(s)}};$.fn.reset=function(){return this.each(function(){try{this.reset()}catch(e){}})};$(function(){$("input[type=file].multi").MultiFile()})})(jQuery);

/* http://z3ext.net/@@/jquery-media/swfobject.js */
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

/* http://z3ext.net/@@/jquery-media/jquery.metadata.js */
/*
 * Metadata - jQuery plugin for parsing metadata from elements
 *
 * Copyright (c) 2006 John Resig, Yehuda Katz, J�örn Zaefferer, Paul McLanahan
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.metadata.js 3640 2007-10-11 18:34:38Z pmclanahan $
 *
 */

/**
 * Sets the type of metadata to use. Metadata is encoded in JSON, and each property
 * in the JSON will become a property of the element itself.
 *
 * There are four supported types of metadata storage:
 *
 *   attr:  Inside an attribute. The name parameter indicates *which* attribute.
 *          
 *   class: Inside the class attribute, wrapped in curly braces: { }
 *   
 *   elem:  Inside a child element (e.g. a script tag). The
 *          name parameter indicates *which* element.
 *   html5: Values are stored in data-* attributes.
 *          
 * The metadata for an element is loaded the first time the element is accessed via jQuery.
 *
 * As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
 * matched by expr, then redefine the metadata type and run another $(expr) for other elements.
 * 
 * @name $.metadata.setType
 *
 * @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
 * @before $.metadata.setType("class")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from the class attribute
 * 
 * @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
 * @before $.metadata.setType("attr", "data")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from a "data" attribute
 * 
 * @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
 * @before $.metadata.setType("elem", "script")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from a nested script element
 * 
 * @example <p id="one" class="some_class" data-item_id="1" data-item_label="Label">This is a p</p>
 * @before $.metadata.setType("html5")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from a series of data-* attributes
 *
 * @param String type The encoding type
 * @param String name The name of the attribute to be used to get metadata (optional)
 * @cat Plugins/Metadata
 * @descr Sets the type of encoding to be used when loading metadata for the first time
 * @type undefined
 * @see metadata()
 */

(function($) {

$.extend({
  metadata : {
    defaults : {
      type: 'class',
      name: 'metadata',
      cre: /({.*})/,
      single: 'metadata'
    },
    setType: function( type, name ){
      this.defaults.type = type;
      this.defaults.name = name;
    },
    get: function( elem, opts ){
      var settings = $.extend({},this.defaults,opts);
      // check for empty string in single property
      if ( !settings.single.length ) settings.single = 'metadata';
      
      var data = $.data(elem, settings.single);
      // returned cached data if it already exists
      if ( data ) return data;
      
      data = "{}";
      
      var getData = function(data) {
        if(typeof data != "string") return data;
        
        if( data.indexOf('{') < 0 ) {
          data = eval("(" + data + ")");
        }
      }
      
      var getObject = function(data) {
        if(typeof data != "string") return data;
        
        data = eval("(" + data + ")");
        return data;
      }
      
      if ( settings.type == "html5" ) {
        var object = {};
        $( elem.attributes ).each(function() {
          var name = this.nodeName;
          if(name.match(/^data-/)) name = name.replace(/^data-/, '');
          else return true;
          object[name] = getObject(this.nodeValue);
        });
      } else {
        if ( settings.type == "class" ) {
          var m = settings.cre.exec( elem.className );
          if ( m )
            data = m[1];
        } else if ( settings.type == "elem" ) {
          if( !elem.getElementsByTagName ) return;
          var e = elem.getElementsByTagName(settings.name);
          if ( e.length )
            data = $.trim(e[0].innerHTML);
        } else if ( elem.getAttribute != undefined ) {
          var attr = elem.getAttribute( settings.name );
          if ( attr )
            data = attr;
        }
        object = getObject(data.indexOf("{") < 0 ? "{" + data + "}" : data);
      }
      
      $.data( elem, settings.single, object );
      return object;
    }
  }
});

/**
 * Returns the metadata object for the first member of the jQuery object.
 *
 * @name metadata
 * @descr Returns element's metadata object
 * @param Object opts An object contianing settings to override the defaults
 * @type jQuery
 * @cat Plugins/Metadata
 */
$.fn.metadata = function( opts ){
  return $.metadata.get( this[0], opts );
};

})(jQuery);

/* http://z3ext.net/@@/jquery-media/jquery.media.js */
/*
 * jQuery Media Plugin for converting elements into rich media content.
 *
 * Examples and documentation at: http://malsup.com/jquery/media/
 * Copyright (c) 2007-2008 M. Alsup
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * @author: M. Alsup
 * @version: 0.92 (24-SEP-2009)
 * @requires jQuery v1.1.2 or later
 * $Id: jquery.media.js 2460 2007-07-23 02:53:15Z malsup $
 *
 * Supported Media Players:
 *	- Flash
 *	- Quicktime
 *	- Real Player
 *	- Silverlight
 *	- Windows Media Player
 *	- iframe
 *
 * Supported Media Formats:
 *	 Any types supported by the above players, such as:
 *	 Video: asf, avi, flv, mov, mpg, mpeg, mp4, qt, smil, swf, wmv, 3g2, 3gp
 *	 Audio: aif, aac, au, gsm, mid, midi, mov, mp3, m4a, snd, rm, wav, wma
 *	 Other: bmp, html, pdf, psd, qif, qtif, qti, tif, tiff, xaml
 *
 * Thanks to Mark Hicken and Brent Pedersen for helping me debug this on the Mac!
 * Thanks to Dan Rossi for numerous bug reports and code bits!
 * Thanks to Skye Giordano for several great suggestions!
 * Thanks to Richard Connamacher for excellent improvements to the non-IE behavior!
 */
;(function($) {

/**
 * Chainable method for converting elements into rich media.
 *
 * @param options
 * @param callback fn invoked for each matched element before conversion
 * @param callback fn invoked for each matched element after conversion
 */
$.fn.media = function(options, f1, f2) {
	if (options == 'undo') {
		return this.each(function() {
			var $this = $(this);
			var html = $this.data('media.origHTML');
			if (html)
				$this.replaceWith(html);
		});
	}
	
	return this.each(function() {
		if (typeof options == 'function') {
			f2 = f1;
			f1 = options;
			options = {};
		}
		var o = getSettings(this, options);
		// pre-conversion callback, passes original element and fully populated options
		if (typeof f1 == 'function') f1(this, o);

		var r = getTypesRegExp();
		var m = r.exec(o.src.toLowerCase()) || [''];

		o.type ? m[0] = o.type : m.shift();
		for (var i=0; i < m.length; i++) {
			fn = m[i].toLowerCase();
			if (isDigit(fn[0])) fn = 'fn' + fn; // fns can't begin with numbers
			if (!$.fn.media[fn])
				continue;  // unrecognized media type
			// normalize autoplay settings
			var player = $.fn.media[fn+'_player'];
			if (!o.params) o.params = {};
			if (player) {
				var num = player.autoplayAttr == 'autostart';
				o.params[player.autoplayAttr || 'autoplay'] = num ? (o.autoplay ? 1 : 0) : o.autoplay ? true : false;
			}
			var $div = $.fn.media[fn](this, o);

			$div.css('backgroundColor', o.bgColor).width(o.width);
			
			if (o.canUndo) {
				var $temp = $('<div></div>').append(this);
				$div.data('media.origHTML', $temp.html()); // store original markup
			}
			
			// post-conversion callback, passes original element, new div element and fully populated options
			if (typeof f2 == 'function') f2(this, $div[0], o, player.name);
			break;
		}
	});
};

/**
 * Non-chainable method for adding or changing file format / player mapping
 * @name mapFormat
 * @param String format File format extension (ie: mov, wav, mp3)
 * @param String player Player name to use for the format (one of: flash, quicktime, realplayer, winmedia, silverlight or iframe
 */
$.fn.media.mapFormat = function(format, player) {
	if (!format || !player || !$.fn.media.defaults.players[player]) return; // invalid
	format = format.toLowerCase();
	if (isDigit(format[0])) format = 'fn' + format;
	$.fn.media[format] = $.fn.media[player];
	$.fn.media[format+'_player'] = $.fn.media.defaults.players[player];
};

// global defautls; override as needed
$.fn.media.defaults = {
	standards:  false,      // use object tags only (no embeds for non-IE browsers)
	canUndo:    true,       // tells plugin to store the original markup so it can be reverted via: $(sel).mediaUndo()
	width:		400,
	height:		400,
	autoplay:	0,		   	// normalized cross-player setting
	bgColor:	'#ffffff', 	// background color
	params:		{ wmode: 'transparent'},	// added to object element as param elements; added to embed element as attrs
	attrs:		{},			// added to object and embed elements as attrs
	flvKeyName: 'file', 	// key used for object src param (thanks to Andrea Ercolino)
	flashvars:	{},			// added to flash content as flashvars param/attr
	flashVersion:	'7',	// required flash version
	expressInstaller: null,	// src for express installer

	// default flash video and mp3 player (@see: http://jeroenwijering.com/?item=Flash_Media_Player)
	flvPlayer:	 'mediaplayer.swf',
	mp3Player:	 'mediaplayer.swf',

	// @see http://msdn2.microsoft.com/en-us/library/bb412401.aspx
	silverlight: {
		inplaceInstallPrompt: 'true', // display in-place install prompt?
		isWindowless:		  'true', // windowless mode (false for wrapping markup)
		framerate:			  '24',	  // maximum framerate
		version:			  '0.9',  // Silverlight version
		onError:			  null,	  // onError callback
		onLoad:			      null,   // onLoad callback
		initParams:			  null,	  // object init params
		userContext:		  null	  // callback arg passed to the load callback
	}
};

// Media Players; think twice before overriding
$.fn.media.defaults.players = {
	flash: {
		name:		 'flash',
		title:		 'Flash',
		types:		 'flv,mp3,swf',
		mimetype:	 'application/x-shockwave-flash',
		pluginspage: 'http://www.adobe.com/go/getflashplayer',
		ieAttrs: {
			classid:  'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
			type:	  'application/x-oleobject',
			codebase: 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + $.fn.media.defaults.flashVersion
		}
	},
	quicktime: {
		name:		 'quicktime',
		title:		 'QuickTime',
		mimetype:	 'video/quicktime',
		pluginspage: 'http://www.apple.com/quicktime/download/',
		types:		 'aif,aiff,aac,au,bmp,gsm,mov,mid,midi,mpg,mpeg,mp4,m4a,psd,qt,qtif,qif,qti,snd,tif,tiff,wav,3g2,3gp',
		ieAttrs: {
			classid:  'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
			codebase: 'http://www.apple.com/qtactivex/qtplugin.cab'
		}
	},
	realplayer: {
		name:		  'real',
		title:		  'RealPlayer',
		types:		  'ra,ram,rm,rpm,rv,smi,smil',
		mimetype:	  'audio/x-pn-realaudio-plugin',
		pluginspage:  'http://www.real.com/player/',
		autoplayAttr: 'autostart',
		ieAttrs: {
			classid: 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'
		}
	},
	winmedia: {
		name:		  'winmedia',
		title:		  'Windows Media',
		types:		  'asx,asf,avi,wma,wmv',
		mimetype:	  $.browser.mozilla && isFirefoxWMPPluginInstalled() ? 'application/x-ms-wmp' : 'application/x-mplayer2',
		pluginspage:  'http://www.microsoft.com/Windows/MediaPlayer/',
		autoplayAttr: 'autostart',
		oUrl:		  'url',
		ieAttrs: {
			classid:  'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6',
			type:	  'application/x-oleobject'
		}
	},
	// special cases
	iframe: {
		name:  'iframe',
		types: 'html,pdf'
	},
	silverlight: {
		name:  'silverlight',
		types: 'xaml'
	}
};

//
//	everything below here is private
//


// detection script for FF WMP plugin (http://www.therossman.org/experiments/wmp_play.html)
// (hat tip to Mark Ross for this script)
function isFirefoxWMPPluginInstalled() {
	var plugs = navigator.plugins;
	for (i = 0; i < plugs.length; i++) {
		var plugin = plugs[i];
		if (plugin['filename'] == 'np-mswmp.dll')
			return true;
	}
	return false;
}

var counter = 1;

for (var player in $.fn.media.defaults.players) {
	var types = $.fn.media.defaults.players[player].types;
	$.each(types.split(','), function(i,o) {
		if (isDigit(o[0])) o = 'fn' + o;
		$.fn.media[o] = $.fn.media[player] = getGenerator(player);
		$.fn.media[o+'_player'] = $.fn.media.defaults.players[player];
	});
};

function getTypesRegExp() {
	var types = '';
	for (var player in $.fn.media.defaults.players) {
		if (types.length) types += ',';
		types += $.fn.media.defaults.players[player].types;
	};
	return new RegExp('\\.(' + types.replace(/,/ig,'|') + ')\\b');
};

function getGenerator(player) {
	return function(el, options) {
		return generate(el, options, player);
	};
};

function isDigit(c) {
	return '0123456789'.indexOf(c) > -1;
};

// flatten all possible options: global defaults, meta, option obj
function getSettings(el, options) {
	options = options || {};
	var $el = $(el);
	var cls = el.className || '';
	// support metadata plugin (v1.0 and v2.0)
	var meta = $.metadata ? $el.metadata() : $.meta ? $el.data() : {};
	meta = meta || {};
	var w = meta.width	 || parseInt(((cls.match(/w:(\d+)/)||[])[1]||0));
	var h = meta.height || parseInt(((cls.match(/h:(\d+)/)||[])[1]||0));

	if (w) meta.width	= w;
	if (h) meta.height = h;
	if (cls) meta.cls = cls;

	var a = $.fn.media.defaults;
	var b = options;
	var c = meta;

	var p = { params: { bgColor: options.bgColor || $.fn.media.defaults.bgColor } };
	var opts = $.extend({}, a, b, c);
	$.each(['attrs','params','flashvars','silverlight'], function(i,o) {
		opts[o] = $.extend({}, p[o] || {}, a[o] || {}, b[o] || {}, c[o] || {});
	});

	if (typeof opts.caption == 'undefined') opts.caption = $el.text();

	// make sure we have a source!
	opts.src = opts.src || $el.attr('href') || $el.attr('src') || 'unknown';
	return opts;
};

//
//	Flash Player
//

// generate flash using SWFObject library if possible
$.fn.media.swf = function(el, opts) {
	if (!window.SWFObject && !window.swfobject) {
		// roll our own
		if (opts.flashvars) {
			var a = [];
			for (var f in opts.flashvars)
				a.push(f + '=' + opts.flashvars[f]);
			if (!opts.params) opts.params = {};
			opts.params.flashvars = a.join('&');
		}
		return generate(el, opts, 'flash');
	}

	var id = el.id ? (' id="'+el.id+'"') : '';
	var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
	var $div = $('<div' + id + cls + '>');

	// swfobject v2+
	if (window.swfobject) {
		$(el).after($div).appendTo($div);
		if (!el.id) el.id = 'movie_player_' + counter++;

		// replace el with swfobject content
		swfobject.embedSWF(opts.src, el.id, opts.width, opts.height, opts.flashVersion,
			opts.expressInstaller, opts.flashvars, opts.params, opts.attrs);
	}
	// swfobject < v2
	else {
		$(el).after($div).remove();
		var so = new SWFObject(opts.src, 'movie_player_' + counter++, opts.width, opts.height, opts.flashVersion, opts.bgColor);
		if (opts.expressInstaller) so.useExpressInstall(opts.expressInstaller);

		for (var p in opts.params)
			if (p != 'bgColor') so.addParam(p, opts.params[p]);
		for (var f in opts.flashvars)
			so.addVariable(f, opts.flashvars[f]);
		so.write($div[0]);
	}

	if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
	return $div;
};

// map flv and mp3 files to the swf player by default
$.fn.media.flv = $.fn.media.mp3 = function(el, opts) {
	var src = opts.src;
	var player = /\.mp3\b/i.test(src) ? $.fn.media.defaults.mp3Player : $.fn.media.defaults.flvPlayer;
	var key = opts.flvKeyName;
	src = encodeURIComponent(src);
	opts.src = player;
	opts.src = opts.src + '?'+key+'=' + (src);
	var srcObj = {};
	srcObj[key] = src;
	opts.flashvars = $.extend({}, srcObj, opts.flashvars );
	return $.fn.media.swf(el, opts);
};

//
//	Silverlight
//
$.fn.media.xaml = function(el, opts) {
	if (!window.Sys || !window.Sys.Silverlight) {
		if ($.fn.media.xaml.warning) return;
		$.fn.media.xaml.warning = 1;
		alert('You must include the Silverlight.js script.');
		return;
	}

	var props = {
		width: opts.width,
		height: opts.height,
		background: opts.bgColor,
		inplaceInstallPrompt: opts.silverlight.inplaceInstallPrompt,
		isWindowless: opts.silverlight.isWindowless,
		framerate: opts.silverlight.framerate,
		version: opts.silverlight.version
	};
	var events = {
		onError: opts.silverlight.onError,
		onLoad: opts.silverlight.onLoad
	};

	var id1 = el.id ? (' id="'+el.id+'"') : '';
	var id2 = opts.id || 'AG' + counter++;
	// convert element to div
	var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
	var $div = $('<div' + id1 + cls + '>');
	$(el).after($div).remove();

	Sys.Silverlight.createObjectEx({
		source: opts.src,
		initParams: opts.silverlight.initParams,
		userContext: opts.silverlight.userContext,
		id: id2,
		parentElement: $div[0],
		properties: props,
		events: events
	});

	if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
	return $div;
};

//
// generate object/embed markup
//
function generate(el, opts, player) {
	var $el = $(el);
	var o = $.fn.media.defaults.players[player];

	if (player == 'iframe') {
		var o = $('<iframe' + ' width="' + opts.width + '" height="' + opts.height + '" >');
		o.attr('src', opts.src);
		o.css('backgroundColor', o.bgColor);
	}
	else if ($.browser.msie) {
		var a = ['<object width="' + opts.width + '" height="' + opts.height + '" '];
		for (var key in opts.attrs)
			a.push(key + '="'+opts.attrs[key]+'" ');
		for (var key in o.ieAttrs || {}) {
			var v = o.ieAttrs[key];
			if (key == 'codebase' && window.location.protocol == 'https:')
				v = v.replace('http','https');
			a.push(key + '="'+v+'" ');
		}
		a.push('></ob'+'ject'+'>');
		var p = ['<param name="' + (o.oUrl || 'src') +'" value="' + opts.src + '">'];
		for (var key in opts.params)
			p.push('<param name="'+ key +'" value="' + opts.params[key] + '">');
		var o = document.createElement(a.join(''));
		for (var i=0; i < p.length; i++)
			o.appendChild(document.createElement(p[i]));
	}
	else if (o.standards) {
		// Rewritten to be standards compliant by Richard Connamacher
		var a = ['<object type="' + o.mimetype +'" width="' + opts.width + '" height="' + opts.height +'"'];
		if (opts.src) a.push(' data="' + opts.src + '" ');
		a.push('>');
		a.push('<param name="' + (o.oUrl || 'src') +'" value="' + opts.src + '">');
		for (var key in opts.params) {
			if (key == 'wmode' && player != 'flash') // FF3/Quicktime borks on wmode
				continue;
			a.push('<param name="'+ key +'" value="' + opts.params[key] + '">');
		}
		// Alternate HTML
		a.push('<div><p><strong>'+o.title+' Required</strong></p><p>'+o.title+' is required to view this media. <a href="'+o.pluginspage+'">Download Here</a>.</p></div>');
		a.push('</ob'+'ject'+'>');
	}
	 else {
	        var a = ['<embed width="' + opts.width + '" height="' + opts.height + '" style="display:block"'];
	        if (opts.src) a.push(' src="' + opts.src + '" ');
	        for (var key in opts.attrs)
	            a.push(key + '="'+opts.attrs[key]+'" ');
	        for (var key in o.eAttrs || {})
	            a.push(key + '="'+o.eAttrs[key]+'" ');
	        for (var key in opts.params) {
	            if (key == 'wmode' && player != 'flash') // FF3/Quicktime borks on wmode
	            	continue;
	            a.push(key + '="'+opts.params[key]+'" ');
	        }
	        a.push('></em'+'bed'+'>');
	    }	
	// convert element to div
	var id = el.id ? (' id="'+el.id+'"') : '';
	var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
	var $div = $('<div' + id + cls + '>');
	$el.after($div).remove();
	($.browser.msie || player == 'iframe') ? $div.append(o) : $div.html(a.join(''));
	if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
	return $div;
};


})(jQuery);


/* http://z3ext.net/@@/jquery-media/media.js */
$(document).ready(function(){
    var portal_url = document.getElementsByTagName('head')[0].attributes['portal'].value;
    $.fn.media.defaults.flvPlayer =  portal_url + '@@/jquery-media/flowplayer-3.1.3.swf';
    $.fn.media.defaults.mp3Player = portal_url + '@@/jquery-media/player.swf';
    $.fn.media.defaults.bgColor = 'transparent';
    $.fn.media.defaults.types = [];
    for (var i in $.fn.media.defaults.players) {
	$.fn.media.defaults.types = $.fn.media.defaults.types.concat($.fn.media.defaults.players[i].types.split(','))
    };
    $.fn.media.defaults.types.sort();
  
    $('a.z-media').media();
});



