$(function() {
	var td = $('div.main-icons table td[class!="devider"]');
	td.click(function() {
		location.href = $(this).find('a').attr('href');
	});
	td.mouseover(function() {
		$(this).addClass('active');
	});
	td.mouseout(function() {
		$(this).removeClass('active');
	});
	
	$('body').append('<div id="more-info" class="tip advantages-more-info"><div class="tcnt"><table><tr><td></td><td class="tl"><img src="' + tm.Config.imgsPath + 'b.gif" alt="" width="10" height="10" /></td><td class="tm"><img src="' + tm.Config.imgsPath + 'b.gif" width="1" height="1" alt="" /></td><td class="tr"><img src="' + tm.Config.imgsPath + 'b.gif" alt="" width="10" height="10" /></td></tr><tr><td class="tail"><div>&nbsp;</div></td><td class="ml"><img src="' + tm.Config.imgsPath + 'b.gif" width="1" height="1" alt="" /></td><td class="mm"><div class="out"></div></td><td class="mr"><img src="' + tm.Config.imgsPath + 'b.gif" width="1" height="1" alt="" /></td></tr><tr><td>&nbsp;</td><td class="bl"><img src="' + tm.Config.imgsPath + 'b.gif" alt="" width="10" height="10" /></td><td class="bm"><img src="' + tm.Config.imgsPath + 'b.gif" width="1" height="1" alt="" /></td><td class="br"><img src="' + tm.Config.imgsPath + 'b.gif" alt="" width="10" height="10" /></td></tr></table></div></div>');

	
	if ($('#advantages-seo').val()) {
		$('.advantages li').each(function() {
			if ($(this).find('p').length > 0 && $(this).find('p').html() != '') {
				setMoreInfo(this);
			}
		});
	}

	function setMoreInfo(elm) {
		$(elm).find('h3').bind('click', function(e) {
			var text = $(this).siblings('p').text();
			$('#more-info').find('div.out').html(text);
			var top = getMouseCoordinates(e)[1] + 15;
			var left = getMouseCoordinates(e)[0] + 20;
			
			$('#more-info').css({
				top: top + 'px',
				left: left + 'px'
			});
			$('#more-info').show();
		});
		
		$(elm).find('h3').bind('mouseover', function(e) {
			$(this).css({textDecoration: 'underline', cursor: 'pointer'});
		});
		
		$(elm).find('h3').bind('mouseout', function() {
			$('#more-info').hide();
			$(this).css({textDecoration: 'none', cursor: 'default'});
		});
	}

	function getMouseCoordinates(e) {
		var x = e.clientX + document.documentElement.scrollLeft;
		var y = e.clientY + document.documentElement.scrollTop;
		return [x,y];
	}

	
});