/* merchtees.com client-side scripts      */
/* All original scripts (c) merchtees.com */
/* All others (c) original authors as  */
/* described below.                    */

Element.addMethods({
  wrap: function(element, tagName) {
    element = $(element);
    var wrapper = document.createElement('tagName');
    element.parentNode.replaceChild(wrapper, element);
    wrapper.appendChild(element);
    return Element.extend(wrapper);
  }
});

Event.observe( window, 'load', function(){
	var logoImage = $('classblogo');
	logoImage.src = logoImage.src.replace(/\.gif/, '.png');
	Event.observe( logoImage, 'mouseover', function(){
		logoImage.src = logoImage.src.replace(/logo-classb/, 'logo-classb-home');
	});
	Event.observe( logoImage, 'mouseout', function(){
		logoImage.src = logoImage.src.replace(/logo-classb-home/, 'logo-classb');
	});
	if($('cart_count')){
		var cartCount = $('cart_count').down('span');
		var cartCountValue = cartCount.innerHTML;
		if( cartCountValue >= 1000){
			cartCount.setStyle({
				fontSize : '8px',
				paddingTop : '7px'
			});
		} else if( cartCountValue >= 100){
			cartCount.setStyle({
				fontSize : '10px',
				paddingTop : '5px'
			});
		} else if (cartCountValue >= 10){
			cartCount.setStyle({
				fontSize : '12px',
				paddingTop : '4px'
			});
		} else {
			cartCount.setStyle({
				fontSize : '13px',
				paddingTop : '3px'
			});
		}
	}
	if(false){
		var testimonialDiv = $('testimonial');
		if(testimonialDiv && Prototype.Browser.IE == true){
			var testimonialWrapper = testimonialDiv.wrap('div');
			testimonialWrapper.setStyle({ display : 'block', height: '100px' });
			testimonialDiv.setStyle({ position: 'absolute' });
		}
	}
});

//var shirtBackgrounds = {"18":{"color_key":"18","name":"Ash (Birch)","shirt_bg_name":"s100-birch","shirt_bg_width":"115","hex_primary":"D7D7D7","brand_key_F":"1"},"1":{"color_key":"1","name":"Black","shirt_bg_name":"s100-black","shirt_bg_width":"115","hex_primary":"090909","brand_key_F":"1"},"2":{"color_key":"2","name":"California Blue","shirt_bg_name":"s100-california_blue","shirt_bg_width":"115","hex_primary":"2982AB","brand_key_F":"1"},"12":{"color_key":"12","name":"Forest Green","shirt_bg_name":"s100-forest_green","shirt_bg_width":"115","hex_primary":"023105","brand_key_F":"1"},"13":{"color_key":"13","name":"Gold","shirt_bg_name":"s100-gold","shirt_bg_width":"115","hex_primary":"FDBB07","brand_key_F":"1"},"22":{"color_key":"22","name":"Green Mist","shirt_bg_name":"s100-green_mist","shirt_bg_width":"115","hex_primary":"96B189","brand_key_F":"1"},"20":{"color_key":"20","name":"Island Yellow","shirt_bg_name":"s100-island_yellow","shirt_bg_width":"115","hex_primary":"F6E200","brand_key_F":"1"},"7":{"color_key":"7","name":"Jade","shirt_bg_name":"s100-jade","shirt_bg_width":"115","hex_primary":"278C67","brand_key_F":"1"},"10":{"color_key":"10","name":"Kelly Green","shirt_bg_name":"s100-kelly_green","shirt_bg_width":"115","hex_primary":"289032","brand_key_F":"1"},"5":{"color_key":"5","name":"Khaki","shirt_bg_name":"s100-khaki","shirt_bg_width":"115","hex_primary":"9F9E84","brand_key_F":"1"},"16":{"color_key":"16","name":"Light Blue","shirt_bg_name":"s100-light_blue","shirt_bg_width":"115","hex_primary":"92C0D8","brand_key_F":"1"},"3":{"color_key":"3","name":"Maroon","shirt_bg_name":"s100-maroon","shirt_bg_width":"115","hex_primary":"561E1E","brand_key_F":"1"},"4":{"color_key":"4","name":"Natural","shirt_bg_name":"s100-natural","shirt_bg_width":"115","hex_primary":"ECEBD7","brand_key_F":"1"},"6":{"color_key":"6","name":"Navy Blue","shirt_bg_name":"s100-navy_blue","shirt_bg_width":"115","hex_primary":"1C1A46","brand_key_F":"1"},"17":{"color_key":"17","name":"Orange","shirt_bg_name":"s100-orange","shirt_bg_width":"115","hex_primary":"C2500A","brand_key_F":"1"},"8":{"color_key":"8","name":"Periblue","shirt_bg_name":"s100-periblue","shirt_bg_width":"115","hex_primary":"787FBA","brand_key_F":"1"},"9":{"color_key":"9","name":"Purple","shirt_bg_name":"s100-purple","shirt_bg_width":"115","hex_primary":"370159","brand_key_F":"1"},"14":{"color_key":"14","name":"Red","shirt_bg_name":"s100-red","shirt_bg_width":"115","hex_primary":"A20005","brand_key_F":"1"},"21":{"color_key":"21","name":"Royal Blue","shirt_bg_name":"s100-royal_blue","shirt_bg_width":"115","hex_primary":"2D27A2","brand_key_F":"1"},"11":{"color_key":"11","name":"Sport Grey (Oxford)","shirt_bg_name":"s100-oxford","shirt_bg_width":"115","hex_primary":"838383","brand_key_F":"1"},"19":{"color_key":"19","name":"White","shirt_bg_name":"s100-white","shirt_bg_width":"115","hex_primary":"F4F4F4","brand_key_F":"1"},"23":{"color_key":"23","name":"Yellow Haze","shirt_bg_name":"s100-yellow_haze","shirt_bg_width":"115","hex_primary":"FCE08B","brand_key_F":"1"},"26":{"color_key":"26","name":"Ash","shirt_bg_name":"ash","shirt_bg_width":null,"hex_primary":"AFB2BB","brand_key_F":"2"},"29":{"color_key":"29","name":"Black","shirt_bg_name":"black","shirt_bg_width":null,"hex_primary":"1B2225","brand_key_F":"2"},"56":{"color_key":"56","name":"Forest","shirt_bg_name":"forest","shirt_bg_width":null,"hex_primary":"0F2115","brand_key_F":"2"},"32":{"color_key":"32","name":"Gold","shirt_bg_name":"gold","shirt_bg_width":null,"hex_primary":"F9960B","brand_key_F":"2"},"39":{"color_key":"39","name":"Heliconia","shirt_bg_name":"s110-heliconia","shirt_bg_width":"115","hex_primary":"BF057B","brand_key_F":"2"},"369":{"color_key":"369","name":"Irish Green","shirt_bg_name":"irish-green","shirt_bg_width":null,"hex_primary":"017030","brand_key_F":"2"},"40":{"color_key":"40","name":"Light Blue","shirt_bg_name":"light-blue","shirt_bg_width":null,"hex_primary":"89B2D8","brand_key_F":"2"},"37":{"color_key":"37","name":"Maroon","shirt_bg_name":"maroon","shirt_bg_width":null,"hex_primary":"420419","brand_key_F":"2"},"46":{"color_key":"46","name":"Navy","shirt_bg_name":"navy","shirt_bg_width":null,"hex_primary":"101D36","brand_key_F":"2"},"33":{"color_key":"33","name":"Orange","shirt_bg_name":"orange","shirt_bg_width":null,"hex_primary":"C92F0C","brand_key_F":"2"},"49":{"color_key":"49","name":"Purple","shirt_bg_name":"purple","shirt_bg_width":null,"hex_primary":"2E1A50","brand_key_F":"2"},"34":{"color_key":"34","name":"Red","shirt_bg_name":"red","shirt_bg_width":null,"hex_primary":"A30E23","brand_key_F":"2"},"45":{"color_key":"45","name":"Royal","shirt_bg_name":"royal","shirt_bg_width":null,"hex_primary":"01277B","brand_key_F":"2"},"27":{"color_key":"27","name":"Sports Grey","shirt_bg_name":"sport-grey","shirt_bg_width":null,"hex_primary":"7D7E85","brand_key_F":"2"},"24":{"color_key":"24","name":"White","shirt_bg_name":"white","shirt_bg_width":null,"hex_primary":"E3E4E9","brand_key_F":"2"},"26":{"color_key":"26","name":"Ash","shirt_bg_name":"s110-ash","shirt_bg_width":null,"hex_primary":"DAD9DE","brand_key_F":"2"},"38":{"color_key":"38","name":"Azalea","shirt_bg_name":"s110-azalea","shirt_bg_width":null,"hex_primary":"EA65A5","brand_key_F":"2"},"29":{"color_key":"29","name":"Black","shirt_bg_name":"s110-black","shirt_bg_width":null,"hex_primary":"0F0D10","brand_key_F":"2"},"365":{"color_key":"365","name":"Blue Dusk","shirt_bg_name":"s110-blue-dusk","shirt_bg_width":null,"hex_primary":"212437","brand_key_F":"2"},"36":{"color_key":"36","name":"Cardinal Red","shirt_bg_name":"s110-cardinal-red","shirt_bg_width":null,"hex_primary":"6A080F","brand_key_F":"2"},"366":{"color_key":"366","name":"Carolina Blue","shirt_bg_name":"s110-carolina-blue","shirt_bg_width":null,"hex_primary":"647FD6","brand_key_F":"2"},"35":{"color_key":"35","name":"Cedar","shirt_bg_name":"s110-cedar","shirt_bg_width":null,"hex_primary":"7A212C","brand_key_F":"2"},"28":{"color_key":"28","name":"Charcoal","shirt_bg_name":"s110-charcoal","shirt_bg_width":null,"hex_primary":"433D3F","brand_key_F":"2"},"58":{"color_key":"58","name":"Chestnut","shirt_bg_name":"s110-chestnut","shirt_bg_width":null,"hex_primary":"523B2D","brand_key_F":"2"},"31":{"color_key":"31","name":"Daisy","shirt_bg_name":"s110-daisy","shirt_bg_width":null,"hex_primary":"F6C930","brand_key_F":"2"},"218":{"color_key":"218","name":"Dark Chocolate","shirt_bg_name":"s110-dark-chocolate","shirt_bg_width":null,"hex_primary":"1D120F","brand_key_F":"2"},"367":{"color_key":"367","name":"Dark Heather","shirt_bg_name":"s110-dark-heather","shirt_bg_width":null,"hex_primary":"2D3034","brand_key_F":"2"},"48":{"color_key":"48","name":"Eggplant","shirt_bg_name":"s110-eggplant","shirt_bg_width":null,"hex_primary":"341C2C","brand_key_F":"2"},"56":{"color_key":"56","name":"Forest","shirt_bg_name":"s110-forest","shirt_bg_width":null,"hex_primary":"181913","brand_key_F":"2"},"32":{"color_key":"32","name":"Gold","shirt_bg_name":"s110-gold","shirt_bg_width":null,"hex_primary":"F39C1A","brand_key_F":"2"},"39":{"color_key":"39","name":"Heliconia","shirt_bg_name":"s110-heliconia","shirt_bg_width":"115","hex_primary":"CA2563","brand_key_F":"2"},"368":{"color_key":"368","name":"Ice Grey","shirt_bg_name":"s110-ice-grey","shirt_bg_width":null,"hex_primary":"BAB8BD","brand_key_F":"2"},"44":{"color_key":"44","name":"Indigo Blue","shirt_bg_name":"s110-indigo-blue","shirt_bg_width":null,"hex_primary":"31405F","brand_key_F":"2"},"42":{"color_key":"42","name":"Iris","shirt_bg_name":"s110-iris","shirt_bg_width":null,"hex_primary":"3D5BBB","brand_key_F":"2"},"369":{"color_key":"369","name":"Irish Green","shirt_bg_name":"s110-irish-green","shirt_bg_width":null,"hex_primary":"24773A","brand_key_F":"2"},"60":{"color_key":"60","name":"Jade","shirt_bg_name":"s110-jade","shirt_bg_width":null,"hex_primary":"1A6572","brand_key_F":"2"},"54":{"color_key":"54","name":"Kelly Green","shirt_bg_name":"s110-kelly-green","shirt_bg_width":null,"hex_primary":"136145","brand_key_F":"2"},"59":{"color_key":"59","name":"Leaf","shirt_bg_name":"s110-leaf","shirt_bg_width":null,"hex_primary":"39484B","brand_key_F":"2"},"40":{"color_key":"40","name":"Light Blue","shirt_bg_name":"s110-light-blue","shirt_bg_width":null,"hex_primary":"8FABDB","brand_key_F":"2"},"216":{"color_key":"216","name":"Light Pink","shirt_bg_name":"s110-light-pink","shirt_bg_width":null,"hex_primary":"F7C0E4","brand_key_F":"2"},"61":{"color_key":"61","name":"Lime","shirt_bg_name":"s110-lime","shirt_bg_width":null,"hex_primary":"7DC64B","brand_key_F":"2"},"37":{"color_key":"37","name":"Maroon","shirt_bg_name":"s110-maroon","shirt_bg_width":null,"hex_primary":"3F0F1A","brand_key_F":"2"},"370":{"color_key":"370","name":"Metro Blue","shirt_bg_name":"s110-metro-blue","shirt_bg_width":null,"hex_primary":"22285A","brand_key_F":"2"},"371":{"color_key":"371","name":"Military Green","shirt_bg_name":"s110-military-green","shirt_bg_width":null,"hex_primary":"454732","brand_key_F":"2"},"25":{"color_key":"25","name":"Natural","shirt_bg_name":"s110-natural","shirt_bg_width":null,"hex_primary":"F2E7D0","brand_key_F":"2"},"46":{"color_key":"46","name":"Navy","shirt_bg_name":"s110-navy","shirt_bg_width":null,"hex_primary":"0E0D1B","brand_key_F":"2"},"41":{"color_key":"41","name":"Oceana","shirt_bg_name":"s110-oceana","shirt_bg_width":null,"hex_primary":"496377","brand_key_F":"2"},"57":{"color_key":"57","name":"Olive","shirt_bg_name":"s110-olive","shirt_bg_width":null,"hex_primary":"393124","brand_key_F":"2"},"33":{"color_key":"33","name":"Orange","shirt_bg_name":"s110-orange","shirt_bg_width":null,"hex_primary":"E92C12","brand_key_F":"2"},"55":{"color_key":"55","name":"Pine","shirt_bg_name":"s110-pine","shirt_bg_width":null,"hex_primary":"4B553C","brand_key_F":"2"},"372":{"color_key":"372","name":"Pistachio","shirt_bg_name":"s110-pistachio","shirt_bg_width":null,"hex_primary":"A1AC74","brand_key_F":"2"},"52":{"color_key":"52","name":"Prairie Dust","shirt_bg_name":"s110-prairie-dust","shirt_bg_width":null,"hex_primary":"5D593C","brand_key_F":"2"},"49":{"color_key":"49","name":"Purple","shirt_bg_name":"s110-purple","shirt_bg_width":null,"hex_primary":"1C0F46","brand_key_F":"2"},"34":{"color_key":"34","name":"Red","shirt_bg_name":"s110-red","shirt_bg_width":null,"hex_primary":"B11617","brand_key_F":"2"},"45":{"color_key":"45","name":"Royal","shirt_bg_name":"s110-royal","shirt_bg_width":null,"hex_primary":"182E8C","brand_key_F":"2"},"217":{"color_key":"217","name":"Safety Green","shirt_bg_name":"s110-safety-green","shirt_bg_width":null,"hex_primary":"FBFF9C","brand_key_F":"2"},"50":{"color_key":"50","name":"Sand","shirt_bg_name":"s110-sand","shirt_bg_width":null,"hex_primary":"C2BCA0","brand_key_F":"2"},"43":{"color_key":"43","name":"Sapphire","shirt_bg_name":"s110-sapphire","shirt_bg_width":null,"hex_primary":"155DAF","brand_key_F":"2"},"53":{"color_key":"53","name":"Serene Green","shirt_bg_name":"s110-serene-green","shirt_bg_width":null,"hex_primary":"9DAB88","brand_key_F":"2"},"27":{"color_key":"27","name":"Sport Grey","shirt_bg_name":"s110-sport-grey","shirt_bg_width":null,"hex_primary":"8C8D8F","brand_key_F":"2"},"373":{"color_key":"373","name":"Steel Green","shirt_bg_name":"s110-steel-green","shirt_bg_width":null,"hex_primary":"49534C","brand_key_F":"2"},"374":{"color_key":"374","name":"Stone Blue","shirt_bg_name":"s110-stone-blue","shirt_bg_width":null,"hex_primary":"617290","brand_key_F":"2"},"51":{"color_key":"51","name":"Tan","shirt_bg_name":"s110-tan","shirt_bg_width":null,"hex_primary":"A29063","brand_key_F":"2"},"375":{"color_key":"375","name":"Tangerine","shirt_bg_name":"s110-tangerine","shirt_bg_width":null,"hex_primary":"ED691F","brand_key_F":"2"},"376":{"color_key":"376","name":"Texas Orange","shirt_bg_name":"s110-texas-orange","shirt_bg_width":null,"hex_primary":"82320D","brand_key_F":"2"},"377":{"color_key":"377","name":"Vegas Gold","shirt_bg_name":"s110-vegas-gold","shirt_bg_width":null,"hex_primary":"D6B972","brand_key_F":"2"},"47":{"color_key":"47","name":"Violet","shirt_bg_name":"s110-violet","shirt_bg_width":null,"hex_primary":"5D61A8","brand_key_F":"2"},"24":{"color_key":"24","name":"White","shirt_bg_name":"s110-white","shirt_bg_width":null,"hex_primary":"F8F6F7","brand_key_F":"2"},"30":{"color_key":"30","name":"Yellow Haze","shirt_bg_name":"s110-yellow-haze","shirt_bg_width":null,"hex_primary":"FAD978","brand_key_F":"2"}};
var shirtBackgrounds = {"26":{"color_key":"26","name":"Ash","shirt_bg_name":"s110-ash","shirt_bg_width":"115","hex_primary":"DAD9DE","brand_key_F":"2"},"865":{"color_key":"865","name":"Avocado","shirt_bg_name":"s110-avocado","shirt_bg_width":"0","hex_primary":"ccd67f","brand_key_F":"2"},"38":{"color_key":"38","name":"Azalea","shirt_bg_name":"s110-azalea","shirt_bg_width":"115","hex_primary":"EA65A5","brand_key_F":"2"},"29":{"color_key":"29","name":"Black","shirt_bg_name":"s110-black","shirt_bg_width":"115","hex_primary":"0F0D10","brand_key_F":"2"},"36":{"color_key":"36","name":"Cardinal Red","shirt_bg_name":"s110-cardinal-red","shirt_bg_width":"115","hex_primary":"6A080F","brand_key_F":"2"},"366":{"color_key":"366","name":"Carolina Blue","shirt_bg_name":"s110-carolina-blue","shirt_bg_width":"115","hex_primary":"647FD6","brand_key_F":"2"},"35":{"color_key":"35","name":"Cedar","shirt_bg_name":"s110-cedar","shirt_bg_width":"115","hex_primary":"7A212C","brand_key_F":"2"},"28":{"color_key":"28","name":"Charcoal","shirt_bg_name":"s110-charcoal","shirt_bg_width":"115","hex_primary":"433D3F","brand_key_F":"2"},"866":{"color_key":"866","name":"Cherry Red","shirt_bg_name":"s110-cherry-red","shirt_bg_width":"0","hex_primary":"9c1c33","brand_key_F":"2"},"58":{"color_key":"58","name":"Chestnut","shirt_bg_name":"s110-chestnut","shirt_bg_width":"115","hex_primary":"523B2D","brand_key_F":"2"},"31":{"color_key":"31","name":"Daisy","shirt_bg_name":"s110-daisy","shirt_bg_width":"115","hex_primary":"F6C930","brand_key_F":"2"},"218":{"color_key":"218","name":"Dark Chocolate","shirt_bg_name":"s110-dark-chocolate","shirt_bg_width":"115","hex_primary":"1D120F","brand_key_F":"2"},"367":{"color_key":"367","name":"Dark Heather","shirt_bg_name":"s110-dark-heather","shirt_bg_width":"115","hex_primary":"2D3034","brand_key_F":"2"},"56":{"color_key":"56","name":"Forest","shirt_bg_name":"s110-forest","shirt_bg_width":"115","hex_primary":"181913","brand_key_F":"2"},"32":{"color_key":"32","name":"Gold","shirt_bg_name":"s110-gold","shirt_bg_width":"115","hex_primary":"F39C1A","brand_key_F":"2"},"39":{"color_key":"39","name":"Heliconia","shirt_bg_name":"s110-heliconia","shirt_bg_width":"115","hex_primary":"CA2563","brand_key_F":"2"},"864":{"color_key":"864","name":"Honey","shirt_bg_name":"s110-honey","shirt_bg_width":"0","hex_primary":"fed072","brand_key_F":"2"},"44":{"color_key":"44","name":"Indigo Blue","shirt_bg_name":"s110-indigo-blue","shirt_bg_width":"115","hex_primary":"31405F","brand_key_F":"2"},"42":{"color_key":"42","name":"Iris","shirt_bg_name":"s110-iris","shirt_bg_width":"115","hex_primary":"3D5BBB","brand_key_F":"2"},"369":{"color_key":"369","name":"Irish Green","shirt_bg_name":"s110-irish-green","shirt_bg_width":"115","hex_primary":"24773A","brand_key_F":"2"},"60":{"color_key":"60","name":"Jade","shirt_bg_name":"s110-jade","shirt_bg_width":"115","hex_primary":"1A6572","brand_key_F":"2"},"54":{"color_key":"54","name":"Kelly Green","shirt_bg_name":"s110-kelly-green","shirt_bg_width":"115","hex_primary":"136145","brand_key_F":"2"},"40":{"color_key":"40","name":"Light Blue","shirt_bg_name":"s110-light-blue","shirt_bg_width":"115","hex_primary":"8FABDB","brand_key_F":"2"},"216":{"color_key":"216","name":"Light Pink","shirt_bg_name":"s110-light-pink","shirt_bg_width":"115","hex_primary":"F7C0E4","brand_key_F":"2"},"61":{"color_key":"61","name":"Lime","shirt_bg_name":"s110-lime","shirt_bg_width":"115","hex_primary":"7DC64B","brand_key_F":"2"},"37":{"color_key":"37","name":"Maroon","shirt_bg_name":"s110-maroon","shirt_bg_width":"115","hex_primary":"3F0F1A","brand_key_F":"2"},"371":{"color_key":"371","name":"Military Green","shirt_bg_name":"s110-military-green","shirt_bg_width":"115","hex_primary":"454732","brand_key_F":"2"},"25":{"color_key":"25","name":"Natural","shirt_bg_name":"s110-natural","shirt_bg_width":"115","hex_primary":"F2E7D0","brand_key_F":"2"},"46":{"color_key":"46","name":"Navy","shirt_bg_name":"s110-navy","shirt_bg_width":"115","hex_primary":"0E0D1B","brand_key_F":"2"},"41":{"color_key":"41","name":"Oceana","shirt_bg_name":"s110-oceana","shirt_bg_width":"115","hex_primary":"496377","brand_key_F":"2"},"57":{"color_key":"57","name":"Olive","shirt_bg_name":"s110-olive","shirt_bg_width":"115","hex_primary":"393124","brand_key_F":"2"},"33":{"color_key":"33","name":"Orange","shirt_bg_name":"s110-orange","shirt_bg_width":"115","hex_primary":"E92C12","brand_key_F":"2"},"868":{"color_key":"868","name":"Orchid","shirt_bg_name":"s110-orchid","shirt_bg_width":"0","hex_primary":"c3b7db","brand_key_F":"2"},"869":{"color_key":"869","name":"Paprika","shirt_bg_name":"s110-paprika","shirt_bg_width":"0","hex_primary":"dc4d3f","brand_key_F":"2"},"55":{"color_key":"55","name":"Pine","shirt_bg_name":"s110-pine","shirt_bg_width":"115","hex_primary":"4B553C","brand_key_F":"2"},"372":{"color_key":"372","name":"Pistachio","shirt_bg_name":"s110-pistachio","shirt_bg_width":"115","hex_primary":"A1AC74","brand_key_F":"2"},"52":{"color_key":"52","name":"Prairie Dust","shirt_bg_name":"s110-prairie-dust","shirt_bg_width":"115","hex_primary":"5D593C","brand_key_F":"2"},"49":{"color_key":"49","name":"Purple","shirt_bg_name":"s110-purple","shirt_bg_width":"115","hex_primary":"1C0F46","brand_key_F":"2"},"34":{"color_key":"34","name":"Red","shirt_bg_name":"s110-red","shirt_bg_width":"115","hex_primary":"B11617","brand_key_F":"2"},"45":{"color_key":"45","name":"Royal","shirt_bg_name":"s110-royal","shirt_bg_width":"115","hex_primary":"182E8C","brand_key_F":"2"},"871":{"color_key":"871","name":"Salmon","shirt_bg_name":"s110-salmon","shirt_bg_width":"0","hex_primary":"fea690","brand_key_F":"2"},"50":{"color_key":"50","name":"Sand","shirt_bg_name":"s110-sand","shirt_bg_width":"115","hex_primary":"C2BCA0","brand_key_F":"2"},"43":{"color_key":"43","name":"Sapphire","shirt_bg_name":"s110-sapphire","shirt_bg_width":"115","hex_primary":"155DAF","brand_key_F":"2"},"53":{"color_key":"53","name":"Serene Green","shirt_bg_name":"s110-serene-green","shirt_bg_width":"115","hex_primary":"9DAB88","brand_key_F":"2"},"872":{"color_key":"872","name":"Sky","shirt_bg_name":"s110-sky","shirt_bg_width":"0","hex_primary":"a3d9f1","brand_key_F":"2"},"27":{"color_key":"27","name":"Sport Grey","shirt_bg_name":"s110-sport-grey","shirt_bg_width":"115","hex_primary":"8C8D8F","brand_key_F":"2"},"374":{"color_key":"374","name":"Stone Blue","shirt_bg_name":"s110-stone-blue","shirt_bg_width":"115","hex_primary":"617290","brand_key_F":"2"},"51":{"color_key":"51","name":"Tan","shirt_bg_name":"s110-tan","shirt_bg_width":"115","hex_primary":"A29063","brand_key_F":"2"},"375":{"color_key":"375","name":"Tangerine","shirt_bg_name":"s110-tangerine","shirt_bg_width":"115","hex_primary":"ED691F","brand_key_F":"2"},"376":{"color_key":"376","name":"Texas Orange","shirt_bg_name":"s110-texas-orange","shirt_bg_width":"115","hex_primary":"82320D","brand_key_F":"2"},"377":{"color_key":"377","name":"Vegas Gold","shirt_bg_name":"s110-vegas-gold","shirt_bg_width":"115","hex_primary":"D6B972","brand_key_F":"2"},"47":{"color_key":"47","name":"Violet","shirt_bg_name":"s110-violet","shirt_bg_width":"115","hex_primary":"5D61A8","brand_key_F":"2"},"24":{"color_key":"24","name":"White","shirt_bg_name":"s110-white","shirt_bg_width":"115","hex_primary":"F8F6F7","brand_key_F":"2"},"30":{"color_key":"30","name":"Yellow Haze","shirt_bg_name":"s110-yellow-haze","shirt_bg_width":"115","hex_primary":"FAD978","brand_key_F":"2"}};


var updateShirtBackground = function(color_key){
	color_key = (color_key && color_key != null && color_key != '')? color_key : '19';

	var choiceForm = $('choiceForm');
	choiceForm['s'].value = color_key;

	//$('shirt-left').src = '/parts/t-shirts/s/'+shirtBackgrounds[color_key]['shirt_bg_name']+'_r1_c1.jpg';
	$('design-primary').style.backgroundImage = 'url(\'/parts/t-shirts/s/'+shirtBackgrounds[color_key]['shirt_bg_name']+'.jpg\')';
	
	$('zoomedin').setStyle({ 'background-color' : '#'+shirtBackgrounds[color_key]['hex_primary'] });
	$('shirtChoice').value = color_key;

	$('priceQuoter').action = '#'+Form.serializeElements( $('choiceForm').getInputs('hidden') );
//	alert($('priceQuoter').action);
}

var updateInkColor = function(ink_color, color_key){

	ink_color = (ink_color && ink_color != null && ink_color != '')? ink_color : 0;
	color_key = (color_key && color_key != null && color_key != '')? color_key : '19';

	var choiceForm = $('choiceForm');
	choiceForm['i['+ink_color+']'].value = color_key;

	Event.observe( 'preview_ink-'+ink_color, 'load', function(){
		$('choicespinner').hide();
	});
	if($('preview_ink-'+ink_color).src != $('preview_ink-'+ink_color).src.replace(/-([0-9]+)\.png/, '-'+color_key+'.png')){
		$('choicespinner').show();
		$('preview_ink-'+ink_color).src = $('preview_ink-'+ink_color).src.replace(/-([0-9]+)\.png/, '-'+color_key+'.png');
	}
	if($('preview_ink_full-'+ink_color).src != $('preview_ink_full-'+ink_color).src.replace(/-([0-9]+)\.png/, '-'+color_key+'.png')){
		$('preview_ink_full-'+ink_color).src = $('preview_ink_full-'+ink_color).src.replace(/-([0-9]+)\.png/, '-'+color_key+'.png');
	}
	$('inkChoice'+ink_color).value = color_key;

	$('priceQuoter').action = '#'+Form.serializeElements( $('choiceForm').getInputs('hidden') );
//	alert($('priceQuoter').action);
}

function makeLeftChest(){
	var design_handle = document.getElementById('preview');
	if(design_handle){
		design_handle.style.width='110px';
		design_handle.style.height='93px';
	} else {
		var design_handles = $('design-primary').getElementsByClassName('preview');
		design_handles.each(function(item) {
			item.style.width='110px';
			item.style.height='93px';
		});
	}
}

function makeFullFront(){
	var design_handle = document.getElementById('preview');
	if(design_handle){
		design_handle.style.width='247px';
		design_handle.style.height='209px';
	} else {
		var design_handles = $('design-primary').getElementsByClassName('preview');
		design_handles.each(function(item) {
			item.style.width='247px';
			item.style.height='209px';
		});
	}
}

LinkQuote = function(){
	VoteCombo('Link');
	$$('.nolink').invoke('disable');
	location.hash = $('choiceForm').serialize();
	$$('.nolink').invoke('enable');
}

VoteCombo = function(voteType){
	$('choiceForm').action = '/parts/t-shirts/stock_design_color_vote.php';
	$('choiceForm').request({
		method: 'post',
		parameters : { 'voteType' : voteType },
		onSuccess: function(transport){
			// This saves favorite color combinations
		    if (transport.responseText.match(/true/)){
				UpdateSavedCombos();
				$('saved_combos_wrap').show();
		    }
		}
	});
	
	$('choiceForm').action = 'http://art.merchtees.com/t-shirts/customcomposite.php';
}

deleteCombo = function(comboId){
	var myRequest = new Ajax.Request('/parts/t-shirts/stock_design_color_vote.php', {
		method: 'post',
		parameters : { 'deleteCombo' : comboId },
		onComplete: function() {
			UpdateSavedCombos();
		},
		onFailure: function() {
			UpdateSavedCombos();
		}
	});
}

UpdateSavedCombos = function( ){
	var designId = $F('design_id');
	new Ajax.Updater('saved_combos', '/parts/t-shirts/stock_design_color_saved_combos.php', {
		method: 'post',
		parameters: { 'd': designId }
	});
}

Event.observe(window, 'load', function() {
	var shirtChooser = $('shirtChoice');
	if(shirtChooser){
		Event.observe(shirtChooser, 'change', function() {
			updateShirtBackground( shirtChooser.value );
		});
		Event.observe($('tq_quan'), 'change', function() {
			$('chooser_q').value = $('tq_quan').value;
			$$('.nolink').invoke('disable');
			$('priceQuoter').action = '#'+Form.serializeElements( $('choiceForm').getInputs('hidden') );
			$$('.nolink').invoke('enable');
		});
		Event.observe($('tq_quan'), 'keyup', function() {
			$('chooser_q').value = $('tq_quan').value;
			$$('.nolink').invoke('disable');
			$('priceQuoter').action = '#'+Form.serializeElements( $('choiceForm').getInputs('hidden') );
			$$('.nolink').invoke('enable');
		});
		
		UpdateSavedCombos();
		$('saved_combos_wrap').hide();
		
		var inkChoosers = $$('.inkChoosers');
	
		inkChoosers.each(function(ob, index) {
			Event.observe(ob, 'change', function() {
				//alert('Ink #'+ob.id.replace(/inkChoice/,'')+', Ink Color: '+ $F(ob));
				updateInkColor( ob.id.replace(/inkChoice/,''), $F(ob));
			});
		});
		
		var lHash = location.hash;
		if(lHash.startsWith('#')){
			lHashO = lHash.replace(/#/,'').toQueryParams();
			//alert($H(lHashO).keys());
			if(lHashO['s'] != undefined){
				updateShirtBackground(lHashO['s']);
				var regex = new RegExp(/i\[([0-9]+)\]/);
				$H(lHashO).each(function(pair) {
					//alert(pair.key);
					var match = regex.exec(pair.key);
					if(match && match != null){
						var inkPosition = pair.key[match.length];
						updateInkColor(inkPosition, pair.value);
					}
				})
				if(lHashO['q'] != undefined && lHashO['q'] != $F('chooser_q')){
					$('tq_quan').value = lHashO['q'];
					if( $('priceQuoter').onsubmit == undefined || $('priceQuoter').onsubmit()){
						$('priceQuoter').submit();
					}
				} else {
					var re = new RegExp("&q="+lHashO['q']);
					var loc = ''+window.location+'';
					$('priceQuoter').action = loc.replace(re, '');
				}
			}
		}
	}
});
function questions(){
var d ='ilto';
var a ='quest';
var b = 'b.com';
var c = 'ions@class';
document.write('<a href="');
document.write('ma');
document.write(d);
document.write(':');
document.write(a + c + b);
document.write('">');
document.write(a + c + b);
document.write('</a>');
}

function currency(val) {
   // Returns passed number as string in ,xxx.xx format.
   val=eval(val)
   workNum=Math.abs((Math.round(val*100)/100));workStr=""+workNum
   if (workStr.indexOf(".")==-1){workStr+=".00"}
   dStr=workStr.substr(0,workStr.indexOf("."));dNum=dStr-0
   pStr=workStr.substr(workStr.indexOf("."))
   while (pStr.length<3){pStr+="0"}

   // comma in thousands place.
   if (dNum>=1000) {
	  dLen=dStr.length
	  dStr=parseInt(""+(dNum/1000))+","+dStr.substring(dLen-3,dLen)
   }

   // comma in millions place.
   if (dNum>=1000000) {
	  dLen=dStr.length
	  dStr=parseInt(""+(dNum/1000000))+","+dStr.substring(dLen-7,dLen)
   }
   retval = dStr + pStr 
   //-- Put numbers in parentheses if negative.
   if (val<0) {retval="("+retval+")"}
   return "$"+retval
}

function preventDefault(e) 
{ 
 e? e.preventDefault() : event.returnValue = false; 
} 
function getEventSrc(e) 
{ 
 var targ = (e||event).target; 
 if(targ) 
  return targ.nodeType==1?targ:targ.parentNode 
 else 
  return event.srcElement; 
} 
function getAncestor(elm,prop,regVal) 
{ 
 while(elm) 
 { 
  if(regVal.test(elm[prop])) return elm; 
  elm = elm.parentNode; 
 } 
} 
function tn(elm){
	var index = getIndex(elm);
	var divs = getElement('subnav').getElementsByTagName('div');
	for(var m=0;m<divs.length;m++){
		divs[m].style.visibility = 'hidden';
	}
	divs[index].style.visibility = 'visible';
}
function tc(){
	var the_div = getNextSibling(this);
	var its_index = getIndex(this);
	if (the_div.className != 'shade'){
		the_div.className='shade';
	} else {
		the_div.className='angle';
	}
}
function togglenav(a){
	var par = getElement('leftnav');
	var con = getElement('content');
	if((par)&&(con)){
		if (par.style.left!='0px'){
		par.style.left = '0px';
		con.style.left = '155px';
		a.innerHTML = '&larr; Minimize';
		} else {
		par.style.left = '-142px';
		con.style.left = '13px';
		a.innerHTML = '&rarr;';
		}
	}
}
function sf(ahref){
	var parform = getAncestor(ahref,'tagName',/form/i);
	if(parform.onsubmit){
		var doit = parform.onsubmit();
		if (doit){
			parform.submit();
			}
		} else {
	parform.submit();
	}
}
function cmpO(original,newval){
	// this checks to make sure they changed the value
	var oVal = document.getElementById(original).value;
	var nVal = document.getElementById(newval).value;
	if(oVal!=nVal){
		return true;
	} else {
		alert('Change quantity first.');
		return false;
	}
}

function getIndex(elm) 
{ 
	var nodes = elm.parentNode.childNodes, node; 
	var i = count = 0; 
	while( (node=nodes.item(i++)) && node!=elm ) 
		if( node.nodeType==1 ) count++; 
	return count;
}
function getNextSibling(el) 
{ 
	while((el=el.nextSibling) && el.nodeType!=1); 
	return el; 
} 
function getElement(ref) {
	if(document.getElementById && document.getElementById(ref)) {
		return document.getElementById(ref);
	} else if (document.all && document.all(ref)) {
		return document.all(ref);
	} else if (document.layers && document.layers[ref]) {
		return document.layers[ref];
	} else {
		return false;
	}
} // getStyle

function getStyle(ref) {
	if(document.getElementById && document.getElementById(ref)) {
		return document.getElementById(ref).style;
	} else if (document.all && document.all(ref)) {
		return document.all(ref).style;
	} else if (document.layers && document.layers[ref]) {
		return document.layers[ref];
	} else {
		return false;
	}
} // getStyle

function init(){
	var the_nav = getElement('leftnav');
	if(the_nav){
	var theheads = the_nav.getElementsByTagName('h6');
		for(var m=0;m<theheads.length;m++){
			theheads[m].onclick=tc;
		}
	}
	getElement('minimize').innerHTML = '<a href="#" onclick="togglenav(this);return false;">&larr; Minimize<\/a>';
	if(getElement('progress')){
		getElement('progress').style.display = 'none';
	}
}
