$(document).ready(function()
{
	$('.wapshop_link_list li a')
		.bind('mousemove', function(){
				$('#clients_mouseover_preview')
				.hide();
		});
		
	$('.webshop_link_list li a, .NOTwapshop_link_list li a')
		.bind('mouseenter', function(e)
		{
			var handle_pieces = $(this).attr('href').toLowerCase().replace('http://', '').split('');
			var allowed_charachters = 'abcdefghijklmnopqrstuvwxyz0123456789';
			for(var char = 0; char < handle_pieces.length; char++)
			{
				if(allowed_charachters.indexOf(handle_pieces[char]) == -1)
				{
					handle_pieces[char] = '';
				}
			}
			handle = handle_pieces.join('');
				
			$('#clients_mouseover_preview')
				.hide()
				.html('<img src="client_screenshots/' + handle + '.png" alt="Preview area" />')
				.css({
					left: ((e.pageX || (e.clientX ? e.clientX + document.body.scrollLeft : 0)) + 50) + 'px',
					top: ((e.pageY || (e.clientY ? e.clientY + document.body.scrollTop : 0)) + 10) + 'px'
				})
				.show('fast').
				bind('mouseenter', function()
				{
					$(this).hide();
				});
		})
		.bind('mouseleave', function()
		{
			$('#clients_mouseover_preview')
				.hide();
		});
	
	$('#clients_wapdialog')
		.dialog({
			autoOpen: false,
			modal: true,
			overlay:
			{
				background: '#ffffff',
				opacity: 0.5
			},
			width: 244,
			height: 244,
			title: 'WAP-SHOP PREVIEW',
			resizable: false,
			dialogClass: 'clients_wapdialog_theme'
		});
	
	$('.wapshop_link_list li a').bind('click', function()
	{
		$('#clients_mouseover_preview')
			.hide();
		
		$('#clients_wapdialog')
			.attr('src', $(this).attr('href'))
			//.show()
			.dialog('open')
			.css({ // We have to do this again, since dialog() changes this...
				marginLeft: '1px',
				width: '242px',
				height: '200px'
			});
			
		return false;
	});
});