function repositionBars() {
$(".header").css({"top":$(window).scrollTop()+"px"});
$("#enricoMattei").css({"top":$(window).scrollTop()+"px"});
$("#bgStoria span").css({"top":$(window).scrollTop()+"px"});
$(".bgWhite").css({"top":$(window).scrollTop()+"px"});
$(".wrapNav").css({"top":$(window).scrollTop()+$(window).height()-$(".wrapNav").height()+"px"});
$(".wrapTimeline").css({"top":$(window).scrollTop()+$(window).height()-$(".wrapNav").height()-$(".wrapTimeline").height()+"px"});
$(".wrapInternalNav").css({"top":$(window).scrollTop()+$(".header").height()-50+"px"});
$(".header").fadeIn(100);
$("#enricoMattei").fadeIn(100);
$(".wrapNav").fadeIn(100);
$(".wrapTimeline").fadeIn(100);
}
function setTimelineIOS(id) {
caneaseizampe_timeline_element = "#nav"+id;
$(".dates .selected").removeClass("selected");
$(caneaseizampe_timeline_element).addClass("selected");
if($("#"+id).length){
timelineWidth = $('.dates li').length * $('.dates li').width();
diff = $(window).width() - 130 - timelineWidth;
oh = $("#"+id).offset().top / $('#content').height();
if(diff>0){
$('.dates').stop().animate({left : 0}, {duration : 700,complete : function() {}});
}else{
if (oh > 0.85) {
$('.dates').stop().animate({left : diff}, {duration : 700,complete : function() {}});
} else if (oh > 0.27) {
$('.dates').stop().animate({left : 50*Math.round((diff*oh)/50)}, {duration : 700,complete : function() {}});
} else if (oh < 0.27) {
$('.dates').stop().animate({left : 0}, {duration : 700,complete : function() {}});
}
}
}
}
function moveBarsUp(id) {
$(".header").stop().animate({top : $("#" + id).offset().top}, {duration : 700});
$("#enricoMattei").stop().animate({top : $("#" + id).offset().top}, {duration : 700});
$(".wrapNav").stop().animate({top : $("#" + id).offset().top+$(window).height()-$(".wrapNav").height()+"px"});
$(".wrapTimeline").stop().animate({top : $("#" + id).offset().top+$(window).height()-$(".wrapNav").height()-$(".wrapTimeline").height()+"px"});
}
function moveBarsDown(id) {
$(".header").stop().animate({top : $("#" + id).offset().top}, {duration : 700});
$("#enricoMattei").stop().animate({top : $("#" + id).offset().top}, {duration : 700});
$(".wrapNav").stop().animate({top : $("#" + id).offset().top+$(window).height()-$(".wrapNav").height()+"px"});
$(".wrapTimeline").stop().animate({top : $("#" + id).offset().top+$(window).height()-$(".wrapNav").height()-$(".wrapTimeline").height()+"px"});
}
function getBgImage(text) {
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
var ret = text.match(exp);
return ret[0];
}
$(document).ready(function() {
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
if ($('.page-inizia-il-viaggio').length) {
for ( var int = 1953; int < 1986; int++) {
$("#"+int).append("
");
// $("#"+int).css({'background-image':$("#"+int).css('background-image').replace("default/files/","default/files/ipad/")});
}
} else if ($('.page-tempi-moderni').length) {
for ( var int = 1986; int < 2006; int++) {
$("#"+int).append("
");
// $("#"+int).css({'background-image':$("#"+int).css('background-image').replace("default/files/","default/files/ipad/")});
}
}
}
});
$(window).load(function() {
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
if (navigator.userAgent.match(/OS 4_[0-9_]* like Mac OS X/i)) {
$(".header").css({"position":"absolute"});
$("#enricoMattei").css({"position":"absolute"});
$(".bgStoria").css({"position":"absolute"});
$(".wrapNav").css({"position":"absolute"});
$(".wrapTimeline").css({"position":"absolute"});
$(".bgWhite").css({'position':'absolute', 'top':'0', 'left':'0', 'width':'100%'});
$(".wrapInternalNav").css({'position':'absolute', 'width':'100%' , 'top':'0'});
$(".post").css({'position':'relative'});
$(".header").css({"top":$(window).scrollTop()+"px"});
$("#enricoMattei").css({"top":$(window).scrollTop()+"px"});
$(".wrapNav").css({"top":$(window).scrollTop()+$(window).height()-$(".wrapNav").height()+"px"});
$(".wrapTimeline").css({"top":$(window).scrollTop()+$(window).height()-$(".wrapNav").height()-$(".wrapTimeline").height()+"px"});
$("#bgStoria span").css({"top":$(window).scrollTop()+"px"});
$(".bgWhite").css({"top":$(window).scrollTop()+"px"});
$(".wrapInternalNav").css({"top":$(window).scrollTop()+$(".header").height()-50+"px"});
};
if ($('.page-inizia-il-viaggio').length) {
$(window).touchwipe({
wipeLeft : function() {
},
wipeRight : function() {
},
wipeUp : function() {
// goToByScrollTimeline(caneaseizampe_element_id-1);
ajaxOneStepUpLoadElements(caneaseizampe_element_id-1);
// moveBarsUp(caneaseizampe_element_id);
// setTimelineIOS(caneaseizampe_element_id);
},
wipeDown : function() {
// goToByScrollTimeline(caneaseizampe_element_id+1);
ajaxOneStepDownLoadElements(caneaseizampe_element_id+1);
// moveBarsDown(caneaseizampe_element_id);
// setTimelineIOS(caneaseizampe_element_id);
},
min_move_x : 20,
min_move_y : 20,
preventDefaultEvents : true
});
// $(".arrowTimline").addClass("off");
for ( var int = 1953; int < 1986; int++) {
$("#"+int).append("
");
}
document.body.addEventListener('touchstart', function(e) {}, false);
document.body.addEventListener('touchend', function(e) {}, false);
$(window).scroll(function(){});
} else if ($('.page-tempi-moderni').length) {
$(window).touchwipe({
wipeLeft : function() {
},
wipeRight : function() {
},
wipeUp : function() {
// goToByScrollTimeline(caneaseizampe_element_id-1);
ajaxOneStepUpLoadElements(caneaseizampe_element_id-1);
if (navigator.userAgent.match(/OS 4_[0-9_]* like Mac OS X/i)) {
moveBarsUp(caneaseizampe_element_id);
setTimelineIOS(caneaseizampe_element_id);
};
},
wipeDown : function() {
// goToByScrollTimeline(caneaseizampe_element_id+1);
ajaxOneStepDownLoadElements(caneaseizampe_element_id+1);
if (navigator.userAgent.match(/OS 4_[0-9_]* like Mac OS X/i)) {
moveBarsDown(caneaseizampe_element_id);
setTimelineIOS(caneaseizampe_element_id);
};
},
min_move_x : 20,
min_move_y : 20,
preventDefaultEvents : true
});
// $(".arrowTimline").addClass("off");
for ( var int = 1986; int < 2006; int++) {
$("#"+int).append("
");
}
document.body.addEventListener('touchstart', function(e) {}, false);
document.body.addEventListener('touchend', function(e) {}, false);
$(window).scroll(function(){});
} else {
if (navigator.userAgent.match(/OS 4_[0-9_]* like Mac OS X/i)) {
document.body.addEventListener('touchstart', function(e) {
// $(".header").fadeOut(100);
// $("#enricoMattei").fadeOut(100);
// $(".wrapNav").fadeOut(100);
// $(".wrapTimeline").fadeOut(100);
}, false);
document.body.addEventListener('touchend', function(e) {
repositionBars();
}, false);
$(window).scroll(function(){
repositionBars();
});
};
};
};
});