// page init
jQuery(function(){
initOpenClose();
initNav();
});
// initNav
function initNav(){
jQuery('#nav li').each(function(){
var hold = jQuery(this);
var drops = hold.find('ul');
var max = 0;
if(drops.length){
drops.each(function(){
var drop = jQuery(this);
var h = drop.outerHeight();
if(h > max) max = h;
});
drops.css({height:max});
};
});
};
// open-close init
function initOpenClose() {
if(jQuery('td.slide-block').length > 0){
jQuery('td.slide-block').OpenClose({
activeClass:'active',
opener:'a.open-close',
slider:'div.block',
effect:'slide',
animSpeed:500
});
}
}
// open-close plugin
jQuery.fn.OpenClose = function(_options){
// default options
var _options = jQuery.extend({
activeClass:'active',
opener:'.opener',
slider:'.slide',
animSpeed: 400,
animStart:false,
animEnd:false,
effect:'fade',
event:'click'
},_options);
return this.each(function(){
// options
var _holder = jQuery(this);
var _slideSpeed = _options.animSpeed;
var _activeClass = _options.activeClass;
var _opener = jQuery(_options.opener, _holder);
var _slider = jQuery(_options.slider, _holder);
var _animStart = _options.animStart;
var _animEnd = _options.animEnd;
var _effect = _options.effect;
var _event = _options.event;
if(_slider.length) {
_opener.bind(_event,function(){
if(!_slider.is(':animated')) {
if(typeof _animStart === 'function') _animStart();
if(_holder.hasClass(_activeClass)) {
_slider[_effect=='fade' ? 'fadeOut' : 'slideUp'](_slideSpeed,function(){
if(typeof _animEnd === 'function') _animEnd();
});
_holder.removeClass(_activeClass);
} else {
_holder.addClass(_activeClass);
_slider[_effect=='fade' ? 'fadeIn' : 'slideDown'](_slideSpeed,function(){
if(typeof _animEnd === 'function') _animEnd();
});
}
}
return false;
});
if(_holder.hasClass(_activeClass)) _slider.show();
else _slider.hide();
}
});
}
function initPage() {
initAutoScalingNav({
menuId: "nav",
liHovering: true,
equalLinks: false,
sideClasses: true,
spacing: 0,
minItem:30,
itemPaddings: 30
});
}
function initAutoScalingNav(o) {
if (!o.menuId) o.menuId = "nav";
if (!o.tag) o.tag = "a";
if (!o.minItem) o.minItem = 0;
if (!o.itemPaddings) o.itemPaddings = 0;
if (!o.spacing) o.spacing = 0;
if (!o.constant) o.constant = 0;
if (!o.minPaddings) o.minPaddings = 0;
if (!o.liHovering) o.liHovering = false;
if (!o.sideClasses) o.sideClasses = false;
if (!o.equalLinks) o.equalLinks = false;
if (!o.flexible) o.flexible = false;
var nav = document.getElementById(o.menuId);
if(nav) {
nav.className += " scaling-active";
var lis = nav.getElementsByTagName("li");
var asFl = [];
var lisFl = [];
var width = 0;
for (var i=0, j=0; i