');
/*
If this select is disabled, remove the actual disabled attribute and let themeroller's .ui-state-disabled class handle it.
This is a workaround for jQuery bug #6211 where options in webkit inherit the select's disabled property. This
won't achieve the same level of 'disabled' behavior (the checkboxes will still be present in form submission),
but it at least gives you a way to emulate the UI.
*/
if(isDisabled){
$select.removeAttr("disabled");
}
$select.find('option').each(function(i){
var $this = $(this),
title = $this.html(),
value = this.value,
inputID = this.id || "ui-multiselect-"+id+"-option-"+i,
$parent = $this.parent(),
hasOptGroup = $parent.is('optgroup'),
isDisabled = $this.is(':disabled'),
labelClasses = ['ui-corner-all'];
if(hasOptGroup){
var label = $parent.attr('label');
if($.inArray(label,optgroups) === -1){
html.push('
';
jQuery('body').append(html);
jQuery(window).resize(function() {
repositionCompare();
});
repositionCompare();
}
// @author: tiberiu: reload the saved and viewed boxes
if ($event == 'click') {
try{
jQuery('#vs').vsReload();
} catch (e) {}
}
}
function repositionCompare() {
var pageWidth = jQuery(window).width();
if(pageWidth < '1420') {
jQuery('#compare_box').addClass('docked');
} else {
jQuery('#compare_box').removeClass('docked');
}
}
function redirectCompare(obj) {
var compare_items = readCookie('compare_items');
compare_items = JSON.parse(unescape(compare_items));
if(compare_items.length < 2) {
alert(i18n.elg_cars_JSNOTIFY.compareatleasttwo);
return false;
}
obj.href = 'utile/compara/?vehicle[typeid]='+compare_items[0].typeid+'&L='+url.charAt(url.length-1);
return true;
}
function deleteCompareItem(vehicle_id) {
var compare_items = readCookie('compare_items');
compare_items = JSON.parse(unescape(compare_items));
if (compare_items === null) {
return;
}
var aux_arr = new Array();
for(i=0;i img').attr('src');
}
image = image.replace('200x200', '48x37');
image = image.replace('_big', '_sm');
if(!price) {
var price = jQuery('#vehicle_'+vehicle_id).parent().next().find('.list_price').text();
}
if(price[0] % 1 != 0) {
price = price.replace(price.charAt(0), "");
}
if(!make_model) {
var make_model = jQuery('#vehicle_'+vehicle_id).parent().next().find('.list_cont_text > a.list_title').text();
}
if(!href) {
var href = jQuery('#vehicle_'+vehicle_id).parent().next().find('.list_cont_text > a.list_title').attr('href');
}
var json_var = {"uid": vehicle_id, "image": image, "price": price, "name": make_model, "href": href, "typeid": current_typeid};
if(compare_items) {
var parsed = JSON.parse(unescape(compare_items));
for(i=0;i= 3) {
alert(i18n.elg_cars_JSNOTIFY.notmorethanthree+'.');
return false;
}
parsed.push(json_var);
createCookie('compare_items', escape(JSON.stringify(parsed)), 0);
} else {
json_var = [{"uid": vehicle_id, "image": image, "price": price, "name": make_model, "href": href, "typeid": current_typeid}];
createCookie('compare_items', escape(JSON.stringify(json_var)), 0);
}
// when in single view: show "Scoate din compara" and hide "Compara"
jQuery('#compared_link').show();
jQuery('#compare_link').hide();
// when in list.tpl: show "Scoate din compara" and hide "Compara"
jQuery('#c_link_'+vehicle_id).hide();
jQuery('#c_link_not_'+vehicle_id).show();
manageCompareWindow('click');
return true;
}
var typeid = 1;
function doCompare(vehicle, object){
var action = 'set';
if (object.checked == false) {
action = 'unset';
}
var post = "uid="+vehicle.uid+"&typeid="+vehicle.typeid+"&todo=COMPARE&action="+action;
jQuery.post (url, post, function(result){
var jsondata=eval("("+result+")")
if (jsondata.content == 'set') {
typeid = jsondata.typeid;
}
});
}
function doCompareToPage(){
var url = jQuery('a#compara').attr("href");
window.location = url+'?vehicle[typeid]='+typeid;
return false;
}
function limitChars(textid, limit)
{
var text = jQuery('#'+textid).val();
if (text !== undefined){
var textlength = text.length;
if(textlength > limit)
{
jQuery('#'+textid).val(text.substr(0,limit));
return false;
}
else
{
jQuery('#charNumber').html(format_number(limit - textlength));
return true;
}
}
}
// format the number in "Mai aveţi 3.000 (de) caractere la dispoziţie." message
function format_number(str) {
var amount = new String(str);
if (amount.length == 4){
output = amount[0]+"."+amount[1]+amount[2]+amount[3];// 3.000
amount = amount.split(""); // 3,0,0,0
}
else{
output = str;
}
return output;
}
(function($) {
$(document).ready(function () {
$('#description').next().hide();
$("#formQuickSearch select").each(function () {
var $label = $("label[for='"+$(this).attr('id')+"']");
$(this).find("option").filter("[value=]").text($label.text());
$label.hide();
});
var $fuel_type_label = $("#formQuickSearch label[for='tipcombustibil']");
setTimeout(function() {$("#formQuickSearch #tipcombustibil input").val($fuel_type_label.text());}, 100);
$fuel_type_label.hide();
});
})(jQuery);
function checkRequiredMultiselects(form_id) {
var selector = '';
if(form_id) {
selector = '#'+form_id;
} else {
selector = 'form';
}
var multiselects = jQuery(selector).find('.required_multiselect');
var error_cnt = 0;
var multiselects_to_open = new Array();
var status = '';
for(var i=0;i'+jQuery.validator.messages.required+'');
}
}
return false;
}
return true;
}
/**
* checks if a multiselect has at least one checkbox selected
**/
function checkMultiselectStatus(multiselect) {
var element_id = jQuery(multiselect).attr('rel');
var checkboxes = jQuery('a#'+element_id).nextAll('.ui-multiselect-options').find('input[type=checkbox]');
var checkboxes_checked = jQuery('a#'+element_id).nextAll('.ui-multiselect-options').find('input[type=checkbox]:checked');
var status = 'ok';
if(checkboxes.length > 0 && checkboxes_checked.length == 0) {
status = 'must_check';
}
return status;
}
// CAPTCHA JS
/***************************************************************
* Copyright notice
*
* (c) 2007-2008 Stanislas Rolland
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/*
* Javascript functions for TYPO3 plugin freeCap (sr_freecap)
*
* TYPO3 CVS ID: $Id$
*/
/*
* Loads a new freeCap image
*
* @param string id: identifier used to uniiquely identify the image
*
* @return void
*/
function newFreeCap(id, noImageMessage) {
if (document.getElementById) {
// extract image name from image source (i.e. cut off ?randomness)
var theImage = document.getElementById("tx_srfreecap_pi2_captcha_image_"+id);
var parts = theImage.src.split("&");
// add ?(random) to prevent browser/isp caching
// parts[0] should be base url up to eID parameter
// parts[1] should be id=page_id
// parts[2] should be L=sys_language_uid
var LParameterInUse = (typeof(parts[2]) != "undefined") && (parts[2].indexOf("L=") != -1);
theImage.src = parts[0] + "&" + parts[1] + (LParameterInUse ? "&" + parts[2] : "") + "&set=" + Math.round(Math.random()*100000);
} else {
alert(noImageMessage ? noImageMessage : "Sorry, we cannot autoreload a new image. Submit the form and a new image will be loaded.");
}
}
/*
* Plays the audio captcha
*
* @param string id: identifier used to uniquely identify the wav file
* @param string wavURL: url of the wave file generating script
*
* @return void
*
* Note: In order for this to work with IE8, [SYS][cookieDomain] must be set using the TYPO3 Install Tool
*/
function playCaptcha(id, wavURL, noPlayMessage) {
if (document.getElementById) {
var theAudio = document.getElementById("tx_srfreecap_pi2_captcha_playAudio_"+id);
var wavURLForOpera = wavURL + "&nocache=" + Math.random();
while (theAudio.firstChild) {
theAudio.removeChild(theAudio.firstChild);
}
var objectElement = document.createElement("object");
objectElement.setAttribute("id", "tx_srfreecap_pi2_captcha_playAudio_object"+id);
objectElement.setAttribute("type", "audio/x-wav");
objectElement.setAttribute("data", wavURLForOpera);
objectElement.setAttribute("height", 0);
objectElement.setAttribute("width", 0);
try {
objectElement.innerHTML = '' + (noPlayMessage ? noPlayMessage : 'Sorry, we cannot play the word of the image.') + '';
} catch (e) {
// IE8 does not allow any element other than param as child of object
objectElement.setAttribute("altHTML", '' + (noPlayMessage ? noPlayMessage : 'Sorry, we cannot play the word of the image.') + '');
}
theAudio.appendChild(objectElement);
// IE8 needs a delay before the param children are appended...
window.setTimeout("addAudioCaptchaParams('" + id + "');", 50);
} else {
alert(noPlayMessage ? noPlayMessage : "Sorry, we cannot play the word of the image.");
}
}
function addAudioCaptchaParams(id) {
var theAudio = document.getElementById("tx_srfreecap_pi2_captcha_playAudio_"+id);
var objectElement = theAudio.firstChild;
var url = objectElement.getAttribute("data");
var parameters = {
"type" : "audio/x-wav",
"filename" : url,
"src" : url,
"autoplay" : true,
"autoStart" : 1,
"hidden" : true,
"controller" : false
};
for (var parameter in parameters) {
if (parameters.hasOwnProperty(parameter)) {
var paramElement = document.createElement("param");
paramElement.setAttribute("value", parameters[parameter]);
paramElement.setAttribute("name", parameter);
paramElement = objectElement.appendChild(paramElement);
}
}
}
// CAPTCHA JS END
//Contains the markup for popups
var popupTemplate =
'
';
},
initialisePopupSelector: function (options) {
var examples = Object.keys(options.popups);
var itemOpen = '
';
var itemClose = '
';
var instances = [];
options.selector.innerHTML = itemOpen + Object.keys(options.popups).join(itemClose+itemOpen) + itemClose;
options.selector.onclick = function (e) {
var targ = e.target, item;
// if the target is the container, exit
if (targ.isEqualNode(options.selector)) return;
// from this point, only the child elements of opts.selector will get through.
// out of these child elements, we want to find the closest direct decendant
while (targ.tagName != 'LI' && targ.parentNode) {
targ = targ.parentNode;
}
if (!targ.parentNode.isEqualNode(options.selector)) return;
// from this point, 'targ' will be a direct decendant of opts.selector
var idx = Array.prototype.indexOf.call(options.selector.children, targ);
if (idx >= 0 && instances[idx]) {
instances[idx].clearStatus();
// We could remember the popup that's currently open, but it gets complicated when we consider
// the revoke button. Therefore, simply close them all regardless
instances.forEach(function (popup) {
if (popup.isOpen()) {
popup.close()
}
popup.toggleRevokeButton(false);
});
instances[idx].open();
}
};
for (var i = 0, l = examples.length; i < l; ++i) {
options.popups[examples[i]].onPopupOpen = function(options) {
return function(){
var codediv = document.getElementById('options');
if(codediv) {
codediv.innerHTML = JSON.stringify(options, null, 2);
}
};
} (options.popups[examples[i]]);
var myOpts = options.popups[examples[i]];
myOpts.autoOpen = false;
options.cookieconsent.initialise(myOpts, function(idx, popup){
instances[idx] = popup;
}.bind(null, i), function(idx, err, popup) {
instances[idx] = popup;
console.error(err);
}.bind(null, i));
}
return instances;
},
};
function timeStamp() {
var now = new Date();
var time = [ now.getHours(), now.getMinutes(), now.getSeconds() ];
for ( var i = 1; i < 3; i++ ) {
if ( time[i] < 10 ) {
time[i] = "0" + time[i];
}
}
return '['+time.join(":")+'] ';
}
! function(e) {
if (!e.hasInitialised) {
var t = {
escapeRegExp: function(e) {
return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&")
},
hasClass: function(e, t) {
var i = " ";
return 1 === e.nodeType && (i + e.className + i).replace(/[\n\t]/g, i).indexOf(i + t + i) >= 0
},
addClass: function(e, t) {
e.className += " " + t
},
removeClass: function(e, t) {
var i = new RegExp("\\b" + this.escapeRegExp(t) + "\\b");
e.className = e.className.replace(i, "")
},
interpolateString: function(e, t) {
var i = /{{([a-z][a-z0-9\-_]*)}}/gi;
return e.replace(i, function(e) {
return t(arguments[1]) || ""
})
},
getCookie: function(e) {
var t = "; " + document.cookie,
i = t.split("; " + e + "=");
return 2 != i.length ? void 0 : i.pop().split(";").shift()
},
setCookie: function(e, t, i, n, o) {
var s = new Date;
s.setDate(s.getDate() + (i || 365));
var r = [e + "=" + t, "expires=" + s.toUTCString(), "path=" + (o || "/")];
n && r.push("domain=" + n), document.cookie = r.join(";")
},
deepExtend: function(e, t) {
for (var i in t) t.hasOwnProperty(i) && (i in e && this.isPlainObject(e[i]) && this.isPlainObject(t[i]) ? this.deepExtend(e[i], t[i]) : e[i] = t[i]);
return e
},
throttle: function(e, t) {
var i = !1;
return function() {
i || (e.apply(this, arguments), i = !0, setTimeout(function() {
i = !1
}, t))
}
},
hash: function(e) {
var t, i, n, o = 0;
if (0 === e.length) return o;
for (t = 0, n = e.length; t < n; ++t) i = e.charCodeAt(t), o = (o << 5) - o + i, o |= 0;
return o
},
normaliseHex: function(e) {
return "#" == e[0] && (e = e.substr(1)), 3 == e.length && (e = e[0] + e[0] + e[1] + e[1] + e[2] + e[2]), e
},
getContrast: function(e) {
e = this.normaliseHex(e);
var t = parseInt(e.substr(0, 2), 16),
i = parseInt(e.substr(2, 2), 16),
n = parseInt(e.substr(4, 2), 16),
o = (299 * t + 587 * i + 114 * n) / 1e3;
return o >= 128 ? "#000" : "#fff"
},
getLuminance: function(e) {
var t = parseInt(this.normaliseHex(e), 16),
i = 38,
n = (t >> 16) + i,
o = (t >> 8 & 255) + i,
s = (255 & t) + i,
r = (16777216 + 65536 * (n < 255 ? n < 1 ? 0 : n : 255) + 256 * (o < 255 ? o < 1 ? 0 : o : 255) + (s < 255 ? s < 1 ? 0 : s : 255)).toString(16).slice(1);
return "#" + r
},
isMobile: function() {
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
},
isPlainObject: function(e) {
return "object" == typeof e && null !== e && e.constructor == Object
}
};
e.status = {
deny: "deny",
allow: "allow",
dismiss: "dismiss"
}, e.transitionEnd = function() {
var e = document.createElement("div"),
t = {
t: "transitionend",
OT: "oTransitionEnd",
msT: "MSTransitionEnd",
MozT: "transitionend",
WebkitT: "webkitTransitionEnd"
};
for (var i in t)
if (t.hasOwnProperty(i) && "undefined" != typeof e.style[i + "ransition"]) return t[i];
return ""
}(), e.hasTransition = !!e.transitionEnd;
var i = Object.keys(e.status).map(t.escapeRegExp);
e.customStyles = {}, e.Popup = function() {
function n() {
this.initialise.apply(this, arguments)
}
function o(e) {
this.openingTimeout = null, t.removeClass(e, "cc-invisible")
}
function s(t) {
t.style.display = "none", t.removeEventListener(e.transitionEnd, this.afterTransition), this.afterTransition = null
}
function r() {
var t = this.options.onInitialise.bind(this);
if (!window.navigator.cookieEnabled) return t(e.status.deny), !0;
if (window.CookiesOK || window.navigator.CookiesOK) return t(e.status.allow), !0;
var i = Object.keys(e.status),
n = this.getStatus(),
o = i.indexOf(n) >= 0;
return o && t(n), o
}
function a() {
var e = this.options.position.split("-"),
t = [];
return e.forEach(function(e) {
t.push("cc-" + e)
}), t
}
function c() {
var e = this.options,
i = "top" == e.position || "bottom" == e.position ? "banner" : "floating";
t.isMobile() && (i = "floating");
var n = ["cc-" + i, "cc-type-" + e.type, "cc-theme-" + e.theme];
e["static"] && n.push("cc-static"), n.push.apply(n, a.call(this));
p.call(this, this.options.palette);
return this.customStyleSelector && n.push(this.customStyleSelector), n
}
function l() {
var e = {},
i = this.options;
i.showLink || (i.elements.link = "", i.elements.messagelink = i.elements.message), Object.keys(i.elements).forEach(function(n) {
e[n] = t.interpolateString(i.elements[n], function(e) {
var t = i.content[e];
return e && "string" == typeof t && t.length ? t : ""
})
});
var n = i.compliance[i.type];
n || (n = i.compliance.info), e.compliance = t.interpolateString(n, function(t) {
return e[t]
});
var o = i.layouts[i.layout];
return o || (o = i.layouts.basic), t.interpolateString(o, function(t) {
return e[t]
})
}
function u(i) {
var n = this.options,
o = document.createElement("div"),
s = n.container && 1 === n.container.nodeType ? n.container : document.body;
o.innerHTML = i;
var r = o.children[0];
return r.style.display = "none", t.hasClass(r, "cc-window") && e.hasTransition && t.addClass(r, "cc-invisible"), this.onButtonClick = h.bind(this), r.addEventListener("click", this.onButtonClick), n.autoAttach && (s.firstChild ? s.insertBefore(r, s.firstChild) : s.appendChild(r)), r
}
function h(n) {
var o = n.target;
if (t.hasClass(o, "cc-btn")) {
var s = o.className.match(new RegExp("\\bcc-(" + i.join("|") + ")\\b")),
r = s && s[1] || !1;
r && (this.setStatus(r), this.close(!0))
}
t.hasClass(o, "cc-close") && (this.setStatus(e.status.dismiss), this.close(!0)), t.hasClass(o, "cc-revoke") && this.revokeChoice()
}
function p(e) {
var i = t.hash(JSON.stringify(e)),
n = "cc-color-override-" + i,
o = t.isPlainObject(e);
return this.customStyleSelector = o ? n : null, o && d(i, e, "." + n), o
}
function d(i, n, o) {
if (e.customStyles[i]) return void++e.customStyles[i].references;
var s = {},
r = n.popup,
a = n.button,
c = n.highlight;
r && (r.text = r.text ? r.text : t.getContrast(r.background), r.link = r.link ? r.link : r.text, s[o + ".cc-window"] = ["color: " + r.text, "background-color: " + r.background], s[o + ".cc-revoke"] = ["color: " + r.text, "background-color: " + r.background], s[o + " .cc-link," + o + " .cc-link:active," + o + " .cc-link:visited"] = ["color: " + r.link], a && (a.text = a.text ? a.text : t.getContrast(a.background), a.border = a.border ? a.border : "transparent", s[o + " .cc-btn"] = ["color: " + a.text, "border-color: " + a.border, "background-color: " + a.background], "transparent" != a.background && (s[o + " .cc-btn:hover, " + o + " .cc-btn:focus"] = ["background-color: " + v(a.background)]), c ? (c.text = c.text ? c.text : t.getContrast(c.background), c.border = c.border ? c.border : "transparent", s[o + " .cc-highlight .cc-btn:first-child"] = ["color: " + c.text, "border-color: " + c.border, "background-color: " + c.background]) : s[o + " .cc-highlight .cc-btn:first-child"] = ["color: " + r.text]));
var l = document.createElement("style");
document.head.appendChild(l), e.customStyles[i] = {
references: 1,
element: l.sheet
};
var u = -1;
for (var h in s) s.hasOwnProperty(h) && l.sheet.insertRule(h + "{" + s[h].join(";") + "}", ++u)
}
function v(e) {
return e = t.normaliseHex(e), "000000" == e ? "#222" : t.getLuminance(e)
}
function f(i) {
if (t.isPlainObject(i)) {
var n = t.hash(JSON.stringify(i)),
o = e.customStyles[n];
if (o && !--o.references) {
var s = o.element.ownerNode;
s && s.parentNode && s.parentNode.removeChild(s), e.customStyles[n] = null
}
}
}
function m(e, t) {
for (var i = 0, n = e.length; i < n; ++i) {
var o = e[i];
if (o instanceof RegExp && o.test(t) || "string" == typeof o && o.length && o === t) return !0
}
return !1
}
function b() {
var t = this.setStatus.bind(this),
i = this.options.dismissOnTimeout;
"number" == typeof i && i >= 0 && (this.dismissTimeout = window.setTimeout(function() {
t(e.status.dismiss)
}, Math.floor(i)));
var n = this.options.dismissOnScroll;
if ("number" == typeof n && n >= 0) {
var o = function(i) {
window.pageYOffset > Math.floor(n) && (t(e.status.dismiss), window.removeEventListener("scroll", o), this.onWindowScroll = null)
};
this.onWindowScroll = o, window.addEventListener("scroll", o)
}
}
function y() {
if ("info" != this.options.type && (this.options.revokable = !0), t.isMobile() && (this.options.animateRevokable = !1), this.options.revokable) {
var e = a.call(this);
this.options.animateRevokable && e.push("cc-animate"), this.customStyleSelector && e.push(this.customStyleSelector);
var i = this.options.revokeBtn.replace("{{classes}}", e.join(" "));
this.revokeBtn = u.call(this, i);
var n = this.revokeBtn;
if (this.options.animateRevokable) {
var o = t.throttle(function(e) {
var i = !1,
o = 20,
s = window.innerHeight - 20;
t.hasClass(n, "cc-top") && e.clientY < o && (i = !0), t.hasClass(n, "cc-bottom") && e.clientY > s && (i = !0), i ? t.hasClass(n, "cc-active") || t.addClass(n, "cc-active") : t.hasClass(n, "cc-active") && t.removeClass(n, "cc-active")
}, 200);
this.onMouseMove = o, window.addEventListener("mousemove", o)
}
}
}
var g = {
enabled: !0,
container: null,
cookie: {
name: "cookieconsent_status",
path: "/",
domain: "",
expiryDays: 365
},
onPopupOpen: function() {},
onPopupClose: function() {},
onInitialise: function(e) {},
onStatusChange: function(e, t) {},
onRevokeChoice: function() {},
content: {
header: "Cookies used on the website!",
message: "This website uses cookies to ensure you get the best experience on our website.",
dismiss: "Got it!",
allow: "Allow cookies",
deny: "Decline",
link: "Learn more",
href: "http://cookiesandyou.com",
close: "❌"
},
elements: {
header: '{{header}} ',
message: '
");
o.style.display = "", this.element = o.firstChild, this.element.style.display = "none", t.addClass(this.element, "cc-invisible")
} else this.element = u.call(this, i);
b.call(this), y.call(this), this.options.autoOpen && this.autoOpen()
}, n.prototype.destroy = function() {
this.onButtonClick && this.element && (this.element.removeEventListener("click", this.onButtonClick), this.onButtonClick = null), this.dismissTimeout && (clearTimeout(this.dismissTimeout), this.dismissTimeout = null), this.onWindowScroll && (window.removeEventListener("scroll", this.onWindowScroll), this.onWindowScroll = null), this.onMouseMove && (window.removeEventListener("mousemove", this.onMouseMove), this.onMouseMove = null), this.element && this.element.parentNode && this.element.parentNode.removeChild(this.element), this.element = null, this.revokeBtn && this.revokeBtn.parentNode && this.revokeBtn.parentNode.removeChild(this.revokeBtn), this.revokeBtn = null, f(this.options.palette), this.options = null
}, n.prototype.open = function(t) {
if (this.element) return this.isOpen() || (e.hasTransition ? this.fadeIn() : this.element.style.display = "", this.options.revokable && this.toggleRevokeButton(), this.options.onPopupOpen.call(this)), this
}, n.prototype.close = function(t) {
if (this.element) return this.isOpen() && (e.hasTransition ? this.fadeOut() : this.element.style.display = "none", t && this.options.revokable && this.toggleRevokeButton(!0), this.options.onPopupClose.call(this)), this
}, n.prototype.fadeIn = function() {
var i = this.element;
if (e.hasTransition && i && (this.afterTransition && s.call(this, i), t.hasClass(i, "cc-invisible"))) {
if (i.style.display = "", this.options["static"]) {
var n = this.element.clientHeight;
this.element.parentNode.style.maxHeight = n + "px"
}
var r = 20;
this.openingTimeout = setTimeout(o.bind(this, i), r)
}
}, n.prototype.fadeOut = function() {
var i = this.element;
e.hasTransition && i && (this.openingTimeout && (clearTimeout(this.openingTimeout), o.bind(this, i)), t.hasClass(i, "cc-invisible") || (this.options["static"] && (this.element.parentNode.style.maxHeight = ""), this.afterTransition = s.bind(this, i), i.addEventListener(e.transitionEnd, this.afterTransition), t.addClass(i, "cc-invisible")))
}, n.prototype.isOpen = function() {
return this.element && "" == this.element.style.display && (!e.hasTransition || !t.hasClass(this.element, "cc-invisible"))
}, n.prototype.toggleRevokeButton = function(e) {
this.revokeBtn && (this.revokeBtn.style.display = e ? "" : "none")
}, n.prototype.revokeChoice = function(e) {
this.options.enabled = !0, this.clearStatus(), this.options.onRevokeChoice.call(this), e || this.autoOpen()
}, n.prototype.hasAnswered = function(t) {
return Object.keys(e.status).indexOf(this.getStatus()) >= 0
}, n.prototype.hasConsented = function(t) {
var i = this.getStatus();
return i == e.status.allow || i == e.status.dismiss
}, n.prototype.autoOpen = function(e) {
!this.hasAnswered() && this.options.enabled && this.open()
}, n.prototype.setStatus = function(i) {
var n = this.options.cookie,
o = t.getCookie(n.name),
s = Object.keys(e.status).indexOf(o) >= 0;
Object.keys(e.status).indexOf(i) >= 0 ? (t.setCookie(n.name, i, n.expiryDays, n.domain, n.path), this.options.onStatusChange.call(this, i, s)) : this.clearStatus()
}, n.prototype.getStatus = function() {
return t.getCookie(this.options.cookie.name)
}, n.prototype.clearStatus = function() {
var e = this.options.cookie;
t.setCookie(e.name, "", -1, e.domain, e.path)
}, n
}(), e.Location = function() {
function e(e) {
t.deepExtend(this.options = {}, s), t.isPlainObject(e) && t.deepExtend(this.options, e), this.currentServiceIndex = -1
}
function i(e, t, i) {
var n, o = document.createElement("script");
o.type = "text/" + (e.type || "javascript"), o.src = e.src || e, o.async = !1, o.onreadystatechange = o.onload = function() {
var e = o.readyState;
clearTimeout(n), t.done || e && !/loaded|complete/.test(e) || (t.done = !0, t(), o.onreadystatechange = o.onload = null)
}, document.body.appendChild(o), n = setTimeout(function() {
t.done = !0, t(), o.onreadystatechange = o.onload = null
}, i)
}
function n(e, t, i, n, o) {
var s = new(window.XMLHttpRequest || window.ActiveXObject)("MSXML2.XMLHTTP.3.0");
if (s.open(n ? "POST" : "GET", e, 1), s.setRequestHeader("X-Requested-With", "XMLHttpRequest"), s.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), Array.isArray(o))
for (var r = 0, a = o.length; r < a; ++r) {
var c = o[r].split(":", 2);
s.setRequestHeader(c[0].replace(/^\s+|\s+$/g, ""), c[1].replace(/^\s+|\s+$/g, ""))
}
"function" == typeof t && (s.onreadystatechange = function() {
s.readyState > 3 && t(s)
}), s.send(n)
}
function o(e) {
return new Error("Error [" + (e.code || "UNKNOWN") + "]: " + e.error)
}
var s = {
timeout: 5e3,
services: ["freegeoip", "ipinfo", "maxmind"],
serviceDefinitions: {
freegeoip: function() {
return {
url: "//freegeoip.net/json/?callback={callback}",
isScript: !0,
callback: function(e, t) {
try {
var i = JSON.parse(t);
return i.error ? o(i) : {
code: i.country_code
}
} catch (n) {
return o({
error: "Invalid response (" + n + ")"
})
}
}
}
},
ipinfo: function() {
return {
url: "//ipinfo.io",
headers: ["Accept: application/json"],
callback: function(e, t) {
try {
var i = JSON.parse(t);
return i.error ? o(i) : {
code: i.country
}
} catch (n) {
return o({
error: "Invalid response (" + n + ")"
})
}
}
}
},
ipinfodb: function(e) {
return {
url: "//api.ipinfodb.com/v3/ip-country/?key={api_key}&format=json&callback={callback}",
isScript: !0,
callback: function(e, t) {
try {
var i = JSON.parse(t);
return "ERROR" == i.statusCode ? o({
error: i.statusMessage
}) : {
code: i.countryCode
}
} catch (n) {
return o({
error: "Invalid response (" + n + ")"
})
}
}
}
},
maxmind: function() {
return {
url: "//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",
isScript: !0,
callback: function(e) {
return window.geoip2 ? void geoip2.country(function(t) {
try {
e({
code: t.country.iso_code
})
} catch (i) {
e(o(i))
}
}, function(t) {
e(o(t))
}) : void e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))
}
}
}
}
};
return e.prototype.getNextService = function() {
var e;
do e = this.getServiceByIdx(++this.currentServiceIndex); while (this.currentServiceIndex < this.options.services.length && !e);
return e
}, e.prototype.getServiceByIdx = function(e) {
var i = this.options.services[e];
if ("function" == typeof i) {
var n = i();
return n.name && t.deepExtend(n, this.options.serviceDefinitions[n.name](n)), n
}
return "string" == typeof i ? this.options.serviceDefinitions[i]() : t.isPlainObject(i) ? this.options.serviceDefinitions[i.name](i) : null
}, e.prototype.locate = function(e, t) {
var i = this.getNextService();
return i ? (this.callbackComplete = e, this.callbackError = t, void this.runService(i, this.runNextServiceOnError.bind(this))) : void t(new Error("No services to run"))
}, e.prototype.setupUrl = function(e) {
var t = this.getCurrentServiceOpts();
return e.url.replace(/\{(.*?)\}/g, function(i, n) {
if ("callback" === n) {
var o = "callback" + Date.now();
return window[o] = function(t) {
e.__JSONP_DATA = JSON.stringify(t)
}, o
}
if (n in t.interpolateUrl) return t.interpolateUrl[n]
})
}, e.prototype.runService = function(e, t) {
var o = this;
if (e && e.url && e.callback) {
var s = e.isScript ? i : n,
r = this.setupUrl(e);
s(r, function(i) {
var n = i ? i.responseText : "";
e.__JSONP_DATA && (n = e.__JSONP_DATA, delete e.__JSONP_DATA), o.runServiceCallback.call(o, t, e, n)
}, this.options.timeout, e.data, e.headers)
}
}, e.prototype.runServiceCallback = function(e, t, i) {
var n = this,
o = function(t) {
s || n.onServiceResult.call(n, e, t)
},
s = t.callback(o, i);
s && this.onServiceResult.call(this, e, s)
}, e.prototype.onServiceResult = function(e, t) {
t instanceof Error || t && t.error ? e.call(this, t, null) : e.call(this, null, t)
}, e.prototype.runNextServiceOnError = function(e, t) {
if (e) {
this.logError(e);
var i = this.getNextService();
i ? this.runService(i, this.runNextServiceOnError.bind(this)) : this.completeService.call(this, this.callbackError, new Error("All services failed"))
} else this.completeService.call(this, this.callbackComplete, t)
}, e.prototype.getCurrentServiceOpts = function() {
var e = this.options.services[this.currentServiceIndex];
return "string" == typeof e ? {
name: e
} : "function" == typeof e ? e() : t.isPlainObject(e) ? e : {}
}, e.prototype.completeService = function(e, t) {
this.currentServiceIndex = -1, e && e(t)
}, e.prototype.logError = function(e) {
var t = this.currentServiceIndex,
i = this.getServiceByIdx(t);
console.error("The service[" + t + "] (" + i.url + ") responded with the following error", e)
}, e
}(), e.Law = function() {
function e(e) {
this.initialise.apply(this, arguments)
}
var i = {
regionalLaw: !0,
hasLaw: ["AT", "BE", "BG", "HR", "CZ", "CY", "DK", "EE", "FI", "FR", "DE", "EL", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "SK", "SI", "ES", "SE", "GB", "UK"],
revokable: ["HR", "CY", "DK", "EE", "FR", "DE", "LV", "LT", "NL", "PT", "ES"],
explicitAction: ["HR", "IT", "ES"]
};
return e.prototype.initialise = function(e) {
t.deepExtend(this.options = {}, i), t.isPlainObject(e) && t.deepExtend(this.options, e)
}, e.prototype.get = function(e) {
var t = this.options;
return {
hasLaw: t.hasLaw.indexOf(e) >= 0,
revokable: t.revokable.indexOf(e) >= 0,
explicitAction: t.explicitAction.indexOf(e) >= 0
}
}, e.prototype.applyLaw = function(e, t) {
var i = this.get(t);
return i.hasLaw || (e.enabled = !1), this.options.regionalLaw && (i.revokable && (e.revokable = !0), i.explicitAction && (e.dismissOnScroll = !1, e.dismissOnTimeout = !1)), e
}, e
}(), e.initialise = function(t, i, n) {
var o = new e.Law(t.law);
i || (i = function() {}), n || (n = function() {}), e.getCountryCode(t, function(n) {
delete t.law, delete t.location, n.code && (t = o.applyLaw(t, n.code)), i(new e.Popup(t))
}, function(i) {
delete t.law, delete t.location, n(i, new e.Popup(t))
})
}, e.getCountryCode = function(t, i, n) {
if (t.law && t.law.countryCode) return void i({
code: t.law.countryCode
});
if (t.location) {
var o = new e.Location(t.location);
return void o.locate(function(e) {
i(e || {})
}, n)
}
i({})
}, e.utils = t, e.hasInitialised = !0, window.cookieconsent = e
}
}(window.cookieconsent || {});/*! jCarousel - v0.3.9 - 2018-07-30
* http://sorgalla.com/jcarousel/
* Copyright (c) 2006-2018 Jan Sorgalla; Licensed MIT */
!function(t){"use strict";var i=t.jCarousel={};i.version="0.3.9";var s=/^([+\-]=)?(.+)$/;i.parseTarget=function(t){var i=!1,e="object"!=typeof t?s.exec(t):null;return e?(t=parseInt(e[2],10)||0,e[1]&&(i=!0,"-="===e[1]&&(t*=-1))):"object"!=typeof t&&(t=parseInt(t,10)||0),{target:t,relative:i}},i.detectCarousel=function(t){for(var i;t.length>0;){if((i=t.filter("[data-jcarousel]")).length>0)return i;if((i=t.find("[data-jcarousel]")).length>0)return i;t=t.parent()}return null},i.base=function(s){return{version:i.version,_options:{},_element:null,_carousel:null,_init:t.noop,_create:t.noop,_destroy:t.noop,_reload:t.noop,create:function(){return this._element.attr("data-"+s.toLowerCase(),!0).data(s,this),!1===this._trigger("create")?this:(this._create(),this._trigger("createend"),this)},destroy:function(){return!1===this._trigger("destroy")?this:(this._destroy(),this._trigger("destroyend"),this._element.removeData(s).removeAttr("data-"+s.toLowerCase()),this)},reload:function(t){return!1===this._trigger("reload")?this:(t&&this.options(t),this._reload(),this._trigger("reloadend"),this)},element:function(){return this._element},options:function(i,s){if(0===arguments.length)return t.extend({},this._options);if("string"==typeof i){if(void 0===s)return void 0===this._options[i]?null:this._options[i];this._options[i]=s}else this._options=t.extend({},this._options,i);return this},carousel:function(){return this._carousel||(this._carousel=i.detectCarousel(this.options("carousel")||this._element),this._carousel||t.error('Could not detect carousel for plugin "'+s+'"')),this._carousel},_trigger:function(i,e,r){var n,o=!1;return r=[this].concat(r||[]),(e||this._element).each(function(){n=t.Event((s+":"+i).toLowerCase()),t(this).trigger(n,r),n.isDefaultPrevented()&&(o=!0)}),!o}}},i.plugin=function(s,e){var r=t[s]=function(i,s){this._element=t(i),this.options(s),this._init(),this.create()};return r.fn=r.prototype=t.extend({},i.base(s),e),t.fn[s]=function(i){var e=Array.prototype.slice.call(arguments,1),n=this;return"string"==typeof i?this.each(function(){var r=t(this).data(s);if(!r)return t.error("Cannot call methods on "+s+' prior to initialization; attempted to call method "'+i+'"');if(!t.isFunction(r[i])||"_"===i.charAt(0))return t.error('No such method "'+i+'" for '+s+" instance");var o=r[i].apply(r,e);return o!==r&&void 0!==o?(n=o,!1):void 0}):this.each(function(){var e=t(this).data(s);e instanceof r?e.reload(i):new r(this,i)}),n},r}}(jQuery),function(t,i){"use strict";var s=t(i),e=function(t){return parseFloat(t)||0};t.jCarousel.plugin("jcarousel",{animating:!1,tail:0,inTail:!1,resizeState:null,resizeTimer:null,lt:null,vertical:!1,rtl:!1,circular:!1,underflow:!1,relative:!1,_options:{list:function(){return this.element().children().eq(0)},items:function(){return this.list().children()},animation:400,transitions:!1,wrap:null,vertical:null,rtl:null,center:!1},_list:null,_items:null,_target:t(),_first:t(),_last:t(),_visible:t(),_fullyvisible:t(),_init:function(){var t=this;return t.resizeState=s.width()+"x"+s.height(),this.onWindowResize=function(){t.resizeTimer&&clearTimeout(t.resizeTimer),t.resizeTimer=setTimeout(function(){var i=s.width()+"x"+s.height();i!==t.resizeState&&(t.resizeState=i,t.reload())},100)},this},_create:function(){this._reload(),s.on("resize.jcarousel",this.onWindowResize)},_destroy:function(){s.off("resize.jcarousel",this.onWindowResize)},_reload:function(){this.vertical=this.options("vertical"),null==this.vertical&&(this.vertical=e(this.list().height())>e(this.list().width())),this.rtl=this.options("rtl"),null==this.rtl&&(this.rtl=function(i){if("rtl"===(""+i.attr("dir")).toLowerCase())return!0;var s=!1;return i.parents("[dir]").each(function(){if(/rtl/i.test(t(this).attr("dir")))return s=!0,!1}),s}(this._element)),this.lt=this.vertical?"top":"left",this.relative="relative"===this.list().css("position"),this._list=null,this._items=null;var i=this.index(this._target)>=0?this._target:this.closest();this.circular="circular"===this.options("wrap"),this.underflow=!1;var s={left:0,top:0};return i.length>0&&(this._prepare(i),this.list().find("[data-jcarousel-clone]").remove(),this._items=null,this.underflow=this._fullyvisible.length>=this.items().length,this.circular=this.circular&&!this.underflow,s[this.lt]=this._position(i)+"px"),this.move(s),this},list:function(){if(null===this._list){var i=this.options("list");this._list=t.isFunction(i)?i.call(this):this._element.find(i)}return this._list},items:function(){if(null===this._items){var i=this.options("items");this._items=(t.isFunction(i)?i.call(this):this.list().find(i)).not("[data-jcarousel-clone]")}return this._items},index:function(t){return this.items().index(t)},closest:function(){var i,s=this,r=this.list().position()[this.lt],n=t(),o=!1,l=this.vertical?"bottom":this.rtl&&!this.relative?"left":"right";return this.rtl&&this.relative&&!this.vertical&&(r+=e(this.list().width())-this.clipping()),this.items().each(function(){if(n=t(this),o)return!1;var a=s.dimension(n);if((r+=a)>=0){if(i=a-e(n.css("margin-"+l)),!(Math.abs(r)-a+i/2<=0))return!1;o=!0}}),n},target:function(){return this._target},first:function(){return this._first},last:function(){return this._last},visible:function(){return this._visible},fullyvisible:function(){return this._fullyvisible},hasNext:function(){if(!1===this._trigger("hasnext"))return!0;var t=this.options("wrap"),i=this.items().length-1,s=this.options("center")?this._target:this._last;return!!(i>=0&&!this.underflow&&(t&&"first"!==t||this.index(s)0&&!this.underflow&&(t&&"last"!==t||this.index(this._first)>0||this.tail&&this.inTail))},clipping:function(){return e(this._element["inner"+(this.vertical?"Height":"Width")]())},dimension:function(t){return e(t["outer"+(this.vertical?"Height":"Width")](!0))},scroll:function(i,s,e){if(this.animating)return this;if(!1===this._trigger("scroll",null,[i,s]))return this;t.isFunction(s)&&(e=s,s=!0);var r=t.jCarousel.parseTarget(i);if(r.relative){var n,o,l,a,h,u,c,f,d=this.items().length-1,_=Math.abs(r.target),p=this.options("wrap");if(r.target>0){var g=this.index(this._last);if(g>=d&&this.tail)this.inTail?"both"===p||"last"===p?this._scroll(0,s,e):t.isFunction(e)&&e.call(this,!1):this._scrollTail(s,e);else if(n=this.index(this._target),this.underflow&&n===d&&("circular"===p||"both"===p||"last"===p)||!this.underflow&&g===d&&("both"===p||"last"===p))this._scroll(0,s,e);else if(l=n+_,this.circular&&l>d){for(f=d,h=this.items().get(-1);f++=0)&&h.after(h.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(h),u||((c={})[this.lt]=this.dimension(h),this.moveBy(c)),this._items=null;this._scroll(h,s,e)}else this._scroll(Math.min(l,d),s,e)}else if(this.inTail)this._scroll(Math.max(this.index(this._first)-_+1,0),s,e);else if(o=this.index(this._first),n=this.index(this._target),l=(a=this.underflow?n:o)-_,a<=0&&(this.underflow&&"circular"===p||"both"===p||"first"===p))this._scroll(d,s,e);else if(this.circular&&l<0){for(f=l,h=this.items().get(0);f++<0;){h=this.items().eq(-1),(u=this._visible.index(h)>=0)&&h.after(h.clone(!0).attr("data-jcarousel-clone",!0)),this.list().prepend(h),this._items=null;var m=this.dimension(h);(c={})[this.lt]=-m,this.moveBy(c)}this._scroll(h,s,e)}else this._scroll(Math.max(l,0),s,e)}else this._scroll(r.target,s,e);return this._trigger("scrollend"),this},moveBy:function(t,i){var s=this.list().position(),r=1,n=0;return this.rtl&&!this.vertical&&(r=-1,this.relative&&(n=e(this.list().width())-this.clipping())),t.left&&(t.left=e(s.left)+n+e(t.left)*r+"px"),t.top&&(t.top=e(s.top)+n+e(t.top)*r+"px"),this.move(t,i)},move:function(i,s){s=s||{};var e=this.options("transitions"),r=!!e,n=!!e.transforms,o=!!e.transforms3d,l=s.duration||0,a=this.list();if(!r&&l>0)a.animate(i,s);else{var h=s.complete||t.noop,u={};if(r){var c={transitionDuration:a.css("transitionDuration"),transitionTimingFunction:a.css("transitionTimingFunction"),transitionProperty:a.css("transitionProperty")},f=h;h=function(){t(this).css(c),f.call(this)},u={transitionDuration:(l>0?l/1e3:0)+"s",transitionTimingFunction:e.easing||s.easing,transitionProperty:l>0?n||o?"all":i.left?"left":"top":"none",transform:"none"}}o?u.transform="translate3d("+(i.left||0)+","+(i.top||0)+",0)":n?u.transform="translate("+(i.left||0)+","+(i.top||0)+")":t.extend(u,i),r&&l>0&&a.one("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd",h),a.css(u),l<=0&&a.each(function(){h.call(this)})}},_scroll:function(i,s,r){if(this.animating)return t.isFunction(r)&&r.call(this,!1),this;if("object"!=typeof i?i=this.items().eq(i):void 0===i.jquery&&(i=t(i)),0===i.length)return t.isFunction(r)&&r.call(this,!1),this;this.inTail=!1,this._prepare(i);var n=this._position(i);if(n===e(this.list().position()[this.lt]))return t.isFunction(r)&&r.call(this,!1),this;var o={};return o[this.lt]=n+"px",this._animate(o,s,r),this},_scrollTail:function(i,s){if(this.animating||!this.tail)return t.isFunction(s)&&s.call(this,!1),this;var r=this.list().position()[this.lt];this.rtl&&this.relative&&!this.vertical&&(r+=e(this.list().width())-this.clipping()),this.rtl&&!this.vertical?r+=this.tail:r-=this.tail,this.inTail=!0;var n={};return n[this.lt]=r+"px",this._update({target:this._target.next(),fullyvisible:this._fullyvisible.slice(1).add(this._visible.last())}),this._animate(n,i,s),this},_animate:function(i,s,e){if(e=e||t.noop,!1===this._trigger("animate"))return e.call(this,!1),this;this.animating=!0;var r=this.options("animation"),n=t.proxy(function(){this.animating=!1;var t=this.list().find("[data-jcarousel-clone]");t.length>0&&(t.remove(),this._reload()),this._trigger("animateend"),e.call(this,!0)},this),o="object"==typeof r?t.extend({},r):{duration:r},l=o.complete||t.noop;return!1===s?o.duration=0:void 0!==t.fx.speeds[o.duration]&&(o.duration=t.fx.speeds[o.duration]),o.complete=function(){n(),l.call(this)},this.move(i,o),this},_prepare:function(i){var s,r,n,o=this.index(i),l=o,a=this.dimension(i),h=this.clipping(),u=this.vertical?"bottom":this.rtl?"left":"right",c=this.options("center"),f={target:i,first:i,last:i,visible:i,fullyvisible:a<=h?i:t()};if(c&&(a/=2,h/=2),a=0)&&s.after(s.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(s),!r){var d={};d[this.lt]=this.dimension(s),this.moveBy(d)}this._items=null}if(0===(n=this.dimension(s)))break;if(a+=n,f.last=s,f.visible=f.visible.add(s),a-e(s.css("margin-"+u))<=h&&(f.fullyvisible=f.fullyvisible.add(s)),a>=h)break}if(!this.circular&&!c&&a=h)););return this._update(f),this.tail=0,c||"circular"===this.options("wrap")||"custom"===this.options("wrap")||this.index(f.last)!==this.items().length-1||(a-=e(f.last.css("margin-"+u)))>h&&(this.tail=a-h),this},_position:function(t){var i=this._first,s=e(i.position()[this.lt]),r=this.options("center"),n=r?this.clipping()/2-this.dimension(i)/2:0;return this.rtl&&!this.vertical?(this.relative?s-=e(this.list().width())-this.dimension(i):s-=this.clipping()-this.dimension(i),s+=n):s-=n,!r&&(this.index(t)>this.index(i)||this.inTail)&&this.tail?(s=this.rtl&&!this.vertical?s-this.tail:s+this.tail,this.inTail=!0):this.inTail=!1,-s},_update:function(i){var s,e=this,r={target:this._target,first:this._first,last:this._last,visible:this._visible,fullyvisible:this._fullyvisible},n=this.index(i.first||r.first)=o&&r<=l)return t.isFunction(e)&&e.call(this,!1),this;for(var a,h=this.items(),u=this.clipping(),c=this.vertical?"bottom":this.rtl?"left":"right",f=0;0!==(a=h.eq(r)).length;){if((f+=this.dimension(a))>=u){f-(parseFloat(a.css("margin-"+c))||0)!==u&&r++;break}if(r<=0)break;r--}return this.scroll(r,s,e)}}(jQuery),function(t){"use strict";t.jCarousel.plugin("jcarouselControl",{_options:{target:"+=1",event:"click",method:"scroll"},_active:null,_init:function(){this.onDestroy=t.proxy(function(){this._destroy(),this.carousel().one("jcarousel:createend",t.proxy(this._create,this))},this),this.onReload=t.proxy(this._reload,this),this.onEvent=t.proxy(function(i){i.preventDefault();var s=this.options("method");t.isFunction(s)?s.call(this):this.carousel().jcarousel(this.options("method"),this.options("target"))},this)},_create:function(){this.carousel().one("jcarousel:destroy",this.onDestroy).on("jcarousel:reloadend jcarousel:scrollend",this.onReload),this._element.on(this.options("event")+".jcarouselcontrol",this.onEvent),this._reload()},_destroy:function(){this._element.off(".jcarouselcontrol",this.onEvent),this.carousel().off("jcarousel:destroy",this.onDestroy).off("jcarousel:reloadend jcarousel:scrollend",this.onReload)},_reload:function(){var i,s=t.jCarousel.parseTarget(this.options("target")),e=this.carousel();if(s.relative)i=e.jcarousel(s.target>0?"hasNext":"hasPrev");else{var r="object"!=typeof s.target?e.jcarousel("items").eq(s.target):s.target;i=e.jcarousel("target").index(r)>=0}return this._active!==i&&(this._trigger(i?"active":"inactive"),this._active=i),this}})}(jQuery),function(t){"use strict";t.jCarousel.plugin("jcarouselPagination",{_options:{perPage:null,item:function(t){return''+t+""},event:"click",method:"scroll"},_carouselItems:null,_pages:{},_items:{},_currentPage:null,_init:function(){this.onDestroy=t.proxy(function(){this._destroy(),this.carousel().one("jcarousel:createend",t.proxy(this._create,this))},this),this.onReload=t.proxy(this._reload,this),this.onScroll=t.proxy(this._update,this)},_create:function(){this.carousel().one("jcarousel:destroy",this.onDestroy).on("jcarousel:reloadend",this.onReload).on("jcarousel:scrollend",this.onScroll),this._reload()},_destroy:function(){this._clear(),this.carousel().off("jcarousel:destroy",this.onDestroy).off("jcarousel:reloadend",this.onReload).off("jcarousel:scrollend",this.onScroll),this._carouselItems=null},_reload:function(){var i=this.options("perPage");if(this._pages={},this._items={},t.isFunction(i)&&(i=i.call(this)),null==i)this._pages=this._calculatePages();else for(var s,e=parseInt(i,10)||0,r=this._getCarouselItems(),n=1,o=0;0!==(s=r.eq(o++)).length;)this._pages[n]?this._pages[n]=this._pages[n].add(s):this._pages[n]=s,o%e==0&&n++;this._clear();var l=this,a=this.carousel().data("jcarousel"),h=this._element,u=this.options("item"),c=this._getCarouselItems().length;t.each(this._pages,function(i,s){var e=l._items[i]=t(u.call(l,i,s));e.on(l.options("event")+".jcarouselpagination",t.proxy(function(){var t=s.eq(0);if(a.circular){var e=a.index(a.target()),r=a.index(t);parseFloat(i)>parseFloat(l._currentPage)?re&&(t="-="+(e+(c-r)))}a[this.options("method")](t)},l)),h.append(e)}),this._update()},_update:function(){var i,s=this.carousel().jcarousel("target");t.each(this._pages,function(t,e){if(e.each(function(){if(s.is(this))return i=t,!1}),i)return!1}),this._currentPage!==i&&(this._trigger("inactive",this._items[this._currentPage]),this._trigger("active",this._items[i])),this._currentPage=i},items:function(){return this._items},reloadCarouselItems:function(){return this._carouselItems=null,this},_clear:function(){this._element.empty(),this._currentPage=null},_calculatePages:function(){for(var t,i,s=this.carousel().data("jcarousel"),e=this._getCarouselItems(),r=s.clipping(),n=0,o=0,l=1,a={};0!==(t=e.eq(o++)).length;)n+(i=s.dimension(t))>r&&(l++,n=0),n+=i,a[l]?a[l]=a[l].add(t):a[l]=t;return a},_getCarouselItems:function(){return this._carouselItems||(this._carouselItems=this.carousel().jcarousel("items")),this._carouselItems}})}(jQuery),function(t,i){"use strict";var s,e;t.each({hidden:"visibilitychange",mozHidden:"mozvisibilitychange",msHidden:"msvisibilitychange",webkitHidden:"webkitvisibilitychange"},function(t,r){if(void 0!==i[t])return s=t,e=r,!1}),t.jCarousel.plugin("jcarouselAutoscroll",{_options:{target:"+=1",interval:3e3,autostart:!0,method:"scroll"},_timer:null,_started:!1,_init:function(){this.onDestroy=t.proxy(function(){this._destroy(),this.carousel().one("jcarousel:createend",t.proxy(this._create,this))},this),this.onAnimateEnd=t.proxy(this._start,this),this.onVisibilityChange=t.proxy(function(){i[s]?this._stop():this._start()},this)},_create:function(){this.carousel().one("jcarousel:destroy",this.onDestroy),t(i).on(e,this.onVisibilityChange),this.options("autostart")&&this.start()},_destroy:function(){this._stop(),this.carousel().off("jcarousel:destroy",this.onDestroy),t(i).off(e,this.onVisibilityChange)},_start:function(){if(this._stop(),this._started)return this.carousel().one("jcarousel:animateend",this.onAnimateEnd),this._timer=setTimeout(t.proxy(function(){this.carousel().jcarousel(this.options("method"),this.options("target"))},this),this.options("interval")),this},_stop:function(){return this._timer&&(this._timer=clearTimeout(this._timer)),this.carousel().off("jcarousel:animateend",this.onAnimateEnd),this},start:function(){return this._started=!0,this._start(),this},stop:function(){return this._started=!1,this._stop(),this}})}(jQuery,document);!function(t){"use strict";t.jCarousel.plugin("jcarouselSwipe",{_options:{perSwipe:1,draggable:!0,method:"scroll"},_init:function(){var t=this;this.carousel().on("jcarousel:reloadend",function(){t._reload()})},_create:function(){this._instance=this.carousel().data("jcarousel"),this._instance._element.css("touch-action",this._instance.vertical?"pan-x":"pan-y"),this._carouselOffset=this.carousel().offset()[this._instance.lt]+parseInt(this.carousel().css(this._instance.vertical?"border-top-width":"border-left-width"))+parseInt(this.carousel().css(this._instance.vertical?"padding-top":"padding-left")),this._slidesCount=this._instance.items().length,this.carousel().find("img, a").attr("draggable",!1).css("user-select","none").on("dragstart",function(t){t.preventDefault()}),this._destroy(),this._instance.items().length>this._instance.fullyvisible().length&&this._initGestures()},_initGestures:function(){function e(e){var i,o,p;e=e.originalEvent||e||window.event,l=n(e);var f=Math.abs(r[u]-l[u]),d=Math.abs(r[_]-l[_]);h&&e.preventDefault(),d>10&&d>f&&!h?t(document).off("touchmove.jcarouselSwipe mousemove.jcarouselSwipe"):(!c._instance.animating&&f>10||h)&&(i=r[u]-l[u],h||(h=!0,c._addClones(),c._currentLT=c._getListPosition(),p=c._instance.options("items"),a=(t.isFunction(p)?p.call(c._instance):c._instance.list().find(p)).last(),s=c._instance.rtl&&!c._instance.vertical?c._instance.dimension(c._instance.list())-a.position()[c._instance.lt]-c._instance.clipping():-1*(a.position()[c._instance.lt]+c._instance.dimension(a)-c._instance.clipping())),o="circular"===c._instance._options.wrap?c._currentLT-i:c._instance.rtl&&!c._instance.vertical?Math.max(0,Math.min(c._currentLT-i,s)):Math.min(0,Math.max(c._currentLT-i,s)),c._setListPosition(o+"px"))}function i(e){e=e.originalEvent||e||window.event,l=n(e);var i=Math.abs(r[u]-l[u]),s=Math.abs(r[_]-l[_]);if(h||!c._options.draggable&&i>10&&i>s){var a=c._getNewTarget(r[u]-l[u]>0);a="circular"===c._instance._options.wrap?a.relative:a.static,o===e.target&&t(e.target).on("click.disable",function(e){e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault(),t(e.target).off("click.disable")}),"circular"===c._instance._options.wrap&&(c._removeClones(),c._instance._items=null),h=!1,c._instance[c._options.method](a,function(){"circular"!==c._instance._options.wrap&&(c._removeClones(),c._instance._items=null)})}t(document).off("touchmove.jcarouselSwipe mousemove.jcarouselSwipe"),t(document).off("touchend.jcarouselSwipe touchcancel.jcarouselSwipe mouseup.jcarouselSwipe")}function n(t){return void 0!==t.touches&&t.touches.length>0?{x:t.touches[0].pageX,y:t.touches[0].pageY}:void 0!==t.changedTouches&&t.changedTouches.length>0?{x:t.changedTouches[0].pageX,y:t.changedTouches[0].pageY}:void 0!==t.pageX?{x:t.pageX,y:t.pageY}:{x:t.clientX,y:t.clientY}}var s,a,o,c=this,r={},l={},h=!1,u=this._instance.vertical?"y":"x",_=this._instance.vertical?"x":"y";this._element.on("touchstart.jcarouselSwipe mousedown.jcarouselSwipe",function(s){s=s.originalEvent||s||window.event,r=n(s),o=s.target||s.srcElement,c._options.draggable&&!c._instance.animating&&t(document).on("touchmove.jcarouselSwipe mousemove.jcarouselSwipe",e),t(document).on("touchend.jcarouselSwipe touchcancel.jcarouselSwipe mouseup.jcarouselSwipe",i)})},_getNewTarget:function(t){var e,i=this._instance.target(),n=this._instance.index(i),s=0,a=this._instance.rtl&&!this._instance.vertical?!t:t;if(this._options.draggable)for(;;){if(e=this._instance.rtl&&!this._instance.vertical?i.offset()[this._instance.lt]+this._instance.dimension(i)-(this._carouselOffset+this._instance.clipping()):i.offset()[this._instance.lt]-this._carouselOffset,!i.length||t&&e>=0||!t&&e<=0)break;if(a){if(!(i=i.next()).length)break;n+=1}else{if(!(i=i.prev()).length)break;n-=1}s++}else n=a?n+1:n-1,s=1;return a?n+=Math.abs(s-this._options.perSwipe*Math.ceil(s/this._options.perSwipe)):n-=Math.abs(s-this._options.perSwipe*Math.ceil(s/this._options.perSwipe)),"first"===this._instance._options.wrap?n=Math.min(this._slidesCount-1,n):"last"===this._instance._options.wrap?n=Math.max(0,n):this._instance._options.wrap||(n=Math.max(0,Math.min(this._slidesCount-1,n))),n%=this._slidesCount,s=this._options.perSwipe*Math.ceil(s/this._options.perSwipe),{static:n,relative:(a?"+":"-")+"="+s}},_getListPosition:function(){var t=this._instance.list(),e=t.position();return this._instance.rtl&&(e.left=t.width()+e.left-this._carousel.width()),e[this._instance.lt]},_setListPosition:function(t){var e=this._instance.options("transitions"),i=!!e.transforms,n=!!e.transforms3d,s={},a="left"===this._instance.lt;t=t||0,n?s.transform="translate3d("+(a?t:0)+","+(a?0:t)+",0)":i?s.transform="translate("+(a?t:0)+","+(a?0:t)+")":s[this._instance.lt]=t,this._instance.list().css(s)},_addClones:function(){var e,i,n,s=this,a=this._instance,o=a.items(),c=a.first(),r=a.last(),l=a.dimension(t(window)),h=[],u=[],_=s._getListPosition(),p={};if(!a._options.wrap)return!1;if("last"!==a._options.wrap){for(i=0,n=0,e=c;io.length-1?0:n,i+=a.dimension(o.eq(n)),u.push(o.eq(n).clone().attr("data-jcarousel-clone",!0))):i+=a.dimension(e);a._items.last().after(u)}},_removeClones:function(){var t,e=this._instance.first().position()[this._instance.lt],i={};this._instance.list().find("[data-jcarousel-clone]").remove(),(t=e-this._instance.first().position()[this._instance.lt])&&(i[this._instance.lt]=this._getListPosition()+t+"px",this._instance.move(i))},_destroy:function(){this._element.off("touchstart.jcarouselSwipe mousedown.jcarouselSwipe"),t(document).off("touchmove.jcarouselSwipe mousemove.jcarouselSwipe touchend.jcarouselSwipe touchcancel.jcarouselSwipe mouseup.jcarouselSwipe")},_reload:function(){this._create()}})}(jQuery);/*
* jQuery plugin for vizualizate si salvate (VS)
*
*/
var $LoadingImage = '';
(function($){
$.fn.vs = function(){}
/**
*reload boxes
*/
$.fn.vsReload = function() {
var $viewedBodyObject = $("#vs_body");
var $parkedBodyObject = $("#vs_body_parked");
// put the loading image to both boxes.
$viewedBodyObject.html($LoadingImage);
$parkedBodyObject.html($LoadingImage);
// just reload boxes
var $action = 'refresh';
$.post(url, {todo:'VS_VEHICLE_SAVE', action:$action}, function($result){
$('#vs').replaceWith($result.content);
var $offset = $("#compare_box").offset();
if ($offset !== null && $offset.top > 500) {
$.fn.vs.scrollToBaseBox();
}
}, "json");
}
/**
* Previous function.
*/
$.fn.vs.Prev = function($object, $start, $count){
// check the start.
if ($start - $count <= 0) {
return;
}
// create the from param to be sent to the server
var $params = new Array();
$params.push({name:'from', value:$start - $count - 1});
$.fn.vs.getContent($params, $object);
};
/**
* Next function
*/
$.fn.vs.Next = function($object, $end, $records){
// get out if not applicable.
if ($end >= $records) {
return;
}
// create the form param to be sent to the server.
var $params = new Array();
$params.push({name:'from', value:$end});
// get the data through ajax
$.fn.vs.getContent($params, $object);
};
/**
* Get content of the next/previous.
*/
$.fn.vs.getContent = function($params, $object) {
// current a tag clicked
var $jObject = $($object);
var $jParentObject = $jObject.parents(".vc_body");
var $action = 'viewed';
if ($jParentObject.attr("id") == 'vs_body_parked') {
$action = 'parked';
}
$params.push({name:'todo', value:'VS_NAVIGATION'});
$params.push({name:'action', value: $action});
$jParentObject.html($LoadingImage);
$.post(url, $params, function($result){
if ($result.content !== null && $result.content !== undefined) {
$jParentObject.html($result.content);
/*.animate({
height: "toggle",
opacity: "show"
}, "slow" );*/
}
$.fn.vs.scrollToBaseBox();
}, 'json');
};
$.fn.vs.toggle = function($object, $containerid) {
var $jContainer = $("#"+$containerid);
var $jObject = $($object);
// $containerid is the id of the div content with viewed cars.
$jContainer.toggle('slow');
// $object is the current clicked a tag.
if ('vc_opened' == $($object).attr('class') ) {
$jObject.attr('class', 'vc_closed');
if ($containerid == 'vs_body_parked') {
$("#vs_bottom_opened").remove();
$jObject.parent().attr('class', "vc_btn_bgr last");
}
} else {
if ($containerid == 'vs_body_parked') {
$jContainer.after('
');
$jObject.parent().attr('class', "vc_btn_bgr");
}
$jObject.attr('class', 'vc_opened');
}
$.fn.vs.scrollToBaseBox();
};
$.fn.vs.salveaza = function($object, $vehicleUid, $vehicleTitle) {
// jquery object of the current clicked a element
var $jObject = $($object);
// parent that is the body which holds the content.
var $currentBodyObject = $jObject.parents(".vc_body");
var $topParentObject = $jObject.parents(".left_vc_box");
// get the other parent ( if saved vehicle -> viewed, if viewed vehicle -> saved )
if ($currentBodyObject.attr("id") == 'vs_body') {
var $viewedBodyObject = $currentBodyObject;
var $parkedBodyObject = $currentBodyObject.nextAll(".vc_body");
} else {
var $viewedBodyObject = $currentBodyObject.prevAll(".vc_body");
var $parkedBodyObject = $currentBodyObject;
}
// save or delete?
var $action = 'save_icon' == $jObject.attr("class") ? 'save' : 'delete';
// put the loading image to both boxes.
$viewedBodyObject.html($LoadingImage);
$parkedBodyObject.html($LoadingImage);
// fac un post pentru a salva sau ÅŸterge maÅŸina.
$.post(url, {todo:'VS_VEHICLE_SAVE', action:$action, 'vehicle[uid]':$vehicleUid, 'vehicle[title]':$vehicleTitle}, function($result){
// buttons save from top, only if provided vehicleUid is equal with the current loaded car.
if ($vehicleUid == $("#vehicle_uid").val()) {
$.fn.vs.toggleButonSalveaza($jObject.attr("class"), $result.label, $vehicleUid, $vehicleTitle);
}
$topParentObject.replaceWith($result.content);
$.fn.vs.scrollToBaseBox();
}, "json");
};
$.fn.vs.salveazaTop = function ($object, $vehicleUid, $vehicleTitle) {
// get the jQuery object
var $jObject = $($object);
// get the parent of the boxes
var $topParentBoxes = $("#vs");
// save or delete?
var $action = 'save_icon' == $jObject.attr("rel") ? 'save' : 'delete';
// fac un post pentru a salva sau ÅŸterge maÅŸina.
$.post(url, {todo:'VS_VEHICLE_SAVE', action:$action, 'vehicle[uid]':$vehicleUid, 'vehicle[title]':$vehicleTitle}, function($result){
// buttons save from top.
$.fn.vs.toggleButonSalveaza($jObject.attr("rel"), $result.label, $vehicleUid, $vehicleTitle, 'single');
$topParentBoxes.replaceWith($result.content);
//$.fn.vs.scrollToBaseBox();
}, "json");
};
// save into parking when in listing of vehicles
$.fn.vs.salveazaList = function ($object, $vehicleUid, $vehicleTitle) {
// save or delete?
var $action = 'save_icon' == $($object).attr("rel") ? 'save' : 'delete';
// fac un post pentru a salva sau ÅŸterge maÅŸina.
$.post(url, {todo:'VS_VEHICLE_SAVE_LIST', action:$action, 'vehicle[uid]':$vehicleUid, 'vehicle[title]':$vehicleTitle}, function($result){
// buttons save from top.
$.fn.vs.toggleButonSalveaza($($object).attr("rel"), $result.label, $vehicleUid, $vehicleTitle, 'list');
$.fn.vs.scrollToBaseBox();
}, "json");
};
// toggle between saved or removed link at park vehicle.
$.fn.vs.toggleButonSalveaza = function($status, $label, $vehicleUid, $vehicleTitle, todo) {
// status means the save or delete...
var $rel = 'save_icon' == $status ? 'remove_icon' : 'save_icon';
var $className = 'save_icon' == $status ? 'saving_remove' : 'saving';
// the link is differnt if it is created for list or single
var $link = ''+$label+'';
var $park_link = "#park_link";
if (todo == 'list') {
$link = ''+$label+'';
$park_link += "_"+$vehicleUid;
}
$($park_link).replaceWith($link);
};
$.fn.vs.scrollToBaseBox = function() {
$("html,body").animate({
scrollTop: $("#vs").offset().top
});
};
})(jQuery);/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
(function($){
$.fn.customAccordion = function() {
return this.each(function() {
$obj = $(this);
var body = $obj.html();
// add onclick event on all a elements with parent
$("div.wp_head_bgr a", $obj).click(function(event){
event.preventDefault();
// this id the
$parent = $(this).parent();
$id = $parent.attr("id").split("_");
$class = $parent.attr("class").split(" ");
// check if content exists. Otherwise make a ajax call for the content and add it after the parent.
if ($('#c_'+$id[1]).html() === null) {
$.fn.customAccordion.getContentAndSave({"id":$id[1],"position":$class[1]}, $parent);
// it is important to call Adjustments in ajaxComplete method, otherwise it might get un-syncronized.
$("#r_"+$id[1]).ajaxComplete(function(){
// $(this).next().show(300);
$.fn.customAccordion.Adjustments($id, $class, $obj);
// remove loading image if exists.
$("#img_"+$id[1]).remove();
// initialize the dialog
/*$("#c_"+$id[1]+" a.dialog_link").click(function(){
var $long_description = $("#l_"+$id[1]).html();
event.preventDefault();
var title = $(this).attr('name');
var action = new Array();
dialogLinkClick(title,action, undefined, $(this));
return false;
});*/
});
} else {
$.fn.customAccordion.Adjustments($id, $class, $obj);
}
return false;
});
});
};
$.fn.customAccordion.Adjustments = function($id, $class, $obj) {
// close all contents and open the required one
$.fn.customAccordion.toggle($id[1]);
// fix the last item, if that's the one being opened.
$.fn.customAccordion.adjustLastElement($id, $class, $obj);
};
/**
* make an ajax post request to the server and get the content of the block being opened.
*/
$.fn.customAccordion.getContentAndSave = function($params, $parent){
// put an image loader near the title.
var $image = '';
$parent.append($image);
// make the post to the server to grabb the content of the tab.
$.post(url, "todo=AVANTAJE_WEBCAR&uid="+$params.id+"&position="+$params.position, function(result){
if (result.content !== null) {
result.content = result.content.replace('wp_opened_content"', 'wp_opened_content" style="display:none;"');
$parent.after(result.content);
}
}, "json");
return content;
};
/*
* toggle the content by hidding the opened one and showing the clicked one.
*/
$.fn.customAccordion.toggle = function($id){
if ($("#r_"+$id).find("a").attr("class") == 'wp_closed') {
// hide opened content
$("div.wp_opened_content").hide();
$("a.wp_opened").attr("class", "wp_closed");
// show and change the arrow
$("#r_"+$id).find("a.wp_closed").attr("class", "wp_opened");
$("#c_"+$id).slideDown("500", "linear");
}
};
/**
* last element has additional content and rules which have to be fixed.
*/
$.fn.customAccordion.adjustLastElement = function($id, $class, $object){
// remove first the div with class bottom_opened
$("div.left_wp_box > div.bottom_opened").remove();
// add the div with class bottom_opened if the box being opened is the last one
if ($class[1] == 'last' || $class[1] == 'last_opened') {
$('#r_'+$id[1], $object).attr("class", "wp_head_bgr last_opened");
$object.after('
');
}
// if the box being opened is not the last, rename last_opened to last.
if ($class[1] != 'last' && $class[1] != 'last_opened') {
$('div.wp_head_bgr.last_opened', $object).attr("class", "wp_head_bgr last");
}
};
})(jQuery);
jQuery(document).ready(function(){
jQuery(".wp_body").customAccordion();
});
jQuery(function(){
manageCompareWindow('load');
jQuery('#details').click(function() {
var classDet = jQuery("#details").attr("class");
if (classDet == 'show'){
jQuery('#details').removeClass('show');
jQuery('#details').addClass('hide');
jQuery("#description").slideToggle();
} else {
jQuery('#details').removeClass('hide');
jQuery('#details').addClass('show');
jQuery("#description").slideToggle();
}
});
jQuery('#calculate_leasing').click(function(){
jQuery('#leasingForm').submit();
return false;
});
});
function calculateEnvironmentTax(tourl, obj) {
var return_status=false;
jQuery.ajax({
url: tourl+'&only_price=1',
async: false,
success:function(result){
if(result == '0') {
jQuery(obj).attr('href', tourl+'&submit_form=1');
jQuery(obj).attr('target', '_blank');
return_status = true;
return true;
}
jQuery(obj).hide();
jQuery(obj).before(''+result+'');
jQuery('#tax_details').show();
return_status = false;
}
});
return return_status;
}
function vehicleSyncCallback(refresh_element, data) {
jQuery("#checking-for-vehicle-valability").hide();
jQuery("#detailed_result_left #photos #thumbs").html('');
if(data['reload']) {
jQuery("#invalid-vehicle").css("display", "inherit");
var counter = 6;
setTimeout(function() {window.location.replace(jQuery("#redirect_url").val());}, (counter - 1) * 1000);
var countdown = function() {
jQuery("#countdown-counter").text(--counter);
if (counter > 0) {
setTimeout(countdown, 1000);
}
}
countdown();
return;
} else if (data['error']) {
alert(data['error']);
} else if (data['blocked']) {
jQuery("#couldnt-check-vehicle").css("display", "inherit");
} else {
jQuery("#valid-vehicle").css("display", "inherit");
jQuery("#detailed_result_left #photos").html(data['images_div']);
jQuery("#detailed_result_center #description span").html(data['description_span']);
jQuery("#price_rating_section").html(data["price_rating_span"]);
jQuery('.dialog_link_slideshow, .dialog_gallery').click(galleryClick);
jQuery('.open_gallery').click(lightGalleryClick);
}
}
(function ($) {
$(document).ready(function () {
$(".ui-dialog #dialog").hover(function () {
$(this).find('#slideshow_gallery').hover(function () {
$html = $(this).find('a').html();
if ($html !== null) {
$(this).find('span').html($html);
}
});
});
if ($(".ajax-get-salesman").length > 0) {
$.ajax({
url: $(".ajax-get-salesman").data("href"),
dataType: "json",
}).done(function (data) {
$("#info_contact_salesmen").html(data);
});
}
if ($(".ajax-get-viewed-cars").length > 0) {
$.ajax({
url: $(".ajax-get-viewed-cars").data("href"),
dataType: "json",
}).done(function (data) {
$("#viewed_parked_cars").html(data);
});
}
});
})(jQuery);
jQuery(function(){
jQuery('#submit_leasing_table').click(function() {
jQuery('#leasing_table_form').submit();
});
jQuery('#advancepercent').change(function() {
calculateAdv();
});
jQuery('#formNrmonth').change(function() {
var vehValue = jQuery('#formPrice').val();
if (vehValue != '0') {
jQuery('#leasing_table_form').submit();
}
});
jQuery('#formTextPrice').click(function() {
if (jQuery('#formTextPrice').attr("readonly") == false){
jQuery('#formTextPrice').val('');
}
});
jQuery('#formTextPrice').change(function() {
if (jQuery('#leasing_table_form').valid()){
var priceVal = jQuery.trim(jQuery('#formTextPrice').val()).replace(",","").replace(".","");
priceVal = priceVal.split(" ")[0];
if (!isNaN(priceVal)){
jQuery('#formPrice').val(priceVal);
} else {
jQuery('#formPrice').val(0);
}
calculateAdv();
}
else {
jQuery('#fixErrors').remove();
jQuery('.yellow_info_p:first').parent().append("
"+i18n.elg_cars_JS.fixerrors+"
");
jQuery('html, body').animate({ scrollTop: jQuery('.yellow_info_p:first').parent().parent().parent().offset().top }, 500);
return false;
}
});
});
function calculateAdv(){
var percent = jQuery('#advancepercent').val();
var vehValue = jQuery('#formPrice').val();
var advValue = (percent * vehValue) /100;
jQuery('#advancevalue').val( addCommas(advValue.toFixed(2))+' EUR' );
if (vehValue != '0' && jQuery('#leasing_table_form').text()!='') {
jQuery('#leasing_table_form').submit();
}
}/**
* jQuery Galleriffic plugin
*
* Copyright (c) 2008 Trent Foley (http://trentacular.com)
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* Much thanks to primary contributer Ponticlaro (http://www.ponticlaro.com)
*/
;
(function($) {
// Globally keep track of all images by their unique hash. Each item is an image data object.
var allImages = {};
var imageCounter = 0;
// Galleriffic static class
$.galleriffic = {
version: '2.0.1',
// Strips invalid characters and any leading # characters
normalizeHash: function(hash) {
return hash.replace(/^.*#/, '').replace(/\?.*$/, '');
},
getImage: function(hash) {
if (!hash)
return undefined;
hash = $.galleriffic.normalizeHash(hash);
return allImages[hash];
},
// Global function that looks up an image by its hash and displays the image.
// Returns false when an image is not found for the specified hash.
// @param {String} hash This is the unique hash value assigned to an image.
gotoImage: function(hash) {
var imageData = $.galleriffic.getImage(hash);
if (!imageData)
return false;
var gallery = imageData.gallery;
gallery.gotoImage(imageData);
return true;
},
// Removes an image from its respective gallery by its hash.
// Returns false when an image is not found for the specified hash or the
// specified owner gallery does match the located images gallery.
// @param {String} hash This is the unique hash value assigned to an image.
// @param {Object} ownerGallery (Optional) When supplied, the located images
// gallery is verified to be the same as the specified owning gallery before
// performing the remove operation.
removeImageByHash: function(hash, ownerGallery) {
var imageData = $.galleriffic.getImage(hash);
if (!imageData)
return false;
var gallery = imageData.gallery;
if (ownerGallery && ownerGallery != gallery)
return false;
return gallery.removeImageByIndex(imageData.index);
}
};
var defaults = {
delay: 0,
numThumbs: 20,
preloadAhead: 40, // Set to -1 to preload all images
enableTopPager: false,
enableBottomPager: true,
maxPagesToShow: 7,
imageContainerSel: '',
captionContainerSel: '',
controlsContainerSel: '',
loadingContainerSel: '',
renderSSControls: true,
renderNavControls: true,
playLinkText: 'Play',
pauseLinkText: 'Pause',
prevLinkText: 'Previous',
nextLinkText: 'Next',
nextPageLinkText: 'Next ›',
prevPageLinkText: '‹ Prev',
enableHistory: false,
enableKeyboardNavigation: false,
autoStart: false,
syncTransitions: false,
defaultTransitionDuration: 500,
onSlideChange: undefined, // accepts a delegate like such: function(prevIndex, nextIndex) { ... }
onTransitionOut: undefined, // accepts a delegate like such: function(slide, caption, isSync, callback) { ... }
onTransitionIn: undefined, // accepts a delegate like such: function(slide, caption, isSync) { ... }
onPageTransitionOut: undefined, // accepts a delegate like such: function(callback) { ... }
onPageTransitionIn: undefined, // accepts a delegate like such: function() { ... }
onImageAdded: undefined, // accepts a delegate like such: function(imageData, $li) { ... }
onImageRemoved: undefined // accepts a delegate like such: function(imageData, $li) { ... }
};
// Primary Galleriffic initialization function that should be called on the thumbnail container.
$.fn.galleriffic = function(settings) {
// Extend Gallery Object
$.extend(this, {
// Returns the version of the script
version: $.galleriffic.version,
// Current state of the slideshow
isSlideshowRunning: false,
slideshowTimeout: undefined,
// This function is attached to the click event of generated hyperlinks within the gallery
clickHandler: function(e, link) {
this.pause();
if (!this.enableHistory) {
// The href attribute holds the unique hash for an image
var hash = $.galleriffic.normalizeHash($(link).attr('href'));
$.galleriffic.gotoImage(hash);
e.preventDefault();
}
},
// Appends an image to the end of the set of images. Argument listItem can be either a jQuery DOM element or arbitrary html.
// @param listItem Either a jQuery object or a string of html of the list item that is to be added to the gallery.
appendImage: function(listItem) {
this.addImage(listItem, false, false);
return this;
},
// Inserts an image into the set of images. Argument listItem can be either a jQuery DOM element or arbitrary html.
// @param listItem Either a jQuery object or a string of html of the list item that is to be added to the gallery.
// @param {Integer} position The index within the gallery where the item shouold be added.
insertImage: function(listItem, position) {
this.addImage(listItem, false, true, position);
return this;
},
// Adds an image to the gallery and optionally inserts/appends it to the DOM (thumbExists)
// @param listItem Either a jQuery object or a string of html of the list item that is to be added to the gallery.
// @param {Boolean} thumbExists Specifies whether the thumbnail already exists in the DOM or if it needs to be added.
// @param {Boolean} insert Specifies whether the the image is appended to the end or inserted into the gallery.
// @param {Integer} position The index within the gallery where the item shouold be added.
addImage: function(listItem, thumbExists, insert, position) {
var $li = ( typeof listItem === "string" ) ? $(listItem) : listItem;
var $aThumb = $li.find('a.thumb');
var slideUrl = $aThumb.attr('href');
var title = $aThumb.attr('title');
var $caption = $li.find('.caption').remove();
var hash = $aThumb.attr('name');
// Increment the image counter
imageCounter++;
// Autogenerate a hash value if none is present or if it is a duplicate
if (!hash || allImages[''+hash]) {
hash = imageCounter;
}
// Set position to end when not specified
if (!insert)
position = this.data.length;
var imageData = {
title:title,
slideUrl:slideUrl,
caption:$caption,
hash:hash,
gallery:this,
index:position
};
// Add the imageData to this gallery's array of images
if (insert) {
this.data.splice(position, 0, imageData);
// Reset index value on all imageData objects
this.updateIndices(position);
}
else {
this.data.push(imageData);
}
var gallery = this;
// Add the element to the DOM
if (!thumbExists) {
// Update thumbs passing in addition post transition out handler
this.updateThumbs(function() {
var $thumbsUl = gallery.find('ul.thumbs');
if (insert)
$thumbsUl.children(':eq('+position+')').before($li);
else
$thumbsUl.append($li);
if (gallery.onImageAdded)
gallery.onImageAdded(imageData, $li);
});
}
// Register the image globally
allImages[''+hash] = imageData;
// Setup attributes and click handler
$aThumb.attr('rel', 'history')
.attr('href', '#'+hash)
.removeAttr('name')
.click(function(e) {
if(jQuery('#is_gallery_popup_open').length > 0) {
gallery.clickHandler(e, this);
} else {
return false;
}
// jQuery(".dialog_gallery").click();
// return false;
});
return this;
},
// Removes an image from the gallery based on its index.
// Returns false when the index is out of range.
removeImageByIndex: function(index) {
if (index < 0 || index >= this.data.length)
return false;
var imageData = this.data[index];
if (!imageData)
return false;
this.removeImage(imageData);
return true;
},
// Convenience method that simply calls the global removeImageByHash method.
removeImageByHash: function(hash) {
return $.galleriffic.removeImageByHash(hash, this);
},
// Removes an image from the gallery.
removeImage: function(imageData) {
var index = imageData.index;
// Remove the image from the gallery data array
this.data.splice(index, 1);
// Remove the global registration
delete allImages[''+imageData.hash];
// Remove the image's list item from the DOM
this.updateThumbs(function() {
var $li = gallery.find('ul.thumbs')
.children(':eq('+index+')')
.remove();
if (gallery.onImageRemoved)
gallery.onImageRemoved(imageData, $li);
});
// Update each image objects index value
this.updateIndices(index);
return this;
},
// Updates the index values of the each of the images in the gallery after the specified index
updateIndices: function(startIndex) {
for (i = startIndex; i < this.data.length; i++) {
this.data[i].index = i;
}
return this;
},
// Scraped the thumbnail container for thumbs and adds each to the gallery
initializeThumbs: function() {
this.data = [];
var gallery = this;
this.find('ul.thumbs > li').each(function(i) {
gallery.addImage($(this), true, false);
});
return this;
},
isPreloadComplete: false,
// Initalizes the image preloader
preloadInit: function() {
if (this.preloadAhead == 0) return this;
this.preloadStartIndex = this.currentImage;
var nextIndex = this.getNextIndex(this.preloadStartIndex);
return this.preloadRecursive(this.preloadStartIndex, nextIndex);
},
// Changes the location in the gallery the preloader should work
// @param {Integer} index The index of the image where the preloader should restart at.
preloadRelocate: function(index) {
// By changing this startIndex, the current preload script will restart
this.preloadStartIndex = index;
return this;
},
// Recursive function that performs the image preloading
// @param {Integer} startIndex The index of the first image the current preloader started on.
// @param {Integer} currentIndex The index of the current image to preload.
preloadRecursive: function(startIndex, currentIndex) {
// Check if startIndex has been relocated
if (startIndex != this.preloadStartIndex) {
var nextIndex = this.getNextIndex(this.preloadStartIndex);
return this.preloadRecursive(this.preloadStartIndex, nextIndex);
}
var gallery = this;
// Now check for preloadAhead count
var preloadCount = currentIndex - startIndex;
if (preloadCount < 0)
preloadCount = this.data.length-1-startIndex+currentIndex;
if (this.preloadAhead >= 0 && preloadCount > this.preloadAhead) {
// Do this in order to keep checking for relocated start index
setTimeout(function() {
gallery.preloadRecursive(startIndex, currentIndex);
}, 500);
return this;
}
var imageData = this.data[currentIndex];
if (!imageData)
return this;
// If already loaded, continue
if (imageData.image)
return this.preloadNext(startIndex, currentIndex);
// Preload the image
var image = new Image();
image.onload = function() {
imageData.image = this;
gallery.preloadNext(startIndex, currentIndex);
};
image.alt = imageData.title;
image.src = imageData.slideUrl;
return this;
},
// Called by preloadRecursive in order to preload the next image after the previous has loaded.
// @param {Integer} startIndex The index of the first image the current preloader started on.
// @param {Integer} currentIndex The index of the current image to preload.
preloadNext: function(startIndex, currentIndex) {
var nextIndex = this.getNextIndex(currentIndex);
if (nextIndex == startIndex) {
this.isPreloadComplete = true;
} else {
// Use setTimeout to free up thread
var gallery = this;
setTimeout(function() {
gallery.preloadRecursive(startIndex, nextIndex);
}, 100);
}
return this;
},
// Safe way to get the next image index relative to the current image.
// If the current image is the last, returns 0
getNextIndex: function(index) {
var nextIndex = index+1;
if (nextIndex >= this.data.length)
nextIndex = 0;
return nextIndex;
},
// Safe way to get the previous image index relative to the current image.
// If the current image is the first, return the index of the last image in the gallery.
getPrevIndex: function(index) {
var prevIndex = index-1;
if (prevIndex < 0)
prevIndex = this.data.length-1;
return prevIndex;
},
// Pauses the slideshow
pause: function() {
this.isSlideshowRunning = false;
if (this.slideshowTimeout) {
clearTimeout(this.slideshowTimeout);
this.slideshowTimeout = undefined;
}
if (this.$controlsContainer) {
this.$controlsContainer
.find('div.ss-controls a').removeClass().addClass('play')
.attr('title', this.playLinkText)
.attr('href', '#play')
.html(this.playLinkText);
}
return this;
},
// Plays the slideshow
play: function() {
this.isSlideshowRunning = true;
if (this.$controlsContainer) {
this.$controlsContainer
.find('div.ss-controls a').removeClass().addClass('pause')
.attr('title', this.pauseLinkText)
.attr('href', '#pause')
.html(this.pauseLinkText);
}
if (!this.slideshowTimeout) {
var gallery = this;
this.slideshowTimeout = setTimeout(function() {
gallery.ssAdvance();
}, this.delay);
}
return this;
},
// Toggles the state of the slideshow (playing/paused)
toggleSlideshow: function() {
if (this.isSlideshowRunning)
this.pause();
else
this.play();
return this;
},
// Advances the slideshow to the next image and delegates navigation to the
// history plugin when history is enabled
// enableHistory is true
ssAdvance: function() {
if (this.isSlideshowRunning)
this.next(true);
return this;
},
// Advances the gallery to the next image.
// @param {Boolean} dontPause Specifies whether to pause the slideshow.
// @param {Boolean} bypassHistory Specifies whether to delegate navigation to the history plugin when history is enabled.
next: function(dontPause, bypassHistory) {
this.gotoIndex(this.getNextIndex(this.currentImage.index), dontPause, bypassHistory);
return this;
},
// Navigates to the previous image in the gallery.
// @param {Boolean} dontPause Specifies whether to pause the slideshow.
// @param {Boolean} bypassHistory Specifies whether to delegate navigation to the history plugin when history is enabled.
previous: function(dontPause, bypassHistory) {
this.gotoIndex(this.getPrevIndex(this.currentImage.index), dontPause, bypassHistory);
return this;
},
// Navigates to the next page in the gallery.
// @param {Boolean} dontPause Specifies whether to pause the slideshow.
// @param {Boolean} bypassHistory Specifies whether to delegate navigation to the history plugin when history is enabled.
nextPage: function(dontPause, bypassHistory) {
var page = this.getCurrentPage();
var lastPage = this.getNumPages() - 1;
if (page < lastPage) {
var startIndex = page * this.numThumbs;
var nextPage = startIndex + this.numThumbs;
this.gotoIndex(nextPage, dontPause, bypassHistory);
}
return this;
},
// Navigates to the previous page in the gallery.
// @param {Boolean} dontPause Specifies whether to pause the slideshow.
// @param {Boolean} bypassHistory Specifies whether to delegate navigation to the history plugin when history is enabled.
previousPage: function(dontPause, bypassHistory) {
var page = this.getCurrentPage();
if (page > 0) {
var startIndex = page * this.numThumbs;
var prevPage = startIndex - this.numThumbs;
this.gotoIndex(prevPage, dontPause, bypassHistory);
}
return this;
},
// Navigates to the image at the specified index in the gallery
// @param {Integer} index The index of the image in the gallery to display.
// @param {Boolean} dontPause Specifies whether to pause the slideshow.
// @param {Boolean} bypassHistory Specifies whether to delegate navigation to the history plugin when history is enabled.
gotoIndex: function(index, dontPause, bypassHistory) {
if (!dontPause)
this.pause();
if (index < 0) index = 0;
else if (index >= this.data.length) index = this.data.length-1;
var imageData = this.data[index];
if (!bypassHistory && this.enableHistory)
$.historyLoad(String(imageData.hash)); // At the moment, historyLoad only accepts string arguments
else
this.gotoImage(imageData);
return this;
},
// This function is garaunteed to be called anytime a gallery slide changes.
// @param {Object} imageData An object holding the image metadata of the image to navigate to.
gotoImage: function(imageData) {
var index = imageData;
if (this.onSlideChange)
this.onSlideChange(this.currentImage.index, index);
this.currentImage = imageData;
this.preloadRelocate(index);
this.refresh();
return this;
},
// Returns the default transition duration value. The value is halved when not
// performing a synchronized transition.
// @param {Boolean} isSync Specifies whether the transitions are synchronized.
getDefaultTransitionDuration: function(isSync) {
if (isSync)
return this.defaultTransitionDuration;
return this.defaultTransitionDuration / 2;
},
// Rebuilds the slideshow image and controls and performs transitions
refresh: function() {
var imageData = this.currentImage;
if (!imageData)
return this;
var index = imageData.index;
// Update Controls
if (this.$controlsContainer) {
this.$controlsContainer
.find('div.nav-controls a.p_left').attr('href', '#'+this.data[this.getPrevIndex(index)].hash).end()
.find('div.nav-controls a.p_right').attr('href', '#'+this.data[this.getNextIndex(index)].hash);
}
var previousSlide = this.$imageContainer.find('span.current').addClass('previous').removeClass('current');
var previousCaption = 0;
if (this.$captionContainer) {
previousCaption = this.$captionContainer.find('span.current').addClass('previous').removeClass('current');
}
// Perform transitions simultaneously if syncTransitions is true and the next image is already preloaded
var isSync = this.syncTransitions && imageData.image;
// Flag we are transitioning
var isTransitioning = true;
var gallery = this;
var transitionOutCallback = function() {
// Flag that the transition has completed
isTransitioning = false;
// Remove the old slide
previousSlide.remove();
// Remove old caption
if (previousCaption)
previousCaption.remove();
if (!isSync) {
if (imageData.image && imageData.hash == gallery.data[gallery.currentImage.index].hash) {
gallery.buildImage(imageData, isSync);
} else {
// Show loading container
if (gallery.$loadingContainer) {
gallery.$loadingContainer.show();
}
}
}
};
if (previousSlide.length == 0) {
// For the first slide, the previous slide will be empty, so we will call the callback immediately
transitionOutCallback();
} else {
if (this.onTransitionOut) {
this.onTransitionOut(previousSlide, previousCaption, isSync, transitionOutCallback);
} else {
previousSlide.fadeTo(this.getDefaultTransitionDuration(isSync), 0.0, transitionOutCallback);
if (previousCaption)
previousCaption.fadeTo(this.getDefaultTransitionDuration(isSync), 0.0);
}
}
// Go ahead and begin transitioning in of next image
if (isSync)
this.buildImage(imageData, isSync);
if (!imageData.image) {
var image = new Image();
// Wire up mainImage onload event
image.onload = function() {
imageData.image = this;
// Only build image if the out transition has completed and we are still on the same image hash
if (!isTransitioning && imageData.hash == gallery.data[gallery.currentImage.index].hash) {
gallery.buildImage(imageData, isSync);
}
};
// set alt and src
image.alt = imageData.title;
image.src = imageData.slideUrl;
}
// This causes the preloader (if still running) to relocate out from the currentIndex
this.relocatePreload = true;
return this.syncThumbs();
},
// Called by the refresh method after the previous image has been transitioned out or at the same time
// as the out transition when performing a synchronous transition.
// @param {Object} imageData An object holding the image metadata of the image to build.
// @param {Boolean} isSync Specifies whether the transitions are synchronized.
buildImage: function(imageData, isSync) {
var gallery = this;
var nextIndex = this.getNextIndex(imageData.index);
this.$imageContainer.empty();
// Construct new hidden span for the image
var newSlide = this.$imageContainer
.append('
')
.find('span.current').css('opacity', '0');
newSlide.find('a')
.append(imageData.image)
.click(function(e) {
jQuery(jQuery('.dialog_link_slideshow')[0]).click();
// jQuery('.dialog_link_slideshow')[0].click();
return false;
// gallery.clickHandler(e, this);
});
var newCaption = 0;
if (this.$captionContainer) {
this.$captionContainer.empty();
// Construct new hidden caption for the image
newCaption = this.$captionContainer
.append('')
.find('span.current').css('opacity', '0')
.append(imageData.caption);
}
// Hide the loading conatiner
if (this.$loadingContainer) {
this.$loadingContainer.hide();
}
// Transition in the new image
if (this.onTransitionIn) {
this.onTransitionIn(newSlide, newCaption, isSync);
} else {
newSlide.fadeTo(this.getDefaultTransitionDuration(isSync), 1.0);
if (newCaption)
newCaption.fadeTo(this.getDefaultTransitionDuration(isSync), 1.0);
}
if (this.isSlideshowRunning) {
if (this.slideshowTimeout)
clearTimeout(this.slideshowTimeout);
this.slideshowTimeout = setTimeout(function() {
gallery.ssAdvance();
}, this.delay);
}
return this;
},
// Returns the current page index that should be shown for the currentImage
getCurrentPage: function() {
return Math.floor(this.currentImage.index / this.numThumbs);
},
// Applies the selected class to the current image's corresponding thumbnail.
// Also checks if the current page has changed and updates the displayed page of thumbnails if necessary.
syncThumbs: function() {
var page = this.getCurrentPage();
if (page != this.displayedPage)
this.updateThumbs();
// Remove existing selected class and add selected class to new thumb
var $thumbs = this.find('ul.thumbs').children();
$thumbs.filter('.selected').removeClass('selected');
$thumbs.eq(this.currentImage.index).addClass('selected');
return this;
},
// Performs transitions on the thumbnails container and updates the set of
// thumbnails that are to be displayed and the navigation controls.
// @param {Delegate} postTransitionOutHandler An optional delegate that is called after
// the thumbnails container has transitioned out and before the thumbnails are rebuilt.
updateThumbs: function(postTransitionOutHandler) {
var gallery = this;
var transitionOutCallback = function() {
// Call the Post-transition Out Handler
if (postTransitionOutHandler)
postTransitionOutHandler();
gallery.rebuildThumbs();
// Transition In the thumbsContainer
if (gallery.onPageTransitionIn)
gallery.onPageTransitionIn();
else
gallery.show();
};
// Transition Out the thumbsContainer
if (this.onPageTransitionOut) {
this.onPageTransitionOut(transitionOutCallback);
} else {
this.hide();
transitionOutCallback();
}
return this;
},
// Updates the set of thumbnails that are to be displayed and the navigation controls.
rebuildThumbs: function() {
var needsPagination = this.data.length > this.numThumbs;
// Rebuild top pager
if (this.enableTopPager) {
var $topPager = this.find('div.top');
if ($topPager.length == 0)
$topPager = this.prepend('').find('div.top');
else
$topPager.empty();
if (needsPagination)
this.buildPager($topPager);
}
// Rebuild bottom pager
if (this.enableBottomPager) {
var $bottomPager = this.find('div.bottom');
if ($bottomPager.length == 0)
$bottomPager = this.append('').find('div.bottom');
else
$bottomPager.empty();
if (needsPagination)
this.buildPager($bottomPager);
}
var page = this.getCurrentPage();
var startIndex = page*this.numThumbs;
var stopIndex = startIndex+this.numThumbs-1;
if (stopIndex >= this.data.length)
stopIndex = this.data.length-1;
// Show/Hide thumbs
var $thumbsUl = this.find('ul.thumbs');
$thumbsUl.find('li').each(function(i) {
var $li = $(this);
if (i >= startIndex && i <= stopIndex) {
$li.show();
} else {
$li.hide();
}
});
this.displayedPage = page;
// Remove the noscript class from the thumbs container ul
$thumbsUl.removeClass('noscript');
return this;
},
// Returns the total number of pages required to display all the thumbnails.
getNumPages: function() {
return Math.ceil(this.data.length/this.numThumbs);
},
// Rebuilds the pager control in the specified matched element.
// @param {jQuery} pager A jQuery element set matching the particular pager to be rebuilt.
buildPager: function(pager) {
var gallery = this;
var numPages = this.getNumPages();
var page = this.getCurrentPage();
var startIndex = page * this.numThumbs;
var pagesRemaining = this.maxPagesToShow - 1;
var pageNum = page - Math.floor((this.maxPagesToShow - 1) / 2) + 1;
if (pageNum > 0) {
var remainingPageCount = numPages - pageNum;
if (remainingPageCount < pagesRemaining) {
pageNum = pageNum - (pagesRemaining - remainingPageCount);
}
}
if (pageNum < 0) {
pageNum = 0;
}
// Prev Page Link
if (page > 0) {
var prevPage = startIndex - this.numThumbs;
pager.append(''+this.prevPageLinkText+'');
}
// Create First Page link if needed
if (pageNum > 0) {
this.buildPageLink(pager, 0, numPages);
if (pageNum > 1)
pager.append('…');
pagesRemaining--;
}
// Page Index Links
while (pagesRemaining > 0) {
this.buildPageLink(pager, pageNum, numPages);
pagesRemaining--;
pageNum++;
}
// Create Last Page link if needed
if (pageNum < numPages) {
var lastPageNum = numPages - 1;
if (pageNum < lastPageNum)
pager.append('…');
this.buildPageLink(pager, lastPageNum, numPages);
}
// Next Page Link
var nextPage = startIndex + this.numThumbs;
if (nextPage < this.data.length) {
pager.append(''+this.nextPageLinkText+'');
}
pager.find('a').click(function(e) {
gallery.clickHandler(e, this);
});
return this;
},
// Builds a single page link within a pager. This function is called by buildPager
// @param {jQuery} pager A jQuery element set matching the particular pager to be rebuilt.
// @param {Integer} pageNum The page number of the page link to build.
// @param {Integer} numPages The total number of pages required to display all thumbnails.
buildPageLink: function(pager, pageNum, numPages) {
var pageLabel = pageNum + 1;
var currentPage = this.getCurrentPage();
if (pageNum == currentPage)
pager.append(''+pageLabel+'');
else if (pageNum < numPages) {
var imageIndex = pageNum*this.numThumbs;
pager.append(''+pageLabel+'');
}
return this;
}
});
// Now initialize the gallery
$.extend(this, defaults, settings);
// Verify the history plugin is available
if (this.enableHistory && !$.historyInit)
this.enableHistory = false;
// Select containers
if (this.imageContainerSel) this.$imageContainer = $(this.imageContainerSel);
if (this.captionContainerSel) this.$captionContainer = $(this.captionContainerSel);
if (this.loadingContainerSel) this.$loadingContainer = $(this.loadingContainerSel);
// Initialize the thumbails
this.initializeThumbs();
if (this.maxPagesToShow < 3)
this.maxPagesToShow = 3;
this.displayedPage = -1;
this.currentImage = this.data[0];
var gallery = this;
// Hide the loadingContainer
if (this.$loadingContainer)
this.$loadingContainer.hide();
// Setup controls
if (this.controlsContainerSel) {
this.$controlsContainer = $(this.controlsContainerSel).empty();
if (this.renderSSControls) {
if (this.autoStart) {
this.$controlsContainer
.append('