$(document).ready(function() {
						   
/////////////////////////////////////////////////////////////////////	
//Drop Down Menus  		////////////////////////////////////////////
///////////////////////////////////////////////////////////////////						   

$(".clothing").hover(function() {
	$(".ClothingMenu").show();
	$(".clothing a").addClass("active");
},function(){
   $(".ClothingMenu").hide();
   $(".clothing a").removeClass("active");
});
$(".ClothingMenu").hover(function() {
	$(".ClothingMenu").show();
	$(".clothing a").addClass("active");
},function(){
   $(".ClothingMenu").hide();
   $(".clothing a").removeClass("active");
});

$(".brands").hover(function() {
	$(".BrandsMenu").show();
	$(".brands a").addClass("active");
},function(){
   $(".BrandsMenu").hide();
   $(".brands a").removeClass("active");
});
$(".BrandsMenu").hover(function() {
	$(".BrandsMenu").show();
	$(".brands a").addClass("active");
},function(){
   $(".BrandsMenu").hide();
   $(".brands a").removeClass("active");
});

/////////////////////////////////////////////////////////////////////	
//Twitter Feed 		////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
if($("#TwitterFeed").length) {	
getTwitters('TwitterFeed', {
	id: 'candyplum', 
	//prefix: '<img height="40" width="40" src="%profile_image_url%" />', 
	clearContents: false, // leave the original message in place
	count: 1, 
	withFriends: true,
	ignoreReplies: false,
	newwindow: true,
	template: '"%text%" <a href="https://twitter.com/%user_screen_name%/">%time%</a>'
	});
}

/////////////////////////////////////////////////////////////////////	
//Highlight Side Bar Category		////////////////////////////////
///////////////////////////////////////////////////////////////////

if($("#fgsdfgsd").length) {
var $path = location.pathname;
var $currentPage, $whichList;
var $breadcrumbLast = $(".Breadcrumb ul:first-child li:last").text();
var $breadcrumbPenultimate = $(".Breadcrumb ul:first-child li:nth-last-child(1)").text();

if ($path.match('/categories/')) {
	$currentPage = $breadcrumbPenultimate;
	$whichList = '.CategoryList';
}
else if($path.match('/brands/')) {
	$currentPage = $breadcrumbPenultimate;
	$whichList = '.BrandList';
}

$($whichList + ' ul li').each(function() {
	 text = $(this).text();
	if (text.match($currentPage)) {
		return $(this).addClass("ActiveSection");
		alert(text);
	}
});
//console.log("exists");
};
/////////////////////////////////////////////////////////////////////	
//Product Specific Page Tabs 		////////////////////////////////
///////////////////////////////////////////////////////////////////
if($("#ProductTabsWrap").length) {
$(".product-tabs").hide();
$("#ProductTabsWrap .product-tabs:first").show();
$(".ProductTabsNav li a").first().addClass("current");

$(".ProductTabsNav li a").click(function() {
	$(".product-tabs").hide();
	var href = $(this).attr("href");
	$(".product-tabs").filter(this.hash).show();
	$(".ProductTabsNav li a").removeClass("current");		
	$(this).addClass("current");
	return false;
});
	//console.log("tabs-present");
};
/////////////////////////////////////////////////////////////////////	
//Home Page Tabs 		////////////////////////////////////////////
///////////////////////////////////////////////////////////////////

$(".home-page-tabs li a:first").addClass("current");
var products = $(".home-tabs"), tabLink = $(".home-page-tabs li a");
$(products).hide();
$(products).first().show();

$(".home-page-tabs li a").click(function() {
	var clicked = $(this).attr("href");
	products.hide();
	tabLink.removeClass("current");
	products.filter(this.hash).show();
	$(this).addClass("current");

	return false;
});

$(".home-page-tabs li a:first").addClass("current");
var products = $(".home-tabs"), tabLink = $(".home-page-tabs li a");
$(products).hide();
$(products).first().show();

$(".home-page-tabs li a").click(function() {
	var clicked = $(this).attr("href");
	products.hide();
	tabLink.removeClass("current");
	products.filter(this.hash).show();
	$(this).addClass("current");

	return false;
});	


/////////////////////////////////////////////////////////////////////	
//Home Page Showreel		////////////////////////////////////////
///////////////////////////////////////////////////////////////////
	
$(".Showreel-nav li a:first").addClass("current-link");
var showreel = $(".showreel-tab"),
showreelATag = $(".Showreel-nav li a");
$(showreel).hide();
$(showreel).first().show();

var num = 1;
$(".Showreel-nav li a").click(function() {
	var clicked = $(this).attr("href");
	
	var totalNum = $(".Showreel-nav li").length;
	num++;
	
	showreel.fadeOut("fast");
	showreelATag.removeClass("current-link");
	showreel.filter(this.hash).fadeIn("slow");
	$(this).addClass("current-link");
	if(num === totalNum) {
		num=0;
	};
	return false;
});	


setInterval(function(){		 
	$(".Showreel-nav a").eq(num).trigger("click");		
}, 6000);

/////////////////////////////////////////////////////////////////////	
//footer carousel     //////////////////////////////////////////////
///////////////////////////////////////////////////////////////////


/*    $(".Brands .jCarouselLite").jCarouselLite({
        btnNext: ".Brands .next",
        btnPrev: ".Brands .prev",
        speed: 1000,
        easing: "easeinout",
		circular: false
    });       
	
	$(".Brands .next, .Brands .prev").click(function() {
		return false;
	});*/

/////////////////////////////////////////////////////////////////////	
//General		////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////

if ($(".FreeDelivery").is(":visible")) {
	$(".Breadcrumb").css({"background":"none","margin-top":"-10px"});
}	
	
if (/Find-Us/i.test(window.location)){
	$(".ViewMapLink").hide();
}

if (/subscribe.php/i.test(window.location)) {
	$(".NewsletterSignUp").hide();
}


$(".Textbox").focus(function() {
	$(this).val("");
});
/*$(":input").click(function() {
	$(this).val('');
});*/

$('a').filter(function(){
	return (!this.target && (this.href.indexOf(window.location.hostname) == -1 || this.href.match(/\.pdf$/i)));
}).attr('target', '_blank');
	
});
