$(document).ready(function() {
	$('ul.sf-menu').supersubs({ 
			minWidth:    5, 
			maxWidth:    27, 
			extraWidth:  1
		}).superfish();
	$('#slider ul').cycle({ 
			fx:		'fade',
			timeout:9000,
                        speedIn:1000,         
                        speedOut:1000,
			pager:'#sliderNav'

	});
	
	$("a[rel='lightbox']").colorbox({iframe:true, innerWidth:600, innerHeight:400});
	
	$('#leftColumn .click').live('click', function() {
		if ($('#leftColumn .leftMenuSlide').css('display') == 'block') {
			$('#leftColumn .leftMenuSlide').slideToggle();
			$('#leftColumn .click img').attr('src', '/assets/images/plus.png');
		} else {
			$('#leftColumn .leftMenuSlide').slideToggle();
			$('#leftColumn .click img').attr('src', '/assets/images/minus.png');
		}
	});
	
	$('#lawyersHome').focus(function() {
		if ($(this).val() == 'Lawyers') {
			$(this).val('');
		}
	});
	$('#lawyersHome').blur(function() {
		if ($(this).val() == '') {
			$(this).val('Lawyers');
		}
	});
	/*
	$('#lawyersHome').keyup(function(e) {
		if(e.keyCode == 13) {
                          var pre = 'http://kingsleynapley.co.uk/profiles/';
                        var link = $(this).attr('rel');
			location.href = (pre + link); ;
		}
	});
*/
	$('#newsHome').change(function() {
		location.href = $(this).val();
	});

	// homepage autocomplete
	$("#lawyersHome").autocomplete(homeAutoComleteProfiles, {
		width: 230,
		max: 6,
		highlight: false,
		multiple: false,
		matchContains: true,
		minChars: 0,
		multipleSeparator: " ",
		scroll: true,
		scrollHeight: 400,
		formatItem: function(row, i, max) {
//			return i + "/" + max + ": \"" + row.name + "\" [" + row.to + "]";
			return i + "/" + max + ": \"" + row.name + "\" ";
		},
		formatMatch: function(row, i, max) {
//			return row.name + " " + row.to;
			return row.name;
		},
		formatResult: function(row) {
//			$('#lawyersHome').attr('rel', row.to);
			return row.name;
		}
	});
	$("#lawyersHome").result(function(event, data, formatted) {
//		console.debug(data);
		var pre = 'http://kingsleynapley.co.uk/profiles/';
		location.href = (pre + data.to); ;
	});
});

