/** 
 * contains jquery plugins:
 * 
 * log
 * 
 * background position
 * browser detect
 * livequery
 * thickbox reloaded
 */
function log(text) {
	if ($.browser.mozilla && console) console.log(text);
}
/**
 * @author Alexander Farkas
 */

(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state == 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
            
           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
			   strg = strg.replace(/center/g,'50%');
               strg = strg.replace(/(\d+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(\d+)(px|\%|em|pt)\s(\d+)(px|\%|em|pt)/);
               return [parseFloat(res[1]),res[2],parseFloat(res[3]),res[4]];
           }
        }
	});
    
})(jQuery);

/**
 * Browser detect
 * @param {Object} $
 */
(function($){$.browserTest=function(a,z){var u='unknown',x='X',m=function(r,h){for(var i=0;i<h.length;i=i+1){r=r.replace(h[i][0],h[i][1]);}return r;},c=function(i,a,b,c){var r={name:m((a.exec(i)||[u,u])[1],b)};r[r.name]=true;r.version=(c.exec(i)||[x,x,x,x])[3];if(r.name.match(/safari/)&&r.version>400){r.version='2.0';}if(r.name==='presto'){r.version=($.browser.version>9.27)?'futhark':'linear_b';}r.versionNumber=parseFloat(r.version,10)||0;r.versionX=(r.version!==x)?(r.version+'').substr(0,1):x;r.className=r.name+r.versionX;return r;};a=(a.match(/Opera|Navigator|Minefield|KHTML|Chrome/)?m(a,[[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/,''],['Chrome Safari','Chrome'],['KHTML','Konqueror'],['Minefield','Firefox'],['Navigator','Netscape']]):a).toLowerCase();$.browser=$.extend((!z)?$.browser:{},c(a,/(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/,[],/(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));$.layout=c(a,/(gecko|konqueror|msie|opera|webkit)/,[['konqueror','khtml'],['msie','trident'],['opera','presto']],/(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);$.os={name:(/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase())||[u])[0].replace('sunos','solaris')};if(!z){$('html').addClass([$.os.name,$.browser.name,$.browser.className,$.layout.name,$.layout.className].join(' '));}};$.browserTest(navigator.userAgent);})(jQuery);

/**
 * LiveQuery
 */

(function($){$.extend($.fn,{livequery:function(type,fn,fn2){var self=this,q;if($.isFunction(type))
fn2=fn,fn=type,type=undefined;$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&type==query.type&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid))
return(q=query)&&false;});q=q||new $.livequery(this.selector,this.context,type,fn,fn2);q.stopped=false;$.livequery.run(q.id);return this;},expire:function(type,fn,fn2){var self=this;if($.isFunction(type))
fn2=fn,fn=type,type=undefined;$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&(!type||type==query.type)&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid)&&!this.stopped)
$.livequery.stop(query.id);});return this;}});$.livequery=function(selector,context,type,fn,fn2){this.selector=selector;this.context=context||document;this.type=type;this.fn=fn;this.fn2=fn2;this.elements=[];this.stopped=false;this.id=$.livequery.queries.push(this)-1;fn.$lqguid=fn.$lqguid||$.livequery.guid++;if(fn2)fn2.$lqguid=fn2.$lqguid||$.livequery.guid++;return this;};$.livequery.prototype={stop:function(){var query=this;if(this.type)
this.elements.unbind(this.type,this.fn);else if(this.fn2)
this.elements.each(function(i,el){query.fn2.apply(el);});this.elements=[];this.stopped=true;},run:function(){if(this.stopped)return;var query=this;var oEls=this.elements,els=$(this.selector,this.context),nEls=els.not(oEls);this.elements=els;if(this.type){nEls.bind(this.type,this.fn);if(oEls.length>0)
$.each(oEls,function(i,el){if($.inArray(el,els)<0)
$.event.remove(el,query.type,query.fn);});}
else{nEls.each(function(){query.fn.apply(this);});if(this.fn2&&oEls.length>0)
$.each(oEls,function(i,el){if($.inArray(el,els)<0)
query.fn2.apply(el);});}}};$.extend($.livequery,{guid:0,queries:[],queue:[],running:false,timeout:null,checkQueue:function(){if($.livequery.running&&$.livequery.queue.length){var length=$.livequery.queue.length;while(length--)
$.livequery.queries[$.livequery.queue.shift()].run();}},pause:function(){$.livequery.running=false;},play:function(){$.livequery.running=true;$.livequery.run();},registerPlugin:function(){$.each(arguments,function(i,n){if(!$.fn[n])return;var old=$.fn[n];$.fn[n]=function(){var r=old.apply(this,arguments);$.livequery.run();return r;}});},run:function(id){if(id!=undefined){if($.inArray(id,$.livequery.queue)<0)
$.livequery.queue.push(id);}
else
$.each($.livequery.queries,function(id){if($.inArray(id,$.livequery.queue)<0)
$.livequery.queue.push(id);});if($.livequery.timeout)clearTimeout($.livequery.timeout);$.livequery.timeout=setTimeout($.livequery.checkQueue,20);},stop:function(id){if(id!=undefined)
$.livequery.queries[id].stop();else
$.each($.livequery.queries,function(id){$.livequery.queries[id].stop();});}});$.livequery.registerPlugin('append','prepend','after','before','wrap','attr','removeAttr','addClass','removeClass','toggleClass','empty','remove');$(function(){$.livequery.play();});var init=$.prototype.init;$.prototype.init=function(a,c){var r=init.apply(this,arguments);if(a&&a.selector)
r.context=a.context,r.selector=a.selector;if(typeof a=='string')
r.context=c||document,r.selector=a;return r;};$.prototype.init.prototype=$.prototype;})(jQuery);


/**
 * Thickbox Reloaded - jQuery plugin
 */

(function($){$.browser.msie6=$.browser.msie&&($.browser.version&&$.browser.version<7||/MSIE 6.0/.test(navigator.userAgent));$.extend({thickbox:new function(){TB_TYPE={AJAX:'ajax',CONFIRM:'confirm',EXTERNAL:'external',IMAGE:'image',INLINE:'inline'};TB_ID={DIM:'tb-dim',LOADING:'tb-loading',MODAL:'tb-modal',TITLE:'tb-title',CLOSE:'tb-close',CONTENT:'tb-content',BROWSE:'tb-browse',NEXT:'tb-next',PREV:'tb-prev'};var dim,loading,modal,content,close;var request;var defaultValues={top:'',left:'',width:300,minWidth:250,height:340,animate:null,i18n:{close:{text:'Close',title:'Close this window'},count:{text:'Image #{image} / #{count}'},next:{text:'Next',title:'Show next image'},prev:{text:'Previous',title:'Show previous image'},confirm:{what:'Are you sure?',confirm:'Yes',cancel:'No'}}};function setup(type,builder){dim=$('#'+TB_ID.DIM);dim=dim.size()&&dim||$('<div id="'+TB_ID.DIM+'">'+($.browser.msie6?'<iframe src="about:blank" frameborder="0"></iframe>':'')+'</div>').appendTo(document.body).hide();$('iframe',dim).bind('focus',hide);loading=$('#'+TB_ID.LOADING);loading=loading.size()&&loading||$('<div id="'+TB_ID.LOADING+'"></div>').appendTo(document.body);modal=$('#'+TB_ID.MODAL);modal=modal.size()&&modal||$('<div id="'+TB_ID.MODAL+'"></div>').append('<b class="tb-tl"></b><b class="tb-tr"></b><b class="tb-br"></b><b class="tb-bl"></b>').appendTo(document.body);modal.attr('class','tb-'+type);content=$('#'+TB_ID.CONTENT);content=content.size()&&content||$('<div id="'+TB_ID.CONTENT+'"></div>').appendTo(modal);close=$('#'+TB_ID.CLOSE);close=close.size()&&close||$('<div id="'+TB_ID.CLOSE+'"><a href="#" title="'+defaultValues.i18n.close.title+'">'+defaultValues.i18n.close.text+'</a></div>').appendTo(modal);$('a',close).bind('click',hide);dim.unbind('click').one('click',hide);if(!dim.is(':visible')){dim.show();}
loading.show();builder();$(document).bind('keydown',keydown).bind('keypress',blockKeys);$(window).bind('scroll',blockScroll);}
function show(width,height,top,left,animate,callback){loading.hide();var css={width:width+'px',height:height+'px'},noUnit=/^\d+$/;if(!top){css['top']='';if(!$.browser.msie6){css['margin-top']=-parseInt(height/2)+'px';}else{dim[0].style.setExpression('height','document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + "px"');loading[0].style.setExpression('marginTop','0 - parseInt(this.offsetHeight / 2) + (document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + "px"');modal[0].style.setExpression('marginTop','0 - parseInt(this.offsetHeight / 2) + (document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + "px"');}}else{css['top']=top+((top+'').match(noUnit)?'px':'');css['margin-top']='';}
if(!left){css['left']='';css['margin-left']=-parseInt(width/2)+'px';}else{css['left']=left+((left+'').match(noUnit)?'px':'');css['margin-left']='';}
animate?modal.css(css).animate(animate.animation,animate.speed):modal.css(css).show();typeof callback=='function'&&callback(modal[0]);}
function hide(callback){if(request){request.abort();request=null;}
loading.hide();modal.hide();dim.hide();content.empty();typeof callback=='function'&&callback();$(document).unbind('keydown',keydown).unbind('keypress',blockKeys);$(window).unbind('scroll',blockScroll);next=previous=function(){};return false;}
function blockKeys(e){var allowed=$('a, button, input, select, textarea',modal);for(var i=0,k=allowed.length;i<k;i++){if(allowed[i]==e.target){return true;}}
return false;}
function blockScroll(){return false;}
var next=function(){},previous=next;function keydown(e){var key=e.which||e.keyCode||-1;switch(key){case 27:hide();break;case 37:previous();break;case 39:next();break;default:blockKeys(e);}}
function buildTitle(title){if(title){content.prepend('<h2 id="'+TB_ID.TITLE+'">'+title+'</h2>');}}
this.defaults=function(override){for(var p in defaultValues.i18n){override.i18n[p]=$.extend(defaultValues.i18n[p],override.i18n[p]);}
defaultValues=$.extend(defaultValues,override);};this.render=function(settings,callback){settings=$.extend({top:defaultValues.top,left:defaultValues.left,width:defaultValues.width,height:defaultValues.height,slideshow:false},settings);return this.each(function(){var $$=$(this),hostname=this.hostname&&this.hostname.replace(/:\d*$/,''),port=parseInt(this.port)||80,hash=this.hash&&this.hash.replace('#','')||'';var isLink=$$.is('a')&&this.href;var isImage=isLink&&this.href.match(/\.(bmp|gif|jpe?g|png)/gi);var isInline=!!hash;var isAjax=hostname==location.hostname&&port==(location.port||80)&&!isInline;var isExternal=isLink&&(hostname!=location.hostname||port!=(location.port||80));var isForm=$$.is('form');var type=isImage&&TB_TYPE.IMAGE||isInline&&TB_TYPE.INLINE||isAjax&&TB_TYPE.AJAX||isExternal&&TB_TYPE.EXTERNAL||isForm&&TB_TYPE.CONFIRM;var builder;switch(type){case TB_TYPE.IMAGE:builder=function(){var title=$$.attr('title')||'',rel=$$.attr('rel');if(rel){var group=$('a[@rel="'+rel+'"]'),size=group.size(),i=group.index($$[0]);var count='<em>'+defaultValues.i18n.count.text.replace(/#\{image\}/,i+1).replace(/#\{count\}/,size)+'</em>';if(size>1){var buildShowFunc=function(el){return function(){modal.hide();content.empty();$(el).trigger('click');return false;};};var nextHtml='<strong id="'+TB_ID.NEXT+'"><a href="#" title="'+defaultValues.i18n.next.title+'">'+defaultValues.i18n.next.text+'</a></strong>';next=buildShowFunc(group[i+1]||group[0]);var previousHtml='<strong id="'+TB_ID.PREV+'"><a href="#" title="'+defaultValues.i18n.prev.title+'">'+defaultValues.i18n.prev.text+'</a></strong>';previous=buildShowFunc(group[i-1]||group[size-1]);}}
var img=new Image();img.onload=function(){img.onload=null;var subtraction=150;var viewportWidth=(self.innerWidth||$.boxModel&&document.documentElement.clientWidth||document.body.clientWidth)-subtraction;var viewportHeight=(self.innerHeight||$.boxModel&&document.documentElement.clientHeight||document.body.clientHeight)-subtraction;var imgWidth=img.width;var imgHeight=img.height;if(imgWidth>viewportWidth){imgHeight=imgHeight*viewportWidth/imgWidth;imgWidth=viewportWidth;if(imgHeight>viewportHeight){imgWidth=imgWidth*viewportHeight/imgHeight;imgHeight=viewportHeight;}}else if(imgHeight>viewportHeight){imgWidth=imgWidth*viewportHeight/imgHeight;imgHeight=viewportHeight;if(imgWidth>viewportWidth){imgHeight=imgHeight*viewportWidth/imgWidth;imgWidth=viewportWidth;}}
imgWidth=parseInt(imgWidth);imgHeight=parseInt(imgHeight);buildTitle(title);$('<img src="'+$$.attr('href')+'" alt="Image" width="'+imgWidth+'" height="'+imgHeight+'" title="'+title+'" />').appendTo(content);if(rel){$(['<p id="'+TB_ID.BROWSE+'">',(previousHtml||''),(nextHtml||''),count,'</p>'].join('')).appendTo(content);if(size>1){$('#'+TB_ID.NEXT+' a').bind('click',next);$('#'+TB_ID.PREV+' a').bind('click',previous);}}
show(Math.max(imgWidth,defaultValues.minWidth)+38,imgHeight+(rel?90:75),settings.top,settings.left,settings.animate,callback);};img.src=$$.attr('href');};break;case TB_TYPE.INLINE:var inlineContent=$($$[0].hash);builder=function(){buildTitle($$.attr('title'));inlineContent.css('display','block').appendTo(content);show(settings.width,settings.height,settings.top,settings.left,settings.animate,callback);};break;case TB_TYPE.AJAX:builder=function(){buildTitle($$.attr('title'));request=$.ajax({url:$$.attr('href'),dataType:'html',success:function(r){content.append(r);show(settings.width,settings.height,settings.top,settings.left,settings.animate,callback);}});};break;case TB_TYPE.EXTERNAL:builder=function(){buildTitle($$.attr('title'));$('<iframe id="'+TB_ID.CONTENT+'" src="'+$$.attr('href')+'" frameborder="0"></iframe>').appendTo(content);show(settings.width,settings.height,settings.top,settings.left,settings.animate,callback);};break;case TB_TYPE.CONFIRM:builder=function(){buildTitle($('*[@type="submit"][@title]',$$).attr('title')||defaultValues.i18n.confirm.what);$('<a id="tb-confirm" href="#">'+defaultValues.i18n.confirm.confirm+'</a>').appendTo(content).click(function(){hide(settings.onConfirm||function(){$$[0].submit();});return false;});$('<a id="tb-cancel" href="#">'+defaultValues.i18n.confirm.cancel+'</a> ').appendTo(content).click(function(){hide();return false;});show(settings.width,(settings.height==defaultValues.height?90:settings.height),settings.top,settings.left,settings.animate,callback);};break;default:alert('You can apply a Thickbox to links and forms only.');}
if(builder){$$.bind((type==TB_TYPE.CONFIRM?'submit':'click'),function(){setup(type,builder);this.blur();return false;});}});};}});$.fn.extend({thickbox:$.thickbox.render});})(jQuery);

var is={ie:navigator.appName=='Microsoft Internet Explorer',java:navigator.javaEnabled(),ns:navigator.appName=='Netscape',ua:navigator.userAgent.toLowerCase(),version:parseFloat(navigator.appVersion.substr(21))||parseFloat(navigator.appVersion),win:navigator.platform=='Win32'}
is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}