$(document).ready(function(){

	var isIE6 = ($.browser.msie && $.browser.version=="6.0");

	//NO IE6 BLOCK
	if(isIE6 == false){
		//TOP NAV HOVERS
		$("#header ul li a img").each( function(){
			//Bind each link that is NOT active
			if( $(this).attr('class') != $('body').attr('class')  ){

				$(this).bind("mouseover", function(e){
					var src = $(this).attr('src');
					var len = src.length;
					var newSrc = src.substring(0, len-4) + '_over.png';
					$(this).attr('src', newSrc);
				});

				$(this).bind("mouseout", function(e){
					var src = $(this).attr('src');
					var len = src.length;
					var newSrc = src.substring(0, len-9) + '.png';
					$(this).attr('src', newSrc);
				});

			}
			
		});

		//LEFT NAV HOVERS
		$("ul#side-nav li a img").each( function(){

			//Bind each link that is NOT active
			if( $(this).attr('class') != $('#side-nav').attr('class')  ){

				$(this).bind("mouseover", function(e){
					var src = $(this).attr('src');
					if( src.indexOf('_over') == -1 ){

						var len = src.length;
						var newSrc = src.substring(0, len-4) + '_over.gif';
						$(this).attr('src', newSrc);
					}
				});

				$(this).bind("mouseout", function(e){
					var src = $(this).attr('src');
					if( src.indexOf('_over') > 0 ){
						var len = src.length;
						var newSrc = src.substring(0, len-9) + '.gif';
						$(this).attr('src', newSrc);
					}
				});

			}
			
		});
		
	}

	//LOGIN BOX
	$('#login_box #username').bind("focus", function(e){
		if($(this).val() == 'email'){
			$(this).val('');
		}
	});

	$('#login_box #username').bind("blur", function(e){
		if($(this).val() == ''){
			$(this).val('email');
		}
	});

	$('#login_box #password').bind("focus", function(e){
		if($(this).val() == 'password'){
			$(this).val('');
		}
	});

	$('#login_box #password').bind("blur", function(e){
		if($(this).val() == ''){
			$(this).val('password');
		}
	});

	//Pass is left empty when an email is supplied
	//In that case put focus on pass field
	if( $('#login_box #password').val() == '' ){
		$('#login_box #password').focus();
	}

	//PRODUCT CAROUSEL
	//if( $('#mycarousel').length > 0){
		$('#productscontainer').attr("style", "");
		jQuery('#mycarousel').jcarousel();
	//}

	//DATE PICKERS
	var currentYear = (new Date).getFullYear();

	$(".datePicker_standard").datepicker({
			dateFormat: 'dd/mm/yy',
			yearRange:(currentYear-120)+':'+currentYear/*, minDate:'+1'*/,
			changeMonth: true,
			changeYear: true
	});

	//PRICE LIST POPUP
	$('a.lightbox').lightBox( {'fixedNavigation':'true'} );
	

	//GOOGLE MAP
	if( $('#map_canvas').length > 0){
		milliesMap.run.initMap();
	}
	
	
	
	
});