var itemsInStore = [
	{'SKU':'INS70772','productName':'Circle Totebag','category':'accessories','unitPrice':'15.00'},
	{'SKU':'INS70764','productName':'Outsider T-Shirt (S)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70765','productName':'Outsider T-Shirt (M)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70766','productName':'Outsider T-Shirt (L)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70767','productName':'Outsider T-Shirt (XL)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70768','productName':'Circle Hoodie (S)','category':'clothing','unitPrice':'45'},
	{'SKU':'INS70769','productName':'Circle Hoodie (M)','category':'clothing','unitPrice':'45'},
	{'SKU':'INS70770','productName':'Circle Hoodie (L)','category':'clothing','unitPrice':'45'},
	{'SKU':'INS70771','productName':'Circle Hoodie (XL)','category':'clothing','unitPrice':'45'},
	{'SKU':'INS70744','productName':'Prisoner T-Shirt (S)','category':'t-shirts','unitPrice':'20'},
	{'SKU':'INS70745','productName':'Prisoner T-Shirt (M)','category':'t-shirts','unitPrice':'20'},
	{'SKU':'INS70747','productName':'Prisoner T-Shirt (XL)','category':'t-shirts','unitPrice':'20'},
	{'SKU':'INS70778','productName':'Prisoner T-Shirt (XXL)','category':'t-shirts','unitPrice':'20'},
	{'SKU':'INS70754','productName':'Pipes T-Shirt (S)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70755','productName':'Pipes T-Shirt (M)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70756','productName':'Pipes T-Shirt (L)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70757','productName':'Pipes T-Shirt (XL)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70758','productName':'Pipes T-Shirt (XXL)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70749','productName':'Target T-Shirt (S)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70750','productName':'Target T-Shirt (M)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70751','productName':'Target T-Shirt (L)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70752','productName':'Target T-Shirt (XL)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70753','productName':'Target T-Shirt (XXL)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70759','productName':'Live Tour T-Shirt (S)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70760','productName':'Live Tour T-Shirt (M)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70761','productName':'Live Tour T-Shirt (L)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70762','productName':'Live Tour T-Shirt (XL)','category':'clothing','unitPrice':'20'},
	{'SKU':'INS70763','productName':'Live Tour T-Shirt (XXL)','category':'clothing','unitPrice':'20'}
];
function getStoreItem(sku) {
	for (var i=0; i<itemsInStore.length; i++) {
		console.log('compare '+sku+' against store item list: '+itemsInStore[i].SKU);
		if (itemsInStore[i].SKU.indexOf(sku)>=0) { console.log('found match, returning '+itemsInStore[i].productName); return itemsInStore[i]; }
	}
	return null;
}
function addItemCookie(value) {
	var date = new Date();
	date.setTime(date.getTime()+(1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	if (value.indexOf('add/')>=0) { value = value.substring(5); }
	var oldvalue = readCookie('CART-ITEMS');
	if (oldvalue!=null && oldvalue!='') {
		value = oldvalue+','+value;
	}
	document.cookie = "CART-ITEMS="+value+expires+"; path=/";
}
function updateCartCookies() {
	var skus = $('div.checkout_item .item_count input');
	var skuList = new Array();
	for (i=0; i<skus.length; i++) {
		for (j=0; j<$(skus[i]).attr('value'); j++) {
			skuList.push($(skus[i]).attr('id'));
		}
	}
	var date = new Date();
	date.setTime(date.getTime()+(1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "CART-ITEMS="+skuList.join(',')+expires+"; path=/";

}
function saveShippingDetails(shipping,tax,total,city,state,country) {
	var date = new Date();
	date.setTime(date.getTime()+(1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "CARTSHIPPING="+shipping+expires+"; path=/";
	document.cookie = "CARTTAX="+tax+expires+"; path=/";
	document.cookie = "CARTTOTAL="+total+expires+"; path=/";
	document.cookie = "CARTCITY="+city+expires+"; path=/";
	document.cookie = "CARTSTATE="+state+expires+"; path=/";
	document.cookie = "CARTCOUNTRY="+country+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function clearCart() {
	document.cookie='CART-ITEMS=;expires=-1';
	document.cookie='CARTSHIPPING=;expires=-1';
	document.cookie='CARTTAX=;expires=-1';
	document.cookie='CARTTOTAL=;expires=-1';
	document.cookie='CARTCITY=;expires=-1';
	document.cookie='CARTSTATE=;expires=-1';
	document.cookie='CARTCOUNTRY=;expires=-1';
}

$(document).ready(function(){
	$('#artist_profile').parent().addClass('sub_260');
	$('#artist_profile').parent().next().addClass('sub_498');
	//$('.page_title .artist_name').remove();
	//$('.page_title h3').remove();
	$('.menu_links li').eq(3).addClass('menu_last');
	
	//$('.new_release .info a.artist_name:contains("Death Cab for Cutie")').after('<span class="link_replace3">Death Cab for Cutie</span><br />');
	$('.new_release .info a.artist_name:contains("Death Cab for Cutie")').remove();
	$('.new_release .info a.artist_name:contains("Jay Farrar and Benjamin Gibbard")').remove();
	
	var artistName = $('.page_title .artist_name').text();
	$('.page_title .artist_name').after(artistName);
	$('.page_title .artist_name').remove();

	var priceSize = $('.page_title a span').text();
	$('.page_title a').after(priceSize);
	$('.page_title a').remove();
	
	$('.cart_total').attr("href", "/cart");
	$('.item_number').attr("href", "/cart");
	
	$('#mini_cart .options').replaceWith('<div class="options"><a href="/cart">View your cart</a> or <a href="https://store.deathcabforcutie.com/checkout">checkout</a></div>');
	
	$('#top_ad').html('<a href="http://deathcab.hasawebstore.com/artist/45087"><img id="blank_img" src="http://feature.atlrec.com/3oh3/store/blank.gif" alt="" border="0"></a>');
	

	
	//$('.staff_pick_big .info span.type').text('Available In');
	//$('.cart_info br').remove();
	$('.cart_info .artist_name').remove();
	
	// for google ecommerce tracking
	$("a[href^='add/']").each(function(i){ $(this).attr('onclick','addItemCookie("'+$(this).attr('href')+'")'); });
	$("a.product_name[href='/cart/clear']").click(clearCart);
	$("a:contains('Update Cart')").attr('href','javascript:updateCartCookies();document.ItemForm.submit();');
	//$("a[href*='/checkout']").each(function(i){ $(this).attr('onclick','updateCartCookies()') });

	$page_title = $('.page_title h3').text();
	/*
	if ($page_title=='Accessories') {
		$('.section_title h3:contains("Products")').text('Accessories');
	}
	else if ($page_title=='Apparel') {
		$('.section_title h3:contains("Products")').text('Apparel');
	//} else {
		//$('#col_498 a.product_name').each(function() {
		  //	$(this).after('<span class="product_name">' + $(this).text() + '</span>');
		  //  $(this).remove();
		//});	
	}
	$('.page_title').remove();
	*/



	    var pathname = window.location.pathname;
		if (pathname!='/') {
			//$('.html_include').hide();
		}
		if (pathname == '/music') {
			var typesArray = $('.type');
			for(var i = 0; i < typesArray.length; i++){
				
			}
		}
		
		$('.menu_links ul li:last').css('background','none');
	
		$('.fields td').css('width','100px');
	


});

