(function($, undefined)
{
    $(function()
	{
		//Slideshow
		if ($('#slideshow').length)
        {
			$('#slideshow').nivoSlider({
				effect:'fade', 
				animSpeed:1500,
				pauseTime:5000,
				controlNav:true,
				directionNavHide:true,
				keyboardNav:true,
				controlNavThumbs:true
			});
		}
		
		//Datepicker
		if (!Modernizr.inputtypes.date) {
			// no native support for <input type="date"> :(
			// Insert JS Datepicker here
		  }
		
		//Shop Nav
		/*$('#sub-menu li ul').hide();
		$('#sub-menu a').click(function()
		{
			$('#sub-menu li ul').toggle('slow', function()
			{
				// Animation complete.
			});
		});*/

		if ($('#map').length)
        {
			//Google Map
			var center = new google.maps.LatLng(56.459007,-2.970799);
			var flagship = new google.maps.LatLng(56.458192,-2.975759);
			// var express = new google.maps.LatLng(56.459007,-2.970799);
			
			var myOptions = 
			{
				zoom: 15,
				center: center,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			}
			
			var map = new google.maps.Map(document.getElementById("map"), myOptions);
			
			var marker = new google.maps.Marker(
			{
				position: flagship, 
				map: map,
				title:"The Green Room Flagship Salon"
			});
			
			// var marker = new google.maps.Marker(
			// {
				// position: express, 
				// map: map,
				// title:"The Green Room Express"
			// });
			
		}
		
		//Hide Delivery address
		if ($("#shipping-address").is(":checked"))
		{
			$("#ship-address").css("display","none");
			$("#payment").show();
		}
		else
		{
			$("#ship-address").show();
			$("#payment").hide();
		}
    
		
		$("#shipping-address").click(function()
		{
			if ($("#shipping-address").is(":checked"))
			{
				$("#ship-address").slideUp("slow");
				$("#payment").slideDown("fast");
			}
			else
			{     
				$("#ship-address").slideDown('slow');
				$("#payment").slideUp("fast");
			}       
		});
		
		//IE6 Hover
		$('#bag-items tr').hover(function() 
		{
			$(this).addClass('table-hover');
		}, 
		function() 
		{
			$(this).removeClass('table-hover');
		});
		
		//US States
		$('#us_bill_states').hide();
		$('#us_ship_states').hide();
		
		if($('#country').val()=='US')
		{
			$('#us_bill_states').show("slow");
		}
		
		if($('#ship-country').val()=='US')
		{
			$('#us_ship_states').show("slow");
		}     
		
		$('#country').change(function()
		{
			if($('#country').val()=='US')
			{
				$('#us_bill_states').slideDown();
			}
			if(($('#country').val()!='US')&&($('#us_bill_states').is(':visible')))
			{
				$('#us_bill_states').slideUp();
			}
		});
		
		$('#ship-country').change(function()
		{
			if($('#ship-country').val()=='US')
			{
				$('#us_ship_states').slideDown();
			}
			
			if(($('#ship-country').val()!='US')&&($('#us_ship_states').is(':visible')))
			{
				$('#us_ship_states').slideUp();
			}
		});
		
		
	});
	
})(jQuery);
