$(document).ready(function(){
	
	$('.nyroModal').nyroModal({});
	
	/*$('div.phone span.number[title]').qtip({
		position: {my: 'top center', at: 'bottom center'},
		style: {classes: 'global-qtip'},
		hide: {fixed: true, delay: 100},
	});*/
	
	$('div.advantages a.[title]').qtip({
		position: {my: 'bottom center', at: 'top center'},
		style: {classes: 'global-qtip'},
		hide: {fixed: true, delay: 100}
	});
	/*$('div.advantages td').mouseenter(function(){
		$(this).find('dl').animate(
			{
				marginTop: '-33px'
			}, 
			100, 
			function(){
				$(this).css({'height': '66px'});
			}
		);
	});
	$('div.advantages td').mouseleave(function(){
		$(this).find('dl').css({'height': '33px'}).animate(
			{
				marginTop: '0'
			}, 
			100
		);
	});*/
	
	$('acronym.[title]').qtip({
		position: {my: 'bottom center', at: 'top center'},
		style: {classes: 'global-qtip'},
		hide: {fixed: true, delay: 100}
	});
	
	$('div.filter span').qtip({
		position: {my: 'top center', at: 'bottom center'},
		style: {classes: 'global-qtip'},
		hide: {fixed: true, delay: 100},
		content: {text: $('ul.filter-categories')}
	});
	
	$('div.additional table').hide();
	$('div.additional div.expand a').click(function(){
		$(this).parent().hide();
		$(this).parent().parent().find('table').fadeIn(400);
	});
	
	function showChild() {
		$('div.navigation div.child').hide();
		$('div.navigation div.parent a').removeClass('hover');
		var index = $('div.navigation td').index(this);
		var parent = $(this).find('div.parent a');
		var child = $(this).find('div.child');
		var position = parent.position();
		if (index > 3) {
			var padding = position.left - child.outerWidth() + parent.outerWidth();
			child.css({'left' : padding + 'px'});
		}
		else {
			var padding = position.left;
			child.css({'left' : padding + 'px'});
		}
		parent.addClass('hover');
		child.show(0);
	}
	function hideChild() {
		var parent = $(this).find('div.parent a');
		var child = $(this).find('div.child');
		parent.removeClass('hover');
		child.hide(0);
	}
	
	var config = {    
		over: showChild,
		timeout: 500,
		out: hideChild,
		interval: 100
	};
	
	$("div.navigation td").hoverIntent(config);
	
});

