/*  */
/**
 * ------------------------------------------------------------------------
 * JA T3v2 System Plugin for J25 & J30
 * ------------------------------------------------------------------------
 * Copyright (C) 2004-2011 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
 * @license - GNU/GPL, http://www.gnu.org/licenses/gpl.html
 * Author: J.O.O.M Solutions Co., Ltd
 * Websites: http://www.joomlart.com - http://www.joomlancers.com
 * ------------------------------------------------------------------------
 */

function switchFontSize (ckname,val) {
    var bd = document.getElementsByTagName('body');
    if (!bd || !bd.length) return;
    bd = bd[0];
    //var oldclass = 'fs'+CurrentFontSize;
    switch (val) {
        case 'inc':
            if (CurrentFontSize+1 < 7) {
                CurrentFontSize++;
            }
            break;
        case 'dec':
            if (CurrentFontSize-1 > 0) {
                CurrentFontSize--;
            }
            break;
        case 'reset':
        default:
            CurrentFontSize = DefaultFontSize;
    }
    var newclass = 'fs'+CurrentFontSize;
    bd.className = bd.className.replace(new RegExp('fs.?', 'g'), '');
    bd.className = trim(bd.className);
    bd.className += (bd.className?' ':'') + newclass;
    createCookie(ckname, CurrentFontSize, 365);
}

function switchTool (ckname, val) {
    createCookie(ckname, val, 365);
    window.location.reload();
}

function cpanel_reset () {
    var matches = document.cookie.match(new RegExp('(?:^|;)\\s*' + tmpl_name.escapeRegExp() + '_([^=]*)=([^;]*)', 'g'));
    if (!matches) return;
    for (var i = 0; i < matches.length; i++) {
        var ck = matches[i].match(new RegExp('(?:^|;)\\s*' + tmpl_name.escapeRegExp() + '_([^=]*)=([^;]*)'));
        if (ck) {
            createCookie (tmpl_name+'_'+ck[1], '', -1);
        }
    }

    if (window.location.href.indexOf('?') > -1) {
        window.location.href = window.location.href.substr(0,window.location.href.indexOf ('?'));
    } else {
        window.location.reload(true);
    }
}

function cpanel_apply () {
    var elems = document.getElementById('ja-cpanel-main').getElementsByTagName('*');

    var usersetting = {};
    for (var i = 0; i < elems.length; i++) {
        var el = elems[i];
        if (el.name && (match = el.name.match(/^user_(.*)$/))) {
            var name = match[1];
            var value = '';
            if (el.tagName.toLowerCase() == 'input' && (el.type.toLowerCase()=='radio' || el.type.toLowerCase()=='checkbox')) {
                if (el.checked) value = el.value;
            } else {
                value = el.value;
            }
            if (usersetting[name]) {
                if (value) usersetting[name] = value + ',' + usersetting[name];
            } else {
                usersetting[name] = value;
            }
        }
    }

    for (var k in usersetting) {
        name  = tmpl_name + '_' + k;
        value = usersetting[k].trim();
        if (value.length > 0) {
            createCookie(name, value, 365);
        }
    }

    if (window.location.href.indexOf ('?')>-1) {
        window.location.href = window.location.href.substr(0,window.location.href.indexOf ('?'));
    } else {
        window.location.reload(true);
    }
}

function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    } else {
        expires = "";
    }
    document.cookie = name+"="+value+expires+"; path=/";
}

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function getScreenWidth () {
    var x = 0;
    if (self.innerHeight) {
            x = self.innerWidth;
    } else if (document.documentElement && document.documentElement.clientHeight) {
            x = document.documentElement.clientWidth;
    } else if (document.body) {
            x = document.body.clientWidth;
    }
    return x;
}

function equalHeight (els) {
    els = $$_(els);
    if (!els || els.length < 2) return;
    var maxh = 0;
    var els_ = [];
    els.each(function(el, i){
        if (!el) return;
        //els_[i] = getDeepestWrapper (el);
        els_[i] = el;
        var ch = els_[i].getCoordinates().height;
        maxh = (maxh < ch) ? ch : maxh;
    },this);

    els_.each(function(el, i) {
        if (!el) return;
        if (el.getStyle('padding-top')!=null && el.getStyle('padding-bottom')!=null) {
            if (maxh-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt() > 0) {
                el.setStyle('min-height', maxh-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt());
            }
        } else {
            if (maxh > 0) el.setStyle('min-height', maxh);
        }
    }, this);
}

function getDeepestWrapper (el) {
    while (el.getChildren().length == 1) {
        el = el.getChildren()[0];
    }
    return el;
}

function fixHeight (els, group1, group2) {
    els = $$_(els);
    group1 = $$_(group1);
    group2 = $$_(group2);
    if (!els || !group1) return;
    var height = 0;
    group1.each(function(el) {
        if (!el) return;
        height += el.getCoordinates().height;
    });
    if (group2) {
        group2.each(function (el){
            if (!el) return;
            height -= el.getCoordinates().height;
        });
    }
    els.each(function(el, i) {
        if (!el) return;
        if (el.getStyle('padding-top') != null && el.getStyle('padding-bottom') != null) {
            if (height-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt() > 0) {
                el.setStyle('min-height', height-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt());
            }
        } else {
            if (height > 0) {
                el.setStyle('min-height', height);
            }
        }
    });
}

function addFirstLastItem (el) {
    el = $(el);
    if (!el || !el.getChildren() || !el.getChildren().length) return;
    el.getChildren ()[0].addClass ('first-item');
    el.getChildren ()[el.getChildren ().length-1].addClass ('last-item');
}

function $$_ (els) {
    if (typeOf(els)=='string') return $$(els);
    var els_ = [];
    els.each (function (el){
        el = $(el);
        if (el) els_.push (el);
    });
    return els_;
}

/*  */
/**
 * ------------------------------------------------------------------------
 * JA T3v2 System Plugin for J25 & J30
 * ------------------------------------------------------------------------
 * Copyright (C) 2004-2011 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
 * @license - GNU/GPL, http://www.gnu.org/licenses/gpl.html
 * Author: J.O.O.M Solutions Co., Ltd
 * Websites: http://www.joomlart.com - http://www.joomlancers.com
 * ------------------------------------------------------------------------
 */
var jaMegaMenuMoo = new Class({

	Implements: Options,

	options: {
		slide: 0, 				//enable slide
		duration: 300, 			//slide speed. lower for slower, bigger for faster
		fading: 0,				//Enable fading
		bgopacity: 0.9, 		//set the transparent background. 0 to disable, 0<bgopacity<1: the opacity of the background
		delayHide: 500,
		direction: 'down',
		action: 'mouseenter', 	//mouseenter or click
		hidestyle: 'normal',
		offset: 5,
		fixArrow: false
	},

	toElement: function () {
		return this.menu;
	},

	initialize: function (menu, options) {
		this.menu = $(menu);
		if (!this.menu) {
			return;
		}
		this.setOptions(options);

		//ignore delayHide if no animation
		if (!this.options.slide && !this.options.fading) {
			this.options.delayHide = 10;
		}

		this.childopen = [];
		this.imgloaded = false;
		this.loaded = false;
		this.prepare();
	},

	prepare: function () {
		//preload images
		var imgElms = this.menu.getElements('img');
		if (imgElms.length && !this.imgloaded) {
			var imgSrcs = [];
			imgElms.each(function (image) {
				imgSrcs.push(image.src)
			});

			new Asset.images(imgSrcs, {
				onComplete: function () {
					this.start();
				}.bind(this)
			});
			
			this.imgloaded = true;
			//call this start if cannot load image after sometime
			this.start.delay(3000, this);
		} else {
			this.start();
		}
	},

	start: function () {
		//init once
		if (this.loaded) {
			return;
		}
		this.loaded = true;
		this.zindex = 1000;

		//get wrapper
		var pw = this.menu;
		while (pw = pw.getParent()) {
			if (pw.hasClass('main') || pw.hasClass('wrap')) {
				this.wrapper = pw;
				break;
			}
		}

		this.items = this.menu.getElements('li.mega');
		this.items.each(function (li) {
			//link item
			var link = li.getChildren('a.mega')[0],
				child = li.getChildren('.childcontent')[0],
				level0 = li.getParent().hasClass('level0'),
				parent = this.getParent(li),
				item = {
					stimer: null,
					direction: ((level0 && this.options.direction == 'up') ? 0 : 1)
				};

			//child content
			if (child) {
				var childwrap = child.getElement('.childcontent-inner-wrap'),
					childinner = child.getElement('.childcontent-inner'),
					width = childinner.getWidth(),
					height = childinner.getHeight(),
					padding = childwrap.getStyle('padding-left').toInt() + childwrap.getStyle('padding-right').toInt(),
					overflow = false;

				child.setStyles({
					width: width + 20,
					height: height + 20
				});

				childwrap.setStyle('width', width);

				if (['auto', 'scroll'].contains(childinner.getStyle('overflow'))) {
					overflow = true;

					//fix for ie6/7
					if (Browser.ie) {
						if (Browser.version <= 7) {
							childinner.setStyle('position', 'relative');
						}

						if (Browser.version == 6) {
							childinner.setStyle('height', childinner.getStyle('max-height') || 400);
						}
					}
				}

				//show direction
				if (this.options.direction == 'up') {
					if (level0) {
						child.setStyle('top', -child.getHeight()); //ajust top position
					} else {
						child.setStyle('bottom', 0);
					}
				}
			}

			if (child && this.options.bgopacity) {
				//Make transparent background
				new Element('div', {
					'class': 'childcontent-bg',
					styles: {
						width: '100%',
						height: height,
						opacity: this.options.bgopacity,
						position: 'absolute',
						top: 0,
						left: 0,
						zIndex: 1,
						background: child.getStyle('background'),
						backgroundImage: child.getStyle('background-image'),
						backgroundRepeat: child.getStyle('background-repeat'),
						backgroundColor: child.getStyle('background-color')
					}
				}).inject(childwrap, 'top');

				child.setStyle('background', 'none');
				childwrap.setStyles({
					position: 'relative',
					zIndex: 2
				});
			}

			if (child && (this.options.slide || this.options.fading)) {

				if (child.hasClass('right')) {
					child.setStyle('right', 0);
				}

				//init Fx.Styles for childcontent
				var fx = new Fx.Morph(childwrap, {
					duration: this.options.duration,
					transition: Fx.Transitions.linear,
					onComplete: this.itemAnimDone.bind(this, item),
					link: 'cancel'
				}),
					stylesOn = {};

				if (this.options.slide) {
					if (level0) {
						stylesOn[item.direction == 1 ? 'margin-top' : 'bottom'] = 0;
					} else {
						stylesOn[window.isRTL ? 'margin-right' : 'margin-left'] = 0;
					}
				}
				if (this.options.fading) {
					stylesOn['opacity'] = 1;
				}
			}

			if (child && this.options.action == 'click') {
				li.addEvent('click', function (e) {
					e.stopPropagation();

					if (li.hasClass('group')) {
						return;
					}

					if (item.status == 'open') {
						if (this.cursorIn(li, e)) {
							this.itemHide(item);
						} else {
							this.hideOthers(li);
						}
					} else {
						this.itemShow(item);
					}
				}.bind(this));
			}

			if (this.options.action == 'mouseover' || this.options.action == 'mouseenter') {
				li.addEvent('mouseover', function (e) {
					if (li.hasClass('group')) {
						return;
					}

					e.stop();
					
					clearTimeout(item.stimer);
					clearTimeout(this.atimer);

					this.intent(item, 'open');
					this.itemShow(item);

				}.bind(this))

				.addEvent('mouseleave', function (e) {
					if (li.hasClass('group')) {
						return;
					}

					clearTimeout(item.stimer);

					this.intent(item, 'close');
					if (child) {
						item.stimer = this.itemHide.delay(this.options.delayHide, this, [item]);
					} else {
						this.itemHide(item);
					}
				}.bind(this));

				//if has childcontent, don't goto link before open childcontent - fix for touch screen
				if (link && child) {
					link.addEvent('click', function (e) {
						if (!item.clickable) {
							e.stop();
						}
					});
				}

				//stop if click on menu item - prevent raise event to container => hide all open submenu
				li.addEvent('click', function (e) {
					e.stopPropagation()
				});

				if (child) {
					child.addEvent('mouseover', function () {
						clearTimeout(item.stimer);
						clearTimeout(this.atimer);

						this.intent(item, 'open');
						this.itemShow(item);
					}.bind(this)).addEvent('mouseleave', function (e) {
						e.stop();

						this.intent(item, 'close');
						clearTimeout(item.stimer);

						if (!this.cursorIn(item.el, e)) {
							this.atimer = this.hideAlls.delay(this.options.delayHide, this);
						}
					}.bind(this))
				}
			}

			//when click on a link - close all open childcontent
			if (link && !child) {
				link.addEvent('click', function (e) {
					e.stopPropagation(); //prevent to raise event up
					this.hideOthers(null);
					//Remove current class
					this.menu.getElements('.active').removeClass('active');

					//Add current class
					var p = li;
					while (p) {
						var idata = p.retrieve('item');

						p.addClass('active');
						idata.link.addClass('active');
						p = idata.parent;
					}
				}.bind(this));
			}

			Object.append(item, {
				el: li,
				parent: parent,
				link: link,
				child: child,
				childwrap: childwrap,
				childinner: childinner,
				width: width,
				height: height,
				padding: padding,
				level0: level0,
				fx: fx,
				stylesOn: stylesOn,
				overflow: overflow,
				clickable: !(link && child)
			});

			li.store('item', item);
		}, this);

		//click on windows will close all submenus
		var container = $('ja-wrapper');
		if (!container) {
			container = document.body;
		}

		container.addEvent('click', function (e) {
			this.hideAlls();
		}.bind(this));

		this.menu.getElements('.childcontent').setStyle('display', 'none');
	},

	getParent: function (el) {
		var p = el;
		while ((p = p.getParent())) {
			if (this.items.contains(p) && !p.hasClass('group')) {
				return p;
			}

			if (!p || p == this.menu) {
				return null;
			}
		}
	},

	intent: function (item, action) {
		item.intent = action;

		while (item.parent && (item = item.parent.retrieve('item'))) {
			item.intent = action;
		}
	},

	cursorIn: function (el, event) {
		if (!el || !event) {
			return false;
		}

		var pos = el.getPosition(),
			cursor = event.page;

		return (cursor.x > pos.x && cursor.x < pos.x + el.getWidth() && cursor.y > pos.y && cursor.y < pos.y + el.getHeight());
	},

	itemOver: function (item) {
		item.el.addClass('over');

		if (item.el.hasClass('haschild')) {
			item.el.removeClass('haschild').addClass('haschild-over');
		}

		if (item.link) {
			item.link.addClass('over');
		}
	},

	itemOut: function (item) {
		item.el.removeClass('over');

		if (item.el.hasClass('haschild-over')) {
			item.el.removeClass('haschild-over').addClass('haschild');
		}

		if (item.link) {
			item.link.removeClass('over');
		}
	},

	itemShow: function (item) {
		
		if(this.childopen.indexOf(item) < this.childopen.length -1){
			this.hideOthers(item.el);
		}
		
		if (item.status == 'open') {
			return; //don't need do anything
		}

		//Setup the class
		this.itemOver(item);

		//push to show queue
		if (item.level0) {
			this.childopen.length = 0;
		}

		if (item.child) {
			this.childopen.push(item);
		}

		item.intent = 'open';
		item.status = 'open';

		this.enableclick.delay(100, this, item);

		if (item.child) {
			//reposition the submenu
			this.positionSubmenu(item);

			if (item.fx && !item.stylesOff) {
				item.stylesOff = {};
				if (this.options.slide) {
					if (item.level0) {
						item.stylesOff[item.direction == 1 ? 'margin-top' : 'bottom'] = -item.height;
					} else {
						item.stylesOff[window.isRTL ? 'margin-right' : 'margin-left'] = (item.direction == 1 ? -item.width : item.width);
					}
				}
				if (this.options.fading) {
					item.stylesOff['opacity'] = 0;
				}
				item.fx.set(item.stylesOff);
			}

			clearTimeout(item.sid);
			item.child.setStyles({
				display: 'block',
				zIndex: this.zindex++
			});
		}

		if (!item.fx || !item.child) {
			return;
		}

		item.child.setStyle('overflow', 'hidden');
		if (item.overflow) {
			item.childinner.setStyle('overflow', 'hidden');
		}

		item.fx.start(item.stylesOn);
	},

	itemHide: function (item) {
		clearTimeout(item.stimer);

		item.status = 'close';
		item.intent = 'close';

		this.itemOut(item);
		this.childopen.erase(item);

		if (!item.fx && item.child) {
			clearTimeout(item.sid);
			item.sid = setTimeout(function(){ item.child.setStyle('display', 'none'); }, this.options.delayHide);
		}

		if (!item.fx || !item.child || item.child.getStyle('opacity') == '0') {
			return;
		}

		item.child.setStyle('overflow', 'hidden');
		if (item.overflow) {
			item.childinner.setStyle('overflow', 'hidden');
		}

		switch (this.options.hidestyle) {
		case 'fast':
			item.fx.options.duration = 100;
			item.fx.start(item.stylesOff);
			break;
		case 'fastwhenshow':
			item.fx.start(Object.merge(item.stylesOff, {
				'opacity': 0
			}));
			break;
		case 'normal':
		default:
			item.fx.start(item.stylesOff);
			break;
		}
	},

	itemAnimDone: function (item) {
		//hide done
		if (item.status == 'close') {
			//reset duration and enable opacity if not fading
			if (this.options.hidestyle.test(/fast/)) {
				item.fx.options.duration = this.options.duration;
				if (!this.options.fading) {
					item.childwrap.setStyle('opacity', 1);
				}
			}
			//hide
			item.child.setStyle('display', 'none');
			this.disableclick.delay(100, this, item);

			var pitem = item.parent ? item.parent.retrieve('item') : null;
			if (pitem && pitem.intent == 'close') {
				this.itemHide(pitem);
			}
		}

		//show done
		if (item.status == 'open') {
			item.child.setStyle('overflow', '');
			if (item.overflow) {
				item.childinner.setStyle('overflow-y', 'auto');
			}

			item.childwrap.setStyle('opacity', 1);
			item.child.setStyle('display', 'block');
		}
	},

	hideOthers: function (el) {
		this.childopen.each(function (item) {
			if (!el || (item.el != el && !item.el.contains(el))) {
				item.intent = 'close';
			}
		});

		if (this.options.slide || this.options.fading) {
			var last = this.childopen.getLast();
			if (last && last.intent == 'close') {
				this.itemHide(last);
			}
		} else {
			this.childopen.each(function (item) {
				if(item.intent == 'close'){
					this.itemHide(item);	
				}
			}, this);
		}
	},

	hideAlls: function (el) {
		this.childopen.flatten().each(function (item) {
			if (!item.fx) {
				this.itemHide(item);
			} else {
				item.intent = 'close';
			}
		}, this);

		if (this.options.slide || this.options.fading) {
			var last = this.childopen.getLast();
			if (last && last.intent == 'close') {
				this.itemHide(last);
			}
		}
	},

	enableclick: function (item) {
		if (item.link && item.child) {
			item.clickable = true;
		}
	},

	disableclick: function (item) {
		item.clickable = false;
	},

	positionSubmenu: function (item) {
		var options = this.options, offsleft, offstop, left, top, stylesOff = {},
			icoord = item.el.getCoordinates(),
			bodySize = $(document.body).getScrollSize(),
			winRect = {
				top: window.getScrollTop(),
				left: window.getScrollLeft(),
				width: window.getWidth(),
				height: window.getHeight()
			},
			wrapRect = this.wrapper ? this.wrapper.getCoordinates() : {
				top: 0,
				left: 0,
				width: winRect.width,
				height: winRect.height
			};

		winRect.top = Math.max(winRect.top, wrapRect.top);
		winRect.left = Math.max(winRect.left, wrapRect.left);
		winRect.width = Math.min(winRect.width, wrapRect.width);
		winRect.height = Math.min(winRect.height, $(document.body).getScrollHeight());
		winRect.right = winRect.left + winRect.width;
		winRect.bottom = winRect.top + winRect.height;

		if (!item.level0) {
			var pitem = item.parent.retrieve('item'),
				offsety = parseFloat(pitem.child.getFirst().getStyle('margin-top')),
				offsetx = parseFloat(pitem.child.getFirst().getStyle(window.isRTL ? 'margin-right' : 'margin-left'));

			item.direction = pitem.direction;

			window.isRTL && (offsetx = 0 - offsetx);
			icoord.top -= offsety;
			icoord.bottom -= offsety;
			icoord.left -= offsetx;
			icoord.right -= offsetx;
		}

		if (item.level0) {
			if (window.isRTL) {
				offsleft = Math.max(winRect.left, icoord.right - item.width - 20);
				left = Math.max(0, offsleft - winRect.left);
			} else {
				offsleft = Math.max(winRect.left, Math.min(winRect.right - item.width, icoord.left));
				left = Math.max(0, Math.min(winRect.right - item.width, icoord.left) - winRect.left);
			}
		} else {
			if (window.isRTL) {
				if (item.direction == 1) {
					offsleft = icoord.left - item.width - 20 + options.offset;
					left = -icoord.width - 20;

					if (offsleft < winRect.left) {
						item.direction = 0;
						offsleft = Math.min(winRect.right, Math.max(winRect.left, icoord.right + item.padding - 20 - options.offset));
						left = icoord.width - 20;
						stylesOff['margin-right'] = item.width;
					}
				} else {
					offsleft = icoord.right + item.padding - 20;
					left = icoord.width - 20;

					if (offsleft + item.width > winRect.right) {
						item.direction = 1;
						offsleft = Math.max(winRect.left, icoord.left - item.width - 20);
						left = -icoord.width - 20;
						stylesOff['margin-right'] = -item.width;
					}
				}
			} else {

				if (item.direction == 1) {
					offsleft = icoord.right - options.offset;
					left = icoord.width;

					if (offsleft + item.width > winRect.right) {
						item.direction = 0;
						offsleft = Math.max(winRect.left, icoord.left - item.width - item.padding + options.offset);
						left = -icoord.width;
						stylesOff['margin-left'] = item.width;
					}
				} else {
					offsleft = icoord.left - item.width - item.padding + options.offset;
					left = -icoord.width;

					if (offsleft < winRect.left) {
						item.direction = 1;
						offsleft = Math.max(winRect.left, Math.min(winRect.right - item.width, icoord.right - options.offset));
						left = icoord.width;
						stylesOff['margin-left'] = -item.width;
					}
				}
			}
		}

		if (options.slide && item.fx && Object.getLength(stylesOff)) {
			item.fx.set(stylesOff);
		}

		// Teline IV
		if (options.fixArrow && item.childinner) {
			item.childinner.setStyle('background-position', (icoord.left - offsleft + (icoord.width / 2 - 4.5)) + 'px top');
		}

		var oldp = item.child.getStyle('display');
		item.child.setStyle('display', 'block');
		if (item.child.getOffsetParent()) {
			left = offsleft - item.child.getOffsetParent().getCoordinates().left;
		}
		item.child.setStyles({
			'margin-left': 0,
			'left': left,
			'display': oldp
		});
	}
});

/*  */
var RSFormProCalendars = {};
var RSFormProPrices = {};

if (typeof RSFormPro != 'object') {
	var RSFormPro = {};
}

var RSFormProUtils = {
	hasClass: function (el, name) {
		return new RegExp('(\\s|^)' + name + '(\\s|$)').test(el.className);
	},
	addClass: function(el, name) {
		if (!RSFormProUtils.hasClass(el, name)) {
			el.className += (el.className ? ' ' : '') + name;
		}
	},
	removeClass: function(el, name) {
		if (RSFormProUtils.hasClass(el, name)) {
			el.className = el.className.replace(new RegExp('(\\s|^)' + name + '(\\s|$)'),' ').replace(/^\s+|\s+$/g, '');
		}
	}
};

RSFormPro.Forms = {};

function isset () {
  // http://kevin.vanzonneveld.net
  // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  // +   improved by: FremyCompany
  // +   improved by: Onno Marsman
  // +   improved by: Rafał Kukawski
  // *     example 1: isset( undefined, true);
  // *     returns 1: false
  // *     example 2: isset( 'Kevin van Zonneveld' );
  // *     returns 2: true
  var a = arguments,
    l = a.length,
    i = 0,
    undef;

  if (l === 0) {
    throw new Error('Empty isset');
  }

  while (i !== l) {
    if (a[i] === undef || a[i] === null) {
      return false;
    }
    i++;
  }
  return true;
}

function refreshCaptcha(componentId, captchaPath)
{
	if(!captchaPath) captchaPath = 'index.php?option=com_rsform&task=captcha&componentId=' + componentId;
	document.getElementById('captcha' + componentId).src = captchaPath + '&' + Math.random();
	document.getElementById('captchaTxt' + componentId).value='';
	document.getElementById('captchaTxt' + componentId).focus();
}

function number_format(number, decimals, dec_point, thousands_sep)
{
    var n = number, prec = decimals;
    n = !isFinite(+n) ? 0 : +n;
    prec = !isFinite(+prec) ? 0 : Math.abs(prec);
    var sep = (typeof thousands_sep == "undefined") ? ',' : thousands_sep;
    var dec = (typeof dec_point == "undefined") ? '.' : dec_point;
 
    var s = (prec > 0) ? n.toFixed(prec) : Math.round(n).toFixed(prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;
 
    var abs = Math.abs(n).toFixed(prec);
    var _, i;
 
    if (abs >= 1000) {
        _ = abs.split(/\D/);
        i = _[0].length % 3 || 3;
 
        _[0] = s.slice(0,i + (n < 0)) +
              _[0].slice(i).replace(/(\d{3})/g, sep+'$1');
 
        s = _.join(dec);
    } else {
        s = s.replace('.', dec);
    }
 
    return s;
}

function buildXmlHttp()
{
	var xmlHttp;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}

function ajaxValidation(form, page)
{
	try
	{
		var el = form.elements.length;
	}
	catch (err)
	{
		form = this;
	}
		
	var xmlHttp = buildXmlHttp();
	var url = '';
	if (typeof rsfp_ajax_root != 'undefined')
		url = rsfp_ajax_root + '/';
	url += 'index.php?option=com_rsform&task=ajaxValidate';
	
	if (page)
		url += '&page=' + page;
	
	var params = new Array();
	var submits = new Array();
	var success = false;
	var formId = 0;
	for (i=0; i<form.elements.length; i++)
	{
		// don't send an empty value
		if (!form.elements[i].name) continue;
		if (form.elements[i].name.length == 0) continue;
		// check if the checkbox is checked
		if (form.elements[i].type == 'checkbox' && form.elements[i].checked == false) continue;
		// check if the radio is selected
		if (form.elements[i].type == 'radio' && form.elements[i].checked == false) continue;
		
		if (form.elements[i].type == 'submit')
		{
			submits.push(form.elements[i]);
			form.elements[i].disabled = true;
		}
		
		// check if form is a dropdown with multiple selections
		if (form.elements[i].type == 'select-multiple')
		{
			for (var j=0; j<form.elements[i].options.length; j++)
				if (form.elements[i].options[j].selected)
					params.push(form.elements[i].name + '=' + encodeURIComponent(form.elements[i].options[j].value));
			
			continue;
		}
		
		if (form.elements[i].name == 'form[formId]')
			formId = form.elements[i].value;
		
		params.push(form.elements[i].name + '=' + encodeURIComponent(form.elements[i].value));
	}
	
	if (typeof ajaxExtraValidationScript[formId] == 'function') {
		ajaxExtraValidationScript[formId]('beforeSend', formId, {'url': url, 'params': params});
	}
	
	params = params.join('&');
	
	xmlHttp.open("POST", url, false);

	//Send the proper header information along with the request
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	//xmlHttp.setRequestHeader("Content-length", params.length);
	//xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
	var success = true;
	
	if (xmlHttp.responseText.indexOf("\n") != -1)
	{
		var response = xmlHttp.responseText.split("\n");
		// All spans set to no error
		var ids = response[0].split(',');
		for (var i=0; i<ids.length; i++)
			if (!isNaN(parseInt(ids[i])) && document.getElementById('component'+ids[i]))
				document.getElementById('component'+ids[i]).className = 'formNoError';
			
		// Show errors
		var ids = response[1].split(',');
		for (var i=0; i<ids.length; i++)
			if (!isNaN(parseInt(ids[i])) && document.getElementById('component'+ids[i]))
			{
				document.getElementById('component'+ids[i]).className = 'formError';
				success = false;
			}
		
		if (response.length == 4)
		{
			page = parseInt(response[2]) - 1;
			totalPages = parseInt(response[3]);
			rsfp_changePage(formId, page, totalPages, false);
		}
		
		if (typeof ajaxExtraValidationScript[formId] == 'function') {
			ajaxExtraValidationScript[formId]('afterSend', formId, {'url': url, 'params': params, 'response': response});
		}
	}
	
	for (var i=0; i<submits.length; i++)
		submits[i].disabled = false;
	
	if (success == false && document.getElementById('rsform_error_' + formId))
	{
		try {
			document.getElementById('rsform_error_' + formId).style.display = 'block';
		}
		catch (err) { }
	}
	
	if (success == true) {
		try {
			document.getElementById('rsform_error_' + formId).style.display = 'none';
		}
		catch (err) { }
	}
	
	return success;
}

var ajaxExtraValidationScript = {};

function rsfp_addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}

function rsfp_getForm(formId)
{
	if (typeof RSFormPro.Forms[formId] == 'undefined') {
		var formIds = document.getElementsByName('form[formId]');
		for (var i=0; i<formIds.length; i++)
		{
			if (parseInt(formIds[i].value) != parseInt(formId))
				continue;
			
			var form = formIds[i].parentNode;		
			if (form.tagName == 'FORM' || form.nodeName == 'FORM') {
				RSFormPro.Forms[formId] = form;
				return form;
			}
			
			while (form.parentNode)
			{
				form = form.parentNode;
				if (form.tagName == 'FORM' || form.nodeName == 'FORM') {
					RSFormPro.Forms[formId] = form;
					return form;
				}
			}
		}
	}
	
	return RSFormPro.Forms[formId];
}

function rsfp_setCalculationsEvents(formId, fields) {
	var func 		= window["rsfp_Calculations" + formId];
	var thefields	= fields ? fields : RSFormProPrices;
	
	// Detect IE8.
	var isIE8 = navigator.userAgent.match(/MSIE 8\.0/);
	var event = 'click';
	
	for(field in thefields) {
		field = field.replace(formId+'_','');
		objects = rsfp_getFieldsByName(formId,field);
		for(i=0;i<objects.length;i++) {
			tagName = objects[i].tagName || objects[i].nodeName;
			
			if (tagName == 'INPUT' || tagName == 'SELECT') {
				// IE8 fix.
				if (tagName == 'INPUT' && isIE8 && objects[i].type && objects[i].type.toLowerCase() == 'checkbox') {
					event = 'click';
				} else {
					event = 'change';
				}
				
				rsfp_addEvent(objects[i], event, function() {
					if (typeof func == "function") {
						func();
					}
				});
			}
		}
	}
}

function rsfp_getValue(formId, name) {
	form		= rsfp_getForm(formId);
	values		= [];
	
	if (typeof form != 'undefined')
	{
		for (var i=0; i<form.elements.length; i++)
		{
			var element = form.elements[i];
			var tagName = element.tagName || element.nodeName;
			
			switch (tagName)
			{
				case 'INPUT':
					if (element.type)
						switch (element.type.toUpperCase())
						{
							case 'TEXT':
							case 'HIDDEN':
								if (!element.name || element.name != 'form[' + name + ']') continue;
								return element.value;
							break;
							
							case 'RADIO':
								if (!element.name || element.name != 'form[' + name + ']') continue;
								
								if (element.checked == true) {
									values.push(element.value);
								}
							break;
							
							case 'CHECKBOX':
								if (!element.name || element.name != 'form[' + name + '][]') continue;
								if (element.checked == true) {
									values.push(element.value);
								}
							break;
						}
				break;
				
				case 'SELECT':
					if (!element.name || element.name != 'form[' + name + '][]') continue;
					
					if (element.options)
						for (var o=0; o<element.options.length; o++)
							if (element.options[o].selected)
							{
								values.push(element.options[o].value);
							}
				break;
			}
		}
	}
	
	return values;
}

function rsfp_toNumber(number, decimal, thousands) {
	if (number.indexOf(thousands) > -1) {
		number = number.split(thousands).join('');
	}

	if (number.indexOf(decimal) > -1) {
		number = parseFloat(number.split(decimal).join('.'));
	}

	return parseFloat(number);
}

function rsfp_verifyChecked(formId, name, value) {
	isChecked = false;
	form = rsfp_getForm(formId);
	
	if (typeof form != 'undefined')
	{
		primary_loop:
		for (var i=0; i<form.elements.length; i++)
		{
			var element = form.elements[i];
			var tagName = element.tagName || element.nodeName;
			
			switch (tagName)
			{
				case 'INPUT':
					if (element.type)
						switch (element.type.toUpperCase())
						{
							case 'RADIO':
								if (!element.name || element.name != 'form[' + name + ']') continue;
								if (element.checked == true && element.value == value)
								{
									isChecked = true;
									break primary_loop;
								}
							break;
							
							case 'CHECKBOX':
								if (!element.name || element.name != 'form[' + name + '][]') continue;
								if (element.checked == true && element.value == value)
								{
									isChecked = true;
									break primary_loop;
								}
							break;
						}
				break;
				
				case 'SELECT':
					if (!element.name || element.name != 'form[' + name + '][]') continue;
					
					if (element.options)
						for (var o=0; o<element.options.length; o++)
							if (element.options[o].selected && element.options[o].value == value)
							{
								isChecked = true;
								break primary_loop;
							}
				break;
			}
		}
	}
	
	return isChecked;
}

function rsfp_addCondition(formId, name, fnCondition) {
	form = rsfp_getForm(formId);
	
	if (typeof form != 'undefined') {
		for (var i=0; i<form.elements.length; i++) {
			var element = form.elements[i];
			var tagName = element.tagName || element.nodeName;
			if (element.name && (element.name == 'form[' + name + ']' || element.name == 'form[' + name + '][]')) {
				if (tagName == 'SELECT') {
					rsfp_addEvent(element, 'change', function() {
						fnCondition();
					});
				} else {
					rsfp_addEvent(element, 'click', function() {
						fnCondition();
					});
				}
			}
		}
	}
}

function rsfp_getBlock(formId, block) {
	form = rsfp_getForm(formId);
	
	var possible = false;
	
	if (typeof form != 'undefined') {
		if (blocks = getElementsByClassName('rsform-block')) {
			for (i=0; i<blocks.length; i++) {
				var classes = blocks[i].className.split(' ');
				for (c=0; c<classes.length; c++) {
					if (classes[c] == 'rsform-block-' + block) {
						if (blocks[i].parentNode) {
							current_block = blocks[i];
							if (current_block == form)
								return [ blocks[i] ];
								
							while (current_block.parentNode) {
								current_block = current_block.parentNode;
								if (current_block == form)
									return [ blocks[i] ];
							}
						}
						
						possible = [ blocks[i] ];
					}
				}
			}
		}
	}
	
	return possible;
}

function rsfp_getFieldsByName(formId, name) {
	form = rsfp_getForm(formId);
	
	var results = [];
	
	if (typeof form != 'undefined') {
		for (var i=0; i<form.elements.length; i++) {
			var element = form.elements[i];
			pushed = false;
			if (element.name && (
				// single fields
				element.name == 'form[' + name + ']' ||
				// multiple fields
				element.name == 'form[' + name + '][]' ||
				// new field - Birthday field
				element.name == 'form[' + name + '][d]' ||
				element.name == 'form[' + name + '][m]' ||
				element.name == 'form[' + name + '][y]'
				)) {
				results.push(element);
				pushed = true;
			}
			
			if (pushed) {
				// for calendar
				if (element.id && element.id.indexOf('txtcal') > -1) {
					var suffix = element.id.replace('txtcal', '');
					results.push(document.getElementById('btn' + suffix));
				}
				// for labels (radio, checkbox)
				var labels = form.getElementsByTagName('label');
				for (var l=0; l<labels.length; l++) {
					if (labels[l].htmlFor && labels[l].htmlFor == element.id)
						results.push(labels[l]);
				}
			}
		}
	}
	
	return results;
}

function rsfp_setDisplay(items, value) {
	for (i=0; i<items.length; i++)
		items[i].style.display = value;
}

function rsfp_checkValidDate(fieldName) {
	var theDate = new Date();
	for (var day=1; day<=31; day++) {
		var year 	= parseInt(document.getElementById(fieldName + 'y').value);
		var month 	= parseInt(document.getElementById(fieldName + 'm').value) - 1;
		
		var index = day - 1;
		if (document.getElementById(fieldName + 'd').options[0].value == '') {
			index++;
		}
		document.getElementById(fieldName + 'd').options[index].disabled = false;
		if (!isNaN(year) && !isNaN(month)) {
			if (typeof theDate.__msh_oldSetFullYear == 'function') {
				theDate.__msh_oldSetFullYear(year, month, day);
			} else {
				theDate.setFullYear(year, month, day);
			}
			
			if (theDate.getDate() != day || theDate.getMonth() != month) {
				document.getElementById(fieldName + 'd').options[index].disabled = true;
			}
		}
	}
	if (document.getElementById(fieldName + 'd').options[document.getElementById(fieldName + 'd').selectedIndex].disabled == true) {
		for (var day=31; day>=28; day--) {
			var index = day - 1;
			if (document.getElementById(fieldName + 'd').options[0].value == '') {
				index++;
			}
			if (document.getElementById(fieldName + 'd').options[index].disabled == false) {
				document.getElementById(fieldName + 'd').value = day;
				break;
			}
		}
	}
}

function rsfp_geolocation(term, id, mapid,  map, marker, geocoder, type) {
	var content = document.getElementById('rsform_geolocation'+id);
	var address	= document.getElementById(mapid).clientWidth;
	
	document.getElementById('rsform_geolocation'+id).style.width = address+'px';
	document.getElementById('rsform_geolocation'+id).style.display = 'none';
	document.getElementById('rsform_geolocation'+id).innerHTML = '';
	
	if (term != '') {
		geocoder.geocode( {'address': term }, function(results, status) {
			if (status == 'OK') {
				for (var i=0; i<results.length; i++) {
					var item	= results[i];
					var theli	= document.createElement('li');
					var thea	= document.createElement('a');
					
					thea.setAttribute('href','javascript:void(0)');
					thea.innerHTML = item.formatted_address;
					
					rsfp_addEvent(thea,'click', (function() {
						var mapValue = type ? item.formatted_address : item.geometry.location.lat().toFixed(5) + ',' + item.geometry.location.lng().toFixed(5);
						var mapId	 = mapid;
						var location = new google.maps.LatLng(item.geometry.location.lat().toFixed(5), item.geometry.location.lng().toFixed(5));
						
						return function() {
							document.getElementById(mapId).value = mapValue;							
							marker.setPosition(location);
							map.setCenter(location);
							document.getElementById('rsform_geolocation'+id).style.display = 'none';
						}
					})());
					
					theli.appendChild(thea);
					content.appendChild(theli);
				}
			
				document.getElementById('rsform_geolocation'+id).style.display = '';
			}
		});
	}
}

function rsfp_runAllConditions(formId) {
	var func = window["rsfp_runAllConditions" + formId];
	if (typeof func == "function") {
		func();
	}
}

/*
	Developed by Robert Nyman, http://www.robertnyman.com
	Code/licensing: http://code.google.com/p/getelementsbyclassname/
*/	
var getElementsByClassName = function (className, tag, elm){
	if (document.getElementsByClassName) {
		getElementsByClassName = function (className, tag, elm) {
			elm = elm || document;
			var elements = elm.getElementsByClassName(className),
				nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
				returnElements = [],
				current;
			for(var i=0, il=elements.length; i<il; i+=1){
				current = elements[i];
				if(!nodeName || nodeName.test(current.nodeName)) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	else if (document.evaluate) {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = "",
				xhtmlNamespace = "http://www.w3.org/1999/xhtml",
				namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
				returnElements = [],
				elements,
				node;
			for(var j=0, jl=classes.length; j<jl; j+=1){
				classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
			}
			try	{
				elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
			}
			catch (e) {
				elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
			}
			while ((node = elements.iterateNext())) {
				returnElements.push(node);
			}
			return returnElements;
		};
	}
	else {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = [],
				elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
				current,
				returnElements = [],
				match;
			for(var k=0, kl=classes.length; k<kl; k+=1){
				classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
			}
			for(var l=0, ll=elements.length; l<ll; l+=1){
				current = elements[l];
				match = false;
				for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
					match = classesToCheck[m].test(current.className);
					if (!match) {
						break;
					}
				}
				if (match) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	return getElementsByClassName(className, tag, elm);
};

function rsfp_changePage(formId, page, totalPages, validate)
{	
	if (validate)
	{
		var form = rsfp_getForm(formId);
		if (!ajaxValidation(form, page))
			return false;
	}
	
	for (var i=0; i<=totalPages; i++)
	{
		var thePage = document.getElementById('rsform_' + formId + '_page_' + i);
		if (thePage)
			rsfp_hidePage(thePage);
	}
	
	var thePage = document.getElementById('rsform_' + formId + '_page_' + page);
	if (thePage)
	{
		rsfp_showPage(thePage);
		try {
			var func = window["rsfp_showProgress_" + formId];
			if (typeof func == "function") {
				func(page);
			}
		}
		catch (err) { }
	}
}

function rsfp_hidePage(thePage) {
	RSFormProUtils.addClass(thePage, 'formHidden');
}

function rsfp_showPage(thePage) {
	RSFormProUtils.removeClass(thePage, 'formHidden');
}

/*  */
// packager build Mobile/Swipe
/*
---

name: Element.defineCustomEvent

description: Allows to create custom events based on other custom events.

authors: Christoph Pojer (@cpojer)

license: MIT-style license.

requires: [Core/Element.Event]

provides: Element.defineCustomEvent

...
*/

(function(){

[Element, Window, Document].invoke('implement', {hasEvent: function(event){
	var events = this.retrieve('events'),
		list = (events && events[event]) ? events[event].values : null;
	if (list){
		var i = list.length;
		while (i--) if (i in list){
			return true;
		}
	}
	return false;
}});

var wrap = function(custom, method, extended){
	method = custom[method];
	extended = custom[extended];

	return function(fn, name){
		if (extended && !this.hasEvent(name)) extended.call(this, fn, name);
		if (method) method.call(this, fn, name);
	};
};

var inherit = function(custom, base, method){
	return function(fn, name){
		base[method].call(this, fn, name);
		custom[method].call(this, fn, name);
	};
};

var events = Element.Events;

Element.defineCustomEvent = function(name, custom){
	var base = events[custom.base];

	custom.onAdd = wrap(custom, 'onAdd', 'onSetup');
	custom.onRemove = wrap(custom, 'onRemove', 'onTeardown');

	events[name] = base ? Object.append({}, custom, {

		base: base.base,

		condition: function(event, name){
			return (!base.condition || base.condition.call(this, event, name)) &&
				(!custom.condition || custom.condition.call(this, event, name));
		},

		onAdd: inherit(custom, base, 'onAdd'),
		onRemove: inherit(custom, base, 'onRemove')

	}) : custom;

	return this;
};

Element.enableCustomEvents = function(){
  Object.each(events, function(event, name){
    if (event.onEnable) event.onEnable.call(event, name);
  });
};

Element.disableCustomEvents = function(){
  Object.each(events, function(event, name){
    if (event.onDisable) event.onDisable.call(event, name);
  });
};

})();


/*
---

name: Browser.Features.Touch

description: Checks whether the used Browser has touch events

authors: Christoph Pojer (@cpojer)

license: MIT-style license.

requires: [Core/Browser]

provides: Browser.Features.Touch

...
*/

Browser.Features.Touch = (function(){
	try {
		document.createEvent('TouchEvent').initTouchEvent('touchstart');
		return true;
	} catch (exception){}
	
	return false;
})();

// Android doesn't have a touch delay and dispatchEvent does not fire the handler
Browser.Features.iOSTouch = (function(){
	var name = 'cantouch', // Name does not matter
		html = document.html,
		hasTouch = false;

	if (!html.addEventListener) return false;

	var handler = function(){
		html.removeEventListener(name, handler, true);
		hasTouch = true;
	};

	try {
		html.addEventListener(name, handler, true);
		var event = document.createEvent('TouchEvent');
		event.initTouchEvent(name);
		html.dispatchEvent(event);
		return hasTouch;
	} catch (exception){}

	handler(); // Remove listener
	return false;
})();


/*
---

name: Swipe

description: Provides a custom swipe event for touch devices

authors: Christopher Beloch (@C_BHole), Christoph Pojer (@cpojer), Ian Collins (@3n)

license: MIT-style license.

requires: [Core/Element.Event, Custom-Event/Element.defineCustomEvent, Browser.Features.Touch]

provides: Swipe

...
*/

(function(){

var name = 'swipe',
	distanceKey = name + ':distance',
	cancelKey = name + ':cancelVertical',
	dflt = 50;

var start = {}, disabled, active;

var clean = function(){
	active = false;
};

var events = {

	touchstart: function(event){
		if (event.touches.length > 1) return;

		var touch = event.touches[0];
		active = true;
		start = {x: touch.pageX, y: touch.pageY};
	},
	
	touchmove: function(event){
		if (disabled || !active) return;
		
		var touch = event.changedTouches[0],
			end = {x: touch.pageX, y: touch.pageY};
		if (this.retrieve(cancelKey) && Math.abs(start.y - end.y) > 10){
			active = false;
			return;
		}
		
		var distance = this.retrieve(distanceKey, dflt),
			delta = end.x - start.x,
			isLeftSwipe = delta < -distance,
			isRightSwipe = delta > distance;

		if (!isRightSwipe && !isLeftSwipe)
			return;
		
		event.preventDefault();
		active = false;
		event.direction = (isLeftSwipe ? 'left' : 'right');
		event.start = start;
		event.end = end;
		
		this.fireEvent(name, event);
	},

	touchend: clean,
	touchcancel: clean

};

Element.defineCustomEvent(name, {

	onSetup: function(){
		this.addEvents(events);
	},

	onTeardown: function(){
		this.removeEvents(events);
	},

	onEnable: function(){
		disabled = false;
	},

	onDisable: function(){
		disabled = true;
		clean();
	}

});

})();



/*  */
/**
 * @version 2.0.4.stable
 * @package DJ-ImageSlider
 * @subpackage DJ-ImageSlider Component
 * @copyright Copyright (C) 2012 DJ-Extensions.com, All rights reserved.
 * @license DJ-Extensions.com Proprietary Use License
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 * @developer Szymon Woronowski - szymon.woronowski@design-joomla.eu
 *
 */

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}('(7($){8 1I=1q;19.C(\'N\',7(){1I=1r});23.24=D 25({26:7(3,E){8 F=0;8 J=0;8 1a=0;8 d=0;8 g=\'g\'+3.4;8 G=E.27;8 H=0;8 13=0;8 14=1q;$(\'a\'+3.4).1b(\'1J\');8 9=$(\'g\'+3.4).28(\'29\');5(1K.1L){8 1c=D 2a();2b(8 i=0;i<3.1d;i++){1c[i]=9[i];1c[i].1b(\'1J\')}}9.1e(7(){F+=3.m;J++});1a=J-3.1d;$(g).6(\'1M\',\'2c\');8 O;5(3.15==2){9.6(\'1M\',\'2d\');9.6(\'P\',0);9.6(\'p\',0);$(g).6(\'v\',3.m);9.6(\'f\',0);9.6(\'1f\',\'1N\');9[0].6(\'f\',1);9[0].6(\'1f\',\'1O\');9.n(\'1s\',{K:\'f\',q:E.q})}b 5(3.15==1){$(g).6(\'P\',0);$(g).6(\'Q\',F);O=D R.S(g,{K:\'P\',q:E.q,1g:E.1g,T:\'U\'})}b{$(g).6(\'p\',0);$(g).6(\'v\',F);O=D R.S(g,{K:\'p\',q:E.q,1g:E.1g,T:\'U\'})}5(3.j==1){8 c=D R.S(\'c\'+3.4,{K:\'f\',q:1h,T:\'U\'}).n(\'f\',0);8 h=D R.S(\'h\'+3.4,{K:\'f\',q:1h,T:\'U\'}).n(\'f\',0)}5(3.V==1){8 1t=D R.S(\'1u\'+3.4,{K:\'f\',q:1h,T:\'U\'}).n(\'f\',0);8 1v=D R.S(\'1w\'+3.4,{K:\'f\',q:1h,T:\'U\'}).n(\'f\',0)}5(3.V){$(\'1u\'+3.4).C(\'16\',7(){5(3.j==1)1i();1j()});$(\'1w\'+3.4).C(\'16\',7(){5(3.j==1)1i();1x()})}5(3.j){$(\'c\'+3.4).C(\'16\',7(){1y();G=1});$(\'h\'+3.4).C(\'16\',7(){1y();G=0})}$(\'a-r\'+3.4).2e({\'2f\':7(){5(3.j==1)1P();5(3.V==1){1t.o(1);1v.o(1)}H=1},\'2g\':7(){5(3.j==1)1i();5(3.V==1){1t.o(0);1v.o(0)}H=0},\'1Q\':7(1z){5(1z.1R==\'p\'){1j()}b 5(1z.1R==\'W\'){1x()}}});$(\'a-r\'+3.4).2h(\'1Q:2i\',1r);5($(\'1A-w\'+3.4)){8 1B=$(\'1A-w\'+3.4).2j(\'.N-L\');1B.1e(7(X,I){X.C(\'16\',7(e){5(!14&&!X.2k(\'N-L-17\')){Y(I)}})})}7 1C(){8 Z=$(\'a-r\'+3.4).2l();8 s=Z.t().x;s-=Z.z(\'k-p\').A();s-=Z.z(\'k-W\').A();s-=Z.z(\'1S-p\').A();s-=Z.z(\'1S-W\').A();8 1k=$(\'a\'+3.4).z(\'1l-v\').A();8 1m=$(\'a\'+3.4).t();8 l=1m.x;5(l>s){l=s}b 5(l<=s&&l<1k){l=(s>1k?1k:s)}8 1T=1m.x/1m.y;8 10=l/1T;$(\'a\'+3.4).6(\'v\',l);$(\'a\'+3.4).6(\'Q\',10);5(3.15==2){$(g).6(\'v\',l);9.6(\'v\',l);9.6(\'Q\',10)}b 5(3.15==1){8 11=9[0].z(\'k-1n\').A();3.m=(10+11)/3.1d;F=J*3.m+J;$(g).6(\'Q\',F);9.6(\'v\',l);9.6(\'Q\',3.m-11);O.n(-3.m*d)}b{8 11=9[0].z(\'k-W\').A();3.m=(l+11)/3.1d;F=J*3.m+J;$(g).6(\'v\',F);9.6(\'v\',3.m-11);9.6(\'Q\',10);O.n(-3.m*d)}5(3.j||3.V){1o=$(\'w\'+3.4).2m(\'a\'+3.4).y;5(1o<0){$(\'a-r\'+3.4).6(\'k-P\',-1o);$(\'a-r\'+3.4).6(\'k-1n\',0)}b{B=0;5(3.V){B=$(\'1u\'+3.4).t().y;B=1D.1l(B,$(\'1w\'+3.4).t().y)}5(3.j){B=1D.1l(B,$(\'c\'+3.4).t().y);B=1D.1l(B,$(\'h\'+3.4).t().y)}k=1o+B-10;5(k>0){$(\'a-r\'+3.4).6(\'k-P\',0);$(\'a-r\'+3.4).6(\'k-1n\',k)}b{$(\'a-r\'+3.4).6(\'k-P\',0);$(\'a-r\'+3.4).6(\'k-1n\',0)}}1E=$(\'w\'+3.4).z(\'12-p\').A()+$(\'w\'+3.4).z(\'12-W\').A();5(1E<0&&19.t().x<$(\'w\'+3.4).t().x-1E){$(\'w\'+3.4).6(\'12-p\',0);$(\'w\'+3.4).6(\'12-W\',0)}}}7 1U(17){5($(\'1A-w\'+3.4))1B.1e(7(L,I){L.2n(\'N-L-17\');5(I==17)L.2o(\'N-L-17\')})}7 1j(){5(d<1a)Y(d+1);b Y(0)}7 1x(){5(d>0)Y(d-1);b Y(1a)}7 Y(I){5(d==I)1V;5(3.15==2){5(14)1V;14=1r;18=d;d=I;1W(18)}b{d=I;O.o(-3.m*d)}1U(d)}7 1W(18){9[d].6(\'1f\',\'1O\');9[d].1X(\'1s\').o(1);9[18].1X(\'1s\').o(0).1F(7(){9[18].6(\'1f\',\'1N\');14=1q})}7 1i(){5(!G){c.o(H,0).1F(7(){5(!13)$(\'c\'+3.4).6(\'u\',\'M\')})}b{h.o(H,0).1F(7(){5(!13)$(\'h\'+3.4).6(\'u\',\'M\')})}13=0}7 1P(){5(!G){$(\'c\'+3.4).6(\'u\',\'1p\');c.o(H,1)}b{$(\'h\'+3.4).6(\'u\',\'1p\');h.o(H,1)}13=1}7 1y(){5(G){$(\'h\'+3.4).6(\'u\',\'M\');5(3.j==1)h.n(\'f\',0);$(\'c\'+3.4).6(\'u\',\'1p\');5(3.j==1)c.n(\'f\',1)}b{$(\'c\'+3.4).6(\'u\',\'M\');5(3.j==1)c.n(\'f\',0);$(\'h\'+3.4).6(\'u\',\'1p\');5(3.j==1)h.n(\'f\',1)}}7 1G(){2p(7(){5(G&&!H)1j();1G()},E.1Y)}7 1H(){$(\'a-r\'+3.4).6(\'2q\',\'M\');$(\'a\'+3.4).1b(\'1Z\');5(1K.1L){1c.1e(7(X){5(X)X.1b(\'1Z\')})}1C();5(3.j){20=$(\'c\'+3.4).t().x;$(\'c\'+3.4).6(\'12-p\',-20/2);21=$(\'c\'+3.4).t().x;$(\'h\'+3.4).6(\'12-p\',-21/2);5(G){$(\'c\'+3.4).6(\'u\',\'M\')}b{$(\'h\'+3.4).6(\'u\',\'M\')}}1G()}5(3.22)1H.1Y(3.22);b 19.C(\'N\',1H);19.C(\'2r\',1C)}})})(2s.4);',62,153,'|||settings|id|if|setStyle|function|var|slides|djslider|else|play|current_slide||opacity|slider|pause||show_buttons|padding|newSliderWidth|slide_size|set|start|left|duration|loader|parentWidth|getSize|display|width|navigation|||getStyle|toInt|buttons_height|addEvent|new|options|slider_size|autoplay|stop|index|loaded_images|property|button|none|load|slideImages|top|height|Fx|Tween|link|cancel|show_arrows|right|el|loadSlide|parent|newSliderHeight|space|margin|show_nav|is_fading|slider_type|click|active|prev_slide|window|max_slides|fade|visibles|visible_slides|each|visibility|transition|200|hideNavigation|nextSlide|maxWidth|max|size|bottom|button_pos|block|false|true|tween|nextFx|next|prevFx|prev|prevSlide|changeNavigation|event|cust|buttons|responsive|Math|buttons_margin|chain|slidePlay|sliderLoaded|DocumentLoaded|hide|Browser|ie8|position|hidden|visible|showNavigation|swipe|direction|border|ratio|updateActiveButton|return|makeFade|get|delay|in|play_width|pause_width|preload|this|DJImageSlider|Class|initialize|auto|getChildren|li|Array|for|relative|absolute|addEvents|mouseenter|mouseleave|store|cancelVertical|getElements|hasClass|getParent|getPosition|removeClass|addClass|setTimeout|background|resize|document'.split('|'),0,{}));


