// Cufon Related code
Cufon.replace('h1, h2, h6, .product_top_strip a, #product_widgets a, .contentDetail h4, p.info, .information p, .itemHomeLeft p, .itemHome p, .continueShopping a, .res_code, .pagesLeft h1, .pagesLeft h2, .pagesLeft h3, .pagesLeft h4, .pagesLeft h5, .pagesLeft h6, .information h3, .textbox h5, .textboxDetail h5, .textboxDetail h4, #homeRow2 h3, #homeLeft h2, #homeRight h2');
Cufon.replace('#crumbs .linobg, #crumbs ul', { color: '#FFF' });
Cufon.replace('#crumbs a, .spy a, #category a, .item h4, .item p, .itemLast h4, .itemLast p, .itemHomeLeft p, itemHomeLeft h4, itemHome p, itemHome h4, .res_name a, .textbox h4, .textbox a, .textboxHome h4, .textboxHome a', { hover: true });


//navigation + menu fade
$(function () {
	if ($.browser.msie && $.browser.version < 7)
		return;

	$('#nav li')
		.removeClass('highlight')
		.find('a')
		.append('<span class="hover" />').each(function ()
		{
			var $span = $('> span.hover', this).css('opacity', 0);
			
			$(this).hover(function ()
			{
				// on hover
				$span.stop().fadeTo(400, 1);
			},
			function ()
			{
				// off hover
				$span.stop().fadeTo(1500, 0);
			});
		});
});



//category menu accordian
/*
function initMenu() {
  $('#category ul').hide();
  $('#category ul:first').hide();
  $('#category li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#category ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  };
*/ 		

$(document).ready(function(){

 //loads the under tabs changer on the homepage
if(jQuery("div.underTabs").size())
{
jQuery('div.underTabs').underTabs();
}

//cycle through images within the ID div
	        $('.picturebox').cycle({ 
			    fx:     'fade', 
    			speed:   800, 
    			timeout: 6000, 
    			next:   '.picturebox', 
    			pause:   1
			 }); 
			 
			 
	//initialise the category menu
	//initMenu();	
			

	// For the Image Galleries on Product Detail pages
	//$(".detail_image_description h2").append('<em></em>')

	$(".detail_thumbs a").hover(function(){
	
		var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("title");
		
		$("#largeImg").attr({ src: largePath, alt: largeAlt });
		
		//$("h2 em").html(" - " + largeAlt + " "); return false;
		
	});
	
	
	//Collapse Widgets on Product Detail
	$('#dimMaster').hide();
	$('#techMaster').hide();
	
	$('#dimTrigger').click(function () {
		$('#dimMaster').slideToggle(300);
    });
    
    $('#techTrigger').click(function () {
		$('#techMaster').slideToggle(300);
    });
        
    
    
	// The spy for related and accessories
	$(".spy img").hover( function() {
	        	$(this).removeClass("widePics");
				$(this).addClass("hoverPicsSmall");
			}, function(){
				$(this).removeClass("hoverPicsSmall");
				$(this).addClass("widePics");
			});
			
			//load Cufon whilst the scrip is running
			Cufon.replace('p.info');
			
	
	
	//Product List Page overlays
  	$('div.item').hover(function() {
    // on hovering over, find the element we want to fade *up*
    var fade = $('> div.itemOverlay', this);
    
    // if the element is currently being animated (to a fadeOut)...
    if (fade.is(':animated')) {
      // ...take it's current opacity back up to 1
      fade.stop().fadeTo(250, 1);
    } else {
      // fade in quickly
      fade.fadeIn(250);
    }
  }, function () {
    // on hovering out, fade the element out
    var fade = $('> div', this);
    if (fade.is(':animated')) {
      fade.stop().fadeTo(3000, 0);
    } else {
      // fade away slowly
      fade.fadeOut(3000);
    }
  });
  
  //Product List Page overlays
  	$('div.itemHomeLeft').hover(function() {
    // on hovering over, find the element we want to fade *up*
    var fade = $('> div.itemOverlay', this);
    
    // if the element is currently being animated (to a fadeOut)...
    if (fade.is(':animated')) {
      // ...take it's current opacity back up to 1
      fade.stop().fadeTo(250, 1);
    } else {
      // fade in quickly
      fade.fadeIn(250);
    }
  }, function () {
    // on hovering out, fade the element out
    var fade = $('> div', this);
    if (fade.is(':animated')) {
      fade.stop().fadeTo(3000, 0);
    } else {
      // fade away slowly
      fade.fadeOut(3000);
    }
  });
  
  //Product List Page overlays
  	$('div.itemHome').hover(function() {
    // on hovering over, find the element we want to fade *up*
    var fade = $('> div.itemOverlay', this);
    
    // if the element is currently being animated (to a fadeOut)...
    if (fade.is(':animated')) {
      // ...take it's current opacity back up to 1
      fade.stop().fadeTo(250, 1);
    } else {
      // fade in quickly
      fade.fadeIn(250);
    }
  }, function () {
    // on hovering out, fade the element out
    var fade = $('> div', this);
    if (fade.is(':animated')) {
      fade.stop().fadeTo(3000, 0);
    } else {
      // fade away slowly
      fade.fadeOut(3000);
    }
  });
  
  
  //Product List Page overlays
  	$('div.cartitem').hover(function() {
    // on hovering over, find the element we want to fade *up*
    var fade = $('> div.cartitemOverlay', this);
    
    // if the element is currently being animated (to a fadeOut)...
    if (fade.is(':animated')) {
      // ...take it's current opacity back up to 1
      fade.stop().fadeTo(250, 1);
    } else {
      // fade in quickly
      fade.fadeIn(250);
    }
  }, function () {
    // on hovering out, fade the element out
    var fade = $('> div', this);
    if (fade.is(':animated')) {
      fade.stop().fadeTo(3000, 0);
    } else {
      // fade away slowly
      fade.fadeOut(3000);
    }
  });
  
  
  
  // 
			// THE ACCOUNT DETAILS PAGE HAS SOME NICE SCRIPTS
			//
			
			//LOGIN VERSION
			// hide the div witht the form
			$('#accountlogin').hide();
			
			// click function that shows the form and hides the trigger button
			$(".editLoginDetails li").click( function() {
			$("#accountlogin").slideDown({ easing: 'easeOutBounce', duration: 1000 });
			$(".editLoginDetails li").animate({ opacity: 'hide' }, 1000);
			});
			
			// click function that reverses the click function above
			$("#accountlogin h3").click( function() {
			$("#accountlogin").slideUp({ easing: 'easeInExpo', duration: 1000 });
			$(".editLoginDetails li").animate({ opacity: 'show' }, 3000);
			}); 
			
			
			
			
			//SHIPPING VERSION
			// hide the div witht the form
			$('#accountshipping').hide();
			
			// click function that shows the form and hides the trigger button
			$(".editShipDetails li").click( function() {
			$("#accountshipping").slideDown({ easing: 'easeOutBounce', duration: 1000 });
			$(".editShipDetails li").animate({ opacity: 'hide' }, 1000);
			});
			
			// click function that reverses the click function above
			$("#accountshipping h3").click( function() {
			$("#accountshipping").slideUp({ easing: 'easeInExpo', duration: 1000 });
			$(".editShipDetails li").animate({ opacity: 'show' }, 3000);
			});


			//BILLING VERSION
			// hide the div witht the form
			$('#accountbilling').hide();
			
			// click function that shows the form and hides the trigger button
			$(".editBillDetails li").click( function() {
			$("#accountbilling").slideDown({ easing: 'easeOutBounce', duration: 1000 });
			$(".editBillDetails li").animate({ opacity: 'hide' }, 1000);
			});
			
			// click function that reverses the click function above
			$("#accountbilling h3").click( function() {
			$("#accountbilling").slideUp({ easing: 'easeInExpo', duration: 1000 });
			$(".editBillDetails li").animate({ opacity: 'show' }, 3000);
			});
			
			
			//PASSWORD VERSION
			// hide the div witht the form
			$('#accountpassword').hide();
			
			// click function that shows the form and hides the trigger button
			$(".editPassDetails li").click( function() {
			$("#accountpassword").slideDown({ easing: 'easeOutBounce', duration: 1000 });
			$(".editPassDetails li").animate({ opacity: 'hide' }, 1000);
			});
			
			// click function that reverses the click function above
			$("#accountpassword h3").click( function() {
			$("#accountpassword").slideUp({ easing: 'easeInExpo', duration: 1000 });
			$(".editPassDetails li").animate({ opacity: 'show' }, 3000);
			}); 
		
		
			// some search js styles
			$('.results').hover( function(){
     			$(this).css('background-color', '#FAFAFA');
			},
			function(){
     			$(this).css('background-color', '#F4F1E9');
			});


});
