$(document).ready(function(){
//$(function(){

	
	// button rollover 
	//$('.imgBtn, input#searchSubmit, input#priceSliderUpdate, input#reviewSubmit').hover(function(){
	//		$(this).attr("src", $(this).attr("src").replace(/(.*)(\..*?)/,'$1-hover$2'));
	//	},
	//	function(){
	//			$(this).attr("src", $(this).attr("src").replace(/(.*)-hover(\..*?)/i, '$1$2'));
	//		});
	// ie6 hover functionality
	$('#calendar li').hover(function(){
			$(this).addClass('hover');
		},
		function(){
				$(this).removeClass('hover');
				if($(this).attr("class").length == 0)
					$(this).removeAttr("class");
			});
	
	
	
	// search field js
	$('#weatherInput').focus(function(){
			if($(this).val() == 'postcode/town')
				$(this).val('');
		}).blur(function(){
				if($(this).val() == '')
					$(this).val('postcode/town');
			}).val('postcode/town');


	//Events Customer Service People Open
	$('ul.people, ul.people2').hide();
	$('.openPeople').click(function(){
		$(this).parent().next('ul.people, ul.people2').slideToggle();
		if($(this).text() == 'Click to Open')
			$(this).text('Click to Close');
		else
			$(this).text('Click to Open');
		return false;
	});

	// preload image rollovers
	//$("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']").each(function(){
	//		$("<img>").attr("src", $(this).attr("src").replace(/(btn-.*)(\..*?)/i, '$1-hover$2'));
	//	});

	// progressive enhancement
	//$(".featured td:first-child").addClass("featuredLeft");
	//$(".featured td:last-child").addClass("featuredRight");
	//$(".quickpeekWrapper tr:first-child td").addClass("first");
	//$(".buyingGuide li:last-child").addClass("last");
	//$(".searchGrid").append("<li class='clearFloat'></li>");


	$('#monthSelect').change(function(){
		//alert($(this).val())
		window.location = window.location.pathname + '?dte=' + $(this).val();
	});
	
	var panelOpen = function(ele){
		ele.attr('src', '/images/icons/ico-arrow-up.gif');
		ele.next().children('.expanderText').html('Click to close');

	}
	var panelClose = function(ele){
		ele.attr('src', '/images/icons/ico-arrow-down.gif');
		ele.next().children('.expanderText').html('Click to open');
	}
	
	
	
		$('.expanderMenu').click(function(){
			var sib = $(this).next();
			if (sib.hasClass('hidden')){
				sib.slideDown().toggleClass('hidden');
			}else{
				sib.slideUp().addClass('hidden');
			}
			var sib = null;
			return false;
		});
		
		$(document).ready(function(){
			var menu = $('#menu2');
			if (menu.hasClass('corp-serv-it') || menu.hasClass('corp-serv-fac') || menu.hasClass('corp-serv-fin')){
				var sib = $('.expanderMenu').next();
				if (sib.hasClass('hidden')){
					sib.slideDown().toggleClass('hidden');
				}
				var sib = null;
			}
			var menu = null;
		 });
		
		
		$('.expander,.expanderText,').click(function(){
				var a = $(this).closest('.dlList').find('div');
				a.slideToggle().toggleClass('hidden');
				if(a.is('.hidden')){
					$(this).closest('.dlList').find('.expander').attr('src', '/images/icons/ico-arrow-down.gif').next().find('a').html('Click to open');
				}
				else{
					$(this).closest('.dlList').find('.expander').attr('src', '/images/icons/ico-arrow-up.gif').next().find('a').html('Click to close');
				}
				return false;
			}).each(function(){
					var a = $(this).closest('.dlList').find('div');
					if(a.is('.hidden')){
						$(this).closest('.dlList').find('.expander').attr('src', '/images/icons/ico-arrow-down.gif').next().find('a').html('Click to open');
					}
					else{
						$(this).closest('.dlList').find('.expander').attr('src', '/images/icons/ico-arrow-up.gif').next().find('a').html('Click to close');
					}
				});

	
	

	//alert($("a[name='"+window.location.hash.replace(/#/ig, '')+"'"));
	//alert($('a[name="' + window.location.hash.replace(/#/ig, '') + '"]').parent().next('ul.hidden').html());
//	if ($('a[name="' + window.location.hash.replace(/#/ig, '') + '"]').parent().next('ul.hidden')){
//		$('a[name="' + window.location.hash.replace(/#/ig, '') + '"]').parent().next('ul.hidden').slideDown().toggleClass('hidden');
//		panelOpen($('a[name="' + window.location.hash.replace(/#/ig, '') + '"]').parent().prev());
//	}
	
	/* WEATHER FEED */
	if ($('#weather form input[type="submit"]')){
		$('#weather form input[type="submit"]').replaceWith('<input type="image" src="images/v2/btn-go.gif" value="Go" />');
	}
});
	
	
	
