$(document).ready(function(){
//this is jQuery 
//*****************************************************************

//  edit buttons when logged in as administrator
$(".reviewtext").append("<div class=reviewarrow></div>");

//  empty search field on focus

	$('#searchfield').focus(function() {
	if( this.value == this.defaultValue ) {
		this.value = ""; 
	}
}).blur(function() {
	if( !this.value.length ) {
		this.value = this.defaultValue;
	}
});

// FIX until the cms homepage module is complete
$('.col1').append($('#featurebanner').html());
//$('.module_smallbanner h3').append("<span style='font-size:45%;'><b>Released 4th October</b> </span>");

//$('.module_smallbanner').append("<a href='/Category/4/Store' style='display:block; font-size:84%; margin-left:28px; text-align:center;padding-top:5px;width:209px; height:18px; background:url(/myfiles/BADLYDRAWN/album_link_bg.gif) bottom right no-repeat;'>Pre order limited edition signed box set</a>");





	$('.mailinglistemailfield').focus(function() {
	if( this.value == this.defaultValue ) {
		this.value = ""; 
	}
}).blur(function() {
	if( !this.value.length ) {
		this.value = this.defaultValue;
	}
});

// facebook widget fix


//  show and hide side menu categories
	$('.menucategories').click(function(){
	$(' ul#menu li ul').slideUp();
		if ($(this).next('ul').css('display') == 'none') {
			$(this).next('ul').slideToggle();
	}
/*	return false;*/
    });
	
	
    // topics accordion
    $(".topics").hide();
    $(".topicheader").click(function() {

        var testa = $(this).next(".topics");
        // dont want it to animate if allready showing
        if ($(testa).css("display") == "none") {
            $(".topics").slideUp("slow");
            $(testa).slideToggle("slow");
        }

        else { return }

    });	
		
	
	
		
    // Forgot Password show/hide
    $(".forgotpassword").hide();
    $(".forgotpasswordlink").click(function() {
  $(".forgotpassword").slideToggle(); return false;
    });	
	
	
// zebrastipe them tables 
$("tr:nth-child(odd)").addClass("odd");


// Product slider
// THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
    var autoscroll = true;
    
   $(".automatedCarousel").automatedCarousel().mouseover(function () {
        autoscroll = false;
    }).mouseout(function () {
        autoscroll = true;
    });
     
    setInterval(function () {
        if (autoscroll) {
            $('.automatedCarousel').trigger('next');
        }
    }, 6000);


// subCategory  banners in category landing page (ProductListingWithThumbsWithSubCategories.ascx)
 $(".categorythumbfeature").hover(function () {
     $(this).find(".categorythumbdetails").animate({top: 190}, 300);	
     },  function () {
    			  $(this).find(".categorythumbdetails").animate({top: 275}, 300);	
     			 }); 	


// gallerysmall widget fade in/out banner using jquery.cycle
 $('.gallerysmallpics').cycle(6800);




// Navigation active styles //
$('#topnav ul li a.active').closest('div > ul > li').children('a').addClass('active');


	
// BASKET (+)/(-) on qty	
$('#basket input.quantity').after("<div class='plus'>+</div>");
$('#basket input.quantity').before("<div class='minus'>-</div>");




// twitter link
 $("a[href*='http://www.twitter.com/badly_drawn_boy']").text('FOLLOW ME ON TWITTER');

	
  var url = location.pathname;

  if (url.indexOf("http://badlydrawn.muronia.com/")) { } else {  $("#fb-root").remove(); }
	

 	$("#content h2:contains('Store')").html('Store: <a href="/Category/4/Store"><span style="color:#97b9c5;">Merchandise</span></a> / <a href="/Category/57/music">Music</a>');

	$("#content h2:contains('Music.')").html('Store:  <a href="/Category/4/Store">Merchandise</a> / <a href="/Category/57/music"><span style="color:#97b9c5;">Music</span></a>');
	
	
// ****************************************************************
}); // DO NOT DELETE THIS LINE



