var itemsInStore = [
	{'SKU':'INS67223','productName':'Want (Deluxe Edition)','category':'CD','unitPrice':'11.99'},
	{'SKU':'INS71636','productName':'Journal','category':'accessories','unitPrice':'10.00'},
	{'SKU':'INS71631','productName':'Reading Rainbow Tee (XS)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS71632','productName':'Reading Rainbow Tee (S)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS71633','productName':'Reading Rainbow Tee (M)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS71634','productName':'Reading Rainbow Tee (L)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS71635','productName':'Reading Rainbow Tee (XL)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS71626','productName':'General T-Shirt (XS)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS71627','productName':'General T-Shirt (S)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS71628','productName':'General T-Shirt (M)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS71629','productName':'General T-Shirt (L)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS71630','productName':'General T-Shirt (XL)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS67211','productName':'Checkers T-Shirt (S)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS67212','productName':'Checkers T-Shirt (M)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS67213','productName':'Checkers T-Shirt (L)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS67214','productName':'Checkers T-Shirt (XL)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS67215','productName':'Grandma T-Shirt (S)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS67216','productName':'Grandma T-Shirt (M)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS67217','productName':'Grandma T-Shirt (L)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS67218','productName':'Grandma T-Shirt (XL)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS67219','productName':'Splat Hands Womens T (S)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS67220','productName':'Splat Hands Womens T (M)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS67221','productName':'Splat Hands Womens T (L)','category':'t-shirts','unitPrice':'15.00'},
	{'SKU':'INS67222','productName':'Splat Hands Womens T (XL)','category':'t-shirts','unitPrice':'15.00'}
	];
function getStoreItem(skuID) {
	for (var i=0; i<itemsInStore.length; i++) {
		console.log('compare '+skuID+' against store item: '+itemsInStore[i].SKU);
		if (itemsInStore[i].SKU.indexOf(skuID)>=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(){
	$('#header .title').after("<div id='site_link'><!--a href='http://3oh3.hasawebstore.com'><img id='toplink_left' src='http://feature.atlrec.com/3oh3/store/blank.gif' alt='3oh!3 store' /></a--><a href='http://www.3oh3music.com' target='_blank'><img id='toplink_right' src='http://feature.atlrec.com/3oh3/store/blank.gif' alt='visitt 3oh!3music.com' /></a></div>");
	$('.staff_pick_small').parent().parent().addClass('home_middle');
	$('#col_260 #artist_profile .image').remove();
	$('#artist_profile').parent().addClass('sub_260');
	$("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();');

	//	$("#BillCountry").html("<option	value='US'>United States</option>");
	//	$("#ShipCountry").html("<option value='US'>United States</option>");
});
