// CSS drop down menu


/*
----------------------------------------------------------------------------------*/

jQuery(document).ready(function () {
	
	// menu initialisation:
	
		jQuery("#menu ul").each(function(i){
			  jQuery(this).parent().find("a").slice(0,1).addClass("sub-menu");
			  jQuery(this).hover(function(){
				jQuery(this).parent().find("a").slice(0,1).addClass("active");
			  },function(){
				jQuery(this).parent().find("a").slice(0,1).removeClass("active");
			  });
			});
		
			// IE6 Fix: Drop-down fix due to lack of support for :hover on list elements
			if(jQuery.browser.msie && (jQuery.browser.version < 7)) {
			  jQuery("#menu").each(function(i){
				jQuery(this).find("li").hover(function(){
				  jQuery(this).addClass("sfhover");
				},function(){
				  jQuery(this).removeClass("sfhover");
				});
			  });
			}
	
	
	//fancybox
	if( jQuery( ".fancybox-iframe" ).length>0 ) {
		
		// get width and height from the rel property
		jQuerythis = jQuery( ".fancybox-iframe" );
		var width = jQuerythis.attr('rel').match(/^[0-9]+/);
		var height = jQuerythis.attr('rel').match(/[0-9]+$/);
		
		if( width == '' || isNaN( width ) ){
			alert('You must set Fancybox Iframe height and width as a rel attribute comma seperated pair');
		}
		
		jQuery( ".fancybox-iframe" ).fancybox({ 
									   
									   
										'width'				: parseInt( width ),
										'height'			: parseInt( height ),
										'autoScale'     	: true,
										'transitionIn'		: 'none',
										'transitionOut'		: 'none',
										'type'				: 'iframe',
										'titleShow'			: false
		});
	}
	if( jQuery( ".fancybox-page" ).length>0 ) {
		
		
				jQuery( ".fancybox-page" ).fancybox({ 
									   
									   
										'width'				: 1024,
										'height'			: 768,
										'autoScale'     	: true,
										'transitionIn'		: 'none',
										'transitionOut'		: 'none',
										'type'				: 'iframe',
										'titleShow'			: false
		});
	
	
	}
	
	
	
	//correct the breadcrumb problem in the cart:
	jQuery('#body .breadcrumb a:first-child').attr({'href' : '/parts-and-merchandise/'});


	if( jQuery("#current_country").length > 0){
		
		if ( jQuery("#current_country :selected").val() == 'AF' ) {
			
			jQuery("#current_country").val('NZ');
		
		}
	}


});
//end docready
