/*
 * jQuery Nivo Slider v2.3
 * http://nivo.dev7studios.com
 *
 * Copyright 2010, Gilbert Pellegrom
 * Free to use and abuse under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 */
(function(b){var a=function(j,q){var g=b.extend({},b.fn.nivoSlider.defaults,q);var m={currentSlide:0,currentImage:"",totalSlides:0,randAnim:"",running:false,paused:false,stop:false};var d=b(j);d.data("nivo:vars",m);d.css("position","relative");d.addClass("nivoSlider");var e=d.children();e.each(function(){var t=b(this);var s="";if(!t.is("img")){if(t.is("a")){t.addClass("nivo-imageLink");s=t}t=t.find("img:first")}var r=t.width();if(r==0){r=t.attr("width")}var i=t.height();if(i==0){i=t.attr("height")}if(r>d.width()){d.width(r)}if(i>d.height()){d.height(i)}if(s!=""){s.css("display","none")}t.css("display","none");m.totalSlides++});if(g.startSlide>0){if(g.startSlide>=m.totalSlides){g.startSlide=m.totalSlides-1}m.currentSlide=g.startSlide}if(b(e[m.currentSlide]).is("img")){m.currentImage=b(e[m.currentSlide])}else{m.currentImage=b(e[m.currentSlide]).find("img:first")}if(b(e[m.currentSlide]).is("a")){b(e[m.currentSlide]).css("display","block")}d.css("background","url("+m.currentImage.attr("src")+") no-repeat");for(var k=0;k<g.slices;k++){var o=Math.round(d.width()/g.slices);if(k==g.slices-1){d.append(b('<div class="nivo-slice"></div>').css({left:(o*k)+"px",width:(d.width()-(o*k))+"px"}))}else{d.append(b('<div class="nivo-slice"></div>').css({left:(o*k)+"px",width:o+"px"}))}}d.append(b('<div class="nivo-caption"><p></p></div>').css({display:"none",opacity:g.captionOpacity}));if(m.currentImage.attr("title")!=""){var n=m.currentImage.attr("title");if(n.substr(0,1)=="#"){n=b(n).html()}b(".nivo-caption p",d).html(n);b(".nivo-caption",d).fadeIn(g.animSpeed)}var c=0;if(!g.manualAdvance&&e.length>1){c=setInterval(function(){p(d,e,g,false)},g.pauseTime)}if(g.directionNav){d.append('<div class="nivo-directionNav"><a class="nivo-prevNav">Prev</a><a class="nivo-nextNav">Next</a></div>');if(g.directionNavHide){b(".nivo-directionNav",d).hide();d.hover(function(){b(".nivo-directionNav",d).show()},function(){b(".nivo-directionNav",d).hide()})}b("a.nivo-prevNav",d).live("click",function(){if(m.running){return false}clearInterval(c);c="";m.currentSlide-=2;p(d,e,g,"prev")});b("a.nivo-nextNav",d).live("click",function(){if(m.running){return false}clearInterval(c);c="";p(d,e,g,"next")})}if(g.controlNav){var l=b('<div class="nivo-controlNav"></div>');d.append(l);for(var k=0;k<e.length;k++){if(g.controlNavThumbs){var f=e.eq(k);if(!f.is("img")){f=f.find("img:first")}if(g.controlNavThumbsFromRel){l.append('<a class="nivo-control" rel="'+k+'"><img src="'+f.attr("rel")+'" alt="" /></a>')}else{l.append('<a class="nivo-control" rel="'+k+'"><img src="'+f.attr("src").replace(g.controlNavThumbsSearch,g.controlNavThumbsReplace)+'" alt="" /></a>')}}else{l.append('<a class="nivo-control" rel="'+k+'">'+(k+1)+"</a>")}}b(".nivo-controlNav a:eq("+m.currentSlide+")",d).addClass("active");b(".nivo-controlNav a",d).live("click",function(){if(m.running){return false}if(b(this).hasClass("active")){return false}clearInterval(c);c="";d.css("background","url("+m.currentImage.attr("src")+") no-repeat");m.currentSlide=b(this).attr("rel")-1;p(d,e,g,"control")})}if(g.keyboardNav){b(window).keypress(function(i){if(i.keyCode=="37"){if(m.running){return false}clearInterval(c);c="";m.currentSlide-=2;p(d,e,g,"prev")}if(i.keyCode=="39"){if(m.running){return false}clearInterval(c);c="";p(d,e,g,"next")}})}if(g.pauseOnHover){d.hover(function(){m.paused=true;clearInterval(c);c=""},function(){m.paused=false;if(c==""&&!g.manualAdvance){c=setInterval(function(){p(d,e,g,false)},g.pauseTime)}})}d.bind("nivo:animFinished",function(){m.running=false;b(e).each(function(){if(b(this).is("a")){b(this).css("display","none")}});if(b(e[m.currentSlide]).is("a")){b(e[m.currentSlide]).css("display","block")}if(c==""&&!m.paused&&!g.manualAdvance){c=setInterval(function(){p(d,e,g,false)},g.pauseTime)}g.afterChange.call(this)});var p=function(r,s,u,x){var y=r.data("nivo:vars");if(y&&(y.currentSlide==y.totalSlides-1)){u.lastSlide.call(this)}if((!y||y.stop)&&!x){return false}u.beforeChange.call(this);if(!x){r.css("background","url("+y.currentImage.attr("src")+") no-repeat")}else{if(x=="prev"){r.css("background","url("+y.currentImage.attr("src")+") no-repeat")}if(x=="next"){r.css("background","url("+y.currentImage.attr("src")+") no-repeat")}}y.currentSlide++;if(y.currentSlide==y.totalSlides){y.currentSlide=0;u.slideshowEnd.call(this)}if(y.currentSlide<0){y.currentSlide=(y.totalSlides-1)}if(b(s[y.currentSlide]).is("img")){y.currentImage=b(s[y.currentSlide])}else{y.currentImage=b(s[y.currentSlide]).find("img:first")}if(u.controlNav){b(".nivo-controlNav a",r).removeClass("active");b(".nivo-controlNav a:eq("+y.currentSlide+")",r).addClass("active")}if(y.currentImage.attr("title")!=""){var z=y.currentImage.attr("title");if(z.substr(0,1)=="#"){z=b(z).html()}if(b(".nivo-caption",r).css("display")=="block"){b(".nivo-caption p",r).fadeOut(u.animSpeed,function(){b(this).html(z);b(this).fadeIn(u.animSpeed)})}else{b(".nivo-caption p",r).html(z)}b(".nivo-caption",r).fadeIn(u.animSpeed)}else{b(".nivo-caption",r).fadeOut(u.animSpeed)}var w=0;b(".nivo-slice",r).each(function(){var i=Math.round(r.width()/u.slices);b(this).css({height:"0px",opacity:"0",background:"url("+y.currentImage.attr("src")+") no-repeat -"+((i+(w*i))-i)+"px 0%"});w++});if(u.effect=="random"){var A=new Array("sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade");y.randAnim=A[Math.floor(Math.random()*(A.length+1))];if(y.randAnim==undefined){y.randAnim="fade"}}if(u.effect.indexOf(",")!=-1){var A=u.effect.split(",");y.randAnim=b.trim(A[Math.floor(Math.random()*A.length)])}y.running=true;if(u.effect=="sliceDown"||u.effect=="sliceDownRight"||y.randAnim=="sliceDownRight"||u.effect=="sliceDownLeft"||y.randAnim=="sliceDownLeft"){var t=0;var w=0;var C=b(".nivo-slice",r);if(u.effect=="sliceDownLeft"||y.randAnim=="sliceDownLeft"){C=b(".nivo-slice",r)._reverse()}C.each(function(){var i=b(this);i.css("top","0px");if(w==u.slices-1){setTimeout(function(){i.animate({height:"100%",opacity:"1.0"},u.animSpeed,"",function(){r.trigger("nivo:animFinished")})},(100+t))}else{setTimeout(function(){i.animate({height:"100%",opacity:"1.0"},u.animSpeed)},(100+t))}t+=50;w++})}else{if(u.effect=="sliceUp"||u.effect=="sliceUpRight"||y.randAnim=="sliceUpRight"||u.effect=="sliceUpLeft"||y.randAnim=="sliceUpLeft"){var t=0;var w=0;var C=b(".nivo-slice",r);if(u.effect=="sliceUpLeft"||y.randAnim=="sliceUpLeft"){C=b(".nivo-slice",r)._reverse()}C.each(function(){var i=b(this);i.css("bottom","0px");if(w==u.slices-1){setTimeout(function(){i.animate({height:"100%",opacity:"1.0"},u.animSpeed,"",function(){r.trigger("nivo:animFinished")})},(100+t))}else{setTimeout(function(){i.animate({height:"100%",opacity:"1.0"},u.animSpeed)},(100+t))}t+=50;w++})}else{if(u.effect=="sliceUpDown"||u.effect=="sliceUpDownRight"||y.randAnim=="sliceUpDown"||u.effect=="sliceUpDownLeft"||y.randAnim=="sliceUpDownLeft"){var t=0;var w=0;var B=0;var C=b(".nivo-slice",r);if(u.effect=="sliceUpDownLeft"||y.randAnim=="sliceUpDownLeft"){C=b(".nivo-slice",r)._reverse()}C.each(function(){var i=b(this);if(w==0){i.css("top","0px");w++}else{i.css("bottom","0px");w=0}if(B==u.slices-1){setTimeout(function(){i.animate({height:"100%",opacity:"1.0"},u.animSpeed,"",function(){r.trigger("nivo:animFinished")})},(100+t))}else{setTimeout(function(){i.animate({height:"100%",opacity:"1.0"},u.animSpeed)},(100+t))}t+=50;B++})}else{if(u.effect=="fold"||y.randAnim=="fold"){var t=0;var w=0;b(".nivo-slice",r).each(function(){var i=b(this);var v=i.width();i.css({top:"0px",height:"100%",width:"0px"});if(w==u.slices-1){setTimeout(function(){i.animate({width:v,opacity:"1.0"},u.animSpeed,"",function(){r.trigger("nivo:animFinished")})},(100+t))}else{setTimeout(function(){i.animate({width:v,opacity:"1.0"},u.animSpeed)},(100+t))}t+=50;w++})}else{if(u.effect=="fade"||y.randAnim=="fade"){var w=0;b(".nivo-slice",r).each(function(){b(this).css("height","100%");if(w==u.slices-1){b(this).animate({opacity:"1.0"},(u.animSpeed*2),"",function(){r.trigger("nivo:animFinished")})}else{b(this).animate({opacity:"1.0"},(u.animSpeed*2))}w++})}}}}}};var h=function(i){if(this.console&&typeof console.log!="undefined"){console.log(i)}};this.stop=function(){if(!b(j).data("nivo:vars").stop){b(j).data("nivo:vars").stop=true;h("Stop Slider")}};this.start=function(){if(b(j).data("nivo:vars").stop){b(j).data("nivo:vars").stop=false;h("Start Slider")}};g.afterLoad.call(this)};b.fn.nivoSlider=function(c){return this.each(function(){var d=b(this);if(d.data("nivoslider")){return}var e=new a(this,c);d.data("nivoslider",e)})};b.fn.nivoSlider.defaults={effect:"random",slices:15,animSpeed:500,pauseTime:3000,startSlide:0,directionNav:true,directionNavHide:true,controlNav:true,controlNavThumbs:false,controlNavThumbsFromRel:false,controlNavThumbsSearch:".jpg",controlNavThumbsReplace:"_thumb.jpg",keyboardNav:true,pauseOnHover:true,manualAdvance:false,captionOpacity:0.8,beforeChange:function(){},afterChange:function(){},slideshowEnd:function(){},lastSlide:function(){},afterLoad:function(){}};b.fn._reverse=[].reverse})(jQuery);

/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie=function(key,value,options){if(arguments.length>1&&String(value)!=="[object Object]"){options=jQuery.extend({},options);if(value===null||value===undefined){options.expires=-1}if(typeof options.expires==='number'){var days=options.expires,t=options.expires=new Date();t.setDate(t.getDate()+days)}value=String(value);return(document.cookie=[encodeURIComponent(key),'=',options.raw?value:encodeURIComponent(value),options.expires?'; expires='+options.expires.toUTCString():'',options.path?'; path='+options.path:'',options.domain?'; domain='+options.domain:'',options.secure?'; secure':''].join(''))}options=value||{};var result,decode=options.raw?function(s){return s}:decodeURIComponent;return(result=new RegExp('(?:^|; )'+encodeURIComponent(key)+'=([^;]*)').exec(document.cookie))?decode(result[1]):null};

/*
 * form validation
 *
 * Copyright 2011, Mariusz Ołownia
 */
var formValidate={init:function(){formValidate.bindForms();if($('.errors').size()){$('.errors').each(function(){$(this).prevAll().addClass('hasError').parent().prev('dt').find('label').addClass('hasErrorLabel')})}},bindForms:function(){$('form.autoValidateForm').submit(function(){return formValidate.validate(this)});$('.autoValidateForm').find('input, select, textarea').each(function(){if($(this).hasClass('validate')){formValidate.configure.element(this);$(this).blur(function(){var element=this;setTimeout(function(){formValidate.validate(element)},100)})}})},validate:function(element){var validateResult=true;switch(element.nodeName){case'FORM':var firstInvalid;$(element).find('input, select, textarea').each(function(){if($(this).hasClass('validate')){var result=formValidate.validate(this);if(firstInvalid==undefined&&!result){firstInvalid=$(this).attr('id')}if(validateResult===true){validateResult=result}}});if(validateResult!==true){var offset=$('#'+$(element).attr('id')+' #'+firstInvalid).offset().top-10;if(window.pageYOffset>offset){$('html, body').animate({scrollTop:offset},1000)}$('#'+$(element).attr('id')+' #'+firstInvalid+'-element input').focus()}break;case'INPUT':case'SELECT':case'TEXTAREA':if($.data(element,'required')){validateResult=formValidate.validator.required(element)}else if($(element).val()==''){if($(element).attr('name').indexOf('[')!==-1){var val='';$(element).parent().find('input').each(function(){val+=$(this).val()});if(val===''){formValidate.render.clearErrors(element)}}else{formValidate.render.clearErrors(element)}break}var validators=$.data(element,'validators');for(var i in validators){if(validateResult===true&&validators[i]!==undefined){validateResult=formValidate.validator[validators[i].toString()](element)}}if(validateResult===true){formValidate.render.clearErrors(element)}else{formValidate.render.elementErrors(element,validateResult)}break}return validateResult===true?true:false},configure:{form:function(){},element:function(element){var $elementLabel=$(element).parent().prev().find('label');var required=$elementLabel.attr('class')=='required'?true:false;var info=$(element).attr('class').split(' ');$.data(element,'required',required);$.data(element,'elementLabel',$elementLabel.html());var validators={},params={};for(var i in info){switch(info[i].substr(0,2)){case'v_':validators[i]=info[i].substr(2);break;case'p_':params[i]=info[i].substr(2);break}}$.data(element,'validators',validators);$.data(element,'validatorParams',params)}},render:{elementErrors:function(element,errors){var $errors=$(element).parent().find('ul.errors');if($errors.size()){if(typeof errors=='string'&&$errors.find('li').html()!=errors){$errors.find('li').html(errors);return}$errors.remove()}if(typeof errors=='string'){errors={0:errors}}$(element).addClass('hasError').parent().prev('dt').find('label').addClass('hasErrorLabel');$(formValidate.render.getTpl(element,errors)).hide().appendTo($(element).parent()).fadeIn()},clearErrors:function(element){var $errors=$(element).parent().find('ul.errors');if($errors.size()){$(element).removeClass('hasError').parent().prev('dt').find('label').removeClass('hasErrorLabel');$(element).parent().find('input').removeClass('hasError');$($errors).fadeOut(250,function(){$(this).remove()})}},getTpl:function(element,errors){var tpl='<ul id="errors-'+$(element).attr('id')+'" class="errors">';for(var errorKey in errors){tpl+='<li>'+errors[errorKey]+'</li>'}tpl+='</ul>';return tpl}},validator:{required:function(element){var isValid=$(element).val().length;if(element.nodeName=='SELECT'&&$(element).val()==0){isValid=false}return isValid?true:formValidate.messages.required},stringLength:function(element){var params=$.data(element,'validatorParams');var min,max;for(var i in params){switch(params[i].substr(0,3)){case'min':min=parseInt(params[i].substr(4));break;case'max':max=parseInt(params[i].substr(4));break}}var value=$(element).val();if(min!==undefined&&max!==undefined){return value.length>=min&&value.length<=max?true:formValidate.messages.assemble(formValidate.messages.stringLengthBetween,{min:min,max:max})}else if(min!==undefined){return value.length>=min?true:formValidate.messages.assemble(formValidate.messages.stringLengthLess,{min:min})}else{return value.length<=max?true:formValidate.messages.assemble(formValidate.messages.stringLengthMore,{max:max})}return true},alpha:function(element){return formValidate.validator.match(element,'alpha')},emailAddress:function(element){return formValidate.validator.match(element,'email')},identical:function(element){var params=$.data(element,'validatorParams');var field;for(var i in params){if(params[i].substr(0,5)=='field'){field=params[i].substr(6);break}}var $confirm=$('input[name="'+field+'"]');$confirm.blur(function(){formValidate.validate(element)});return!$confirm.val().length||$confirm.val()==$(element).val()?true:formValidate.messages.assemble(formValidate.messages.identical,{label:$.data(element,'elementLabel')});return true},match:function(element,rule){var value=$(element).val();var pattern=formValidate.patterns[rule];if(pattern.global){pattern.lastIndex=0}return!value.length||pattern.test(value)?true:formValidate.messages[rule]},ajax:function(element){var url=$(element).parents('form.autoValidateForm').attr('action');var $element=$(element),inputValue={},isValid=true;if($element.attr('name').indexOf('[')!==-1){$element.parent().find('input').each(function(){inputValue[$(this).attr('name')]=$(this).val()})}else{inputValue[$element.attr('name')]=$element.val()}$.ajax({url:url,data:inputValue,type:'post',dataType:'json',async:false,success:function(response){if(!$.isArray(response)){isValid=response[$element.parent().prev().find('label').attr('for')]}},error:function(xhr,desc,er){alert('Wystąpił błąd aplikacji')}});return isValid}},helper:{strstr:function(haystack,needle,bool){var pos=0;haystack+='';pos=haystack.indexOf(needle);if(pos==-1){return false}else{if(bool){return haystack.substr(0,pos)}else{return haystack.slice(pos)}}}},messages:{assemble:function(msg,params){for(var id in params){msg=msg.replace("%"+id+"%",params[id])}return msg},required:"To pole jest wymagane",alpha:"Dozwolone tylko litery",email:"Niepoprawny adres e-mail",stringLengthLess:"Minimalna ilość znaków to %min%",stringLengthMore:"Maksymalna ilość znaków to %max%",stringLengthBetween:"Ilość znaków powinna być między %min% a %max%",identical:"%label% nie zostało poprawnie powtórzone"},patterns:{integer:/^\d+$/,alpha:/^[a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ]+$/,url:/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,email:/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,date:/^((0?\d)|(1[012]))\/([012]?\d|30|31)\/\d{1,4}$/,number:/^[+-]?(\d+(\.\d*)?|\.\d+)([Ee]\d+)?$/,nonHtml:/^[^<>]*$/}};

/**
 @preserve CLEditor WYSIWYG HTML Editor v1.3.0
 http://premiumsoftware.net/cleditor
 requires jQuery v1.4.2 or later

 Copyright 2010, Chris Landowski, Premium Software, LLC
 Dual licensed under the MIT or GPL Version 2 licenses.
*/
(function($){$.cleditor={defaultOptions:{width:500,height:250,controls:"bold italic underline strikethrough subscript superscript | font size "+"style | color highlight removeformat | bullets numbering | outdent "+"indent | alignleft center alignright justify | undo redo | "+"rule image link unlink | cut copy paste pastetext | print source",colors:"FFF FCC FC9 FF9 FFC 9F9 9FF CFF CCF FCF "+"CCC F66 F96 FF6 FF3 6F9 3FF 6FF 99F F9F "+"BBB F00 F90 FC6 FF0 3F3 6CC 3CF 66C C6C "+"999 C00 F60 FC3 FC0 3C0 0CC 36F 63F C3C "+"666 900 C60 C93 990 090 399 33F 60C 939 "+"333 600 930 963 660 060 366 009 339 636 "+"000 300 630 633 330 030 033 006 309 303",fonts:"Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond,"+"Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana",sizes:"1,2,3,4,5,6,7",styles:[["Paragraph","<p>"],["Header 1","<h1>"],["Header 2","<h2>"],["Header 3","<h3>"],["Header 4","<h4>"],["Header 5","<h5>"],["Header 6","<h6>"]],useCSS:false,docType:'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',docCSSFile:"",bodyStyle:"margin:4px; font:10pt Arial,Verdana; cursor:text"},buttons:{init:"bold,,|"+"italic,,|"+"underline,,|"+"strikethrough,,|"+"subscript,,|"+"superscript,,|"+"font,,fontname,|"+"size,Font Size,fontsize,|"+"style,,formatblock,|"+"color,Font Color,forecolor,|"+"highlight,Text Highlight Color,hilitecolor,color|"+"removeformat,Remove Formatting,|"+"bullets,,insertunorderedlist|"+"numbering,,insertorderedlist|"+"outdent,,|"+"indent,,|"+"alignleft,Align Text Left,justifyleft|"+"center,,justifycenter|"+"alignright,Align Text Right,justifyright|"+"justify,,justifyfull|"+"undo,,|"+"redo,,|"+"rule,Insert Horizontal Rule,inserthorizontalrule|"+"image,Insert Image,insertimage,url|"+"link,Insert Hyperlink,createlink,url|"+"unlink,Remove Hyperlink,|"+"cut,,|"+"copy,,|"+"paste,,|"+"pastetext,Paste as Text,inserthtml,|"+"print,,|"+"source,Show Source"},imagesPath:function(){return imagesPath()}};$.fn.cleditor=function(options){var $result=$([]);this.each(function(idx,elem){if(elem.tagName=="TEXTAREA"){var data=$.data(elem,CLEDITOR);if(!data)data=new cleditor(elem,options);$result=$result.add(data)}});return $result};var BACKGROUND_COLOR="backgroundColor",BUTTON="button",BUTTON_NAME="buttonName",CHANGE="change",CLEDITOR="cleditor",CLICK="click",DISABLED="disabled",DIV_TAG="<div>",TRANSPARENT="transparent",UNSELECTABLE="unselectable",MAIN_CLASS="cleditorMain",TOOLBAR_CLASS="cleditorToolbar",GROUP_CLASS="cleditorGroup",BUTTON_CLASS="cleditorButton",DISABLED_CLASS="cleditorDisabled",DIVIDER_CLASS="cleditorDivider",POPUP_CLASS="cleditorPopup",LIST_CLASS="cleditorList",COLOR_CLASS="cleditorColor",PROMPT_CLASS="cleditorPrompt",MSG_CLASS="cleditorMsg",ie=$.browser.msie,ie6=/msie\s6/i.test(navigator.userAgent),iOS=/iphone|ipad|ipod/i.test(navigator.userAgent),popups={},documentClickAssigned,buttons=$.cleditor.buttons;$.each(buttons.init.split("|"),function(idx,button){var items=button.split(","),name=items[0];buttons[name]={stripIndex:idx,name:name,title:items[1]===""?name.charAt(0).toUpperCase()+name.substr(1):items[1],command:items[2]===""?name:items[2],popupName:items[3]===""?name:items[3]}});delete buttons.init;cleditor=function(area,options){var editor=this;editor.options=options=$.extend({},$.cleditor.defaultOptions,options);var $area=editor.$area=$(area).hide().data(CLEDITOR,editor).blur(function(){updateFrame(editor,true)});var $main=editor.$main=$(DIV_TAG).addClass(MAIN_CLASS).width(options.width).height(options.height);var $toolbar=editor.$toolbar=$(DIV_TAG).addClass(TOOLBAR_CLASS).appendTo($main);var $group=$(DIV_TAG).addClass(GROUP_CLASS).appendTo($toolbar);$.each(options.controls.split(" "),function(idx,buttonName){if(buttonName==="")return true;if(buttonName=="|"){var $div=$(DIV_TAG).addClass(DIVIDER_CLASS).appendTo($group);$group=$(DIV_TAG).addClass(GROUP_CLASS).appendTo($toolbar)}else{var button=buttons[buttonName];var $buttonDiv=$(DIV_TAG).data(BUTTON_NAME,button.name).addClass(BUTTON_CLASS).attr("title",button.title).bind(CLICK,$.proxy(buttonClick,editor)).appendTo($group).hover(hoverEnter,hoverLeave);var map={};if(button.css)map=button.css;else if(button.image)map.backgroundImage=imageUrl(button.image);if(button.stripIndex)map.backgroundPosition=button.stripIndex*-24;$buttonDiv.css(map);if(ie)$buttonDiv.attr(UNSELECTABLE,"on");if(button.popupName)createPopup(button.popupName,options,button.popupClass,button.popupContent,button.popupHover)}});$main.insertBefore($area).append($area);if(!documentClickAssigned){$(document).click(function(e){var $target=$(e.target);if(!$target.add($target.parents()).is("."+PROMPT_CLASS))hidePopups()});documentClickAssigned=true}if(/auto|%/.test(""+options.width+options.height))$(window).resize(function(){refresh(editor)});refresh(editor)};var fn=cleditor.prototype,methods=[["clear",clear],["disable",disable],["execCommand",execCommand],["focus",focus],["hidePopups",hidePopups],["sourceMode",sourceMode,true],["refresh",refresh],["select",select],["selectedHTML",selectedHTML,true],["selectedText",selectedText,true],["showMessage",showMessage],["updateFrame",updateFrame],["updateTextArea",updateTextArea]];$.each(methods,function(idx,method){fn[method[0]]=function(){var editor=this,args=[editor];for(var x=0;x<arguments.length;x++){args.push(arguments[x])}var result=method[1].apply(editor,args);if(method[2])return result;return editor}});fn.change=function(handler){var $this=$(this);return handler?$this.bind(CHANGE,handler):$this.trigger(CHANGE)};function buttonClick(e){var editor=this,buttonDiv=e.target,buttonName=$.data(buttonDiv,BUTTON_NAME),button=buttons[buttonName],popupName=button.popupName,popup=popups[popupName];if(editor.disabled||$(buttonDiv).attr(DISABLED)==DISABLED)return;var data={editor:editor,button:buttonDiv,buttonName:buttonName,popup:popup,popupName:popupName,command:button.command,useCSS:editor.options.useCSS};if(button.buttonClick&&button.buttonClick(e,data)===false)return false;if(buttonName=="source"){if(sourceMode(editor)){delete editor.range;editor.$area.hide();editor.$frame.show();buttonDiv.title=button.title}else{editor.$frame.hide();editor.$area.show();buttonDiv.title="Show Rich Text"}setTimeout(function(){refreshButtons(editor)},100)}else if(!sourceMode(editor)){if(popupName){var $popup=$(popup);if(popupName=="url"){if(buttonName=="link"&&selectedText(editor)===""){showMessage(editor,"A selection is required when inserting a link.",buttonDiv);return false}$popup.children(":button").unbind(CLICK).bind(CLICK,function(){var $text=$popup.find(":text"),url=$.trim($text.val());if(url!=="")execCommand(editor,data.command,url,null,data.button);$text.val("http://");hidePopups();focus(editor)})}else if(popupName=="pastetext"){$popup.children(":button").unbind(CLICK).bind(CLICK,function(){var $textarea=$popup.find("textarea"),text=$textarea.val().replace(/\n/g,"<br />");if(text!=="")execCommand(editor,data.command,text,null,data.button);$textarea.val("");hidePopups();focus(editor)})}if(buttonDiv!==$.data(popup,BUTTON)){showPopup(editor,popup,buttonDiv);return false}return}else if(buttonName=="print")editor.$frame[0].contentWindow.print();else if(!execCommand(editor,data.command,data.value,data.useCSS,buttonDiv))return false}focus(editor)}function hoverEnter(e){var $div=$(e.target).closest("div");$div.css(BACKGROUND_COLOR,$div.data(BUTTON_NAME)?"#FFF":"#FFC")}function hoverLeave(e){$(e.target).closest("div").css(BACKGROUND_COLOR,"transparent")}function popupClick(e){var editor=this,popup=e.data.popup,target=e.target;if(popup===popups.msg||$(popup).hasClass(PROMPT_CLASS))return;var buttonDiv=$.data(popup,BUTTON),buttonName=$.data(buttonDiv,BUTTON_NAME),button=buttons[buttonName],command=button.command,value,useCSS=editor.options.useCSS;if(buttonName=="font")value=target.style.fontFamily.replace(/"/g,"");else if(buttonName=="size"){if(target.tagName=="DIV")target=target.children[0];value=target.innerHTML}else if(buttonName=="style")value="<"+target.tagName+">";else if(buttonName=="color")value=hex(target.style.backgroundColor);else if(buttonName=="highlight"){value=hex(target.style.backgroundColor);if(ie)command='backcolor';else useCSS=true}var data={editor:editor,button:buttonDiv,buttonName:buttonName,popup:popup,popupName:button.popupName,command:command,value:value,useCSS:useCSS};if(button.popupClick&&button.popupClick(e,data)===false)return;if(data.command&&!execCommand(editor,data.command,data.value,data.useCSS,buttonDiv))return false;hidePopups();focus(editor)}function checksum(text){var a=1,b=0;for(var index=0;index<text.length;++index){a=(a+text.charCodeAt(index))%65521;b=(b+a)%65521}return(b<<16)|a}function clear(editor){editor.$area.val("");updateFrame(editor)}function createPopup(popupName,options,popupTypeClass,popupContent,popupHover){if(popups[popupName])return popups[popupName];var $popup=$(DIV_TAG).hide().addClass(POPUP_CLASS).appendTo("body");if(popupContent)$popup.html(popupContent);else if(popupName=="color"){var colors=options.colors.split(" ");if(colors.length<10)$popup.width("auto");$.each(colors,function(idx,color){$(DIV_TAG).appendTo($popup).css(BACKGROUND_COLOR,"#"+color)});popupTypeClass=COLOR_CLASS}else if(popupName=="font")$.each(options.fonts.split(","),function(idx,font){$(DIV_TAG).appendTo($popup).css("fontFamily",font).html(font)});else if(popupName=="size")$.each(options.sizes.split(","),function(idx,size){$(DIV_TAG).appendTo($popup).html("<font size="+size+">"+size+"</font>")});else if(popupName=="style")$.each(options.styles,function(idx,style){$(DIV_TAG).appendTo($popup).html(style[1]+style[0]+style[1].replace("<","</"))});else if(popupName=="url"){$popup.html('Enter URL:<br><input type=text value="http://" size=35><br><input type=button value="Submit">');popupTypeClass=PROMPT_CLASS}else if(popupName=="pastetext"){$popup.html('Paste your content here and click submit.<br /><textarea cols=40 rows=3></textarea><br /><input type=button value=Submit>');popupTypeClass=PROMPT_CLASS}if(!popupTypeClass&&!popupContent)popupTypeClass=LIST_CLASS;$popup.addClass(popupTypeClass);if(ie){$popup.attr(UNSELECTABLE,"on").find("div,font,p,h1,h2,h3,h4,h5,h6").attr(UNSELECTABLE,"on")}if($popup.hasClass(LIST_CLASS)||popupHover===true)$popup.children().hover(hoverEnter,hoverLeave);popups[popupName]=$popup[0];return $popup[0]}function disable(editor,disabled){if(disabled){editor.$area.attr(DISABLED,DISABLED);editor.disabled=true}else{editor.$area.removeAttr(DISABLED);delete editor.disabled}try{if(ie)editor.doc.body.contentEditable=!disabled;else editor.doc.designMode=!disabled?"on":"off"}catch(err){}refreshButtons(editor)}function execCommand(editor,command,value,useCSS,button){restoreRange(editor);if(!ie){if(useCSS===undefined||useCSS===null)useCSS=editor.options.useCSS;editor.doc.execCommand("styleWithCSS",0,useCSS.toString())}var success=true,description;if(ie&&command.toLowerCase()=="inserthtml")getRange(editor).pasteHTML(value);else{try{success=editor.doc.execCommand(command,0,value||null)}catch(err){description=err.description;success=false}if(!success){if("cutcopypaste".indexOf(command)>-1)showMessage(editor,"For security reasons, your browser does not support the "+command+" command. Try using the keyboard shortcut or context menu instead.",button);else showMessage(editor,(description?description:"Error executing the "+command+" command."),button)}}refreshButtons(editor);return success}function focus(editor){setTimeout(function(){if(sourceMode(editor))editor.$area.focus();else editor.$frame[0].contentWindow.focus();refreshButtons(editor)},0)}function getRange(editor){if(ie)return getSelection(editor).createRange();return getSelection(editor).getRangeAt(0)}function getSelection(editor){if(ie)return editor.doc.selection;return editor.$frame[0].contentWindow.getSelection()}function hex(s){var m=/rgba?\((\d+), (\d+), (\d+)/.exec(s),c=s.split("");if(m){s=(m[1]<<16|m[2]<<8|m[3]).toString(16);while(s.length<6)s="0"+s}return"#"+(s.length==6?s:c[1]+c[1]+c[2]+c[2]+c[3]+c[3])}function hidePopups(){$.each(popups,function(idx,popup){$(popup).hide().unbind(CLICK).removeData(BUTTON)})}function imagesPath(){var cssFile="jquery.cleditor.css",href=$("link[href$='"+cssFile+"']").attr("href");return href.substr(0,href.length-cssFile.length)+"images/"}function imageUrl(filename){return"url("+imagesPath()+filename+")"}function refresh(editor){var $main=editor.$main,options=editor.options;if(editor.$frame)editor.$frame.remove();var $frame=editor.$frame=$('<iframe frameborder="0" src="javascript:true;">').hide().appendTo($main);var contentWindow=$frame[0].contentWindow,doc=editor.doc=contentWindow.document,$doc=$(doc);doc.open();doc.write(options.docType+'<html>'+((options.docCSSFile==='')?'':'<head><link rel="stylesheet" type="text/css" href="'+options.docCSSFile+'" /></head>')+'<body style="'+options.bodyStyle+'"></body></html>');doc.close();if(ie)$doc.click(function(){focus(editor)});updateFrame(editor);if(ie){$doc.bind("beforedeactivate beforeactivate selectionchange keypress",function(e){if(e.type=="beforedeactivate")editor.inactive=true;else if(e.type=="beforeactivate"){if(!editor.inactive&&editor.range&&editor.range.length>1)editor.range.shift();delete editor.inactive}else if(!editor.inactive){if(!editor.range)editor.range=[];editor.range.unshift(getRange(editor));while(editor.range.length>2)editor.range.pop()}});$frame.focus(function(){restoreRange(editor)})}($.browser.mozilla?$doc:$(contentWindow)).blur(function(){updateTextArea(editor,true)});$doc.click(hidePopups).bind("keyup mouseup",function(){refreshButtons(editor)});if(iOS)editor.$area.show();else $frame.show();$(function(){var $toolbar=editor.$toolbar,$group=$toolbar.children("div:last"),wid=$main.width();var hgt=$group.offset().top+$group.outerHeight()-$toolbar.offset().top+1;$toolbar.height(hgt);hgt=(/%/.test(""+options.height)?$main.height():parseInt(options.height))-hgt;$frame.width(wid).height(hgt);editor.$area.width(wid).height(ie6?hgt-2:hgt);disable(editor,editor.disabled);refreshButtons(editor)})}function refreshButtons(editor){if(!iOS&&$.browser.webkit&&!editor.focused){editor.$frame[0].contentWindow.focus();window.focus();editor.focused=true}var queryObj=editor.doc;if(ie)queryObj=getRange(editor);var inSourceMode=sourceMode(editor);$.each(editor.$toolbar.find("."+BUTTON_CLASS),function(idx,elem){var $elem=$(elem),button=$.cleditor.buttons[$.data(elem,BUTTON_NAME)],command=button.command,enabled=true;if(editor.disabled)enabled=false;else if(button.getEnabled){var data={editor:editor,button:elem,buttonName:button.name,popup:popups[button.popupName],popupName:button.popupName,command:button.command,useCSS:editor.options.useCSS};enabled=button.getEnabled(data);if(enabled===undefined)enabled=true}else if(((inSourceMode||iOS)&&button.name!="source")||(ie&&(command=="undo"||command=="redo")))enabled=false;else if(command&&command!="print"){if(ie&&command=="hilitecolor")command="backcolor";if(!ie||command!="inserthtml"){try{enabled=queryObj.queryCommandEnabled(command)}catch(err){enabled=false}}}if(enabled){$elem.removeClass(DISABLED_CLASS);$elem.removeAttr(DISABLED)}else{$elem.addClass(DISABLED_CLASS);$elem.attr(DISABLED,DISABLED)}})}function restoreRange(editor){if(ie&&editor.range)editor.range[0].select()}function select(editor){setTimeout(function(){if(sourceMode(editor))editor.$area.select();else execCommand(editor,"selectall")},0)}function selectedHTML(editor){restoreRange(editor);var range=getRange(editor);if(ie)return range.htmlText;var layer=$("<layer>")[0];layer.appendChild(range.cloneContents());var html=layer.innerHTML;layer=null;return html}function selectedText(editor){restoreRange(editor);if(ie)return getRange(editor).text;return getSelection(editor).toString()}function showMessage(editor,message,button){var popup=createPopup("msg",editor.options,MSG_CLASS);popup.innerHTML=message;showPopup(editor,popup,button)}function showPopup(editor,popup,button){var offset,left,top,$popup=$(popup);if(button){var $button=$(button);offset=$button.offset();left=--offset.left;top=offset.top+$button.height()}else{var $toolbar=editor.$toolbar;offset=$toolbar.offset();left=Math.floor(($toolbar.width()-$popup.width())/2)+offset.left;top=offset.top+$toolbar.height()-2}hidePopups();$popup.css({left:left,top:top}).show();if(button){$.data(popup,BUTTON,button);$popup.bind(CLICK,{popup:popup},$.proxy(popupClick,editor))}setTimeout(function(){$popup.find(":text,textarea").eq(0).focus().select()},100)}function sourceMode(editor){return editor.$area.is(":visible")}function updateFrame(editor,checkForChange){var code=editor.$area.val(),options=editor.options,updateFrameCallback=options.updateFrame,$body=$(editor.doc.body);if(updateFrameCallback){var sum=checksum(code);if(checkForChange&&editor.areaChecksum==sum)return;editor.areaChecksum=sum}var html=updateFrameCallback?updateFrameCallback(code):code;html=html.replace(/<(?=\/?script)/ig,"&lt;");if(options.updateTextArea)editor.frameChecksum=checksum(html);if(html!=$body.html()){$body.html(html);$(editor).triggerHandler(CHANGE)}}function updateTextArea(editor,checkForChange){var html=$(editor.doc.body).html(),options=editor.options,updateTextAreaCallback=options.updateTextArea,$area=editor.$area;if(updateTextAreaCallback){var sum=checksum(html);if(checkForChange&&editor.frameChecksum==sum)return;editor.frameChecksum=sum}var code=updateTextAreaCallback?updateTextAreaCallback(html):html;if(options.updateFrame)editor.areaChecksum=checksum(code);if(code!=$area.val()){$area.val(code);$(editor).triggerHandler(CHANGE)}}})(jQuery);

/*!
 * jQzoom Evolution Library v2.3  - Javascript Image magnifier
 * http://www.mind-projects.it
 *
 * Copyright 2011, Engineer Marco Renzi
 * Licensed under the BSD license.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the organization nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * Date: 03 May 2011 22:16:00
 */
(function($){var isIE6=($.browser.msie&&$.browser.version<7);var body=$(document.body);var window=$(window);var jqzoompluging_disabled=false;$.fn.jqzoom=function(options){return this.each(function(){var node=this.nodeName.toLowerCase();if(node=='a'){new jqzoom(this,options)}})};jqzoom=function(el,options){var api=null;api=$(el).data("jqzoom");if(api)return api;var obj=this;var settings=$.extend({},$.jqzoom.defaults,options||{});obj.el=el;el.rel=$(el).attr('rel');el.zoom_active=false;el.zoom_disabled=false;el.largeimageloading=false;el.largeimageloaded=false;el.scale={};el.timer=null;el.mousepos={};el.mouseDown=false;$(el).css({'outline-style':'none','text-decoration':'none'});var img=$("img:eq(0)",el);el.title=$(el).attr('title');el.imagetitle=img.attr('title');var zoomtitle=($.trim(el.title).length>0)?el.title:el.imagetitle;var smallimage=new Smallimage(img);var lens=new Lens();var stage=new Stage();var largeimage=new Largeimage();var loader=new Loader();$(el).bind('click',function(e){e.preventDefault();return false});var zoomtypes=['standard','drag','innerzoom','reverse'];if($.inArray($.trim(settings.zoomType),zoomtypes)<0){settings.zoomType='standard'}$.extend(obj,{create:function(){if($(".zoomPad",el).length==0){el.zoomPad=$('<div/>').addClass('zoomPad');img.wrap(el.zoomPad)}if(settings.zoomType=='innerzoom'){settings.zoomWidth=smallimage.w;settings.zoomHeight=smallimage.h}if($(".zoomPup",el).length==0){lens.append()}if($(".zoomWindow",el).length==0){stage.append()}if($(".zoomPreload",el).length==0){loader.append()}if(settings.preloadImages||settings.zoomType=='drag'||settings.alwaysOn){obj.load()}obj.init()},init:function(){if(settings.zoomType=='drag'){$(".zoomPad",el).mousedown(function(){el.mouseDown=true});$(".zoomPad",el).mouseup(function(){el.mouseDown=false});document.body.ondragstart=function(){return false};$(".zoomPad",el).css({cursor:'default'});$(".zoomPup",el).css({cursor:'move'})}if(settings.zoomType=='innerzoom'){$(".zoomWrapper",el).css({cursor:'crosshair'})}$(".zoomPad",el).bind('mouseenter mouseover',function(event){img.attr('title','');$(el).attr('title','');el.zoom_active=true;smallimage.fetchdata();if(el.largeimageloaded){obj.activate(event)}else{obj.load()}});$(".zoomPad",el).bind('mouseleave',function(event){obj.deactivate()});$(".zoomPad",el).bind('mousemove',function(e){if(e.pageX>smallimage.pos.r||e.pageX<smallimage.pos.l||e.pageY<smallimage.pos.t||e.pageY>smallimage.pos.b){lens.setcenter();return false}el.zoom_active=true;if(el.largeimageloaded&&!$('.zoomWindow',el).is(':visible')){obj.activate(e)}if(el.largeimageloaded&&(settings.zoomType!='drag'||(settings.zoomType=='drag'&&el.mouseDown))){lens.setposition(e)}});var thumb_preload=new Array();var i=0;var thumblist=new Array();thumblist=$('a').filter(function(){var regex=new RegExp("gallery[\\s]*:[\\s]*'"+$.trim(el.rel)+"'","i");var rel=$(this).attr('rel');if(regex.test(rel)){return this}});if(thumblist.length>0){var first=thumblist.splice(0,1);thumblist.push(first)}thumblist.each(function(){if(settings.preloadImages){var thumb_options=$.extend({},eval("("+$.trim($(this).attr('rel'))+")"));thumb_preload[i]=new Image();thumb_preload[i].src=thumb_options.largeimage;i++}$(this).click(function(e){if($(this).hasClass('zoomThumbActive')){return false}thumblist.each(function(){$(this).removeClass('zoomThumbActive')});e.preventDefault();obj.swapimage(this);return false})})},load:function(){if(el.largeimageloaded==false&&el.largeimageloading==false){var url=$(el).attr('href');el.largeimageloading=true;largeimage.loadimage(url)}},activate:function(e){clearTimeout(el.timer);lens.show();stage.show()},deactivate:function(e){switch(settings.zoomType){case'drag':break;default:img.attr('title',el.imagetitle);$(el).attr('title',el.title);if(settings.alwaysOn){lens.setcenter()}else{stage.hide();lens.hide()}break}el.zoom_active=false},swapimage:function(link){el.largeimageloading=false;el.largeimageloaded=false;var options=new Object();options=$.extend({},eval("("+$.trim($(link).attr('rel'))+")"));if(options.smallimage&&options.largeimage){var smallimage=options.smallimage;var largeimage=options.largeimage;$(link).addClass('zoomThumbActive');$(el).attr('href',largeimage);img.attr('src',smallimage);lens.hide();stage.hide();obj.load()}else{alert('ERROR :: Missing parameter for largeimage or smallimage.');throw'ERROR :: Missing parameter for largeimage or smallimage.'}return false}});if(img[0].complete){smallimage.fetchdata();if($(".zoomPad",el).length==0)obj.create()}function Smallimage(image){var $obj=this;this.node=image[0];this.findborder=function(){var bordertop=0;bordertop=image.css('border-top-width');btop='';var borderleft=0;borderleft=image.css('border-left-width');bleft='';if(bordertop){for(i=0;i<3;i++){var x=[];x=bordertop.substr(i,1);if(isNaN(x)==false){btop=btop+''+bordertop.substr(i,1)}else{break}}}if(borderleft){for(i=0;i<3;i++){if(!isNaN(borderleft.substr(i,1))){bleft=bleft+borderleft.substr(i,1)}else{break}}}$obj.btop=(btop.length>0)?eval(btop):0;$obj.bleft=(bleft.length>0)?eval(bleft):0};this.fetchdata=function(){$obj.findborder();$obj.w=image.width();$obj.h=image.height();$obj.ow=image.outerWidth();$obj.oh=image.outerHeight();$obj.pos=image.offset();$obj.pos.l=image.offset().left+$obj.bleft;$obj.pos.t=image.offset().top+$obj.btop;$obj.pos.r=$obj.w+$obj.pos.l;$obj.pos.b=$obj.h+$obj.pos.t;$obj.rightlimit=image.offset().left+$obj.ow;$obj.bottomlimit=image.offset().top+$obj.oh};this.node.onerror=function(){alert('Problems while loading image.');throw'Problems while loading image.'};this.node.onload=function(){$obj.fetchdata();if($(".zoomPad",el).length==0)obj.create()};return $obj};function Loader(){var $obj=this;this.append=function(){this.node=$('<div/>').addClass('zoomPreload').css('visibility','hidden').html(settings.preloadText);$('.zoomPad',el).append(this.node)};this.show=function(){this.node.top=(smallimage.oh-this.node.height())/2;this.node.left=(smallimage.ow-this.node.width())/2;this.node.css({top:this.node.top,left:this.node.left,position:'absolute',visibility:'visible'})};this.hide=function(){this.node.css('visibility','hidden')};return this}function Lens(){var $obj=this;this.node=$('<div/>').addClass('zoomPup');this.append=function(){$('.zoomPad',el).append($(this.node).hide());if(settings.zoomType=='reverse'){this.image=new Image();this.image.src=smallimage.node.src;$(this.node).empty().append(this.image)}};this.setdimensions=function(){this.node.w=(parseInt((settings.zoomWidth)/el.scale.x)>smallimage.w)?smallimage.w:(parseInt(settings.zoomWidth/el.scale.x));this.node.h=(parseInt((settings.zoomHeight)/el.scale.y)>smallimage.h)?smallimage.h:(parseInt(settings.zoomHeight/el.scale.y));this.node.top=(smallimage.oh-this.node.h-2)/2;this.node.left=(smallimage.ow-this.node.w-2)/2;this.node.css({top:0,left:0,width:this.node.w+'px',height:this.node.h+'px',position:'absolute',display:'none',borderWidth:1+'px'});if(settings.zoomType=='reverse'){this.image.src=smallimage.node.src;$(this.node).css({'opacity':1});$(this.image).css({position:'absolute',display:'block',left:-(this.node.left+1-smallimage.bleft)+'px',top:-(this.node.top+1-smallimage.btop)+'px'})}};this.setcenter=function(){this.node.top=(smallimage.oh-this.node.h-2)/2;this.node.left=(smallimage.ow-this.node.w-2)/2;this.node.css({top:this.node.top,left:this.node.left});if(settings.zoomType=='reverse'){$(this.image).css({position:'absolute',display:'block',left:-(this.node.left+1-smallimage.bleft)+'px',top:-(this.node.top+1-smallimage.btop)+'px'})}largeimage.setposition()};this.setposition=function(e){el.mousepos.x=e.pageX;el.mousepos.y=e.pageY;var lensleft=0;var lenstop=0;function overleft(lens){return el.mousepos.x-(lens.w)/2<smallimage.pos.l}function overright(lens){return el.mousepos.x+(lens.w)/2>smallimage.pos.r}function overtop(lens){return el.mousepos.y-(lens.h)/2<smallimage.pos.t}function overbottom(lens){return el.mousepos.y+(lens.h)/2>smallimage.pos.b}lensleft=el.mousepos.x+smallimage.bleft-smallimage.pos.l-(this.node.w+2)/2;lenstop=el.mousepos.y+smallimage.btop-smallimage.pos.t-(this.node.h+2)/2;if(overleft(this.node)){lensleft=smallimage.bleft-1}else if(overright(this.node)){lensleft=smallimage.w+smallimage.bleft-this.node.w-1}if(overtop(this.node)){lenstop=smallimage.btop-1}else if(overbottom(this.node)){lenstop=smallimage.h+smallimage.btop-this.node.h-1}this.node.left=lensleft;this.node.top=lenstop;this.node.css({'left':lensleft+'px','top':lenstop+'px'});if(settings.zoomType=='reverse'){if($.browser.msie&&$.browser.version>7){$(this.node).empty().append(this.image)}$(this.image).css({position:'absolute',display:'block',left:-(this.node.left+1-smallimage.bleft)+'px',top:-(this.node.top+1-smallimage.btop)+'px'})}largeimage.setposition()};this.hide=function(){img.css({'opacity':1});this.node.hide()};this.show=function(){if(settings.zoomType!='innerzoom'&&(settings.lens||settings.zoomType=='drag')){this.node.show()}if(settings.zoomType=='reverse'){img.css({'opacity':settings.imageOpacity})}};this.getoffset=function(){var o={};o.left=$obj.node.left;o.top=$obj.node.top;return o};return this};function Stage(){var $obj=this;this.node=$("<div class='zoomWindow'><div class='zoomWrapper'><div class='zoomWrapperTitle'></div><div class='zoomWrapperImage'></div></div></div>");this.ieframe=$('<iframe class="zoomIframe" src="javascript:\'\';" marginwidth="0" marginheight="0" align="bottom" scrolling="no" frameborder="0" ></iframe>');this.setposition=function(){this.node.leftpos=0;this.node.toppos=0;if(settings.zoomType!='innerzoom'){switch(settings.position){case"left":this.node.leftpos=(smallimage.pos.l-smallimage.bleft-Math.abs(settings.xOffset)-settings.zoomWidth>0)?(0-settings.zoomWidth-Math.abs(settings.xOffset)):(smallimage.ow+Math.abs(settings.xOffset));this.node.toppos=Math.abs(settings.yOffset);break;case"top":this.node.leftpos=Math.abs(settings.xOffset);this.node.toppos=(smallimage.pos.t-smallimage.btop-Math.abs(settings.yOffset)-settings.zoomHeight>0)?(0-settings.zoomHeight-Math.abs(settings.yOffset)):(smallimage.oh+Math.abs(settings.yOffset));break;case"bottom":this.node.leftpos=Math.abs(settings.xOffset);this.node.toppos=(smallimage.pos.t-smallimage.btop+smallimage.oh+Math.abs(settings.yOffset)+settings.zoomHeight<screen.height)?(smallimage.oh+Math.abs(settings.yOffset)):(0-settings.zoomHeight-Math.abs(settings.yOffset));break;default:this.node.leftpos=(smallimage.rightlimit+Math.abs(settings.xOffset)+settings.zoomWidth<screen.width)?(smallimage.ow+Math.abs(settings.xOffset)):(0-settings.zoomWidth-Math.abs(settings.xOffset));this.node.toppos=Math.abs(settings.yOffset);break}}this.node.css({'left':this.node.leftpos+'px','top':this.node.toppos+'px'});return this};this.append=function(){$('.zoomPad',el).append(this.node);this.node.css({position:'absolute',display:'none',zIndex:5001});if(settings.zoomType=='innerzoom'){this.node.css({cursor:'default'});var thickness=(smallimage.bleft==0)?1:smallimage.bleft;$('.zoomWrapper',this.node).css({borderWidth:thickness+'px'})}$('.zoomWrapper',this.node).css({width:Math.round(settings.zoomWidth)+'px',borderWidth:thickness+'px'});$('.zoomWrapperImage',this.node).css({width:'100%',height:Math.round(settings.zoomHeight)+'px'});$('.zoomWrapperTitle',this.node).css({width:'100%',position:'absolute'});$('.zoomWrapperTitle',this.node).hide();if(settings.title&&zoomtitle.length>0){$('.zoomWrapperTitle',this.node).html(zoomtitle).show()}$obj.setposition()};this.hide=function(){switch(settings.hideEffect){case'fadeout':this.node.fadeOut(settings.fadeoutSpeed,function(){});break;default:this.node.hide();break}this.ieframe.hide()};this.show=function(){switch(settings.showEffect){case'fadein':this.node.fadeIn();this.node.fadeIn(settings.fadeinSpeed,function(){});break;default:this.node.show();break}if(isIE6&&settings.zoomType!='innerzoom'){this.ieframe.width=this.node.width();this.ieframe.height=this.node.height();this.ieframe.left=this.node.leftpos;this.ieframe.top=this.node.toppos;this.ieframe.css({display:'block',position:"absolute",left:this.ieframe.left,top:this.ieframe.top,zIndex:99,width:this.ieframe.width+'px',height:this.ieframe.height+'px'});$('.zoomPad',el).append(this.ieframe);this.ieframe.show()}}};function Largeimage(){var $obj=this;this.node=new Image();this.loadimage=function(url){loader.show();this.url=url;this.node.style.position='absolute';this.node.style.border='0px';this.node.style.display='none';this.node.style.left='-5000px';this.node.style.top='0px';document.body.appendChild(this.node);this.node.src=url};this.fetchdata=function(){var image=$(this.node);var scale={};this.node.style.display='block';$obj.w=image.width();$obj.h=image.height();$obj.pos=image.offset();$obj.pos.l=image.offset().left;$obj.pos.t=image.offset().top;$obj.pos.r=$obj.w+$obj.pos.l;$obj.pos.b=$obj.h+$obj.pos.t;scale.x=($obj.w/smallimage.w);scale.y=($obj.h/smallimage.h);el.scale=scale;document.body.removeChild(this.node);$('.zoomWrapperImage',el).empty().append(this.node);lens.setdimensions()};this.node.onerror=function(){alert('Problems while loading the big image.');throw'Problems while loading the big image.'};this.node.onload=function(){$obj.fetchdata();loader.hide();el.largeimageloading=false;el.largeimageloaded=true;if(settings.zoomType=='drag'||settings.alwaysOn){lens.show();stage.show();lens.setcenter()}};this.setposition=function(){var left=-el.scale.x*(lens.getoffset().left-smallimage.bleft+1);var top=-el.scale.y*(lens.getoffset().top-smallimage.btop+1);$(this.node).css({'left':left+'px','top':top+'px'})};return this};$(el).data("jqzoom",obj)};$.jqzoom={defaults:{zoomType:'standard',zoomWidth:300,zoomHeight:300,xOffset:10,yOffset:0,position:"right",preloadImages:true,preloadText:'Loading zoom',title:true,lens:true,imageOpacity:0.4,alwaysOn:false,showEffect:'show',hideEffect:'hide',fadeinSpeed:'slow',fadeoutSpeed:'2000'},disable:function(el){var api=$(el).data('jqzoom');api.disable();return false},enable:function(el){var api=$(el).data('jqzoom');api.enable();return false},disableAll:function(el){jqzoompluging_disabled=true},enableAll:function(el){jqzoompluging_disabled=false}}})(jQuery);

/**
 * http://github.com/valums/file-uploader
 *
 * Multiple file upload component with progress-bar, drag-and-drop.
 * © 2010 Andrew Valums ( andrew(at)valums.com )
 *
 * Licensed under GNU GPL 2 or later, see license.txt.
 */ 
var qq=qq||{};qq.extend=function(first,second){for(var prop in second){first[prop]=second[prop]}};qq.indexOf=function(arr,elt,from){if(arr.indexOf)return arr.indexOf(elt,from);from=from||0;var len=arr.length;if(from<0)from+=len;for(;from<len;from++){if(from in arr&&arr[from]===elt){return from}}return-1};qq.getUniqueId=(function(){var id=0;return function(){return id++}})();qq.attach=function(element,type,fn){if(element.addEventListener){element.addEventListener(type,fn,false)}else if(element.attachEvent){element.attachEvent('on'+type,fn)}};qq.detach=function(element,type,fn){if(element.removeEventListener){element.removeEventListener(type,fn,false)}else if(element.attachEvent){element.detachEvent('on'+type,fn)}};qq.preventDefault=function(e){if(e.preventDefault){e.preventDefault()}else{e.returnValue=false}};qq.insertBefore=function(a,b){b.parentNode.insertBefore(a,b)};qq.remove=function(element){element.parentNode.removeChild(element)};qq.contains=function(parent,descendant){if(parent==descendant)return true;if(parent.contains){return parent.contains(descendant)}else{return!!(descendant.compareDocumentPosition(parent)&8)}};qq.toElement=(function(){var div=document.createElement('div');return function(html){div.innerHTML=html;var element=div.firstChild;div.removeChild(element);return element}})();qq.css=function(element,styles){if(styles.opacity!=null){if(typeof element.style.opacity!='string'&&typeof(element.filters)!='undefined'){styles.filter='alpha(opacity='+Math.round(100*styles.opacity)+')'}}qq.extend(element.style,styles)};qq.hasClass=function(element,name){var re=new RegExp('(^| )'+name+'( |$)');return re.test(element.className)};qq.addClass=function(element,name){if(!qq.hasClass(element,name)){element.className+=' '+name}};qq.removeClass=function(element,name){var re=new RegExp('(^| )'+name+'( |$)');element.className=element.className.replace(re,' ').replace(/^\s+|\s+$/g,"")};qq.setText=function(element,text){element.innerText=text;element.textContent=text};qq.children=function(element){var children=[],child=element.firstChild;while(child){if(child.nodeType==1){children.push(child)}child=child.nextSibling}return children};qq.getByClass=function(element,className){if(element.querySelectorAll){return element.querySelectorAll('.'+className)}var result=[];var candidates=element.getElementsByTagName("*");var len=candidates.length;for(var i=0;i<len;i++){if(qq.hasClass(candidates[i],className)){result.push(candidates[i])}}return result};qq.obj2url=function(obj,temp,prefixDone){var uristrings=[],prefix='&',add=function(nextObj,i){var nextTemp=temp?(/\[\]$/.test(temp))?temp:temp+'['+i+']':i;if((nextTemp!='undefined')&&(i!='undefined')){uristrings.push((typeof nextObj==='object')?qq.obj2url(nextObj,nextTemp,true):(Object.prototype.toString.call(nextObj)==='[object Function]')?encodeURIComponent(nextTemp)+'='+encodeURIComponent(nextObj()):encodeURIComponent(nextTemp)+'='+encodeURIComponent(nextObj))}};if(!prefixDone&&temp){prefix=(/\?/.test(temp))?(/\?$/.test(temp))?'':'&':'?';uristrings.push(temp);uristrings.push(qq.obj2url(obj))}else if((Object.prototype.toString.call(obj)==='[object Array]')&&(typeof obj!='undefined')){for(var i=0,len=obj.length;i<len;++i){add(obj[i],i)}}else if((typeof obj!='undefined')&&(obj!==null)&&(typeof obj==="object")){for(var i in obj){add(obj[i],i)}}else{uristrings.push(encodeURIComponent(temp)+'='+encodeURIComponent(obj))}return uristrings.join(prefix).replace(/^&/,'').replace(/%20/g,'+')};var qq=qq||{};qq.FileUploaderBasic=function(o){this._options={debug:false,action:'/server/upload',params:{},button:null,multiple:true,maxConnections:3,allowedExtensions:[],sizeLimit:0,minSizeLimit:0,onSubmit:function(id,fileName){},onProgress:function(id,fileName,loaded,total){},onComplete:function(id,fileName,responseJSON){},onCancel:function(id,fileName){},messages:{typeError:"{file} has invalid extension. Only {extensions} are allowed.",sizeError:"{file} is too large, maximum file size is {sizeLimit}.",minSizeError:"{file} is too small, minimum file size is {minSizeLimit}.",emptyError:"{file} is empty, please select files again without it.",onLeave:"The files are being uploaded, if you leave now the upload will be cancelled."},showMessage:function(message){alert(message)}};qq.extend(this._options,o);this._filesInProgress=0;this._handler=this._createUploadHandler();if(this._options.button){this._button=this._createUploadButton(this._options.button)}this._preventLeaveInProgress()};qq.FileUploaderBasic.prototype={setParams:function(params){this._options.params=params},getInProgress:function(){return this._filesInProgress},_createUploadButton:function(element){var self=this;return new qq.UploadButton({element:element,multiple:this._options.multiple&&qq.UploadHandlerXhr.isSupported(),onChange:function(input){self._onInputChange(input)}})},_createUploadHandler:function(){var self=this,handlerClass;if(qq.UploadHandlerXhr.isSupported()){handlerClass='UploadHandlerXhr'}else{handlerClass='UploadHandlerForm'}var handler=new qq[handlerClass]({debug:this._options.debug,action:this._options.action,maxConnections:this._options.maxConnections,onProgress:function(id,fileName,loaded,total){self._onProgress(id,fileName,loaded,total);self._options.onProgress(id,fileName,loaded,total)},onComplete:function(id,fileName,result){self._onComplete(id,fileName,result);self._options.onComplete(id,fileName,result)},onCancel:function(id,fileName){self._onCancel(id,fileName);self._options.onCancel(id,fileName)}});return handler},_preventLeaveInProgress:function(){var self=this;qq.attach(window,'beforeunload',function(e){if(!self._filesInProgress){return}var e=e||window.event;e.returnValue=self._options.messages.onLeave;return self._options.messages.onLeave})},_onSubmit:function(id,fileName){this._filesInProgress++},_onProgress:function(id,fileName,loaded,total){},_onComplete:function(id,fileName,result){this._filesInProgress--;if(result.error){this._options.showMessage(result.error)}},_onCancel:function(id,fileName){this._filesInProgress--},_onInputChange:function(input){if(this._handler instanceof qq.UploadHandlerXhr){this._uploadFileList(input.files)}else{if(this._validateFile(input)){this._uploadFile(input)}}this._button.reset()},_uploadFileList:function(files){for(var i=0;i<files.length;i++){if(!this._validateFile(files[i])){return}}for(var i=0;i<files.length;i++){this._uploadFile(files[i])}},_uploadFile:function(fileContainer){var id=this._handler.add(fileContainer);var fileName=this._handler.getName(id);if(this._options.onSubmit(id,fileName)!==false){this._onSubmit(id,fileName);this._handler.upload(id,this._options.params)}},_validateFile:function(file){var name,size;if(file.value){name=file.value.replace(/.*(\/|\\)/,"")}else{name=file.fileName!=null?file.fileName:file.name;size=file.fileSize!=null?file.fileSize:file.size}if(!this._isAllowedExtension(name)){this._error('typeError',name);return false}else if(size===0){this._error('emptyError',name);return false}else if(size&&this._options.sizeLimit&&size>this._options.sizeLimit){this._error('sizeError',name);return false}else if(size&&size<this._options.minSizeLimit){this._error('minSizeError',name);return false}return true},_error:function(code,fileName){var message=this._options.messages[code];function r(name,replacement){message=message.replace(name,replacement)}r('{file}',this._formatFileName(fileName));r('{extensions}',this._options.allowedExtensions.join(', '));r('{sizeLimit}',this._formatSize(this._options.sizeLimit));r('{minSizeLimit}',this._formatSize(this._options.minSizeLimit));this._options.showMessage(message)},_formatFileName:function(name){if(name.length>33){name=name.slice(0,19)+'...'+name.slice(-13)}return name},_isAllowedExtension:function(fileName){var ext=(-1!==fileName.indexOf('.'))?fileName.replace(/.*[.]/,'').toLowerCase():'';var allowed=this._options.allowedExtensions;if(!allowed.length){return true}for(var i=0;i<allowed.length;i++){if(allowed[i].toLowerCase()==ext){return true}}return false},_formatSize:function(bytes){var i=-1;do{bytes=bytes/1024;i++}while(bytes>99);return Math.max(bytes,0.1).toFixed(1)+['kB','MB','GB','TB','PB','EB'][i]}};qq.FileUploader=function(o){qq.FileUploaderBasic.apply(this,arguments);qq.extend(this._options,{element:null,listElement:null,template:'<div class="qq-uploader">'+'<div class="qq-upload-drop-area"><span>Drop files here to upload</span></div>'+'<div class="qq-upload-button">Dodaj zdjęcia</div>'+'<ul class="qq-upload-list"></ul>'+'</div>',fileTemplate:'<li>'+'<span class="qq-upload-file"></span>'+'<span class="qq-upload-spinner"></span>'+'<span class="qq-upload-size"></span>'+'<a class="qq-upload-cancel" href="#">Cancel</a>'+'<span class="qq-upload-failed-text">Failed</span>'+'</li>',classes:{button:'qq-upload-button',drop:'qq-upload-drop-area',dropActive:'qq-upload-drop-area-active',list:'qq-upload-list',file:'qq-upload-file',spinner:'qq-upload-spinner',size:'qq-upload-size',cancel:'qq-upload-cancel',success:'qq-upload-success',fail:'qq-upload-fail'}});qq.extend(this._options,o);this._element=this._options.element;this._element.innerHTML=this._options.template;this._listElement=this._options.listElement||this._find(this._element,'list');this._classes=this._options.classes;this._button=this._createUploadButton(this._find(this._element,'button'));this._bindCancelEvent();this._setupDragDrop()};qq.extend(qq.FileUploader.prototype,qq.FileUploaderBasic.prototype);qq.extend(qq.FileUploader.prototype,{_find:function(parent,type){var element=qq.getByClass(parent,this._options.classes[type])[0];if(!element){throw new Error('element not found '+type)}return element},_setupDragDrop:function(){var self=this,dropArea=this._find(this._element,'drop');var dz=new qq.UploadDropZone({element:dropArea,onEnter:function(e){qq.addClass(dropArea,self._classes.dropActive);e.stopPropagation()},onLeave:function(e){e.stopPropagation()},onLeaveNotDescendants:function(e){qq.removeClass(dropArea,self._classes.dropActive)},onDrop:function(e){dropArea.style.display='none';qq.removeClass(dropArea,self._classes.dropActive);self._uploadFileList(e.dataTransfer.files)}});dropArea.style.display='none';qq.attach(document,'dragenter',function(e){if(!dz._isValidFileDrag(e))return;dropArea.style.display='block'});qq.attach(document,'dragleave',function(e){if(!dz._isValidFileDrag(e))return;var relatedTarget=document.elementFromPoint(e.clientX,e.clientY);if(!relatedTarget||relatedTarget.nodeName=="HTML"){dropArea.style.display='none'}})},_onSubmit:function(id,fileName){qq.FileUploaderBasic.prototype._onSubmit.apply(this,arguments);this._addToList(id,fileName)},_onProgress:function(id,fileName,loaded,total){qq.FileUploaderBasic.prototype._onProgress.apply(this,arguments);var item=this._getItemByFileId(id);var size=this._find(item,'size');size.style.display='inline';var text;if(loaded!=total){text=Math.round(loaded/total*100)+'% from '+this._formatSize(total)}else{text=this._formatSize(total)}qq.setText(size,text)},_onComplete:function(id,fileName,result){qq.FileUploaderBasic.prototype._onComplete.apply(this,arguments);var item=this._getItemByFileId(id);qq.remove(this._find(item,'cancel'));qq.remove(this._find(item,'spinner'));if(result.success){qq.addClass(item,this._classes.success)}else{qq.addClass(item,this._classes.fail)}},_addToList:function(id,fileName){var item=qq.toElement(this._options.fileTemplate);item.qqFileId=id;var fileElement=this._find(item,'file');qq.setText(fileElement,this._formatFileName(fileName));this._find(item,'size').style.display='none';this._listElement.appendChild(item)},_getItemByFileId:function(id){var item=this._listElement.firstChild;while(item){if(item.qqFileId==id)return item;item=item.nextSibling}},_bindCancelEvent:function(){var self=this,list=this._listElement;qq.attach(list,'click',function(e){e=e||window.event;var target=e.target||e.srcElement;if(qq.hasClass(target,self._classes.cancel)){qq.preventDefault(e);var item=target.parentNode;self._handler.cancel(item.qqFileId);qq.remove(item)}})}});qq.UploadDropZone=function(o){this._options={element:null,onEnter:function(e){},onLeave:function(e){},onLeaveNotDescendants:function(e){},onDrop:function(e){}};qq.extend(this._options,o);this._element=this._options.element;this._disableDropOutside();this._attachEvents()};qq.UploadDropZone.prototype={_disableDropOutside:function(e){if(!qq.UploadDropZone.dropOutsideDisabled){qq.attach(document,'dragover',function(e){if(e.dataTransfer){e.dataTransfer.dropEffect='none';e.preventDefault()}});qq.UploadDropZone.dropOutsideDisabled=true}},_attachEvents:function(){var self=this;qq.attach(self._element,'dragover',function(e){if(!self._isValidFileDrag(e))return;var effect=e.dataTransfer.effectAllowed;if(effect=='move'||effect=='linkMove'){e.dataTransfer.dropEffect='move'}else{e.dataTransfer.dropEffect='copy'}e.stopPropagation();e.preventDefault()});qq.attach(self._element,'dragenter',function(e){if(!self._isValidFileDrag(e))return;self._options.onEnter(e)});qq.attach(self._element,'dragleave',function(e){if(!self._isValidFileDrag(e))return;self._options.onLeave(e);var relatedTarget=document.elementFromPoint(e.clientX,e.clientY);if(qq.contains(this,relatedTarget))return;self._options.onLeaveNotDescendants(e)});qq.attach(self._element,'drop',function(e){if(!self._isValidFileDrag(e))return;e.preventDefault();self._options.onDrop(e)})},_isValidFileDrag:function(e){var dt=e.dataTransfer,isWebkit=navigator.userAgent.indexOf("AppleWebKit")>-1;return dt&&dt.effectAllowed!='none'&&(dt.files||(!isWebkit&&dt.types.contains&&dt.types.contains('Files')))}};qq.UploadButton=function(o){this._options={element:null,multiple:false,name:'file',onChange:function(input){},hoverClass:'qq-upload-button-hover',focusClass:'qq-upload-button-focus'};qq.extend(this._options,o);this._element=this._options.element;qq.css(this._element,{position:'relative',overflow:'hidden',direction:'ltr'});this._input=this._createInput()};qq.UploadButton.prototype={getInput:function(){return this._input},reset:function(){if(this._input.parentNode){qq.remove(this._input)}qq.removeClass(this._element,this._options.focusClass);this._input=this._createInput()},_createInput:function(){var input=document.createElement("input");if(this._options.multiple){input.setAttribute("multiple","multiple")}input.setAttribute("type","file");input.setAttribute("name",this._options.name);qq.css(input,{position:'absolute',right:0,top:0,fontFamily:'Arial',fontSize:'118px',margin:0,padding:0,cursor:'pointer',opacity:0});this._element.appendChild(input);var self=this;qq.attach(input,'change',function(){self._options.onChange(input)});qq.attach(input,'mouseover',function(){qq.addClass(self._element,self._options.hoverClass)});qq.attach(input,'mouseout',function(){qq.removeClass(self._element,self._options.hoverClass)});qq.attach(input,'focus',function(){qq.addClass(self._element,self._options.focusClass)});qq.attach(input,'blur',function(){qq.removeClass(self._element,self._options.focusClass)});if(window.attachEvent){input.setAttribute('tabIndex',"-1")}return input}};qq.UploadHandlerAbstract=function(o){this._options={debug:false,action:'/upload.php',maxConnections:999,onProgress:function(id,fileName,loaded,total){},onComplete:function(id,fileName,response){},onCancel:function(id,fileName){}};qq.extend(this._options,o);this._queue=[];this._params=[]};qq.UploadHandlerAbstract.prototype={log:function(str){if(this._options.debug&&window.console)console.log('[uploader] '+str)},add:function(file){},upload:function(id,params){var len=this._queue.push(id);var copy={};qq.extend(copy,params);this._params[id]=copy;if(len<=this._options.maxConnections){this._upload(id,this._params[id])}},cancel:function(id){this._cancel(id);this._dequeue(id)},cancelAll:function(){for(var i=0;i<this._queue.length;i++){this._cancel(this._queue[i])}this._queue=[]},getName:function(id){},getSize:function(id){},getQueue:function(){return this._queue},_upload:function(id){},_cancel:function(id){},_dequeue:function(id){var i=qq.indexOf(this._queue,id);this._queue.splice(i,1);var max=this._options.maxConnections;if(this._queue.length>=max&&i<max){var nextId=this._queue[max-1];this._upload(nextId,this._params[nextId])}}};qq.UploadHandlerForm=function(o){qq.UploadHandlerAbstract.apply(this,arguments);this._inputs={}};qq.extend(qq.UploadHandlerForm.prototype,qq.UploadHandlerAbstract.prototype);qq.extend(qq.UploadHandlerForm.prototype,{add:function(fileInput){fileInput.setAttribute('name','qqfile');var id='qq-upload-handler-iframe'+qq.getUniqueId();this._inputs[id]=fileInput;if(fileInput.parentNode){qq.remove(fileInput)}return id},getName:function(id){return this._inputs[id].value.replace(/.*(\/|\\)/,"")},_cancel:function(id){this._options.onCancel(id,this.getName(id));delete this._inputs[id];var iframe=document.getElementById(id);if(iframe){iframe.setAttribute('src','javascript:false;');qq.remove(iframe)}},_upload:function(id,params){var input=this._inputs[id];if(!input){throw new Error('file with passed id was not added, or already uploaded or cancelled')}var fileName=this.getName(id);var iframe=this._createIframe(id);var form=this._createForm(iframe,params);form.appendChild(input);var self=this;this._attachLoadEvent(iframe,function(){self.log('iframe loaded');var response=self._getIframeContentJSON(iframe);self._options.onComplete(id,fileName,response);self._dequeue(id);delete self._inputs[id];setTimeout(function(){qq.remove(iframe)},1)});form.submit();qq.remove(form);return id},_attachLoadEvent:function(iframe,callback){qq.attach(iframe,'load',function(){if(!iframe.parentNode){return}if(iframe.contentDocument&&iframe.contentDocument.body&&iframe.contentDocument.body.innerHTML=="false"){return}callback()})},_getIframeContentJSON:function(iframe){var doc=iframe.contentDocument?iframe.contentDocument:iframe.contentWindow.document,response;this.log("converting iframe's innerHTML to JSON");this.log("innerHTML = "+doc.body.innerHTML);try{response=eval("("+doc.body.innerHTML+")")}catch(err){response={}}return response},_createIframe:function(id){var iframe=qq.toElement('<iframe src="javascript:false;" name="'+id+'" />');iframe.setAttribute('id',id);iframe.style.display='none';document.body.appendChild(iframe);return iframe},_createForm:function(iframe,params){var form=qq.toElement('<form method="post" enctype="multipart/form-data"></form>');var queryString=qq.obj2url(params,this._options.action);form.setAttribute('action',queryString);form.setAttribute('target',iframe.name);form.style.display='none';document.body.appendChild(form);return form}});qq.UploadHandlerXhr=function(o){qq.UploadHandlerAbstract.apply(this,arguments);this._files=[];this._xhrs=[];this._loaded=[]};qq.UploadHandlerXhr.isSupported=function(){var input=document.createElement('input');input.type='file';return('multiple'in input&&typeof File!="undefined"&&typeof(new XMLHttpRequest()).upload!="undefined")};qq.extend(qq.UploadHandlerXhr.prototype,qq.UploadHandlerAbstract.prototype);qq.extend(qq.UploadHandlerXhr.prototype,{add:function(file){if(!(file instanceof File)){throw new Error('Passed obj in not a File (in qq.UploadHandlerXhr)')}return this._files.push(file)-1},getName:function(id){var file=this._files[id];return file.fileName!=null?file.fileName:file.name},getSize:function(id){var file=this._files[id];return file.fileSize!=null?file.fileSize:file.size},getLoaded:function(id){return this._loaded[id]||0},_upload:function(id,params){var file=this._files[id],name=this.getName(id),size=this.getSize(id);this._loaded[id]=0;var xhr=this._xhrs[id]=new XMLHttpRequest();var self=this;xhr.upload.onprogress=function(e){if(e.lengthComputable){self._loaded[id]=e.loaded;self._options.onProgress(id,name,e.loaded,e.total)}};xhr.onreadystatechange=function(){if(xhr.readyState==4){self._onComplete(id,xhr)}};params=params||{};params['qqfile']=name;var queryString=qq.obj2url(params,this._options.action);xhr.open("POST",queryString,true);xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("X-File-Name",encodeURIComponent(name));xhr.setRequestHeader("Content-Type","application/octet-stream");xhr.send(file)},_onComplete:function(id,xhr){if(!this._files[id])return;var name=this.getName(id);var size=this.getSize(id);this._options.onProgress(id,name,size,size);if(xhr.status==200){this.log("xhr - server response received");this.log("responseText = "+xhr.responseText);var response;try{response=eval("("+xhr.responseText+")")}catch(err){response={}}this._options.onComplete(id,name,response)}else{this._options.onComplete(id,name,{})}this._files[id]=null;this._xhrs[id]=null;this._dequeue(id)},_cancel:function(id){this._options.onCancel(id,this.getName(id));this._files[id]=null;if(this._xhrs[id]){this._xhrs[id].abort();this._xhrs[id]=null}}});

/**
 * jquery multiSelect
 */
(function($){$.fn.multiSelect=function(options){var opts=$.extend({debug:false,wrapperClass:'ms-wrapper',containerClass:'ms-container',nodeClass:'ms-container-node',removeClass:'ms-remove',loadingClass:'ms-loading'},options);function log(){if(opts.debug&&this.console)console.log(Array.prototype.slice.call(arguments))}function initMultiSelect(){var $$=$(this),$container=$('<ul />',{'class':opts.containerClass}),$textInput=$('<input />',{name:$$.attr('name')+'-ms-input',type:'text','class':'ms-input'}),$loading=$('<span />',{'class':opts.loadingClass});var values=[];function uncheckNode($node){var $option=$node.parent().prev('select').find('option[value="'+$node.data('value')+'"]');values.push({id:$node.data('value'),value:$option.html()});$textInput.autocomplete('option','source',values);$option.removeAttr('selected');$node.remove()}function createNodeValue(value,label){var $node=$('<li />',{'class':opts.nodeClass}).data('value',value);$node.append('<span>'+label+'</span><a href="#" class="'+opts.removeClass+'">remove</a>');$node.find('.'+opts.removeClass).click(function(e){e.preventDefault();uncheckNode($(this).parent())});return $node}function loadValues($multi){var $container=$multi.next('.'+opts.containerClass);$multi.find('option:selected').each(function(){$container.append(createNodeValue($(this).attr('value'),$(this).html()))});$multi.find('option').not(':selected').each(function(){values.push({id:$(this).attr('value'),value:$(this).html()})})}$container.insertAfter($$.hide().wrap($('<div />',{'class':opts.wrapperClass}))).parent().append($textInput).append($loading);loadValues($$);$textInput.autocomplete({source:values,select:function(e,ui){values=$.grep(values,function(el,i){return el.id!=ui.item.id});$container.append(createNodeValue(ui.item.id,ui.item.value));$$.find('option[value="'+ui.item.id+'"]').attr('selected','selected');$(this).val('').autocomplete('option','source',values);e.preventDefault()}})}return $(this).each(initMultiSelect)}})(jQuery);
