$(function(){
	initGall();
	addClass({
		tagName:'div',
		tagClass:'div-class',
		classAdd:'div-add-class'
	})
	addClass({
		tagName:'a',
		tagClass:'open-class',
		classAdd:'inner-row',
		addToParent:true
	})
	initPopup({
		openEvent:'click'
	});
	initPopup({
		popupHolderClass:'popup-hover'
	});
	initCustomForms();
	clearInputs();
	initWysiwyg();
	initCustomFile();
	initSlider();
	initDatepicker();
	initRemoveBox();
});

// IE 6 hover plugin
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('9 u=k(){9 g=/^([^#.>`]*)(#|\\.|\\>|\\`)(.+)$/;k u(a,b){9 c=a.J(/\\s*\\,\\s*/);9 d=[];n(9 i=0;i<c.l;i++){d=d.v(o(c[i],b))};6 d};k o(a,b,c){a=a.z(" ","`");9 d=a.r(g);9 e,5,m,7,i,h;9 f=[];4(d==8){d=[a,a]};4(d[1]==""){d[1]="*"};4(c==8){c="`"};4(b==8){b=E};K(d[2]){w"#":7=d[3].r(g);4(7==8){7=[8,d[3]]};e=E.L(7[1]);4(e==8||(d[1]!="*"&&!x(e,d[1]))){6 f};4(7.l==2){f.A(e);6 f};6 o(7[3],e,7[2]);w".":4(c!=">"){5=p(b,d[1])}y{5=b.B};n(i=0,h=5.l;i<h;i++){e=5[i];4(e.C!=1){q};7=d[3].r(g);4(7!=8){4(e.j==8||e.j.r("(\\\\s|^)"+7[1]+"(\\\\s|$)")==8){q};m=o(7[3],e,7[2]);f=f.v(m)}y 4(e.j!=8&&e.j.r("(\\\\s|^)"+d[3]+"(\\\\s|$)")!=8){f.A(e)}};6 f;w">":4(c!=">"){5=p(b,d[1])}y{5=b.B};n(i=0,h=5.l;i<h;i++){e=5[i];4(e.C!=1){q};4(!x(e,d[1])){q};m=o(d[3],e,">");f=f.v(m)};6 f;w"`":5=p(b,d[1]);n(i=0,h=5.l;i<h;i++){e=5[i];m=o(d[3],e,"`");f=f.v(m)};6 f;M:4(c!=">"){5=p(b,d[1])}y{5=b.B};n(i=0,h=5.l;i<h;i++){e=5[i];4(e.C!=1){q};4(!x(e,d[1])){q};f.A(e)};6 f}};k p(a,b){4(b=="*"&&a.F!=8){6 a.F};6 a.p(b)};k x(a,b){4(b=="*"){6 N};6 a.O.G().z("P:","")==b.G()};6 u}();k Q(a,b){9 c=u(a);n(9 i=0;i<c.l;i++){c[i].R=k(){4(t.j.H(b)==-1){t.j+=" "+b}};c[i].S=k(){4(t.j.H(b)!=-1){t.j=t.j.z(b,"")}}}}4(D.I&&!D.T){D.I("U",V)}',58,58,'||||if|listNodes|return|subselector|null|var||||||||limit||className|function|length|listSubNodes|for|doParse|getElementsByTagName|continue|match||this|parseSelector|concat|case|matchNodeNames|else|replace|push|childNodes|nodeType|window|document|all|toLowerCase|indexOf|attachEvent|split|switch|getElementById|default|true|nodeName|html|hoverForIE6|onmouseover|onmouseout|opera|onload|ieHover'.split('|'),0,{}))
/*parametrs [selector, hover_class]*/
function ieHover() {
	hoverForIE6('.btnbig', 'btnbig-hover');
	hoverForIE6('.btnnorm', 'btnnorm-hover');
	hoverForIE6('.btnsmall', 'btnsmall-hover');
}

// init slider
function initSlider(){
	jQuery( "div.scale1" ).each(function(){
		var hold = jQuery(this),
			slider = hold.find('div.scale');
		slider.slider({
			range: "min",
			value: 50,
			min: 1,
			max: 100
		});
	});
	jQuery( "div.scale2" ).each(function(){
		var hold = jQuery(this),
			slider = hold.find('div.scale'),
			amount = hold.find('em.amount');
		slider.slider({
			range: "min",
			value: 2,
			min: 0,
			max: 9,
			slide: function( event, ui ) {
				amount.html(ui.value );
			}
		});
		amount.html(slider.slider( "value" ));
	})
	jQuery( "div.scale3" ).each(function(){
		var hold = jQuery(this),
			slider = hold.find('div.scale'),
			amount = hold.find('em.amount');
		slider.slider({
			range: true,
			min: 0,
			max: 9,
			values: [ 2, 5 ],
			slide: function( event, ui ) {
				amount.html(ui.values[ 0 ] + " - " + ui.values[ 1 ]);
			}
		});
		amount.html(slider.slider( "values", 0 ) + " - " + slider.slider( "values", 1 ));
	})
}

// init remove box
function initRemoveBox(){
	jQuery('div.message').each(function(){
		var hold = jQuery(this),
			close = hold.find('a.close');
		close.click(function(){
			hold.fadeOut('slow', function() {hold.remove();});
			return false;
		});
	})
}

// init datepicker
function initDatepicker(){
	var focusClass = 'focus';
	jQuery('div.calendar').each(function(){
		var hold = jQuery(this),
			input = hold.find('input.datepicker'),
			img = hold.find('img');
		
		img.click(function(){
			input.trigger('focus');
			return false;
		});
		input.date_input();
		var datepicker = hold.find('.date_selector');
		datepicker.click(function(){
			return false;
		});
		input.bind('focus', function(){
			input.addClass(focusClass);
		}).bind('blur', function(){
			input.removeClass(focusClass);
		});
	});
}

// init custom file
function initCustomFile() {
	var inputs = document.getElementsByTagName('input');
	for (var i= 0; i < inputs.length; i++) {
		if(inputs[i].className.indexOf('file-input-area') != -1) {
			new customFileUpload(inputs[i]);
		}
	}
}
// custom file input module
function customFileUpload(obj, opt) {
	if(obj) {
		this.options = {
			jsActiveClass:'file-input-js-active',
			fakeClass:'file-input-value',
			hoverClass:'hover'
		}
		this.fileInput = obj;
		this.fileInput.custClass = this;
		this.init();
	}
}
customFileUpload.prototype = {
	init: function() {
		this.getElements();
		this.setStyles();
		this.addEvents();
	},
	getElements: function() {
		this.fileInputParent = this.fileInput.parentNode;
		this.fileInputParent.className += ' ' + this.options.jsActiveClass;
		var tmpInputs = this.fileInput.parentNode.getElementsByTagName('input');
		for(var i = 0; i < tmpInputs.length; i++) {
			if(tmpInputs[i].className.indexOf(this.options.fakeClass) != -1) {
				this.fakeInput = tmpInputs[i];
				this.fakeInput.readOnly = true;
				break;
			}
		}
	},
	getFileName: function(){
		return this.fileInput.value.replace(/^[\s\S]*(?:\\|\/)([\s\S^\\\/]*)$/g, "$1");
	},
	setStyles: function() {
		// IE styling fix
		if((/(MSIE)/gi).test(navigator.userAgent)) {
			this.tmpNode = document.createElement('span');
			this.fileInputParent.insertBefore(this.tmpNode,this.fileInput);
			this.fileInputParent.insertBefore(this.fileInput,this.tmpNode);
			this.fileInputParent.removeChild(this.tmpNode);
		}
		this.fileInput.style.opacity = 0;
		this.fileInput.style.filter = 'alpha(opacity=0)';
	},
	addEvents: function() {
		this.fileInput.onchange = this.bind(this.updateTitle,this);
		this.fileInput.onmouseover = this.bind(function(){
			this.fileInputParent.className += ' ' + this.options.hoverClass;
		},this);
		this.fileInput.onmouseout = this.bind(function(){
			this.fileInputParent.className = this.fileInputParent.className.replace(' '+this.options.hoverClass,'');
		},this);
	},
	updateTitle: function() {
		if(this.fakeInput) {
			this.fakeInput.value = this.getFileName();
		}
	},
	bind: function(func, scope) {
		return function() {
			return func.apply(scope, arguments);
		}
	}
}

// clear inputs
function clearInputs(){
	clearFormFields({
		clearInputs: false,
		clearTextareas: false,
		passwordFieldText: false,
		addClassFocus: "focus",
		filterClass: "default"
	});
}
function clearFormFields(o)
{
	if (o.clearInputs == null) o.clearInputs = true;
	if (o.clearTextareas == null) o.clearTextareas = true;
	if (o.passwordFieldText == null) o.passwordFieldText = false;
	if (o.addClassFocus == null) o.addClassFocus = false;
	if (o.activeClass == null) o.activeClass = 'active-text';
	if (!o.filterClass) o.filterClass = "default";
	if (o.addClass == null) o.addClass = true;
	if (o.addClass) {
		var inputs = document.getElementsByTagName("input");
		for (var i = 0; i < inputs.length; i++ ) {
			if((inputs[i].type == "text" || inputs[i].type == "password") && inputs[i].className.indexOf(o.filterClass) == -1) {
				if(o.clearInputs) inputs[i].valueHtml = inputs[i].value;
				inputs[i].onfocus = function ()	{
					if(o.clearInputs) if(this.valueHtml == this.value) this.value = "";
					if(this.fake) {
						inputsSwap(this, this.previousSibling);
						this.previousSibling.focus();
					}
					if(o.addClassFocus && !this.fake) {
						this.className += " " + o.addClassFocus;
						this.parentNode.className += " parent-" + o.addClassFocus;
					}
				}
				inputs[i].onblur = function () {
					if(this.value == "") {
						if(o.clearInputs) this.value = this.valueHtml;
						if(o.passwordFieldText && this.type == "password") inputsSwap(this, this.nextSibling);
					}
					else{
						if(this.className.indexOf(o.activeClass) == -1){
							this.className += " " + o.activeClass;
						}
					}
					if(o.addClassFocus) {
						this.className = this.className.replace(o.addClassFocus, "");
						this.parentNode.className = this.parentNode.className.replace("parent-"+o.addClassFocus, "");
					}
				}
				if(o.passwordFieldText && inputs[i].type == "password") {
					var fakeInput = document.createElement("input");
					fakeInput.type = "text";
					if(o.clearInputs) fakeInput.value = inputs[i].value;
					fakeInput.className = inputs[i].className;
					fakeInput.fake = true;
					inputs[i].parentNode.insertBefore(fakeInput, inputs[i].nextSibling);
					inputsSwap(inputs[i], null);
				}
			}
		}
	}
	if(o.clearTextareas) {
		var textareas = document.getElementsByTagName("textarea");
		for(var i=0; i<textareas.length; i++) {
			if(textareas[i].className.indexOf(o.filterClass) == -1) {
				if(o.clearInputs) textareas[i].valueHtml = textareas[i].value;
				textareas[i].onfocus = function() {
					if(o.clearInputs) if(this.value == this.valueHtml) this.value = "";
					if(o.addClassFocus) {
						this.className += " " + o.addClassFocus;
						this.parentNode.className += " parent-" + o.addClassFocus;
					}
				}
				textareas[i].onblur = function() {
					if(o.clearInputs) if(this.value == "") this.value = this.valueHtml;
					if(o.addClassFocus) {
						this.className = this.className.replace(o.addClassFocus, "");
						this.parentNode.className = this.parentNode.className.replace("parent-"+o.addClassFocus, "");
					}
				}
			}
		}
	}
	function inputsSwap(el, el2) {
		if(el) el.style.display = "none";
		if(el2) el2.style.display = "inline";
	}
}

// custom forms init
function initCustomForms() {
	jQuery('select').customSelect();
	jQuery('input:radio').customRadio();
	jQuery('input:checkbox').customCheckbox();
}
// custom forms plugin
(function(jQuery){
	// custom checkboxes module
	jQuery.fn.customCheckbox = function(_options){
		var _options = jQuery.extend({
			checkboxStructure: '<div></div>',
			checkboxDisabled: 'disabled',
			checkboxDefault: 'checkboxArea',
			checkboxChecked: 'checkboxAreaChecked'
		}, _options);
		return this.each(function(){
			var checkbox = jQuery(this);
			if(!checkbox.hasClass('outtaHere') && checkbox.is(':checkbox')){
				var replaced = jQuery(_options.checkboxStructure);
				this._replaced = replaced;
				if(checkbox.is(':disabled')) replaced.addClass(_options.checkboxDisabled);
				else if(checkbox.is(':checked')) replaced.addClass(_options.checkboxChecked);
				else replaced.addClass(_options.checkboxDefault);

				replaced.click(function(){
					if(checkbox.is(':checked')) checkbox.removeAttr('checked');
					else checkbox.attr('checked', 'checked');
					changeCheckbox(checkbox);
				});
				checkbox.click(function(){
					changeCheckbox(checkbox);
				});
				replaced.insertBefore(checkbox);
				checkbox.addClass('outtaHere');
			}
		});
		function changeCheckbox(_this){
			_this.change();
			if(_this.is(':checked')) _this.get(0)._replaced.removeClass().addClass(_options.checkboxChecked);
			else _this.get(0)._replaced.removeClass().addClass(_options.checkboxDefault);
		}
	}

	// custom radios module
	jQuery.fn.customRadio = function(_options){
		var _options = jQuery.extend({
			radioStructure: '<div></div>',
			radioDisabled: 'disabled',
			radioDefault: 'radioArea',
			radioChecked: 'radioAreaChecked'
		}, _options);
		return this.each(function(){
			var radio = jQuery(this);
			if(!radio.hasClass('outtaHere') && radio.is(':radio')){
				var replaced = jQuery(_options.radioStructure);
				this._replaced = replaced;
				if(radio.is(':disabled')) replaced.addClass(_options.radioDisabled);
				else if(radio.is(':checked')) replaced.addClass(_options.radioChecked);
				else replaced.addClass(_options.radioDefault);
				replaced.click(function(){
					if(jQuery(this).hasClass(_options.radioDefault)){
						radio.attr('checked', 'checked');
						changeRadio(radio.get(0));
					}
				});
				radio.click(function(){
					changeRadio(this);
				});
				replaced.insertBefore(radio);
				radio.addClass('outtaHere');
			}
		});
		function changeRadio(_this){
			jQuery(_this).change();
			jQuery('input:radio[name='+jQuery(_this).attr("name")+']').not(_this).each(function(){
				if(this._replaced && !jQuery(this).is(':disabled')) this._replaced.removeClass().addClass(_options.radioDefault);
			});
			_this._replaced.removeClass().addClass(_options.radioChecked);
		}
	}

	// custom selects module
	jQuery.fn.customSelect = function(_options) {
		var _options = jQuery.extend({
			selectStructure: '<div class="selectArea"><span class="left"></span><span class="center"></span><a href="#" class="selectButton"></a><div class="disabled"></div></div>',
			hideOnMouseOut: false,
			copyClass: true,
			selectText: '.center',
			selectBtn: '.selectButton',
			selectDisabled: '.disabled',
			optStructure: '<div class="optionsDivVisible"><div class="select-top"></div><div class="select-center"><ul></ul><div class="select-bottom"></div></div>',
			optList: 'ul'
		}, _options);
		return this.each(function() {
			var select = jQuery(this);
			if(!select.hasClass('outtaHere')) {
				if(select.is(':visible')) {
					var hideOnMouseOut = _options.hideOnMouseOut;
					var copyClass = _options.copyClass;
					var replaced = jQuery(_options.selectStructure);
					var selectText = replaced.find(_options.selectText);
					var selectBtn = replaced.find(_options.selectBtn);
					var selectDisabled = replaced.find(_options.selectDisabled).hide();
					var optHolder = jQuery(_options.optStructure);
					var optList = optHolder.find(_options.optList);
					if(copyClass) optHolder.addClass('drop-'+select.attr('class'));

					if(select.attr('disabled')) selectDisabled.show();
					select.find('option').each(function(){
						var selOpt = jQuery(this);
						var _opt = jQuery('<li><a href="#">' + selOpt.html() + '</a></li>');
						if(selOpt.attr('selected')) {
							selectText.html(selOpt.html());
							_opt.addClass('selected');
						}
						_opt.children('a').click(function() {
							optList.find('li').removeClass('selected');
							select.find('option').removeAttr('selected');
							jQuery(this).parent().addClass('selected');
							selOpt.attr('selected', 'selected');
							selectText.html(selOpt.html());
							select.change();
							optHolder.hide();
							return false;
						});
						optList.append(_opt);
					});
					replaced.width(select.outerWidth());
					replaced.insertBefore(select);
					optHolder.css({
						width: select.outerWidth(),
						display: 'none',
						position: 'absolute'
					});
					jQuery(document.body).append(optHolder);

					var optTimer;
					replaced.hover(function() {
						if(optTimer) clearTimeout(optTimer);
					}, function() {
						if(hideOnMouseOut) {
							optTimer = setTimeout(function() {
								optHolder.hide();
							}, 200);
						}
					});
					optHolder.hover(function(){
						if(optTimer) clearTimeout(optTimer);
					}, function() {
						if(hideOnMouseOut) {
							optTimer = setTimeout(function() {
								optHolder.hide();
							}, 200);
						}
					});
					selectBtn.click(function() {
						if(optHolder.is(':visible')) {
							optHolder.hide();
						}
						else{
							if(_activeDrop) _activeDrop.hide();
							optHolder.children('ul').css({height:'auto', overflow:'hidden'});
							optHolder.css({
								top: replaced.offset().top + replaced.outerHeight(),
								left: replaced.offset().left,
								display: 'block'
							});
							if(optHolder.children('ul').height() > 200) optHolder.children('ul').css({height:200, overflow:'auto'});
							_activeDrop = optHolder;
						}
						return false;
					});
					replaced.addClass(select.attr('class'));
					select.addClass('outtaHere');
				}
			}
		});
	}

	// event handler on DOM ready
	var _activeDrop;
	jQuery(function(){
		jQuery('body').click(hideOptionsClick)
		jQuery(window).resize(hideOptions)
	});
	function hideOptions() {
		if(_activeDrop && _activeDrop.length) {
			_activeDrop.hide();
			_activeDrop = null;
		}
	}
	function hideOptionsClick(e) {
		if(_activeDrop && _activeDrop.length) {
			var f = false;
			jQuery(e.target).parents().each(function(){
				if(this == _activeDrop) f=true;
			});
			if(!f) {
				_activeDrop.hide();
				_activeDrop = null;
			}
		}
	}
})(jQuery);

// initet WYSIWYG editor
function initWysiwyg(){
	jQuery('.wysiwyg').wysiwyg({css: templateDir+"css/wysiwyg.css"});	// nick edit
	if (jQuery.browser.msie && jQuery.browser.version < 9) {
		jQuery('.wysiwyg').css('width', '572px');
	}
}

function initGall(){
	var g1 = $('#carousel').gallery({
		autoRotation:5000,
		effect:'fade',
		listOfSlides:'div.carousel-holder > ul.fader > li'
	});
	jQuery ( '.gallery-box' ).each ( function () {
		var _holder = jQuery ( this ),
			_next = jQuery ( '.link-next', this ),
			_prev = jQuery ( '.link-prev', this ),
			_list = jQuery ( '.gallery', this );
		
		_list.carouFredSel ({
			next: _next,
			prev: _prev,
			auto: false,
			width: 810,
			scroll: {
				items: 2,
				onBefore: function () {
					if ( _activePopup ) {
						_activePopup.css({
							top: - 99999,
							left: - 99999
						})
						_activePopup = null;
					}
				}
			},
			items: {
				width: 'variable'
			}
		})
	})
	
	var _activePopup = null;
	
	jQuery ( 'a.btn-question' ).each ( function () {
		var _btn = jQuery ( this ),
			_popup = jQuery ( this.hash ),
			_btnClose = jQuery ( '.close', _popup );
		
		_btn.click ( function () {
			if ( _activePopup ) {
				_activePopup.css({
					top: - 99999,
					left: - 99999
				})
				_activePopup = null;
			}
			
			_popup.css({
				top: _btn.offset ().top + 15,
				left: _btn.offset ().left - _popup.width () + 28
			})
			_activePopup = _popup
			return false;
		})
		
		_btnClose.click ( function () {
			_popup.css({
				top: - 99999,
				left: - 99999
			})
			_activePopup = null;
			return false;
		})
	})
	
	jQuery ( document ).bind ( 'click', function ( e ) {
		if ( _activePopup ) {
			onClick ( e, _activePopup.get ( 0 ) );
		}
	})
	
	function onClick ( e, obj ) {
		e = e || window.event;
		
		var target = e.target || e.srcElement;
		var popup = obj;
		
		while ( target.parentNode && target.tagName.toLowerCase () != 'body' ) {
			if ( target == popup ) return;
			target = target.parentNode;
		}
		
		_activePopup.css({
			top: - 99999,
			left: - 99999
		})
		_activePopup = null;
	}
}
;(function($) {
	$.fn.gallery = function(options) { return new Gallery(this.get(0), options); };
	function Gallery(context, options) { this.init(context, options); };
	Gallery.prototype = {
		options:{},
		init: function (context, options){
			this.options = $.extend({
				infinite: false,								//true = infinite gallery
				duration: 700,									//duration of effect it 1000 = 1sec
				slideElement: 1,								//number of elements for a slide
				autoRotation: false,							//false = option is disabled; 1000 = 1sec
				effect: false,									//false = slide; true = fade
				listOfSlides: 'ul > li',						//elements galleries
				switcher: false,								//false = option is disabled; 'ul > li' = elements switcher
				disableBtn: false,								//false = option is disabled; 'hidden' = class adds an buttons "prev" and "next"
				nextBtn: 'a.link-next, a.btn-next, a.next',		//button "next"
				prevBtn: 'a.link-prev, a.btn-prev, a.prev',		//button "prev"
				circle: true,									//true = cyclic gallery; false = not cyclic gallery
				direction: false,								//false = horizontal; true = vertical
				event: 'click',									//event for the buttons and switcher
				IE: false,										//forced off effect it "fade" in IE
				autoHeight: false								//auto height on fade
			}, options || {});
			var _el = $(context).find(this.options.listOfSlides);
			if (this.options.effect) this.list = _el;
			else this.list = _el.parent();
			this.switcher = $(context).find(this.options.switcher);
			this.nextBtn = $(context).find(this.options.nextBtn);
			this.prevBtn = $(context).find(this.options.prevBtn);
			this.count = _el.index(_el.filter(':last'));
			
			if (this.options.switcher) this.active = this.switcher.index(this.switcher.filter('.active:eq(0)'));
			else this.active = _el.index(_el.filter('.active:eq(0)'));
			if (this.active < 0) this.active = 0;
			this.last = this.active;
			
			this.woh = _el.outerWidth(true);
			if (!this.options.direction) this.installDirections(this.list.parent().width());
			else {
				this.woh = _el.outerHeight(true);
				this.installDirections(this.list.parent().height());
			}
			
			if (!this.options.effect) {
				this.rew = this.count - this.wrapHolderW + 1;
				if (!this.options.direction) this.anim = '{marginLeft: -(this.woh * this.active)}';
				else this.anim = '{marginTop: -(this.woh * this.active)}';
				eval('this.list.css('+this.anim+')');
			}
			else {
				this.rew = this.count;
				this.list.css({opacity: 0}).removeClass('active').eq(this.active).addClass('active').css({opacity: 1}).css('opacity', 'auto');
				this.switcher.removeClass('active').eq(this.active).addClass('active');
				if(this.options.autoHeight) this.list.parent().css({height: this.list.eq(this.active).outerHeight()});
			}
			this.flag = true;
			if (this.options.infinite){
				this.count++;
				this.active += this.count;
				this.list.append(_el.clone());
				this.list.append(_el.clone());
				eval('this.list.css('+this.anim+')');
			}
			
			this.initEvent(this, this.nextBtn, true);
			this.initEvent(this, this.prevBtn, false);
			if (this.options.disableBtn) this.initDisableBtn();
			if (this.options.autoRotation) this.runTimer(this);
			if (this.options.switcher) this.initEventSwitcher(this, this.switcher);
		},
		initDisableBtn: function(){
			this.prevBtn.removeClass('prev-'+this.options.disableBtn);
			this.nextBtn.removeClass('next-'+this.options.disableBtn);
			if (this.active == 0 || this.count+1 == this.wrapHolderW) this.prevBtn.addClass('prev-'+this.options.disableBtn);
			if (this.active == 0 && this.count == 1 || this.count+1 <= this.wrapHolderW) this.nextBtn.addClass('next-'+this.options.disableBtn);
			if (this.active == this.rew) this.nextBtn.addClass('next-'+this.options.disableBtn);
		},
		installDirections: function(temp){
			this.wrapHolderW = Math.ceil(temp / this.woh);
			if (((this.wrapHolderW - 1) * this.woh + this.woh / 2) > temp) this.wrapHolderW--;
		},
		fadeElement: function(){
			if ($.browser.msie && this.options.IE){
				this.list.eq(this.last).css({opacity:0});
				this.list.removeClass('active').eq(this.active).addClass('active').css({opacity:'auto'});
			}
			else{
				this.list.eq(this.last).animate({opacity:0}, {queue:false, duration: this.options.duration});
				this.list.removeClass('active').eq(this.active).addClass('active').animate({
					opacity:1
				}, {queue:false, duration: this.options.duration, complete: function(){
					$(this).css('opacity','auto');
				}});
			}
			if(this.options.autoHeight) this.list.parent().animate({height: this.list.eq(this.active).outerHeight()}, {queue:false, duration: this.options.duration});
			if (this.options.switcher) this.switcher.removeClass('active').eq(this.active).addClass('active');
			this.last = this.active;
		},
		scrollElement: function($this){
			if (!$this.options.infinite) eval('$this.list.animate('+$this.anim+', {queue:false, duration: $this.options.duration});');
			else eval('$this.list.animate('+$this.anim+', $this.options.duration, function(){ $this.flag = true });');
			if ($this.options.switcher) $this.switcher.removeClass('active').eq($this.active / $this.options.slideElement).addClass('active');
		},
		runTimer: function($this){
			if($this._t) clearTimeout($this._t);
			$this._t = setInterval(function(){
				if ($this.options.infinite) $this.flag = false;
				$this.toPrepare($this, true);
			}, this.options.autoRotation);
		},
		initEventSwitcher: function($this, el){
			el.bind($this.options.event, function(){
				$this.active = $this.switcher.index($(this)) * $this.options.slideElement;
				if($this._t) clearTimeout($this._t);
				if ($this.options.disableBtn) $this.initDisableBtn();
				if (!$this.options.effect) $this.scrollElement($this);
				else $this.fadeElement();
				if ($this.options.autoRotation) $this.runTimer($this);
				return false;
			});
		},
		initEvent: function($this, addEventEl, dir){
			addEventEl.bind($this.options.event, function(){
				if ($this.flag){
					if ($this.options.infinite) $this.flag = false;
					if($this._t) clearTimeout($this._t);
					$this.toPrepare($this, dir);
					if ($this.options.autoRotation) $this.runTimer($this);
				}
				return false;
			});
		},
		toPrepare: function($this, side){
			if (!$this.options.infinite){
				if (($this.active == $this.rew) && $this.options.circle && side) $this.active = -$this.options.slideElement;
				if (($this.active == 0) && $this.options.circle && !side) $this.active = $this.rew + $this.options.slideElement;
				for (var i = 0; i < $this.options.slideElement; i++){
					if (side) { if ($this.active + 1 <= $this.rew) $this.active++; }
					else { if ($this.active - 1 >= 0) $this.active--; }
				};
			}
			else{
				if ($this.active >= $this.count + $this.count && side) $this.active -= $this.count;
				if ($this.active <= $this.count-1 && !side) $this.active += $this.count;
				eval('$this.list.css('+$this.anim+')');
				if (side) $this.active += $this.options.slideElement;
				else $this.active -= $this.options.slideElement;
			}
			if (this.options.disableBtn) this.initDisableBtn();
			if (!$this.options.effect) $this.scrollElement($this);
			else $this.fadeElement();
		},
		stop: function(){
			if (this._t) clearTimeout(this._t);
		},
		play: function(){
			if (this._t) clearTimeout(this._t);
			if (this.options.autoRotation) this.runTimer(this);
		}
	}
}(jQuery));

function initPopup(_popup) {
	if (!_popup.popupHolderTag) _popup.popupHolderTag = 'div';
	if (!_popup.popupTag) _popup.popupTag = 'div';
	if (!_popup.popupHolderClass) _popup.popupHolderClass = 'popup-holder';
	if (!_popup.popupClass) _popup.popupClass = 'popup';
	if (!_popup.linkOpenClass) _popup.linkOpenClass = 'open';
	if (!_popup.linkCloseClass) _popup.linkCloseClass = 'close';
	if (!_popup.openClass) _popup.openClass = 'active';
	if (!_popup.openEvent) _popup.openEvent = 'hover';
	
	var timer = [],
		activePopup = null;
	var _popupHolderTag = document.getElementsByTagName(_popup.popupHolderTag);
	if (_popupHolderTag) {
		for (var i=0; i<_popupHolderTag.length; i++) {
			if (_popupHolderTag[i].className.indexOf(_popup.popupHolderClass) != -1) {
				var _popupLink = _popupHolderTag[i].getElementsByTagName('a');
				for (var j=0; j<_popupLink.length; j++) {
					_popupLink[j].parent = _popupHolderTag[i];
					if (_popupLink[j].className.indexOf(_popup.linkOpenClass) != -1) {
						if (_popup.openEvent == 'click') {
							_popupLink[j].onclick = function(){
								if (this.parent.className.indexOf(_popup.openClass) != -1) {
									this.parent.className = this.parent.className.replace(_popup.openClass,'');
									if ( activePopup ) {
										activePopup.className = activePopup.className.replace ( _popup.openClass, '' );
										activePopup = null;
									}
								} else {
									this.parent.className += ' '+_popup.openClass;
									if ( activePopup ) {
										activePopup.className = activePopup.className.replace ( _popup.openClass, '' );
									}
									activePopup = this.parent;
								}
								return false;
							}
						} else {
							var _popupTag = _popupHolderTag[i].getElementsByTagName(_popup.popupTag);
							for (var k=0; k<_popupTag.length; k++) {
								if (_popupTag[k].className.indexOf(_popup.popupClass) != -1) {
									_popupTag[k].parent = _popupHolderTag[i];
									_popupTag[k].onmouseover = function(){
										if (timer[j]) clearTimeout(timer[j]);
										if (this.parent.className.indexOf(_popup.openClass) == -1) {
											this.parent.className += ' '+_popup.openClass;
										}
									}
									_popupTag[k].onmouseout = function(){
										var _this = this;
										timer[j] = setTimeout(function(){
											_this.parent.className = _this.parent.className.replace(_popup.openClass,'');
										},2);
									}	
								}
							}
							_popupLink[j].onmouseover = function(){
								if (timer[j]) clearTimeout(timer[j]);
								if (this.parent.className.indexOf(_popup.openClass) == -1) {
									this.parent.className += ' '+_popup.openClass;
								}
							}
							_popupLink[j].onmouseout = function(){
								var _this = this;
								timer[j] = setTimeout(function(){
									_this.parent.className = _this.parent.className.replace(_popup.openClass,'');
								},2);
							}
						}
					} else if (_popupLink[j].className.indexOf(_popup.linkCloseClass) != -1) {
						_popupLink[j].onclick = function(){
							if (this.parent.className.indexOf(_popup.openClass) != -1) {
								this.parent.className = this.parent.className.replace(_popup.openClass,'');
								if ( activePopup ) {
									activePopup.className.replace ( _popup.openClass, '' );
									activePopup = null;
								}
							} else {
								this.parent.className += ' '+_popup.openClass;
								if ( activePopup ) {
									activePopup.className.replace ( _popup.openClass, '' );
								}
								activePopup = this.parent;
							}
							return false;
						}
					}
				}
			}
		}
	}
	jQuery ( document ).bind ( 'click', function ( e ) {
		if ( activePopup ) {
			onClick ( e, activePopup );
		}
	})
	
	function onClick ( e, obj ) {
		e = e || window.event;
		
		var target = e.target || e.srcElement;
		var popup = obj;
		
		while ( target.parentNode && target.tagName.toLowerCase () != 'body' ) {
			if ( target == popup ) return;
			target = target.parentNode;
		}
		
		activePopup.className = activePopup.className.replace ( _popup.openClass, '' );
		activePopup = null;
	}
}

// date picker
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('D=(6($){6 D(2A,w){j(1T(w)!="2D")w={};$.2C(5,D.1Y,w);5.n=$(2A);5.1Q("1l","L","11","10","E");5.1P();5.E();5.L()};D.1Y={1G:["2V","2M","2S","2Q","2g","2N","2O","2P","2R","2L","2G","2F"],1v:["2H","2I","2K","2J","2g","2T","2U","36","35","3a","3b","3d"],1F:["3c","32","31","2W","2E","2X","2Y"],N:1};D.30={1P:6(){b R=$(\'<p h="2Z">\'+\'<m h="P 17" Y="[1g-1U]">&#2u;</m>\'+\' <m h="K"></m> \'+\'<m h="P 1a" Y="[1g-2h]">&#2n;</m>\'+\'</p>\');5.2v=$(".K",R);$(".17",R).F(5.u(6(){5.Q(-1)}));$(".1a",R).F(5.u(6(){5.Q(1)}));b V=$(\'<p h="3e">\'+\'<m h="P 17" Y="[2x+1g-1U]">&#2u;</m>\'+\' <m h="2t"></m> \'+\'<m h="P 1a" Y="[2x+1g-2h]">&#2n;</m>\'+\'</p>\');5.2q=$(".2t",V);$(".17",V).F(5.u(6(){5.Q(-12)}));$(".1a",V).F(5.u(6(){5.Q(12)}));b T=$(\'<Z h="T"></Z>\').S(R,V);b 15="<26><1W><1b>";$(5.1S(5.1F)).2k(6(){15+="<2l>"+5+"</2l>"});15+="</1b></1W><o></o></26>";5.x=5.O=$(\'<Z h="3m"></Z>\').S(T,15).3I(5.n);j($.2B.3K&&$.2B.3L<7){5.19=$(\'<2m h="3H" 3y="0" 3B="#"></2m>\').3F(5.x);5.O=5.O.3E(5.19);$(".P",T).23(6(){$(5).1d("1h")});$(".P",T).2f(6(){$(5).1t("1h")})};5.o=$("o",5.x);5.n.25(5.u(6(){5.E()}));5.E()},1D:6(8){b J=l g(8.f(),8.c(),1);j(!5.v||!(5.v.f()==J.f()&&5.v.c()==J.c())){5.v=J;b C=5.C(8),1e=5.1e(8);b 2o=5.29(C,1e);b M="";1f(b i=0;i<=2o;i++){b A=l g(C.f(),C.c(),C.q()+i,12,2i);j(5.2e(A))M+="<1b>";j(A.c()==8.c()){M+=\'<y h="1j" 8="\'+5.U(A)+\'">\'+A.q()+\'</y>\'}2j{M+=\'<y h="3J" 8="\'+5.U(A)+\'">\'+A.q()+\'</y>\'};j(5.2p(A))M+="</1b>"};5.o.1y().S(M);5.2v.1y().S(5.1J(8));5.2q.1y().S(5.v.f());$(".1j",5.o).F(5.u(6(e){5.1x($(e.1R).3D("8"))}));$("y[8="+5.U(l g())+"]",5.o).1d("3z");$("y.1j",5.o).23(6(){$(5).1d("1h")});$("y.1j",5.o).2f(6(){$(5).1t("1h")})};$(\'.1s\',5.o).1t("1s");$(\'y[8=\'+5.1w+\']\',5.o).1d("1s")},E:6(8){j(1T(8)=="3A"){8=5.2d(5.n.1Z())};j(!8)8=l g();5.r=8;5.1w=5.U(5.r);5.1D(5.r)},1x:6(20){5.n.1Z(20).25();5.L()},1l:6(){5.O.18("24","3G");$([21,1k.1c]).F(5.11);5.n.1r("28",5.1l);$(1k.1c).1K(5.10);5.2b()},L:6(){5.O.18("24","3M");$([21,1k.1c]).1r("F",5.11);5.n.28(5.1l);$(1k.1c).1r("1K",5.10)},11:6(e){j(e.1R!=5.n[0]&&!5.1L(e)){5.L()}},1L:6(e){b k=5.x.3C();k.1N=k.16+5.x.2y();k.1O=k.14+5.x.1H();a e.1M<k.1O&&e.1M>k.14&&e.22<k.1N&&e.22>k.16},10:6(e){3w(e.3f){t 9:t 27:5.L();a;z;t 13:5.1x(5.1w);z;t 33:5.1B(e.2w?-12:-1);z;t 34:5.1B(e.2w?12:1);z;t 38:5.W(-7);z;t 3x:5.W(7);z;t 37:5.W(-1);z;t 39:5.W(1);z;3k:a}e.3j()},2d:6(2c){b X;j(X=2c.3g(/^(\\d{1,2}) ([^\\s]+) (\\d{4,4})$/)){a l g(X[3],5.1X(X[2]),X[1],12,2i)}2j{a 3h}},U:6(8){a 8.q()+" "+5.1v[8.c()]+" "+8.f()},2b:6(){b k=5.n.k();5.O.18({14:k.14+5.n.1H(),16:k.16});j(5.19){5.19.18({3i:5.x.2y(),3n:5.x.1H()})}},W:6(B){b I=l g(5.r.f(),5.r.c(),5.r.q()+B);5.E(I)},1B:6(B){b I=l g(5.r.f(),5.r.c()+B,5.r.q());j(I.c()==5.r.c()+B+1){I.3o(0)};5.E(I)},Q:6(B){b J=l g(5.v.f(),5.v.c()+B,5.v.q());5.1D(J)},1J:6(8){a 5.1G[8.c()]},u:6(1p){b 1I=5;a 6(){a 1p.3u(1I,1n)}},1Q:6(){1f(b i=0;i<1n.1q;i++){5[1n[i]]=5.u(5[1n[i]])}},1m:6(1E,1V){1f(b i=0;i<1E.1q;i++){j(1V==1E[i])a i}},3v:6(K){a 5.1m(5.1G,K)},1X:6(K){a 5.1m(5.1v,K)},3t:6(2z){a 5.1m(5.1F,2z)},29:6(H,G){H=g.2s(H.f(),H.c(),H.q());G=g.2s(G.f(),G.c(),G.q());a(G-H)/3s},1u:6(2r,8,1C){b 2a=1C*(3p.3q(8.1o()-2r-(1C*7))%7);a l g(8.f(),8.c(),8.q()+2a)},C:6(8){a 5.1u(5.N,l g(8.f(),8.c()),-1)},1e:6(8){a 5.1u((5.N-1)%7,l g(8.f(),8.c()+1,0),1)},2e:6(8){a 8.1o()==5.N},2p:6(8){a 8.1o()==(5.N-1)%7},1S:6(1z){b 1A=[];1f(b i=0;i<1z.1q;i++){1A[i]=1z[(i+5.N)%7]};a 1A}};$.1p.1i=6(w){a 5.2k(6(){l D(5,w)})};$.1i={3r:6(w){$("n.1i").1i(w)}};a D})(3l);',62,235,'|||||this|function||date||return|var|getMonth||event|getFullYear|Date|class||if|offset|new|span|input|tbody||getDate|selectedDate||case|bindToObj|currentMonth|opts|dateSelector|td|break|currentDay|amount|rangeStart|DateInput|selectDate|click|end|start|newDate|newMonth|month_name|hide|dayCells|start_of_week|rootLayers|button|moveMonthBy|monthNav|append|nav|dateToString|yearNav|moveDateBy|matches|title|div|keydownHandler|hideIfClickOutside|||top|tableShell|left|prev|css|ieframe|next|tr|body|addClass|rangeEnd|for|Page|hover|date_input|selectable_day|document|show|indexFor|arguments|getDay|fn|length|unbind|selected|removeClass|changeDayTo|short_month_names|selectedDateString|changeInput|empty|days|newDays|moveDateMonthBy|direction|selectMonth|array|short_day_names|month_names|outerHeight|self|monthName|keydown|insideSelector|pageY|right|bottom|build|bindMethodsToObj|target|adjustDays|typeof|Up|value|thead|shortMonthNum|DEFAULT_OPTS|val|dateString|window|pageX|mouseover|display|change|table||focus|daysBetween|difference|setPosition|string|stringToDate|isFirstDayOfWeek|mouseout|May|Down|00|else|each|th|iframe|187|numDays|isLastDayOfWeek|yearNameSpan|dayOfWeek|UTC|year_name|171|monthNameSpan|ctrlKey|Ctrl|outerWidth|day_name|el|browser|extend|object|Thu|December|November|Jan|Feb|Apr|Mar|October|February|June|July|August|April|September|March|Jun|Jul|January|Wed|Fri|Sat|month_nav|prototype|Tue|Mon|||Sep|Aug||||Oct|Nov|Sun|Dec|year_nav|keyCode|match|null|width|preventDefault|default|jQuery|date_selector|height|setDate|Math|abs|initialize|86400000|shortDayNum|apply|monthNum|switch|40|frameborder|today|undefined|src|position|attr|add|insertBefore|block|date_selector_ieframe|insertAfter|unselected_month|msie|version|none'.split('|'),0,{}))

/*!
 * jQuery UI 1.8.12
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI
 */
;(function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.12",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,
NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,
"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");
if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,l,m){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(l)g-=parseFloat(c.curCSS(f,
"border"+this+"Width",true))||0;if(m)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,
d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");if("area"===b){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&k(a)}return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b?a.href||!isNaN(d):!isNaN(d))&&k(a)},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}});
c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e<b.length;e++)a.options[b[e][0]]&&
b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")==="hidden")return false;b=b&&b==="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,h,i){return c.ui.isOverAxis(a,d,h)&&c.ui.isOverAxis(b,e,i)}})}})(jQuery);
;/*!
 * jQuery UI Widget 1.8.12
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Widget
 */
;(function(b,j){if(b.cleanData){var k=b.cleanData;b.cleanData=function(a){for(var c=0,d;(d=a[c])!=null;c++)b(d).triggerHandler("remove");k(a)}}else{var l=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){b(this).triggerHandler("remove")});return l.call(b(this),a,c)})}}b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h,
a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.charAt(0)==="_")return h;
e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}):this.each(function(){var g=b.data(this,a);g?g.option(d||{})._init():b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=b.extend(true,{},this.options,
this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},
widget:function(){return this.element},option:function(a,c){var d=a;if(arguments.length===0)return b.extend({},this.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(d,e){c._setOption(d,e)});return this},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this},
enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);
;/*!
 * jQuery UI Mouse 1.8.12
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Mouse
 *
 * Depends:
 *	jquery.ui.widget.js
 */
;(function(b){b.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var a=this;this.element.bind("mousedown."+this.widgetName,function(c){return a._mouseDown(c)}).bind("click."+this.widgetName,function(c){if(true===b.data(c.target,a.widgetName+".preventClickEvent")){b.removeData(c.target,a.widgetName+".preventClickEvent");c.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(a){a.originalEvent=
a.originalEvent||{};if(!a.originalEvent.mouseHandled){this._mouseStarted&&this._mouseUp(a);this._mouseDownEvent=a;var c=this,e=a.which==1,f=typeof this.options.cancel=="string"?b(a.target).parents().add(a.target).filter(this.options.cancel).length:false;if(!e||f||!this._mouseCapture(a))return true;this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet)this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=true},this.options.delay);if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a)){this._mouseStarted=
this._mouseStart(a)!==false;if(!this._mouseStarted){a.preventDefault();return true}}true===b.data(a.target,this.widgetName+".preventClickEvent")&&b.removeData(a.target,this.widgetName+".preventClickEvent");this._mouseMoveDelegate=function(d){return c._mouseMove(d)};this._mouseUpDelegate=function(d){return c._mouseUp(d)};b(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);a.preventDefault();return a.originalEvent.mouseHandled=
true}},_mouseMove:function(a){if(b.browser.msie&&!(document.documentMode>=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);
if(this._mouseStarted){this._mouseStarted=false;a.target==this._mouseDownEvent.target&&b.data(a.target,this.widgetName+".preventClickEvent",true);this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
;/*
 * jQuery UI Position 1.8.12
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Position
 */
;(function(c){c.ui=c.ui||{};var n=/left|center|right/,o=/top|center|bottom/,t=c.fn.position,u=c.fn.offset;c.fn.position=function(b){if(!b||!b.of)return t.apply(this,arguments);b=c.extend({},b);var a=c(b.of),d=a[0],g=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],h,k,j;if(d.nodeType===9){h=a.width();k=a.height();j={top:0,left:0}}else if(d.setTimeout){h=a.width();k=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";h=k=0;j={top:b.of.pageY,
left:b.of.pageX}}else{h=a.outerWidth();k=a.outerHeight();j=a.offset()}c.each(["my","at"],function(){var f=(b[this]||"").split(" ");if(f.length===1)f=n.test(f[0])?f.concat(["center"]):o.test(f[0])?["center"].concat(f):["center","center"];f[0]=n.test(f[0])?f[0]:"center";f[1]=o.test(f[1])?f[1]:"center";b[this]=f});if(g.length===1)g[1]=g[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(b.at[0]==="right")j.left+=h;else if(b.at[0]==="center")j.left+=h/2;if(b.at[1]==="bottom")j.top+=
k;else if(b.at[1]==="center")j.top+=k/2;j.left+=e[0];j.top+=e[1];return this.each(function(){var f=c(this),l=f.outerWidth(),m=f.outerHeight(),p=parseInt(c.curCSS(this,"marginLeft",true))||0,q=parseInt(c.curCSS(this,"marginTop",true))||0,v=l+p+(parseInt(c.curCSS(this,"marginRight",true))||0),w=m+q+(parseInt(c.curCSS(this,"marginBottom",true))||0),i=c.extend({},j),r;if(b.my[0]==="right")i.left-=l;else if(b.my[0]==="center")i.left-=l/2;if(b.my[1]==="bottom")i.top-=m;else if(b.my[1]==="center")i.top-=
m/2;i.left=Math.round(i.left);i.top=Math.round(i.top);r={left:i.left-p,top:i.top-q};c.each(["left","top"],function(s,x){c.ui.position[g[s]]&&c.ui.position[g[s]][x](i,{targetWidth:h,targetHeight:k,elemWidth:l,elemHeight:m,collisionPosition:r,collisionWidth:v,collisionHeight:w,offset:e,my:b.my,at:b.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(i,{using:b.using}))})};c.ui.position={fit:{left:function(b,a){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();b.left=
d>0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];b.left+=
a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=c(b),
g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery);
;/*
 * jQuery UI Slider 1.8.12
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Slider
 *
 * Depends:
 *	jquery.ui.core.js
 *	jquery.ui.mouse.js
 *	jquery.ui.widget.js
 */
;(function(d){d.widget("ui.slider",d.ui.mouse,{widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null},_create:function(){var b=this,a=this.options;this._mouseSliding=this._keySliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget ui-widget-content ui-corner-all");a.disabled&&this.element.addClass("ui-slider-disabled ui-disabled");
this.range=d([]);if(a.range){if(a.range===true){this.range=d("<div></div>");if(!a.values)a.values=[this._valueMin(),this._valueMin()];if(a.values.length&&a.values.length!==2)a.values=[a.values[0],a.values[0]]}else this.range=d("<div></div>");this.range.appendTo(this.element).addClass("ui-slider-range");if(a.range==="min"||a.range==="max")this.range.addClass("ui-slider-range-"+a.range);this.range.addClass("ui-widget-header")}d(".ui-slider-handle",this.element).length===0&&d("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle");
if(a.values&&a.values.length)for(;d(".ui-slider-handle",this.element).length<a.values.length;)d("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle");this.handles=d(".ui-slider-handle",this.element).addClass("ui-state-default ui-corner-all");this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(c){c.preventDefault()}).hover(function(){a.disabled||d(this).addClass("ui-state-hover")},function(){d(this).removeClass("ui-state-hover")}).focus(function(){if(a.disabled)d(this).blur();
else{d(".ui-slider .ui-state-focus").removeClass("ui-state-focus");d(this).addClass("ui-state-focus")}}).blur(function(){d(this).removeClass("ui-state-focus")});this.handles.each(function(c){d(this).data("index.ui-slider-handle",c)});this.handles.keydown(function(c){var e=true,f=d(this).data("index.ui-slider-handle"),h,g,i;if(!b.options.disabled){switch(c.keyCode){case d.ui.keyCode.HOME:case d.ui.keyCode.END:case d.ui.keyCode.PAGE_UP:case d.ui.keyCode.PAGE_DOWN:case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:e=
false;if(!b._keySliding){b._keySliding=true;d(this).addClass("ui-state-active");h=b._start(c,f);if(h===false)return}break}i=b.options.step;h=b.options.values&&b.options.values.length?(g=b.values(f)):(g=b.value());switch(c.keyCode){case d.ui.keyCode.HOME:g=b._valueMin();break;case d.ui.keyCode.END:g=b._valueMax();break;case d.ui.keyCode.PAGE_UP:g=b._trimAlignValue(h+(b._valueMax()-b._valueMin())/5);break;case d.ui.keyCode.PAGE_DOWN:g=b._trimAlignValue(h-(b._valueMax()-b._valueMin())/5);break;case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:if(h===
b._valueMax())return;g=b._trimAlignValue(h+i);break;case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:if(h===b._valueMin())return;g=b._trimAlignValue(h-i);break}b._slide(c,f,g);return e}}).keyup(function(c){var e=d(this).data("index.ui-slider-handle");if(b._keySliding){b._keySliding=false;b._stop(c,e);b._change(c,e);d(this).removeClass("ui-state-active")}});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");
this._mouseDestroy();return this},_mouseCapture:function(b){var a=this.options,c,e,f,h,g;if(a.disabled)return false;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();c=this._normValueFromMouse({x:b.pageX,y:b.pageY});e=this._valueMax()-this._valueMin()+1;h=this;this.handles.each(function(i){var j=Math.abs(c-h.values(i));if(e>j){e=j;f=d(this);g=i}});if(a.range===true&&this.values(1)===a.min){g+=1;f=d(this.handles[g])}if(this._start(b,
g)===false)return false;this._mouseSliding=true;h._handleIndex=g;f.addClass("ui-state-active").focus();a=f.offset();this._clickOffset=!d(b.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:b.pageX-a.left-f.width()/2,top:b.pageY-a.top-f.height()/2-(parseInt(f.css("borderTopWidth"),10)||0)-(parseInt(f.css("borderBottomWidth"),10)||0)+(parseInt(f.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(b,g,c);return this._animateOff=true},_mouseStart:function(){return true},
_mouseDrag:function(b){var a=this._normValueFromMouse({x:b.pageX,y:b.pageY});this._slide(b,this._handleIndex,a);return false},_mouseStop:function(b){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(b,this._handleIndex);this._change(b,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(b){var a;
if(this.orientation==="horizontal"){a=this.elementSize.width;b=b.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{a=this.elementSize.height;b=b.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}a=b/a;if(a>1)a=1;if(a<0)a=0;if(this.orientation==="vertical")a=1-a;b=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+a*b)},_start:function(b,a){var c={handle:this.handles[a],value:this.value()};if(this.options.values&&this.options.values.length){c.value=
this.values(a);c.values=this.values()}return this._trigger("start",b,c)},_slide:function(b,a,c){var e;if(this.options.values&&this.options.values.length){e=this.values(a?0:1);if(this.options.values.length===2&&this.options.range===true&&(a===0&&c>e||a===1&&c<e))c=e;if(c!==this.values(a)){e=this.values();e[a]=c;b=this._trigger("slide",b,{handle:this.handles[a],value:c,values:e});this.values(a?0:1);b!==false&&this.values(a,c,true)}}else if(c!==this.value()){b=this._trigger("slide",b,{handle:this.handles[a],
value:c});b!==false&&this.value(c)}},_stop:function(b,a){var c={handle:this.handles[a],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(a);c.values=this.values()}this._trigger("stop",b,c)},_change:function(b,a){if(!this._keySliding&&!this._mouseSliding){var c={handle:this.handles[a],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(a);c.values=this.values()}this._trigger("change",b,c)}},value:function(b){if(arguments.length){this.options.value=
this._trimAlignValue(b);this._refreshValue();this._change(null,0)}else return this._value()},values:function(b,a){var c,e,f;if(arguments.length>1){this.options.values[b]=this._trimAlignValue(a);this._refreshValue();this._change(null,b)}else if(arguments.length)if(d.isArray(arguments[0])){c=this.options.values;e=arguments[0];for(f=0;f<c.length;f+=1){c[f]=this._trimAlignValue(e[f]);this._change(null,f)}this._refreshValue()}else return this.options.values&&this.options.values.length?this._values(b):
this.value();else return this._values()},_setOption:function(b,a){var c,e=0;if(d.isArray(this.options.values))e=this.options.values.length;d.Widget.prototype._setOption.apply(this,arguments);switch(b){case "disabled":if(a){this.handles.filter(".ui-state-focus").blur();this.handles.removeClass("ui-state-hover");this.handles.attr("disabled","disabled");this.element.addClass("ui-disabled")}else{this.handles.removeAttr("disabled");this.element.removeClass("ui-disabled")}break;case "orientation":this._detectOrientation();
this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue();break;case "value":this._animateOff=true;this._refreshValue();this._change(null,0);this._animateOff=false;break;case "values":this._animateOff=true;this._refreshValue();for(c=0;c<e;c+=1)this._change(null,c);this._animateOff=false;break}},_value:function(){var b=this.options.value;return b=this._trimAlignValue(b)},_values:function(b){var a,c;if(arguments.length){a=this.options.values[b];
return a=this._trimAlignValue(a)}else{a=this.options.values.slice();for(c=0;c<a.length;c+=1)a[c]=this._trimAlignValue(a[c]);return a}},_trimAlignValue:function(b){if(b<=this._valueMin())return this._valueMin();if(b>=this._valueMax())return this._valueMax();var a=this.options.step>0?this.options.step:1,c=(b-this._valueMin())%a;alignValue=b-c;if(Math.abs(c)*2>=a)alignValue+=c>0?a:-a;return parseFloat(alignValue.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},
_refreshValue:function(){var b=this.options.range,a=this.options,c=this,e=!this._animateOff?a.animate:false,f,h={},g,i,j,l;if(this.options.values&&this.options.values.length)this.handles.each(function(k){f=(c.values(k)-c._valueMin())/(c._valueMax()-c._valueMin())*100;h[c.orientation==="horizontal"?"left":"bottom"]=f+"%";d(this).stop(1,1)[e?"animate":"css"](h,a.animate);if(c.options.range===true)if(c.orientation==="horizontal"){if(k===0)c.range.stop(1,1)[e?"animate":"css"]({left:f+"%"},a.animate);
if(k===1)c.range[e?"animate":"css"]({width:f-g+"%"},{queue:false,duration:a.animate})}else{if(k===0)c.range.stop(1,1)[e?"animate":"css"]({bottom:f+"%"},a.animate);if(k===1)c.range[e?"animate":"css"]({height:f-g+"%"},{queue:false,duration:a.animate})}g=f});else{i=this.value();j=this._valueMin();l=this._valueMax();f=l!==j?(i-j)/(l-j)*100:0;h[c.orientation==="horizontal"?"left":"bottom"]=f+"%";this.handle.stop(1,1)[e?"animate":"css"](h,a.animate);if(b==="min"&&this.orientation==="horizontal")this.range.stop(1,
1)[e?"animate":"css"]({width:f+"%"},a.animate);if(b==="max"&&this.orientation==="horizontal")this.range[e?"animate":"css"]({width:100-f+"%"},{queue:false,duration:a.animate});if(b==="min"&&this.orientation==="vertical")this.range.stop(1,1)[e?"animate":"css"]({height:f+"%"},a.animate);if(b==="max"&&this.orientation==="vertical")this.range[e?"animate":"css"]({height:100-f+"%"},{queue:false,duration:a.animate})}}});d.extend(d.ui.slider,{version:"1.8.12"})})(jQuery);
;

/**
 * WYSIWYG - jQuery plugin 0.6
 *
 * Copyright (c) 2008-2009 Juan M Martinez
 * http://plugins.jquery.com/project/jWYSIWYG
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * $Id: $
 */
;(function( $ )
{
    $.fn.document = function()
    {
        var element = this.get(0);

        if ( element.nodeName.toLowerCase() == 'iframe' )
        {
            return element.contentWindow.document;
            /*
            return ( $.browser.msie )
                ? document.frames[element.id].document
                : element.contentWindow.document // contentDocument;
             */
        }
        return this;
    };

    $.fn.documentSelection = function()
    {
        var element = this.get(0);

        if ( element.contentWindow.document.selection )
            return element.contentWindow.document.selection.createRange().text;
        else
            return element.contentWindow.getSelection().toString();
    };

    $.fn.wysiwyg = function( options )
    {
        if ( arguments.length > 0 && arguments[0].constructor == String )
        {
            var action = arguments[0].toString();
            var params = [];

            for ( var i = 1; i < arguments.length; i++ )
                params[i - 1] = arguments[i];

            if ( action in Wysiwyg )
            {
                return this.each(function()
                {
                    $.data(this, 'wysiwyg')
                     .designMode();

                    Wysiwyg[action].apply(this, params);
                });
            }
            else return this;
        }

        var controls = {};

        /**
         * If the user set custom controls, we catch it, and merge with the
         * defaults controls later.
         */
        if ( options && options.controls )
        {
            var controls = options.controls;
            delete options.controls;
        }

        options = $.extend({
            html : '<'+'?xml version="1.0" encoding="UTF-8"?'+'><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">STYLE_SHEET</head><body style="margin: 0px;">INITIAL_CONTENT</body></html>',
            css  : {},

            debug        : false,

            autoSave     : true,  // http://code.google.com/p/jwysiwyg/issues/detail?id=11
            rmUnwantedBr : true,  // http://code.google.com/p/jwysiwyg/issues/detail?id=15
            brIE         : true,

            controls : {},
            messages : {}
        }, options);

        options.messages = $.extend(true, options.messages, Wysiwyg.MSGS_EN);
        options.controls = $.extend(true, options.controls, Wysiwyg.TOOLBAR);

        for ( var control in controls )
        {
            if ( control in options.controls )
                $.extend(options.controls[control], controls[control]);
            else
                options.controls[control] = controls[control];
        }

        // not break the chain
        return this.each(function()
        {
            Wysiwyg(this, options);
        });
    };

    function Wysiwyg( element, options )
    {
        return this instanceof Wysiwyg
            ? this.init(element, options)
            : new Wysiwyg(element, options);
    }

    $.extend(Wysiwyg, {
        insertImage : function( szURL, attributes )
        {
            var self = $.data(this, 'wysiwyg');

            if ( self.constructor == Wysiwyg && szURL && szURL.length > 0 )
            {
                if ($.browser.msie) self.focus();
                if ( attributes )
                {
                    self.editorDoc.execCommand('insertImage', false, '#jwysiwyg#');
                    var img = self.getElementByAttributeValue('img', 'src', '#jwysiwyg#');

                    if ( img )
                    {
                        img.src = szURL;

                        for ( var attribute in attributes )
                        {
                            img.setAttribute(attribute, attributes[attribute]);
                        }
                    }
                }
                else
                {
                    self.editorDoc.execCommand('insertImage', false, szURL);
                }
            }
        },

        createLink : function( szURL )
        {
            var self = $.data(this, 'wysiwyg');

            if ( self.constructor == Wysiwyg && szURL && szURL.length > 0 )
            {
                var selection = $(self.editor).documentSelection();

                if ( selection.length > 0 )
                {
                    if ($.browser.msie) self.focus();
                    self.editorDoc.execCommand('unlink', false, []);
                    self.editorDoc.execCommand('createLink', false, szURL);
                }
                else if ( self.options.messages.nonSelection )
                    alert(self.options.messages.nonSelection);
            }
        },

        insertHtml : function( szHTML )
        {
            var self = $.data(this, 'wysiwyg');

            if ( self.constructor == Wysiwyg && szHTML && szHTML.length > 0 )
            {
                if ($.browser.msie)
                {
                    self.focus();
                    self.editorDoc.execCommand('insertImage', false, '#jwysiwyg#');
                    var img = self.getElementByAttributeValue('img', 'src', '#jwysiwyg#');
                    if (img)
                    {
                        $(img).replaceWith(szHTML);
                    }
                }
                else
                {
                    self.editorDoc.execCommand('insertHTML', false, szHTML);
                }
            }
        },

        setContent : function( newContent )
        {
            var self = $.data(this, 'wysiwyg');
                self.setContent( newContent );
                self.saveContent();
        },

        clear : function()
        {
            var self = $.data(this, 'wysiwyg');
                self.setContent('');
                self.saveContent();
        },

        MSGS_EN : {
            nonSelection : 'select the text you wish to link'
        },

        TOOLBAR : {
            bold          : { visible : true, tags : ['b', 'strong'], css : { fontWeight : 'bold' }, tooltip : "Bold" },
            italic        : { visible : true, tags : ['i', 'em'], css : { fontStyle : 'italic' }, tooltip : "Italic" },
            strikeThrough : { visible : true, tags : ['s', 'strike'], css : { textDecoration : 'line-through' }, tooltip : "Strike-through" },
            underline     : { visible : true, tags : ['u'], css : { textDecoration : 'underline' }, tooltip : "Underline" },

            separator00 : { visible : true, separator : true },

            justifyLeft   : { visible : true, css : { textAlign : 'left' }, tooltip : "Justify Left" },
            justifyCenter : { visible : true, tags : ['center'], css : { textAlign : 'center' }, tooltip : "Justify Center" },
            justifyRight  : { visible : true, css : { textAlign : 'right' }, tooltip : "Justify Right" },
            justifyFull   : { visible : true, css : { textAlign : 'justify' }, tooltip : "Justify Full" },

            separator01 : { visible : true, separator : true },

            indent  : { visible : true, tooltip : "Indent" },
            outdent : { visible : true, tooltip : "Outdent" },

            separator02 : { visible : false, separator : true },

            subscript   : { visible : true, tags : ['sub'], tooltip : "Subscript" },
            superscript : { visible : true, tags : ['sup'], tooltip : "Superscript" },

            separator03 : { visible : true, separator : true },

            undo : { visible : true, tooltip : "Undo" },
            redo : { visible : true, tooltip : "Redo" },

            separator04 : { visible : true, separator : true },

            insertOrderedList    : { visible : true, tags : ['ol'], tooltip : "Insert Ordered List" },
            insertUnorderedList  : { visible : true, tags : ['ul'], tooltip : "Insert Unordered List" },
            insertHorizontalRule : { visible : true, tags : ['hr'], tooltip : "Insert Horizontal Rule" },

            separator05 : { separator : true },

            createLink : {
                visible : true,
                exec    : function()
                {
                    var selection = $(this.editor).documentSelection();

                    if ( selection.length > 0 )
                    {
                        if ( $.browser.msie )
                        {
                            this.focus();
                            this.editorDoc.execCommand('createLink', true, null);
                        }
                        else
                        {
                            var szURL = prompt('URL', 'http://');

                            if ( szURL && szURL.length > 0 )
                            {
                                this.editorDoc.execCommand('unlink', false, []);
                                this.editorDoc.execCommand('createLink', false, szURL);
                            }
                        }
                    }
                    else if ( this.options.messages.nonSelection )
                        alert(this.options.messages.nonSelection);
                },

                tags : ['a'],
                tooltip : "Create link"
            },

            insertImage : {
                visible : true,
                exec    : function()
                {
                    if ( $.browser.msie )
                    {
                        this.focus();
                        this.editorDoc.execCommand('insertImage', true, null);
                    }
                    else
                    {
                        var szURL = prompt('URL', 'http://');

                        if ( szURL && szURL.length > 0 )
                            this.editorDoc.execCommand('insertImage', false, szURL);
                    }
                },

                tags : ['img'],
                tooltip : "Insert image"
            },

            separator06 : { separator : true },

            h1mozilla : { visible : true && $.browser.mozilla, className : 'h1', command : 'heading', arguments : ['h1'], tags : ['h1'], tooltip : "Header 1" },
            h2mozilla : { visible : true && $.browser.mozilla, className : 'h2', command : 'heading', arguments : ['h2'], tags : ['h2'], tooltip : "Header 2" },
            h3mozilla : { visible : true && $.browser.mozilla, className : 'h3', command : 'heading', arguments : ['h3'], tags : ['h3'], tooltip : "Header 3" },

            h1 : { visible : true && !( $.browser.mozilla ), className : 'h1', command : 'formatBlock', arguments : ['<H1>'], tags : ['h1'], tooltip : "Header 1" },
            h2 : { visible : true && !( $.browser.mozilla ), className : 'h2', command : 'formatBlock', arguments : ['<H2>'], tags : ['h2'], tooltip : "Header 2" },
            h3 : { visible : true && !( $.browser.mozilla ), className : 'h3', command : 'formatBlock', arguments : ['<H3>'], tags : ['h3'], tooltip : "Header 3" },

            separator07 : { visible : false, separator : true },

            cut   : { visible : false, tooltip : "Cut" },
            copy  : { visible : false, tooltip : "Copy" },
            paste : { visible : false, tooltip : "Paste" },

            separator08 : { separator : false && !( $.browser.msie ) },

            increaseFontSize : { visible : false && !( $.browser.msie ), tags : ['big'], tooltip : "Increase font size" },
            decreaseFontSize : { visible : false && !( $.browser.msie ), tags : ['small'], tooltip : "Decrease font size" },

            separator09 : { separator : true },

            html : {
                visible : false,
                exec    : function()
                {
                    if ( this.viewHTML )
                    {
                        this.setContent( $(this.original).val() );
                        $(this.original).hide();
                    }
                    else
                    {
                        this.saveContent();
                        $(this.original).show();
                    }

                    this.viewHTML = !( this.viewHTML );
                },
                tooltip : "View source code"
            },

            removeFormat : {
                visible : true,
                exec    : function()
                {
                    if ($.browser.msie) this.focus();
                    this.editorDoc.execCommand('removeFormat', false, []);
                    this.editorDoc.execCommand('unlink', false, []);
                },
                tooltip : "Remove formatting"
            }
        }
    });

    $.extend(Wysiwyg.prototype,
    {
        original : null,
        options  : {},

        element  : null,
        editor   : null,

        focus : function()
        {
            $(this.editorDoc.body).focus();
        },

        init : function( element, options )
        {
            var self = this;

            this.editor = element;
            this.options = options || {};

            $.data(element, 'wysiwyg', this);

            var newX = element.width || element.clientWidth;
            var newY = element.height || element.clientHeight;

            if ( element.nodeName.toLowerCase() == 'textarea' )
            {
                this.original = element;

                if ( newX == 0 && element.cols )
                    newX = ( element.cols * 8 ) + 21;

                if ( newY == 0 && element.rows )
                    newY = ( element.rows * 16 ) + 16;

                var editor = this.editor = $('<iframe src="javascript:false;"></iframe>').css({
                    minHeight : ( newY - 6 ).toString() + 'px',
                    width     : ( newX - 0 ).toString() + 'px'
                }).attr('id', $(element).attr('id') + 'IFrame')
                .attr('frameborder', '0');

                /**
                 * http://code.google.com/p/jwysiwyg/issues/detail?id=96
                 */
                this.editor.attr('tabindex', $(element).attr('tabindex'));

                if ( $.browser.msie )
                {
                    this.editor
                        .css('height', ( newY ).toString() + 'px');

                    /**
                    var editor = $('<span></span>').css({
                        width     : ( newX - 6 ).toString() + 'px',
                        height    : ( newY - 8 ).toString() + 'px'
                    }).attr('id', $(element).attr('id') + 'IFrame');

                    editor.outerHTML = this.editor.outerHTML;
                     */
                }
            }

            var panel = this.panel = $('<ul role="menu" class="panel"></ul>');

            this.appendControls();
            this.element = $('<div></div>').css({
                width : ( newX > 0 ) ? ( newX ).toString() + 'px' : '100%'
            }).addClass('wysiwyg')
                .append(panel)
                .append( $('<div><!-- --></div>').css({ clear : 'both' }) )
                .append(editor)
		;

            $(element)
                .hide()
                .before(this.element)
		;

            this.viewHTML = false;
            this.initialHeight = newY - 8;

            /**
             * @link http://code.google.com/p/jwysiwyg/issues/detail?id=52
             */
            this.initialContent = $(element).val();
            this.initFrame();

            if ( this.initialContent.length == 0 )
                this.setContent('');

            /**
             * http://code.google.com/p/jwysiwyg/issues/detail?id=100
             */
            var form = $(element).closest('form');

            if ( this.options.autoSave )
	    {
                form.submit(function() { self.saveContent(); });
	    }

            form.bind('reset', function()
            {
                self.setContent( self.initialContent );
                self.saveContent();
            });
        },

        initFrame : function()
        {
            var self = this;
            var style = '';

            /**
             * @link http://code.google.com/p/jwysiwyg/issues/detail?id=14
             */
            if ( this.options.css && this.options.css.constructor == String )
	    {
                style = '<link rel="stylesheet" type="text/css" media="screen" href="' + this.options.css + '" />';
	    }

            this.editorDoc = $(this.editor).document();
            this.editorDoc_designMode = false;

            try {
                this.editorDoc.designMode = 'on';
                this.editorDoc_designMode = true;
            } catch ( e ) {
                // Will fail on Gecko if the editor is placed in an hidden container element
                // The design mode will be set ones the editor is focused

                $(this.editorDoc).focus(function()
                {
                    self.designMode();
                });
            }

            this.editorDoc.open();
            this.editorDoc.write(
                this.options.html
                    /**
                     * @link http://code.google.com/p/jwysiwyg/issues/detail?id=144
                     */
                    .replace(/INITIAL_CONTENT/, function() { return self.initialContent; })
                    .replace(/STYLE_SHEET/, function() { return style; })
            );
            this.editorDoc.close();

            this.editorDoc.contentEditable = 'true';

            if ( $.browser.msie )
            {
                /**
                 * Remove the horrible border it has on IE.
                 */
                setTimeout(function() { $(self.editorDoc.body).css('border', 'none'); }, 0);
            }

            $(this.editorDoc).click(function( event )
            {
                self.checkTargets( event.target ? event.target : event.srcElement);
            });

            /**
             * @link http://code.google.com/p/jwysiwyg/issues/detail?id=20
             */
            $(this.original).focus(function()
            {
                if (!$.browser.msie)
                {
                    self.focus();
                }
            });

            if ( this.options.autoSave )
            {
                /**
                 * @link http://code.google.com/p/jwysiwyg/issues/detail?id=11
                 */
                $(this.editorDoc).keydown(function() { self.saveContent(); })
                                 .keyup(function() { self.saveContent(); })
                                 .mousedown(function() { self.saveContent(); });
            }

            if ( this.options.css )
            {
                setTimeout(function()
                {
                    if ( self.options.css.constructor == String )
                    {
                        /**
                         * $(self.editorDoc)
                         * .find('head')
                         * .append(
                         *     $('<link rel="stylesheet" type="text/css" media="screen" />')
                         *     .attr('href', self.options.css)
                         * );
                         */
                    }
                    else
                        $(self.editorDoc).find('body').css(self.options.css);
                }, 0);
            }

            $(this.editorDoc).keydown(function( event )
            {
                if ( $.browser.msie && self.options.brIE && event.keyCode == 13 )
                {
                    var rng = self.getRange();
                    rng.pasteHTML('<br />');
                    rng.collapse(false);
                    rng.select();
                    return false;
                }
                return true;
            });
        },

        designMode : function()
        {
            if ( !( this.editorDoc_designMode ) )
            {
                try {
                    this.editorDoc.designMode = 'on';
                    this.editorDoc_designMode = true;
                } catch ( e ) {}
            }
        },

        getSelection : function()
        {
            return ( window.getSelection ) ? window.getSelection() : document.selection;
        },

        getRange : function()
        {
            var selection = this.getSelection();

            if ( !( selection ) )
                return null;

            return ( selection.rangeCount > 0 ) ? selection.getRangeAt(0) : selection.createRange();
        },

        getContent : function()
        {
            return $( $(this.editor).document() ).find('body').html();
        },

        setContent : function( newContent )
        {
            $( $(this.editor).document() ).find('body').html(newContent);
        },

        saveContent : function()
        {
            if ( this.original )
            {
                var content = this.getContent();

                if ( this.options.rmUnwantedBr )
		{
                    content = ( content.substr(-4) == '<br>' ) ? content.substr(0, content.length - 4) : content;
		}

                $(this.original).val(content);
            }
        },

        withoutCss: function()
        {
            if ($.browser.mozilla)
            {
                try
                {
                    this.editorDoc.execCommand('styleWithCSS', false, false);
                }
                catch (e)
                {
                    try
                    {
                        this.editorDoc.execCommand('useCSS', false, true);
                    }
                    catch (e)
                    {
                    }
                }
            }
        },

        appendMenu : function( cmd, args, className, fn, tooltip )
        {
            var self = this;
            args = args || [];

            $('<li></li>').append(
                $('<a role="menuitem" tabindex="-1" href="javascript:;">' + (className || cmd) + '</a>')
                    .addClass(className || cmd)
                    .attr('title', tooltip)
            ).click(function() {
                if ( fn ) fn.apply(self); else
                {
                    self.withoutCss();
                    self.editorDoc.execCommand(cmd, false, args);
                }
                if ( self.options.autoSave ) self.saveContent();
            }).appendTo( this.panel );
        },

        appendMenuSeparator : function()
        {
            $('<li role="separator" class="separator"></li>').appendTo( this.panel );
        },

        appendControls : function()
        {
            for ( var name in this.options.controls )
            {
                var control = this.options.controls[name];

                if ( control.separator )
                {
                    if ( control.visible !== false )
                        this.appendMenuSeparator();
                }
                else if ( control.visible )
                {
                    this.appendMenu(
                        control.command || name, control.arguments || [],
                        control.className || control.command || name || 'empty', control.exec,
                        control.tooltip || control.command || name || ''
                    );
                }
            }
        },

        checkTargets : function( element )
        {
            for ( var name in this.options.controls )
            {
                var control = this.options.controls[name];
                var className = control.className || control.command || name || 'empty';

                $('.' + className, this.panel).removeClass('active');

                if ( control.tags )
                {
                    var elm = element;

                    do {
                        if ( elm.nodeType != 1 )
                            break;

                        if ( $.inArray(elm.tagName.toLowerCase(), control.tags) != -1 )
                            $('.' + className, this.panel).addClass('active');
                    } while ((elm = elm.parentNode));
                }

                if ( control.css )
                {
                    var elm = $(element);

                    do {
                        if ( elm[0].nodeType != 1 )
                            break;

                        for ( var cssProperty in control.css )
                            if ( elm.css(cssProperty).toString().toLowerCase() == control.css[cssProperty] )
                                $('.' + className, this.panel).addClass('active');
                    } while ((elm = elm.parent()));
                }
            }
        },

        getElementByAttributeValue : function( tagName, attributeName, attributeValue )
        {
            var elements = this.editorDoc.getElementsByTagName(tagName);

            for ( var i = 0; i < elements.length; i++ )
            {
                var value = elements[i].getAttribute(attributeName);

                if ( $.browser.msie )
                {
                    /** IE add full path, so I check by the last chars. */
                    value = value.substr(value.length - attributeValue.length);
                }

                if ( value == attributeValue )
                    return elements[i];
            }

            return false;
        }
    });
})(jQuery);

function addClass (_options) {
	var _tagName = _options.tagName;
	var _tagClass = _options.tagClass;
	var _classAdd = _options.classAdd;
	var _addToParent = false || _options.addToParent;
	var _el = document.getElementsByTagName(_tagName);
	if (_el) {
		for (var i=0; i < _el.length; i++) {
			if (_el[i].className.indexOf(_tagClass) != -1) {
				_el[i].onclick = function() {
					if (_addToParent) {
						if (this.parentNode.className.indexOf(_classAdd) == -1) {
							this.parentNode.className += ' '+_classAdd;
						} else {
							this.parentNode.className = this.parentNode.className.replace(_classAdd,'');
						}
					} else {
						if (this.className.indexOf(_classAdd) == -1) {
							this.className += ' '+_classAdd;
						} else {
							this.className = this.className.replace(_classAdd,'');
						}
					}
					return false;
				}
			}
		}
	}
}

/*	
 *	jQuery carouFredSel 3.2.1
 *	Demo's and documentation:
 *	caroufredsel.frebsite.nl
 *	
 *	Copyright (c) 2010 Fred Heusschen
 *	www.frebsite.nl
 *
 *	Dual licensed under the MIT and GPL licenses.
 *	http://en.wikipedia.org/wiki/MIT_License
 *	http://en.wikipedia.org/wiki/GNU_General_Public_License
 */
 
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(v($){$.1h.1i=v(o){9(I.U==0)y 14(\'3h 3i 2t.\');9(I.U>1){y I.1x(v(){$(I).1i(o)})}I.2u=v(o){9(q o!=\'1a\')o={};9(q o.S==\'C\'){9(o.S<=3j)o.S={u:o.S};A o.S={W:o.S}}A{9(q o.S==\'15\')o.S={X:o.S}}9(q o.u==\'C\')o.u={G:o.u};A 9(q o.u==\'15\')o.u={G:o.u,1K:o.u,1L:o.u};8=$.1M(K,{},$.1h.1i.2L,o);8.P=2M(8.P);8.11=(8.P[0]==0&&8.P[1]==0&&8.P[2]==0&&8.P[3]==0)?Q:K;1j=(8.1j==\'2N\'||8.1j==\'1k\')?\'E\':\'H\';9(8.1j==\'2O\'||8.1j==\'1k\'){8.w=[\'1K\',\'2P\',\'1L\',\'2Q\',\'1k\',\'22\',\'3k\',\'3l\']}A{8.w=[\'1L\',\'2Q\',\'1K\',\'2P\',\'22\',\'1k\',\'3m\',\'3n\'];8.P=[8.P[3],8.P[2],8.P[1],8.P[0]]}9(8[8.w[2]]==\'L\'){8[8.w[2]]=1l(8,J(j))[1];8.u[8.w[2]]=\'L\'}A{9(!8.u[8.w[2]]){8.u[8.w[2]]=J(j)[8.w[3]](K)}}9(!8.u[8.w[0]]){8.u[8.w[0]]=J(j)[8.w[1]](K)}9(8.u.G==\'3o\'){9(q 8[8.w[0]]==\'C\'){8.1y=8[8.w[0]];8[8.w[0]]=1N}A{8.1y=l.1O()[8.w[7]]()}9(q 8.u[8.w[0]]==\'C\'){8.u.G=2v.3p(8.1y/8.u[8.w[0]])}A{2w=K;8.u.G=0}}9(q 8.u.1P!=\'C\')8.u.1P=8.u.G;9(q 8.S.u!=\'C\')8.S.u=8.u.G;9(q 8.S.W!=\'C\')8.S.W=3q;8.L=1Q(8.L,Q,K);8.H=1Q(8.H);8.E=1Q(8.E);8.T=1Q(8.T,K);8.L=$.1M({},8.S,8.L);8.H=$.1M({},8.S,8.H);8.E=$.1M({},8.S,8.E);8.T=$.1M({},8.S,8.T);9(q 8.T.23!=\'Z\')8.T.23=Q;9(q 8.T.2x!=\'v\')8.T.2x=$.1h.1i.2R;9(q 8.L.V!=\'Z\')8.L.V=K;9(q 8.L.1R!=\'Z\')8.L.1R=K;9(q 8.L.2y!=\'C\')8.L.2y=0;9(q 8.L.24!=\'C\')8.L.24=(8.L.W<10)?3r:8.L.W*5};I.2S=v(){l.O({25:\'3s\',3t:\'3u\'});j.z(\'2T\',{1K:j.O(\'1K\'),1L:j.O(\'1L\'),25:j.O(\'25\'),22:j.O(\'22\'),1k:j.O(\'1k\')}).O({25:\'3v\'});9(8.11){J(j).1x(v(){D m=1S($(I).O(8.w[6]));9(26(m))m=0;$(I).z(\'Y\',m)})}27(8,F)};I.2U=v(){j.16(\'1e\',v(e,g){9(q g!=\'Z\')g=Q;9(g)1m=K;9(28!=1N){3w(28)}9(29!=1N){3x(29)}});j.16(\'V\',v(e,d,f,g){j.B(\'1e\');9(8.L.V){9(q g!=\'Z\'){9(q f==\'Z\')g=f;A 9(q d==\'Z\')g=d;A g=Q}9(q f!=\'C\'){9(q d==\'C\')f=d;A f=0}9(d!=\'H\'&&d!=\'E\')d=1j;9(g)1m=Q;9(1m)y;28=3y(v(){9(j.1b(\':1z\')){j.B(\'V\',d)}A{2a=0;j.B(d,8.L)}},8.L.24+f-2a);9(8.L.1A===\'3z\'){29=3A(v(){2a+=2V},2V)}}});9(2w){j.16(\'H\',v(e,b,c){9(j.1b(\':1z\'))y;9(1m)y;D d=J(j),1n=0,x=0;9(q b==\'C\')c=b;9(q c!=\'C\'){1T(D a=d.U-1;a>=0;a--){1f=d.18(\':2z(\'+a+\')\')[8.w[1]](K);9(1n+1f>8.1y)2A;1n+=1f;x++}c=x}1T(D a=d.U-c;a<d.U;a++){1f=d.18(\':2z(\'+a+\')\')[8.w[1]](K);9(1n+1f>8.1y)2A;1n+=1f;9(a==d.U-1)a=0;x++};8.u.G=x;j.B(\'2B\',[b,c])});j.16(\'E\',v(e,b,c){9(j.1b(\':1z\'))y;9(1m)y;D d=J(j),1n=0,x=0;9(q b==\'C\')c=b;9(q c!=\'C\')c=8.u.G;1T(D a=c;a<d.U;a++){1f=d.18(\':2z(\'+a+\')\')[8.w[1]](K);9(1n+1f>8.1y)2A;1n+=1f;9(a==d.U-1)a=0;x++};8.u.G=x;j.B(\'2C\',[b,c])}).B(\'E\',{W:0})}A{j.16(\'H\',v(e,a,b){j.B(\'2B\',[a,b])});j.16(\'E\',v(e,a,b){j.B(\'2C\',[a,b])})}j.16(\'2B\',v(e,b,c){9(j.1b(\':1z\'))y;9(1m)y;9(8.u.1P>=F)y 14(\'1t 2D u: 1U 1V\');9(q b==\'C\')c=b;9(q b!=\'1a\')b=8.H;9(q c!=\'C\')c=b.u;9(q c!=\'C\')y 14(\'1t a 2b C: 1U 1V\');9(!8.1u){D d=F-M;9(d-c<0){c=d}9(M==0){c=0}}M+=c;9(M>=F)M-=F;9(!8.1u){9(M==0&&c!=0&&8.H.2c){8.H.2c()}9(8.2d){9(c==0){j.B(\'E\',F-8.u.G);y Q}}A{9(M==0&&8.H.R)8.H.R.2e(\'1W\');9(8.E.R)8.E.R.2E(\'1W\')}}9(c==0){y Q}J(j,\':2f(\'+(F-c-1)+\')\').3B(j);9(F<8.u.G+c)J(j,\':1o(\'+((8.u.G+c)-F)+\')\').2W(K).2F(j);D f=2G(j,8,c),1p=J(j,\':1v(\'+(c-1)+\')\'),17=f[1].18(\':1B\'),1c=f[0].18(\':1B\');9(8.11)17.O(8.w[6],17.z(\'Y\'));D g=1l(8,J(j,\':1o(\'+c+\')\')),1q=2g(1l(8,f[0],K),8);9(8.11)17.O(8.w[6],17.z(\'Y\')+8.P[1]);D h={},2H={},1C={},N=b.W;9(N==\'L\')N=8.S.W/8.S.u*c;A 9(N<=0)N=0;A 9(N<10)N=g[0]/N;9(b.2h)b.2h(f[1],f[0],1q,N);9(8.11){D i=8.P[3];1C[8.w[6]]=1p.z(\'Y\');2H[8.w[6]]=1c.z(\'Y\')+8.P[1];1p.O(8.w[6],1p.z(\'Y\')+8.P[3]);1p.1D().1r(1C,{W:N,X:b.X});1c.1D().1r(2H,{W:N,X:b.X})}A{D i=0}h[8.w[4]]=i;9((q 8[8.w[0]]!=\'C\'&&q 8.u[8.w[0]]!=\'C\')||(q 8[8.w[2]]!=\'C\'&&q 8.u[8.w[2]]!=\'C\')){l.1D().1r(1q,{W:N,X:b.X})}j.z(\'1E\',c).z(\'1F\',b).z(\'2i\',f[1]).z(\'2j\',f[0]).z(\'2k\',1q).O(8.w[4],-g[0]).1r(h,{W:N,X:b.X,2X:v(){9(j.z(\'1F\').2l){j.z(\'1F\').2l(j.z(\'2i\'),j.z(\'2j\'),j.z(\'2k\'))}9(F<8.u.G+j.z(\'1E\')){J(j,\':2f(\'+(F-1)+\')\').1X()}D a=J(j,\':1v(\'+(8.u.G+j.z(\'1E\')-1)+\')\');9(8.11){a.O(8.w[6],a.z(\'Y\'))}}});j.B(\'1w\').B(\'V\',N)});j.16(\'2C\',v(e,c,d){9(j.1b(\':1z\'))y;9(1m)y;9(8.u.1P>=F)y 14(\'1t 2D u: 1U 1V\');9(q c==\'C\')d=c;9(q c!=\'1a\')c=8.E;9(q d!=\'C\')d=c.u;9(q d!=\'C\')y 14(\'1t a 2b C: 1U 1V\');9(!8.1u){9(M==0){9(d>F-8.u.G){d=F-8.u.G}}A{9(M-d<8.u.G){d=M-8.u.G}}}M-=d;9(M<0)M+=F;9(!8.1u){9(M==8.u.G&&d!=0&&8.E.2c){8.E.2c()}9(8.2d){9(d==0){j.B(\'H\',F-8.u.G);y Q}}A{9(M==8.u.G&&8.E.R)8.E.R.2e(\'1W\');9(8.H.R)8.H.R.2E(\'1W\')}}9(d==0){y Q}9(F<8.u.G+d)J(j,\':1o(\'+((8.u.G+d)-F)+\')\').2W(K).2F(j);D f=2G(j,8,d),1p=J(j,\':1v(\'+(d-1)+\')\'),17=f[0].18(\':1B\'),1c=f[1].18(\':1B\');9(8.11){17.O(8.w[6],17.z(\'Y\'));1c.O(8.w[6],1c.z(\'Y\'))}D g=1l(8,J(j,\':1o(\'+d+\')\')),1q=2g(1l(8,f[1],K),8);9(8.11){17.O(8.w[6],17.z(\'Y\')+8.P[1]);1c.O(8.w[6],1c.z(\'Y\')+8.P[1])}D h={},2I={},1C={},N=c.W;9(N==\'L\')N=8.S.W/8.S.u*d;A 9(N<=0)N=0;A 9(N<10)N=g[0]/N;9(c.2h)c.2h(f[0],f[1],1q,N);h[8.w[4]]=-g[0];9(8.11){2I[8.w[6]]=17.z(\'Y\');1C[8.w[6]]=1p.z(\'Y\')+8.P[3];1c.O(8.w[6],1c.z(\'Y\')+8.P[1]);17.1D().1r(2I,{W:N,X:c.X});1p.1D().1r(1C,{W:N,X:c.X})}9((q 8[8.w[0]]!=\'C\'&&q 8.u[8.w[0]]!=\'C\')||(q 8[8.w[2]]!=\'C\'&&q 8.u[8.w[2]]!=\'C\')){l.1D().1r(1q,{W:N,X:c.X})}j.z(\'1E\',d).z(\'1F\',c).z(\'2i\',f[0]).z(\'2j\',f[1]).z(\'2k\',1q).1r(h,{W:N,X:c.X,2X:v(){9(j.z(\'1F\').2l){j.z(\'1F\').2l(j.z(\'2i\'),j.z(\'2j\'),j.z(\'2k\'))}9(F<8.u.G+j.z(\'1E\')){J(j,\':2f(\'+(F-1)+\')\').1X()}D a=(8.11)?8.P[3]:0;j.O(8.w[4],a);D b=J(j,\':1o(\'+j.z(\'1E\')+\')\').2F(j).18(\':1B\');9(8.11){b.O(8.w[6],b.z(\'Y\'))}}});j.B(\'1w\').B(\'V\',N)});j.16(\'1G\',v(e,a,b,c,d){9(j.1b(\':1z\'))y Q;a=2m(a,b,c,M,F,j);9(a==0)y Q;9(q d!=\'1a\')d=Q;9(8.1u){9(a<F/2)j.B(\'E\',[d,a]);A j.B(\'H\',[d,F-a])}A{9(M==0||M>a)j.B(\'E\',[d,a]);A j.B(\'H\',[d,F-a])}}).16(\'2Y\',v(e,a,b,c,d){9(q a==\'1a\'&&q a.1Y==\'12\')a=$(a);9(q a==\'15\')a=$(a);9(q a!=\'1a\'||q a.1Y==\'12\'||a.U==0)y 14(\'1t a 2b 1a.\');9(q b==\'12\'||b==\'2Z\'){j.2J(a)}A{b=2m(b,d,c,M,F,j);D f=J(j,\':1v(\'+b+\')\');9(f.U){9(b<=M)M+=a.U;f.3C(a)}A{j.2J(a)}}F=J(j).U;1H(\'\',\'.2n\',j);1Z(j,8);27(8,F);j.B(\'1w\',K)}).16(\'30\',v(e,a,b,c){9(q a==\'12\'||a==\'2Z\'){J(j,\':1B\').1X()}A{a=2m(a,c,b,M,F,j);D d=J(j,\':1v(\'+a+\')\');9(d.U){9(a<M)M-=d.U;d.1X()}}F=J(j).U;1H(\'\',\'.2n\',j);1Z(j,8);27(8,F);j.B(\'1w\',K)}).16(\'1w\',v(e,b){9(!8.T.13)y Q;9(q b==\'Z\'&&b){J(8.T.13).1X();1T(D a=0;a<2v.3D(F/8.u.G);a++){8.T.13.2J(8.T.2x(a+1))}J(8.T.13).19(\'1I\').1x(v(a){$(I).1I(v(e){e.1g();j.B(\'1G\',[a*8.u.G,0,K,8.T])})})}D c=(M==0)?0:2v.3E((F-M)/8.u.G);J(8.T.13).2E(\'2t\').18(\':1v(\'+c+\')\').2e(\'2t\')})};I.31=v(){9(8.L.1A&&8.L.V){l.2o(v(){j.B(\'1e\')},v(){j.B(\'V\')})}9(8.H.R){8.H.R.1I(v(e){j.B(\'H\');e.1g()});9(8.H.1A&&8.L.V){8.H.R.2o(v(){j.B(\'1e\')},v(){j.B(\'V\')})}9(!8.1u&&!8.2d){8.H.R.2e(\'1W\')}}9($.1h.1d){9(8.H.1d){l.1d(v(e,a){9(a>0){e.1g();2p=(q 8.H.1d==\'C\')?8.H.1d:\'\';j.B(\'H\',2p)}})}9(8.E.1d){l.1d(v(e,a){9(a<0){e.1g();2p=(q 8.E.1d==\'C\')?8.E.1d:\'\';j.B(\'E\',2p)}})}}9(8.E.R){8.E.R.1I(v(e){e.1g();j.B(\'E\')});9(8.E.1A&&8.L.V){8.E.R.2o(v(){j.B(\'1e\')},v(){j.B(\'V\')})}}9(8.T.13){j.B(\'1w\',K);9(8.T.1A&&8.L.V){8.T.13.2o(v(){j.B(\'1e\')},v(){j.B(\'V\')})}}9(8.E.1s||8.H.1s){$(32).33(v(e){D k=e.34;9(k==8.E.1s){e.1g();j.B(\'E\')}9(k==8.H.1s){e.1g();j.B(\'H\')}})}9(8.T.23){$(32).33(v(e){D k=e.34;9(k>=49&&k<3F){k=(k-49)*8.u.G;9(k<=F){e.1g();j.B(\'1G\',[k,0,K,8.T])}}})}9(8.L.V){j.B(\'V\',8.L.2y);9($.1h.1R&&8.L.1R){j.1R(\'1e\',\'V\')}}};I.35=v(){j.B(\'1e\').O(j.z(\'2T\')).19(\'1e\').19(\'V\').19(\'H\').19(\'E\').19(\'3G\').19(\'1G\').19(\'2Y\').19(\'30\').19(\'1w\');l.3H(j);y I};I.3I=v(a,b){9(q a==\'12\')y 8;9(q b==\'12\'){D r=36(\'8.\'+a);9(q r==\'12\')r=\'\';y r}36(\'8.\'+a+\' = b\');I.2u(8);1Z(j,8);y I};I.1H=v(a,b){1H(a,b,j)};I.3J=v(){9(M==0){y 0}y F-M};D j=$(I);9($(I).1O().1b(\'.3a\')){D l=j.1O();I.35()}D l=$(I).3K(\'<3L 3M="3a" />\').1O(),8={},F=J(j).U,M=0,28=1N,29=1N,2a=0,1m=Q,1j=\'E\',2w=Q;I.2u(o);I.2S();I.2U();I.31();1H(\'\',\'.2n\',j);1Z(j,8);9(8.u.20!==0&&8.u.20!==Q){D s=8.u.20;9(8.u.20===K){s=2q.3N.3b;9(!s.U)s=0}j.B(\'1G\',[s,0,K,{W:0}])}y I};$.1h.1i.2L={2d:K,1u:K,1j:\'1k\',P:0,u:{G:5,20:0},S:{X:\'3O\',1A:Q,1d:Q}};$.1h.1i.2R=v(a){y\'<a 3P="#"><3c>\'+a+\'</3c></a>\'};v 1H(a,b,c){9(q a==\'12\'||a.U==0)a=$(\'3Q\');A 9(q a==\'15\')a=$(a);9(q a!=\'1a\')y Q;9(q b==\'12\')b=\'\';a.3R(\'a\'+b).1x(v(){D h=I.3b||\'\';9(h.U>0&&J(c).3d($(h))!=-1){$(I).19(\'1I\').1I(v(e){e.1g();c.B(\'1G\',h)})}})}v 27(o,t){9(o.u.1P>=t){14(\'1t 2D u: 1U 1V\');D f=\'3S\'}A{D f=\'3T\'}9(o.H.R)o.H.R[f]();9(o.E.R)o.E.R[f]();9(o.T.13)o.T.13[f]()}v 2K(k){9(k==\'2O\')y 39;9(k==\'1k\')y 37;9(k==\'2N\')y 38;9(k==\'3U\')y 40;y-1};v 1Q(a,b,c){9(q b!=\'Z\')b=Q;9(q c!=\'Z\')c=Q;9(q a==\'12\')a={};9(q a==\'15\'){D d=2K(a);9(d==-1)a=$(a);A a=d}9(b){9(q a.1Y!=\'12\')a={13:a};9(q 3V==\'Z\')a={23:a};9(q a.13==\'15\')a.13=$(a.13)}A 9(c){9(q a==\'Z\')a={V:a};9(q a==\'C\')a={24:a}}A{9(q a.1Y!=\'12\')a={R:a};9(q a==\'C\')a={1s:a};9(q a.R==\'15\')a.R=$(a.R);9(q a.1s==\'15\')a.1s=2K(a.1s)}y a};v J(a,f){9(q f!=\'15\')f=\'\';y $(\'> *\'+f,a)};v 2G(c,o,n){D a=J(c,\':1o(\'+o.u.G+\')\'),3e=J(c,\':1o(\'+(o.u.G+n)+\'):2f(\'+(n-1)+\')\');y[a,3e]};v 2m(a,b,c,d,e,f){9(q a==\'15\'){9(26(a))a=$(a);A a=1S(a)}9(q a==\'1a\'){9(q a.1Y==\'12\')a=$(a);a=J(f).3d(a);9(a==-1)a=0;9(q c!=\'Z\')c=Q}A{9(q c!=\'Z\')c=K}9(26(a))a=0;A a=1S(a);9(26(b))b=0;A b=1S(b);9(c){a+=d}a+=b;9(e>0){3f(a>=e){a-=e}3f(a<0){a+=e}}y a};v 1l(o,a,b){9(q b!=\'Z\')b=Q;D c=o.w,21=0,1J=0;9(b&&q o[c[0]]==\'C\')21+=o[c[0]];A 9(q o.u[c[0]]==\'C\')21+=o.u[c[0]]*a.U;A{a.1x(v(){21+=$(I)[c[1]](K)})}9(b&&q o[c[2]]==\'C\')1J+=o[c[2]];A 9(q o.u[c[2]]==\'C\')1J+=o.u[c[2]];A{a.1x(v(){D m=$(I)[c[3]](K);9(1J<m)1J=m})}y[21,1J]};v 2g(a,o){D b=(o.11)?o.P:[0,0,0,0];D c={};c[o.w[0]]=a[0]+b[1]+b[3];c[o.w[2]]=a[1]+b[0]+b[2];y c};v 1Z(a,o){D b=a.1O(),$i=J(a),$l=$i.18(\':1v(\'+(o.u.G-1)+\')\'),1b=1l(o,$i,Q);b.O(2g(1l(o,$i.18(\':1o(\'+o.u.G+\')\'),K),o));9(o.11){$l.O(o.w[6],$l.z(\'Y\')+o.P[1]);a.O(o.w[5],o.P[0]);a.O(o.w[4],o.P[3])}a.O(o.w[0],1b[0]*2);a.O(o.w[2],1b[1])};v 2M(p){9(q p==\'C\')p=[p];A 9(q p==\'15\')p=p.3g(\'3W\').3X(\'\').3g(\' \');9(q p!=\'1a\'){14(\'1t a 2b 3Y, P 3Z 41 "0".\');p=[0]}1T(i 42 p){p[i]=1S(p[i])}43(p.U){2r 0:y[0,0,0,0];2r 1:y[p[0],p[0],p[0],p[0]];2r 2:y[p[0],p[1],p[0],p[1]];2r 3:y[p[0],p[1],p[2],p[1]];44:y p}};v 14(m){9(q m==\'15\')m=\'1i: \'+m;9(2q.2s&&2q.2s.14)2q.2s.14(m);A 45{2s.14(m)}46(47){}y Q};$.1h.2n=v(o){I.1i(o)}})(48);',62,258,'||||||||opts|if|||||||||||||||||typeof||||items|function|dimentions||return|data|else|trigger|number|var|next|totalItems|visible|prev|this|getItems|true|auto|firstItem|a_dur|css|padding|false|button|scroll|pagination|length|play|duration|easing|cfs_origCssMargin|boolean||usePadding|undefined|container|log|string|bind|l_old|filter|unbind|object|is|l_new|mousewheel|pause|current|preventDefault|fn|carouFredSel|direction|left|getSizes|pausedGlobal|total|lt|l_cur|w_siz|animate|key|Not|circular|nth|updatePageStatus|each|maxDimention|animated|pauseOnHover|last|a_cur|stop|cfs_numItems|cfs_slideObj|slideTo|link_anchors|click|s2|width|height|extend|null|parent|minimum|getNaviObject|nap|parseInt|for|not|scrolling|disabled|remove|jquery|setSizes|start|s1|top|keys|pauseDuration|position|isNaN|showNavi|autoTimeout|autoInterval|pauseTimePassed|valid|onEnd|infinite|addClass|gt|mapWrapperSizes|onBefore|cfs_oldItems|cfs_newItems|cfs_wrapSize|onAfter|getItemIndex|caroufredsel|hover|num|window|case|console|selected|init|Math|varnumvisitem|anchorBuilder|delay|eq|break|scrollPrev|scrollNext|enough|removeClass|appendTo|getCurrentItems|a_new|a_old|append|getKeyCode|defaults|getPadding|up|right|outerWidth|outerHeight|pageAnchorBuilder|build|cfs_origCss|bind_events|100|clone|complete|insertItem|end|removeItem|bind_buttons|document|keyup|keyCode|destroy|eval||||caroufredsel_wrapper|hash|span|index|ni|while|split|No|element|50|marginRight|innerWidth|marginBottom|innerHeight|variable|floor|500|2500|relative|overflow|hidden|absolute|clearTimeout|clearInterval|setTimeout|resume|setInterval|prependTo|before|ceil|round|58|scrollTo|replaceWith|configuration|current_position|wrap|div|class|location|swing|href|body|find|hide|show|down|Object|px|join|value|set||to|in|switch|default|try|catch|err|jQuery|'.split('|'),0,{}))
