$(document).ready(function() {
InitCarousel();
InitPropertyCarousel();
InitOffCanvasNavigation();
InitMap();
InitChosen();
InitEzmark();
InitPriceSlider();
InitImageSlider();
InitAccordion();
InitTabs();
InitPalette();
});
function InitPalette() {
if ($.cookie('palette') == 'true') {
$('.palette').addClass('open');
}
$('.palette .toggle a').on({
click: function(e) {
e.preventDefault();
var palette = $(this).closest('.palette');
if (palette.hasClass('open')) {
palette.animate({'left': '-195'}, 500, function() {
palette.removeClass('open');
});
$.cookie('palette', false)
} else {
palette.animate({'left': '0'}, 500, function() {
palette.addClass('open');
$.cookie('palette', true);
});
}
}
});
if ($.cookie('color-variant')) {
var link = $('.palette').find('a.'+ $.cookie('color-variant'));
var file = link.attr('href');
var klass = link.attr('class');
$('#color-variant').attr('href', file);
$('body').addClass(klass);
}
if ($.cookie('pattern')) {
$('body').addClass($.cookie('pattern'));
}
if ($.cookie('header')) {
$('body').addClass($.cookie('header'));
}
$('.palette a').on({
click: function(e) {
e.preventDefault();
// Colors
if ($(this).closest('div').hasClass('colors')) {
var file = $(this).attr('href');
var klass = $(this).attr('class');
$('#color-variant').attr('href', file);
if (!$('body').hasClass(klass)) {
$('body').removeClass($.cookie('color-variant'));
$('body').addClass(klass);
}
$.cookie('color-variant', klass)
}
// Patterns
else if ($(this).closest('div').hasClass('patterns')) {
var klass = $(this).attr('class');
if (!$('body').hasClass(klass)) {
$('body').removeClass($.cookie('pattern'));
$('body').addClass(klass);
$.cookie('pattern', klass);
}
}
// Headers
else if ($(this).closest('div').hasClass('headers')) {
var klass = $(this).attr('class');
if (!$('body').hasClass(klass)) {
$('body').removeClass($.cookie('header'));
$('body').addClass(klass);
$.cookie('header', klass);
}
}
}
});
$('.palette .reset').on({
click: function() {
$('body').removeClass($.cookie('color-variant'));
$('#color-variant').attr('href', null);
$.removeCookie('color-variant');
$('body').removeClass($.cookie('pattern'));
$.removeCookie('pattern');
$('body').removeClass($.cookie('header'));
$.removeCookie('header');
}
})
}
function InitPropertyCarousel() {
$('.carousel.property .content li img').on({
click: function(e) {
var src = $(this).attr('src');
var img = $(this).closest('.carousel.property').find('.preview img');
img.attr('src', src);
$('.carousel.property .content li').each(function() {
$(this).removeClass('active');
});
$(this).closest('li').addClass('active');
}
})
}
function InitTabs() {
$('.tabs a').click(function (e) {
e.preventDefault();
$(this).tab('show');
});
}
function InitImageSlider() {
$('.iosSlider').iosSlider({
desktopClickDrag: true,
snapToChildren: true,
infiniteSlider: true,
navSlideSelector: '.slider .navigation li',
onSlideComplete: function(args) {
if(!args.slideChanged) return false;
$(args.sliderObject).find('.slider-info').attr('style', '');
$(args.currentSlideObject).find('.slider-info').animate({
left: '15px',
opacity: '.9'
}, 'easeOutQuint');
},
onSliderLoaded: function(args) {
$(args.sliderObject).find('.slider-info').attr('style', '');
$(args.currentSlideObject).find('.slider-info').animate({
left: '15px',
opacity: '.9'
}, 'easeOutQuint');
},
onSlideChange: function(args) {
$('.slider .navigation li').removeClass('active');
$('.slider .navigation li:eq(' + (args.currentSlideNumber - 1) + ')').addClass('active');
},
autoSlide: true,
scrollbar: true,
scrollbarContainer: '.sliderContainer .scrollbarContainer',
scrollbarMargin: '0',
scrollbarBorderRadius: '0',
keyboardControls: true
});
}
function InitAccordion() {
$('.accordion').on('show', function (e) {
$(e.target).prev('.accordion-heading').find('.accordion-toggle').addClass('active');
});
$('.accordion').on('hide', function (e) {
$(this).find('.accordion-toggle').not($(e.target)).removeClass('active');
});
}
function InitPriceSlider() {
jQuery('.price-value .from').text(100);
jQuery('.price-value .from').currency({ region: 'EUR', thousands: ' ', decimal: ',', decimals: 0 });
jQuery('.price-value .to').text(1000000);
jQuery('.price-value .to').currency({ region: 'EUR', thousands: ' ', decimal: ',', decimals: 0 });
$('.property-filter .price-slider').slider({
range: true,
min: 100,
max: 1000000,
values: [100, 1000000],
slide: function(event, ui) {
jQuery('.property-filter .price-from input').attr('value', ui.values[0]);
jQuery('.property-filter .price-to input').attr('value', ui.values[1]);
jQuery('.price-value .from').text(ui.values[0]);
jQuery('.price-value .from').currency({ region: 'EUR', thousands: ' ', decimal: ',', decimals: 0 });
jQuery('.price-value .to').text(ui.values[1]);
jQuery('.price-value .to').currency({ region: 'EUR', thousands: ' ', decimal: ',', decimals: 0 });
}
});
}
function InitEzmark() {
$('input[type="checkbox"]').ezMark();
$('input[type="radio"]').ezMark();
}
function InitChosen() {
$('select').chosen({
disable_search_threshold: 10
});
}
function InitOffCanvasNavigation() {
$('#btn-nav').on({
click: function() {
$('body').toggleClass('nav-open');
}
})
}
function InitCarousel() {
$('#main .carousel .content ul').carouFredSel({
scroll: {
items: 1
},
auto: false,
next: {
button: '#main .carousel-next',
key: 'right'
},
prev: {
button: '#main .carousel-prev',
key: 'left'
}
});
$('.carousel-wrapper .content ul').carouFredSel({
scroll: {
items: 1
},
auto: false,
next: {
button: '.carousel-wrapper .carousel-next',
key: 'right'
},
prev: {
button: '.carousel-wrapper .carousel-prev',
key: 'left'
}
});
}
function LoadMapProperty() {
var locations = new Array(
[38.127653,13.161312] );
var markers = new Array();
var mapOptions = {
center: new google.maps.LatLng(38.127653,13.161312),
zoom: 17,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
};
var map = new google.maps.Map(document.getElementById('property-map'), mapOptions);
$.each(locations, function(index, location) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(location[0], location[1]),
map: map,
icon: 'http://www.casarapido.it/personalizzazione/tpl/img/marker-transparent.png'
});
var myOptions = {
content: '',
disableAutoPan: false,
maxWidth: 0,
pixelOffset: new google.maps.Size(-146, -190),
zIndex: null,
closeBoxURL: "",
infoBoxClearance: new google.maps.Size(1, 1),
position: new google.maps.LatLng(location[0], location[1]),
isHidden: false,
pane: "floatPane",
enableEventPropagation: false
};
marker.infobox = new InfoBox(myOptions);
marker.infobox.isOpen = false;
var myOptions = {
draggable: true,
content: '
',
disableAutoPan: true,
pixelOffset: new google.maps.Size(-21, -58),
position: new google.maps.LatLng(location[0], location[1]),
closeBoxURL: "",
isHidden: false,
// pane: "mapPane",
enableEventPropagation: true
};
marker.marker = new InfoBox(myOptions);
marker.marker.open(map, marker);
markers.push(marker);
google.maps.event.addListener(marker, "click", function (e) {
var curMarker = this;
$.each(markers, function (index, marker) {
// if marker is not the clicked marker, close the marker
if (marker !== curMarker) {
marker.infobox.close();
marker.infobox.isOpen = false;
}
});
if(curMarker.infobox.isOpen === false) {
curMarker.infobox.open(map, this);
curMarker.infobox.isOpen = true;
map.panTo(curMarker.getPosition());
} else {
curMarker.infobox.close();
curMarker.infobox.isOpen = false;
}
});
});
}
function LoadMap() {
var locations = new Array(
[38.189063,13.300692, 'Superficie: 1502
Contratto: Vendita
Provincia: Palermo
Zona: Lanza di Scalea-Velodromo
Tipologia: Villa bifamiliare
€ 430000
'], [38.078968,13.538193, 'Superficie: 2302
Contratto: Affitto
Provincia: Palermo - Provincia
Zona: Santa Flavia (Pa)
Tipologia: Villa singola
€ 1000
'], [38.1730657,13.3349538, 'Superficie: 1252
Contratto: Affitto
Provincia: Palermo
Zona: Pallavicino-Villaggio Ruffini
Tipologia: Appartamento
€ 640
'], [38.1376316,13.3093451, 'Superficie: 1302
Contratto: Vendita
Provincia: Palermo
Zona: Michelangelo
Tipologia: Appartamento
€ 100000
'], [38.1369632,13.3399732, 'Superficie: 1352
Contratto: Vendita
Provincia: Palermo
Zona: Sciuti-Lazio-Restivo
Tipologia: Appartamento
€ 190000
'], [38.1076932,13.3352852, 'Superficie: 802
Contratto: Vendita
Provincia: Palermo
Zona: Calatafimi Bassa
Tipologia: Appartamento
€ 120000
'], [38.1013358,13.3735356, 'Superficie: 952
Contratto: Vendita
Provincia: Palermo
Zona: Oreto Nuova - Orsa Minore
Tipologia: Appartamento
€ 95000
'], [38.1137873,13.3282932, 'Superficie: 462
Contratto: Vendita
Provincia: Palermo
Zona: Pitrè alta - Altarello
Tipologia: Appartamento
€ 50000
'], [38.1723377,13.2371557, 'Superficie: 802
Contratto: Vendita
Provincia: Palermo - Provincia
Zona: Capaci (Pa)
Tipologia: Appartamento
€ 150000
'], [38.0814986,13.2889834, 'Superficie: 500002
Contratto: Vendita
Provincia: Palermo - Provincia
Zona: Monreale (Pa)
Tipologia: Terreno edificabile
€ 675000
'], [38.1307911,13.356542, 'Superficie: 4402
Contratto: Vendita
Provincia: Palermo
Zona: Libertà - Croci - Politeama
Tipologia: Box/Garage
€ 250000
'], [38.1394739,13.3100763, 'Superficie: 1102
Contratto: Vendita
Provincia: Palermo
Zona: Cruillas
Tipologia: Appartamento
€ 160000
'], [38.1734763,13.3323495, 'Superficie: 902
Contratto: Vendita
Provincia: Palermo
Zona: Pallavicino-Villaggio Ruffini
Tipologia: Appartamento
€ 130000
'], [38.083531,13.359791, 'Superficie: 1462
Contratto: Vendita
Provincia: Palermo
Zona: Bonagia-Borgo Ulivia-Falsomiele
Tipologia: Appartamento
€ 160000
'], [37.9952057,13.8849433, 'Superficie: 652
Contratto: Vendita
Provincia: Palermo
Zona: Campofelice di Roccella - Cefalù
Tipologia: Villa bifamiliare
€ 175000
'], [38.1399867,13.3451471, 'Superficie: 1302
Contratto: Vendita
Provincia: Palermo
Zona: Libertà - Croci - Politeama
Tipologia: Appartamento

2
€ 250000
'], [38.1681414,12.7362245, 'Superficie: 1102
Contratto: Vendita
Provincia: Trapani - Provincia
Zona: San Vito lo Capo
Tipologia: Villa singola
€ 290000
'], [38.0960089,13.3893806, 'Superficie: 122
Contratto: Vendita
Provincia: Palermo
Zona: Corso dei Mille - Giafar
Tipologia: Box/Garage
€ 11000
'], [38.0428331,13.4600973, 'Superficie: 7002
Contratto: Affitto
Provincia: Palermo - Provincia
Zona: Misilmeri (Pa)
Tipologia: Villa singola

7

11
€ 3000
'], [38.0677521,13.2766306, 'Superficie: 1802
Contratto: Vendita
Provincia: Palermo - Provincia
Zona: Monreale (Pa)
Tipologia: Villa singola

2

2
€ 250000
'], [38.1332348,13.3546333, 'Superficie: 1852
Contratto: Vendita
Provincia: Palermo
Zona: Libertà - Croci - Politeama
Tipologia: Appartamento
€ 400000
'], [38.0995947,13.3328409, 'Superficie: 1402
Contratto: Vendita
Provincia: Palermo
Zona: Calatafimi Bassa
Tipologia: Appartamento
€ 229000
'], [38.076363,13.2888027, 'Superficie: 142
Contratto: Vendita
Provincia: Palermo - Provincia
Zona: Monreale (Pa)
Tipologia: Appartamento
€ 10000
'], [38.1278662,13.298245, 'Superficie: 952
Contratto: Vendita
Provincia: Palermo
Zona: Borgo Nuovo - Castellana
Tipologia: Appartamento
€ 89000
'], [38.11916,13.3209647, 'Superficie: 1152
Contratto: Vendita
Provincia: Palermo
Zona: Perpignano Alta
Tipologia: Appartamento
€ 135000
'], [38.1047954,13.3534782, 'Superficie: 832
Contratto: Vendita
Provincia: Palermo
Zona: Università-Villaggio Santa Rosalia
Tipologia: Appartamento
€ 58000
'], [38.1264442,13.3424704, 'Superficie: 1232
Contratto: Vendita
Provincia: Palermo
Zona: Malaspina-Aurispa-Parlatore
Tipologia: Appartamento
€ 175000
'], [38.1400591,13.3325438, 'Superficie: 1252
Contratto: Affitto
Provincia: Palermo
Zona: Sciuti-Lazio-Restivo
Tipologia: Appartamento
€ 600
'], [38.1399867,13.3451471, 'Superficie: 1302
Contratto: Vendita
Provincia: Palermo
Zona: Libertà - Croci - Politeama
Tipologia: Ufficio

2
€ 250000
'] );
var markers = new Array();
var mapOptions = {
center: new google.maps.LatLng(38.125321, 13.355772,17),
zoom: 17,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
$.each(locations, function(index, location) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(location[0], location[1]),
map: map,
icon: 'http://www.casarapido.it/personalizzazione/tpl/assets/img/marker-transparent.png'
});
var myOptions = {
content: location[2],
disableAutoPan: false,
maxWidth: 0,
pixelOffset: new google.maps.Size(-146, -190),
zIndex: null,
closeBoxMargin: "0px -15px -15px 0px",
closeBoxURL: "http://www.casarapido.it/personalizzazione/tpl/assets/img/close-button.png",
infoBoxClearance: new google.maps.Size(1, 1),
position: new google.maps.LatLng(location[0], location[1]),
isHidden: false,
pane: "floatPane",
enableEventPropagation: false
};
marker.infobox = new InfoBox(myOptions);
marker.infobox.isOpen = false;
var myOptions = {
draggable: true,
content: '',
disableAutoPan: true,
pixelOffset: new google.maps.Size(-21, -58),
position: new google.maps.LatLng(location[0], location[1]),
closeBoxURL: "",
isHidden: false,
// pane: "mapPane",
enableEventPropagation: true
};
marker.marker = new InfoBox(myOptions);
marker.marker.open(map, marker);
markers.push(marker);
google.maps.event.addListener(marker, "click", function (e) {
var curMarker = this;
$.each(markers, function (index, marker) {
// if marker is not the clicked marker, close the marker
if (marker !== curMarker) {
marker.infobox.close();
marker.infobox.isOpen = false;
}
});
if(curMarker.infobox.isOpen === false) {
curMarker.infobox.open(map, this);
curMarker.infobox.isOpen = true;
map.panTo(curMarker.getPosition());
} else {
curMarker.infobox.close();
curMarker.infobox.isOpen = false;
}
});
});
}
function InitMap() {
google.maps.event.addDomListener(window, 'load', LoadMap);
google.maps.event.addDomListener(window, 'load', LoadMapProperty);
}