<!--
function setCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires=";expires="+date.toGMTString();}else{var expires="";}document.cookie=name+"="+value+expires+";path=/";}
function getCookie(cookie_name){var results=document.cookie.match('(^|;)?'+cookie_name+'=([^;]*)(;|$)');if(results){return(unescape(results[2]));}else{return null;}}
function checkCookie(x){if((getCookie(x)!=null)&&(getCookie(x)!="")){return true;}else{return false;}}
function setCounter(x){if(getCookie('counter'+x)!=null){setCookie('counter'+x,(parseInt(getCookie('counter'+x))+1));}else{setCookie('counter'+x,'1');}}
function setOpacity(obj,opacity) {opacity=(opacity==100)?99.999:opacity;var object=document.getElementById(obj);object.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+opacity+");";object.style.KHTMLOpacity = opacity/100;object.style.MozOpacity = opacity/100;object.style.opacity = opacity/100;}
function fadeOut(y){t2=0;for(m=100;m>=0;m--){setTimeout("setOpacity('"+y+"',"+m+")",(t2*5));t2++}}
function fadeIn(y){t2=0;for(m=0;m<=100;m++){setTimeout("setOpacity('"+y+"',"+m+")",(t2*5));t2++}}
function getSize(x){
	var allInputs=x.getElementsByTagName('input');
	for(v=0;v<allInputs.length;v++){if(allInputs[v].checked==true)return allInputs[v].value;}
}
function addProduct(x){
	if(cookieEnabled()==false){
		alert('You must have cookies enabled in order to shop for merchandise. For directions on how to enable cookies, visit http://www.google.com/cookies.html.');
	}else{

		var productRow=x.parentNode.parentNode.parentNode,product=productRow.getElementsByTagName('img')[0],color=x.parentNode.parentNode.getElementsByTagName('input')[0],size=getSize(productRow),quantity=productRow.getElementsByTagName('select')[0],price=productRow.getElementsByTagName('h4')[0].innerHTML,theProduct,productIdMatch="",finalQuantity=quantity.value,counterIncrement="true",allCookies=document.cookie.split(';'),addedId;		
		if(color.value==""){
			alert("Please select a color in order to add to cart.");
		}else{
			for(i=0;i<allCookies.length;i++){
				if((allCookies[i].substring(1,allCookies[i].indexOf('=')).replace(/[0-9]/g,'')==productRow.id)&&(allCookies[i].substring(allCookies[i].indexOf('|')+1,allCookies[i].lastIndexOf('|'))==color.value+'|'+size)){
					productIdMatch=allCookies[i].substring(1,allCookies[i].indexOf('=')).replace(/[a-zA-Z]/g,'');
					finalQuantity=(parseInt(allCookies[i].substring(allCookies[i].lastIndexOf('|')+1,allCookies[i].indexOf('$')))+parseInt(quantity.value))
					counterIncrement='false';
				}
			}
			if(counterIncrement=='false'){
				theProduct=productRow.id+productIdMatch;
			}else{
				setCounter(productRow.id);
				theProduct=productRow.id+getCookie('counter'+productRow.id);
			}
			setCookie(theProduct,product.alt+'|'+color.value+'|'+size+'|'+finalQuantity+'$'+price.substring(8,(price.length-3)));
			quantity.selectedIndex=0;
			if(!productRow.getElementsByTagName('span')[0].id){productRow.getElementsByTagName('span')[0].id=productRow.id+'addedId';}
			addedID=productRow.id+'addedId';
			setOpacity(productRow.getElementsByTagName('span')[0].id,100);
			setTimeout('fadeOut("'+productRow.getElementsByTagName('span')[0].id+'")','2000');
		}
	}
}
function deleteCookie(x){setCookie(x.parentNode.nextSibling.nextSibling.nextSibling.nextSibling.getElementsByTagName('input')[0].id,"",-1);window.location=window.location.href;}
function confirmDelete(x){var answer=confirm("Remove this item from your cart?");if(answer){deleteCookie(x);}}
function changeQuantity(x){if(isNaN(x.value)){x.value=x.value.replace(/[^0-9]/g,'');}else{var newQuantity=1;var cookieString=getCookie(x.id);cookieId=cookieString.substring(0,cookieString.indexOf('='));cookieCost=cookieString.substring(cookieString.indexOf('$'),cookieString.length);cookieString=cookieString.substring(cookieString.lastIndexOf('|')+1,cookieString.indexOf('&'));if(document.getElementById(x.id).value){newQuantity=document.getElementById(x.id).value};cookieString=cookieString+newQuantity+cookieCost;if(newQuantity==0){setCookie(x.id,"",-1);}else{setCookie(x.id,cookieString)};window.location=window.location.href;}}
function zoomIn(x){document.getElementById(x).style.zIndex='15';setTimeout('fadeIn("'+x+'")','0');}
function zoomOut(x){if(document.getElementById(x).style.zIndex=='15'){setTimeout('fadeOut("'+x+'")','0');document.getElementById(x).style.zIndex='5';}}
function highlight(x){x.parentNode.style.borderColor="#000000";}
function unHighlight(x){if(x.parentNode.className=="swatch"){x.parentNode.style.borderColor="#f7f7f7";}}
function setColor(x){var allSwatches=x.parentNode.parentNode.getElementsByTagName('div');for(i=0;i<allSwatches.length;i++){if(allSwatches[i].className=="swatch selected"){allSwatches[i].className="swatch";allSwatches[i].style.borderColor="#f7f7f7";}};x.parentNode.className="swatch selected";x.parentNode.parentNode.parentNode.getElementsByTagName('input')[0].value=x.title;x.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('p')[0].innerHTML=x.title;x.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('img')[0].src='/images/m_'+x.parentNode.parentNode.parentNode.parentNode.id+'_'+x.title.replace(/ /g,'_').toLowerCase()+'.gif';}
function setOrder(){
	if(document.cookie.indexOf('$')!=-1){
		var allCookies=document.cookie.split(';').sort(),cookieSplit,counter=1,orderRow;
		for(d=0;d<allCookies.length;d++){
			if((allCookies[d].indexOf('counter')==-1)&&(allCookies[d].indexOf('__')==-1)){
				if(counter>10){
					alert('You can only have up to ten line items per order. Please adjust your order and resubmit. If you want to order more then ten products, you can submit a second order afterwards.')
					for(p=1;p<11;p++){
						orderRow='theOrder'+p;
						document.getElementById(orderRow).value='';
					}
					return false;
				}else{
					cookieSplit=allCookies[d].split('|');
					product=cookieSplit[0].substring(cookieSplit[0].indexOf("=")+1,cookieSplit[0].length);
					quantity=cookieSplit[3].substring(0,cookieSplit[3].indexOf("$"));
					cost=cookieSplit[3].substring(cookieSplit[3].indexOf("$")+1,cookieSplit[3].length);
					orderRow='theOrder'+(counter);
					document.getElementById(orderRow).value=product+' | Color: '+cookieSplit[1]+' | Size: '+cookieSplit[2]+' | '+quantity+' x $'+cost+'.00 | SUBTOTAL: $'+((parseInt(quantity)*parseInt(cost)))+'.00';
					counter++;
				}
			}
		}
	}
	document.getElementById('theTotal').value='$'+total+'.00';
	confirmSubmit('order');
}
function confirmSubmit(x){var answer=confirm("You are about to submit your order...Continue?");if(answer){if(validate(document.getElementById(x))==true){submitOrder(x);}}}
function submitOrder(x){
	document.getElementById(x).submit();
}
function clearCart(){
	var allCookies=document.cookie.split(';').sort();
	for(d=0;d<allCookies.length;d++){
		if(allCookies[d].indexOf('__')==-1){
			setCookie(allCookies[d].substring(0,allCookies[d].indexOf('=')),"",-1);
		}
	}
}
function cookieEnabled(){setCookie('test','none');if(getCookie('test')){setCookie('test',"",-1);return true;}else{return false;}}
//-->