function myLog(msg) {
	console.log(msg);
}

$(document).ready(function() {
	var filter = new filterProcess();
	$('a').each(function(){
		if ($(this).attr('rel') && document.getElementById($(this).attr('rel'))) {
			$(this).hover(
				function() {
					$('#'+$(this).attr('rel')).css('visibility', 'visible');						
				},
				function() {
					$('#'+$(this).attr('rel')).css('visibility', 'hidden');						
				}
			);
			$(this).mousemove(function(e) {
				if ($('#' + $(this).attr('rel')).css('visibility') == 'visible') {
					$('#' + $(this).attr('rel'))
						.css('top', e.pageY+16)
						.css('left', e.pageX+16);
					myLog($('#' + $(this).attr('rel')).css('top'));
				}
			});
		}
	});
});

function filterProcess() {
	if (document.getElementById('productFilter')) {
		$('.filter_content').hide();
		_self = this;
		$('#filterColors > .filter_content > input').each(function(){
			if (!$(this).attr('checked')) $('#filterColors > .filter_content').show();
		});
		$('#filterShapes > .filter_content > input').each(function(){
			if (!$(this).attr('checked')) $('#filterShapes > .filter_content').show();
		});
		if ($('#filterLength').val() != '') $('#filterDimensions > .filter_content').show();
		if ($('#filterWidth').val() != '') $('#filterDimensions > .filter_content').show();
		$('.filter_open').click(function(){ _self.toggleItem(this); });
	}	
}

filterProcess.prototype.toggleItem = function(item) {
	$('#'+$(item).parent().attr('id')+' > .filter_content').toggle('slow');
	if ($(item).text() == '+') {
		$(item).text('-');
	} else {
		$(item).text('+');
	}
}

