(function($, undefined)
{
    $(function()
	{
		
		//Cufon
		Cufon.replace('#search-form label, h1, h2, h4, .chat b');
		
		//Dropdowns
		//$.simpledropdown("#brand-select, #category-select, .page-numbers-dropdown, .order-by-dropdown");
		$('#brands').selectbox();
		$('#categories').selectbox();
		$('#top_orderby').selectbox();
		$('#top_selectpage').selectbox();
		$('#btm_orderby').selectbox();
		$('#btm_selectpage').selectbox();
		
		//Slideshow
		if ($('#slideshow').length)
        {
			$('#slideshow').cycle({
				fx: 'fade'				
			});
		}
        
		//More thumbs
        $('#vertscroll').cycle({
			fx:     'scrollVert',
			timeout: 0,
			next:   '.vert-next',
			prev:   '.vert-prev',
			cleartype: true				
		});
		
		//Center image on item page
		$('.item-large a').centerscreen({
			parent : 1,
			animate : 0,
			vertical_adjustment : -300,
			onresize : 1
		});
		
		//Item Tabs
		if ($('.tabs').length)
        {
			{
				var tabContainers = $('div.tabs > div');
				tabContainers.hide().filter(':first').show();
				
				$('div.tabs ul.description-nav a').click(function () {
						tabContainers.hide();
						tabContainers.filter(this.hash).show();
						$('div.tabs ul.description-nav a').removeClass('selected');
						$(this).addClass('selected');
						return false;
				}).filter(':first').click();
			}
		}
		
		//Lightbox
		$(".size-chart").fancybox();
		
		//Checkout Page
		
		//Hide Delivery address
		$("#ship-address").css("display","none");
		
		$("#shipping-address").click(function()
		{
			if ($("#shipping-address").is(":checked"))
			{
				$("#ship-address").hide("fast");	
				$("#payment").show("fast");
			}
			else
			{     
				$("#ship-address").show("fast");
				$("#payment").hide("fast");
			}       
		});
		
		//IE6 Hover
		$('#bag-items tr').hover(function() 
		{
			$(this).addClass('table-hover');
		}, 
		function() 
		{
			$(this).removeClass('table-hover');
		});
		
		//Google Map
		if ($('#map').length)
        {
			var myLatlng = new google.maps.LatLng(57.14397,-2.111381);
			var myOptions = 
			{
				zoom: 16,
				center: myLatlng,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			}
			
			var map = new google.maps.Map(document.getElementById("map"), myOptions);
			
			var marker = new google.maps.Marker(
			{
				position: myLatlng, 
				map: map,
				title:"Something For Me"
			});
		}
		
	});
	
})(jQuery);

$(document).ready(function(){
        //This function deals with shipping addresses in the basket
        $('#us_bill_states').hide();
        $('#us_ship_states').hide();
        
        if($('#country').val()=='US'){
            $('#us_bill_states').show();
        }
        
        if($('#ship-country').val()=='US'){
            $('#us_ship_states').show();
        }     
        
        $('#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();
            }
        });
});

