function pie(){
var _selectors =".content-box .visual";
if (window.PIE) {
$(_selectors).each(function() {
PIE.attach(this);
});
};
};
$(document).ready(function(){
LoadCurrencies();
pie();
initGalleryPhoto();
$(".tab-holer .tab-list a").live('click', function(){
var thisHold = $(this).parents(".tab-holer");
var tClass = $(this).attr("href").split('/');
tClass = tClass[tClass.length -1];
thisHold.find(".tab-content").hide();
thisHold.find("div."+tClass).show();
$(this).parents("ul").find("li").removeClass("active");
$(this).parent().addClass("active");
return false;
});
$('.present-gallery').galleryScroll();
$('.gallery-holder').galleryScroll();
$('.gallery-header').galleryScroll();
$('.gallery ul li a, .gallery-photo ul li a').lightBox();
$(window).load(function(){
$('.list-news li .visual img:not(".img-frame")').each(function(){
$(this).parents('.visual').width($(this).outerWidth()+5);
});
});
});
jQuery.fn.galleryScroll = function(_options){
// defaults options
var _options = jQuery.extend({
btPrev: 'a.prev',
btNext: 'a.next',
holderList: 'div.gallery',
scrollElParent: 'ul',
scrollEl: 'li',
slideNum: '.switcher',
duration : 500,
step: 1,
circleSlide: true,
disableClass: 'disable',
funcOnclick: null,
autoSlide:false,
innerMargin:0,
stepWidth:false
},_options);
return this.each(function(){
var _this = jQuery(this);
var _holderBlock = jQuery(_options.holderList,_this);
var _gWidth = _holderBlock.width();
var _animatedBlock = jQuery(_options.scrollElParent,_holderBlock);
var _liWidth = jQuery(_options.scrollEl,_animatedBlock).outerWidth(true);
var _liSum = jQuery(_options.scrollEl,_animatedBlock).length * _liWidth;
var _margin = -_options.innerMargin;
var f = 0;
var _step = 0;
var _autoSlide = _options.autoSlide;
var _timerSlide = null;
if (!_options.step) _step = _gWidth; else _step = _options.step*_liWidth;
if (_options.stepWidth) _step = _options.stepWidth;
if (!_options.circleSlide) {
if (_options.innerMargin == _margin)
jQuery(_options.btPrev,_this).addClass('prev-'+_options.disableClass);
}
if (_options.slideNum && !_options.step) {
var _lastSection = 0;
var _sectionWidth = 0;
while(_sectionWidth < _liSum)
{
_sectionWidth = _sectionWidth + _gWidth;
if(_sectionWidth > _liSum) {
_lastSection = _sectionWidth - _liSum;
}
}
}
if (_autoSlide) {
_timerSlide = setTimeout(function(){
autoSlide(_autoSlide);
}, _autoSlide);
_animatedBlock.hover(function(){
clearTimeout(_timerSlide);
}, function(){
_timerSlide = setTimeout(function(){
autoSlide(_autoSlide)
}, _autoSlide);
});
}
// click button 'Next'
jQuery(_options.btNext,_this).bind('click',function(){
jQuery(_options.btPrev,_this).removeClass('prev-'+_options.disableClass);
if (!_options.circleSlide) {
if (_margin + _step > _liSum - _gWidth - _options.innerMargin) {
if (_margin != _liSum - _gWidth - _options.innerMargin) {
_margin = _liSum - _gWidth + _options.innerMargin;
jQuery(_options.btNext,_this).addClass('next-'+_options.disableClass);
_f2 = 0;
}
} else {
_margin = _margin + _step;
if (_margin == _liSum - _gWidth - _options.innerMargin) {
jQuery(_options.btNext,_this).addClass('next-'+_options.disableClass);_f2 = 0;
}
}
} else {
if (_margin + _step > _liSum - _gWidth + _options.innerMargin) {
if (_margin != _liSum - _gWidth + _options.innerMargin) {
_margin = _liSum - _gWidth + _options.innerMargin;
} else {
_f2 = 1;
_margin = -_options.innerMargin;
}
} else {
_margin = _margin + _step;
_f2 = 0;
}
}
_animatedBlock.animate({marginLeft: -_margin+"px"}, {queue:false,duration: _options.duration });
if (_timerSlide) {
clearTimeout(_timerSlide);
_timerSlide = setTimeout(function(){
autoSlide(_options.autoSlide)
}, _options.autoSlide);
}
if (_options.slideNum && !_options.step) jQuery.fn.galleryScroll.numListActive(_margin,jQuery(_options.slideNum, _this),_gWidth,_lastSection);
if (jQuery.isFunction(_options.funcOnclick)) {
_options.funcOnclick.apply(_this);
}
return false;
});
// click button 'Prev'
var _f2 = 1;
jQuery(_options.btPrev, _this).bind('click',function(){
jQuery(_options.btNext,_this).removeClass('next-'+_options.disableClass);
if (_margin - _step >= -_step - _options.innerMargin && _margin - _step <= -_options.innerMargin) {
if (_f2 != 1) {
_margin = -_options.innerMargin;
_f2 = 1;
} else {
if (_options.circleSlide) {
_margin = _liSum - _gWidth + _options.innerMargin;
f=1;_f2=0;
} else {
_margin = -_options.innerMargin
}
}
} else if (_margin - _step < -_step + _options.innerMargin) {
_margin = _margin - _step;
f=0;
}
else {_margin = _margin - _step;f=0;};
if (!_options.circleSlide && _margin == _options.innerMargin) {
jQuery(this).addClass('prev-'+_options.disableClass);
_f2=0;
}
if (!_options.circleSlide && _margin == -_options.innerMargin) jQuery(this).addClass('prev-'+_options.disableClass);
_animatedBlock.animate({marginLeft: -_margin + "px"}, {queue:false, duration: _options.duration});
if (_options.slideNum && !_options.step) jQuery.fn.galleryScroll.numListActive(_margin,jQuery(_options.slideNum, _this),_gWidth,_lastSection);
if (_timerSlide) {
clearTimeout(_timerSlide);
_timerSlide = setTimeout(function(){
autoSlide(_options.autoSlide)
}, _options.autoSlide);
}
if (jQuery.isFunction(_options.funcOnclick)) {
_options.funcOnclick.apply(_this);
}
return false;
});
if (_liSum <= _gWidth) {
jQuery(_options.btPrev,_this).addClass('prev-'+_options.disableClass).unbind('click');
jQuery(_options.btNext,_this).addClass('next-'+_options.disableClass).unbind('click');
}
// auto slide
function autoSlide(autoSlideDuration){
//if (_options.circleSlide) {
jQuery(_options.btNext,_this).trigger('click');
//}
};
// Number list
jQuery.fn.galleryScroll.numListCreate = function(_elNumList, _liSumWidth, _width, _section){
var _numListElC = '';
var _num = 1;
var _difference = _liSumWidth + _section;
while(_difference > 0)
{
_numListElC += '
'+_num+'';
_num++;
_difference = _difference - _width;
}
jQuery(_elNumList).html('');
};
jQuery.fn.galleryScroll.numListActive = function(_marginEl, _slideNum, _width, _section){
if (_slideNum) {
jQuery('a',_slideNum).removeClass('active');
var _activeRange = _width - _section-1;
var _n = 0;
if (_marginEl != 0) {
while (_marginEl > _activeRange) {
_activeRange = (_n * _width) -_section-1 + _options.innerMargin;
_n++;
}
}
var _a = (_activeRange+_section+1 + _options.innerMargin)/_width - 1;
jQuery('a',_slideNum).eq(_a).addClass('active');
}
};
if (_options.slideNum && !_options.step) {
jQuery.fn.galleryScroll.numListCreate(jQuery(_options.slideNum, _this), _liSum, _gWidth,_lastSection);
jQuery.fn.galleryScroll.numListActive(_margin, jQuery(_options.slideNum, _this),_gWidth,_lastSection);
numClick();
};
function numClick() {
jQuery(_options.slideNum, _this).find('a').click(function(){
jQuery(_options.btPrev,_this).removeClass('prev-'+_options.disableClass);
jQuery(_options.btNext,_this).removeClass('next-'+_options.disableClass);
var _indexNum = jQuery(_options.slideNum, _this).find('a').index(jQuery(this));
_margin = (_step*_indexNum) - _options.innerMargin;
f=0; _f2=0;
if (_indexNum == 0) _f2=1;
if (_margin + _step > _liSum) {
_margin = _margin - (_margin - _liSum) - _step + _options.innerMargin;
if (!_options.circleSlide) jQuery(_options.btNext, _this).addClass('next-'+_options.disableClass);
}
_animatedBlock.animate({marginLeft: -_margin + "px"}, {queue:false, duration: _options.duration});
if (!_options.circleSlide && _margin==0) jQuery(_options.btPrev,_this).addClass('prev-'+_options.disableClass);
jQuery.fn.galleryScroll.numListActive(_margin, jQuery(_options.slideNum, _this),_gWidth,_lastSection);
if (_timerSlide) {
clearTimeout(_timerSlide);
_timerSlide = setTimeout(function(){
autoSlide(_options.autoSlide)
}, _options.autoSlide);
}
return false;
});
};
jQuery(window).resize(function(){
_gWidth = _holderBlock.width();
_liWidth = jQuery(_options.scrollEl,_animatedBlock).outerWidth(true);
_liSum = jQuery(_options.scrollEl,_animatedBlock).length * _liWidth;
if (!_options.step) _step = _gWidth; else _step = _options.step*_liWidth;
if (_options.slideNum && !_options.step) {
var _lastSection = 0;
var _sectionWidth = 0;
while(_sectionWidth < _liSum)
{
_sectionWidth = _sectionWidth + _gWidth;
if(_sectionWidth > _liSum) {
_lastSection = _sectionWidth - _liSum;
}
};
jQuery.fn.galleryScroll.numListCreate(jQuery(_options.slideNum, _this), _liSum, _gWidth,_lastSection);
jQuery.fn.galleryScroll.numListActive(_margin, jQuery(_options.slideNum, _this),_gWidth,_lastSection);
numClick();
};
//if (_margin == _options.innerMargin) jQuery(this).addClass(_options.disableClass);
if (_liSum - _gWidth < _margin - _options.innerMargin) {
if (!_options.circleSlide) jQuery(_options.btNext, _this).addClass('next-'+_options.disableClass);
_animatedBlock.animate({marginLeft: -(_liSum - _gWidth + _options.innerMargin)}, {queue:false, duration: _options.duration});
};
});
});
}
function initGalleryPhoto(){
$('.gallery-photo').each(function(){
var _this = $(this);
var _lis = _this.find('li');
var _next = _this.find('.next');
var _prev = _this.find('.prev');
if (_lis.length >= 5) {
_lis.eq(0).addClass('l02');
_lis.eq(1).addClass('l01');
_lis.eq(2).addClass('active');
_lis.eq(3).addClass('r01');
_lis.eq(4).addClass('r02');
} else if (_lis.length == 4){
_lis.eq(0).addClass('l01');
_lis.eq(1).addClass('active');
_lis.eq(2).addClass('r01');
_lis.eq(3).addClass('r02');
} else if (_lis.length == 3){
_lis.eq(0).addClass('l01');
_lis.eq(1).addClass('active');
_lis.eq(2).addClass('r01');
} else if (_lis.length == 2){
_lis.eq(0).addClass('active');
_lis.eq(1).addClass('r01');
}else if (_lis.length == 1){
_lis.eq(0).addClass('active');
}
_this.find('.number').text(_lis.filter('.active').index() + 1 + ' θη ' + _lis.length);
_next.click(function(){
if(_lis.is(':animated')){
return false;
}
if (_lis.filter('.active').is(':last-child')){
return false;
}
_lis.filter('.l02').css({'z-index':1}).animate({'left':-100, 'width':60, 'top':40, 'opacity':0.1}, 500, function(){
$(this).removeClass('l02');
});
_lis.filter('.l01').css({'z-index':2}).animate({'left':2, 'width':93, 'top':30, 'opacity':0.25}, 500, function(){
$(this).removeClass('l01').addClass('l02');
});
_lis.filter('.active').css({'z-index':3}).animate({'left':28, 'width':137, 'top':15, 'opacity':0.5}, 500, function(){
$(this).removeClass('active').addClass('l01');
});
_lis.filter('.r01').css({'z-index':4}).animate({'left':67, 'width':179, 'top':0, 'opacity':1}, 500, function(){
$(this).removeClass('r01').addClass('active');
_this.find('.number').text($(this).index() + 1 + ' θη ' + _lis.length);
});
_lis.filter('.r02').css({'z-index':3}).animate({'left':154, 'width':137, 'top':15, 'opacity':0.5}, 500, function(){
$(this).removeClass('r02').addClass('r01');
});
_lis.filter('.r02').next().css({'left':418, 'width':60, 'top':40, 'z-index':2, 'opacity':0.1}).show().animate({'left':225, 'width':93, 'top':30, 'opacity':0.25}, 500, function(){
$(this).addClass('r02');
//_this.find('.gallery ul').append(_this.find('.gallery ul').find('li:first-child'));
});
return false;
});
_prev.click(function(){
if(_lis.is(':animated')){
return false;
}
if (_lis.filter('.active').is(':first-child')){
return false;
}
_lis.filter('.l02').prev().css({'left':-100, 'width':60, 'top':40, 'z-index':2, 'opacity':0.1}).show().animate({'left':2, 'width':93, 'top':30, 'opacity':0.25}, 500, function(){
$(this).addClass('l02');
});
_lis.filter('.l02').css({'z-index':3}).animate({'left':28, 'width':137, 'top':15, 'opacity':0.5}, 500, function(){
$(this).removeClass('l02').addClass('l01');
});
_lis.filter('.l01').css({'z-index':4}).animate({'left':67, 'width':179, 'top':0, 'opacity':1}, 500, function(){
$(this).removeClass('l01').addClass('active');
_this.find('.number').text($(this).index() + 1 + ' θη ' + _lis.length);
});
_lis.filter('.active').css({'z-index':3}).animate({'left':154, 'width':137, 'top':15, 'opacity':0.5}, 500, function(){
$(this).removeClass('active').addClass('r01');
});
_lis.filter('.r01').css({'z-index':2}).animate({'left':225, 'width':93, 'top':30, 'opacity':0.25}, 500, function(){
$(this).removeClass('r01').addClass('r02');
});
_lis.filter('.r02').css({'z-index':1}).animate({'left':418, 'width':60, 'top':40, 'opacity':0.1}, 500, function(){
$(this).removeClass('r02');
//_this.find('.gallery ul').prepend(_this.find('.gallery ul').find('li:last-child'));
});
return false;
});
});
}