var _timer = null;
var _active = 0;
var _items = null;
$(document).ready(initPage);
function initPage(){
initGallery();
toTop();
initSlide();
footerToggle();
navModal();
}
//ロケーションバー消し------------------------------------------------------------------------------------------------------
addEventListener("load", function() {
setTimeout(hideURLbar, 0);
}, false);
function hideURLbar(){
if (!window.location.hash) window.scrollTo(0,1);
}
//スライド------------------------------------------------------------------------------------------------------
function loadGallery(url) {
if (url) {
$.ajax({
url: url,
success: function(data){
$('#image-gallery').append($('figure', data));
initProductGallery();
}}
);
}
}
function initGallery(c) {
var ctx = (typeof(c) == 'undefined') ? document : c;
$('.image-gallery', jQuery(ctx)).each(function(i, el){
var $this = $(this);
var counter = 'counter1'+i;
var tcontrol = 'tcontrol1'+i;
$this.touchSlider({
item: '.item',
holder: 'div.wrapp',
box: 'ul.frame',
mode: 'index',
center: true,
single: true,
prevLink: 'a.prev',
nextLink: 'a.next',
lockScroll: true,
onChange: function(prev, curr) {
$('#'+tcontrol+' a').removeClass('active');
$('#'+tcontrol+' a').filter(function(i){return i == curr}).addClass('active');
if( $this.hasClass('auto-slide')) {clearTimeout(_timer);_active = curr; initTimer();}
},
onStart: function() {
$('#'+tcontrol, $this).remove();
$('div.control', $this).append('
');
for (var i = 0; i < $this.get(0).getCount(); i++) {
var el = $(''+(i+1)+'');
el.attr('index', i);
$('#'+tcontrol).append(el);
el.bind('click', function(){
$this.get(0).moveTo($(this).attr('index'));
return false;
});
}
}
});
});
if ($('.auto-slide', jQuery(ctx)).length) {
clearTimeout(_timer);
initTimer();
_items = $('.auto-slide a.item');
}
}
function initTimer(){
_timer = setTimeout('changeGallery()', 4000);
}
function changeGallery() {
_active++;
if (_active >= _items.length) {
_active = 0;
$('.auto-slide').get(0).moveTo(0);
} else {
$('.auto-slide').get(0).moveNext();
}
}
function initSlide() {
var _parentSlide = '.slide-block';
var _linkSlide = 'a.open-close';
var _slideBlock = 'div.body';
var _openClassS = 'active';
var _durationSlide = 500;
$(_parentSlide).each(function(){
if (!$(this).is('.'+_openClassS)) {
$(this).find(_slideBlock).css('display','none');
}
});
$(_linkSlide,_parentSlide).click(function(){
if ($(this).parents(_parentSlide).is('.'+_openClassS)) {
$(this).parents(_parentSlide).removeClass(_openClassS);
$(this).parents(_parentSlide).find(_slideBlock).slideUp(_durationSlide);
} else {
$(this).parents(_parentSlide).addClass(_openClassS);
$(this).parents(_parentSlide).find(_slideBlock).slideDown(_durationSlide, function(){
$('.gallery').each(function(){
if (typeof(this.refresh) != 'undefined') {
this.refresh();
}
});
});
}
return false;
});
}
//footer toggle------------------------------------------------------------------------------------------------------
function footerToggle(){
$(".toggle_container").hide();
$(".trigger").toggle(function(){
$(this).addClass("active");
}, function () {
$(this).removeClass("active");
});
$(".trigger").eq(0).next(".toggle_container").slideToggle("slow,");
$(".trigger").eq(0).addClass("active");
$(".trigger").eq(0).click(function(){
$(this).toggleClass("active");
});
$(".trigger").click(function(){
$(this).next(".toggle_container").slideToggle("slow,");
});
};
//toTop------------------------------------------------------------------------------------------------------
function toTop(){
$("#toTop a").click(function(){
$('html,body').animate({ scrollTop: $($(this).attr("href")).offset().top }, 'slow','swing');
return false;
})
};
//nav modal------------------------------------------------------------------------------------------------------
var documentHeight = 0;
var $loadedContent = "";
function navModal () {
setTimeout(scrollTo, 100, 0, 1);
$('#nav_btn a').click(function () {
documentHeight = $(document).height();
var target = $(this).attr('href');
$(target).css({ height: documentHeight }).show().addClass('fadeIn');
return false;
});
$('#nav_btn .currentIcon').click(function () {
navAsideReset();
return false;
});
$('.navClickArea').click(function () {
navAsideReset();
return false;
});
};
function navAsideReset() {
$('#nav_wrap').hide();
}