function tkRealTimeQty(){
  var _qty_1 = zeroNotNull( jQuery('input[id=qty]').val() );
  var _qty_2 = zeroNotNull( jQuery('input[id=BoxQty]').val() );
  return _qty_1 + _qty_2;
}
function tkTealTimeProductOptions(){
  var _temp = '';
  jQuery('select.inputreq').each(
	function(){
    	if(_temp.length > 0){_temp = _temp + ", ";}
    	_temp = _temp + jQuery(this).val();
	});
	return _temp;
}
function isSet(gaField){return (( typeof( gaField  ) != 'undefined' )&&(gaField !=null));}
function emptyNotNull(gaField){if(isSet(gaField)){return gaField;}else{return '';}}
function oneNotNull(gaField){if(isSet(gaField)){return gaField;}else{return 1;}}
function zeroNotNull(gaField){if(isSet(gaField)){return gaField;}else{return 0;}}
function tkRealTimeInternalId(){return ('' + emptyNotNull( jQuery('input:hidden[id=itemid]').val()));}
function tkRealTimeCouponCode(){return ('' + emptyNotNull( jQuery('input[id=kReferralCode]').val()));}
var trackAddToCart = function(){_gaq.push(['_trackEvent','Shopping','Add To Cart ' + tkItemId(),tkRealTimeQty()]);};
var trackApplyCoupon = function(){ _gaq.push(['_trackEvent','Shopping','Apply Coupon:' + tkRealTimeCouponCode()]); };
var trackActionCheckout = function(){_gaq.push(['_trackEvent','Shopping','Proceed To Checkout']);};
var trackActionRegister = function(){ _gaq.push(['_trackEvent','Shopping','New Customer']); };
var trackActionReturningCustomer = function(){ _gaq.push(['_trackEvent','Shopping','Returning Customer']); };
var trackActionShippingInfo = function(){ _gaq.push(['_trackEvent','Shopping','Shipping Info']); };
var trackActionShippingMethod = function(){ _gaq.push(['_trackEvent','Shopping','Shipping Method']); };
var trackActionPaymentInfo = function() {_gaq.push(['_trackEvent','Shopping','Payment Info']); };
var trackActionReviewOrder = function() {_gaq.push(['_trackEvent','Shopping','Review Order']); };
jQuery(document).ready(function(){
  jQuery('input:image[id=addtocart]').unbind('click',trackAddToCart);
  jQuery('input:image[id=addtocart]').bind('click',trackAddToCart);
  jQuery('input:submit[id=applycoupon]').unbind('click',trackApplyCoupon);
  jQuery('input:submit[id=applycoupon]').bind('click',trackApplyCoupon);
  jQuery('input:submit[id=checkout]').unbind('click',trackActionCheckout);
  jQuery('input:submit[id=checkout]').bind('click',trackActionCheckout);
  jQuery('input:button[id=register]').unbind('click',trackActionRegister);
  jQuery('input:button[id=register]').bind('click',trackActionRegister);
  jQuery('.greytitle').each(function(){
    var _temp = jQuery(this).html();
    if(isSet(_temp) && (_temp.indexOf("Shipping Address") > -1)){
      jQuery('input:button[id=submitter]').unbind('click',trackActionShippingInfo);
      jQuery('input:button[id=submitter]').bind('click',trackActionShippingInfo);
    } else if(isSet(_temp) && (_temp.indexOf("Shipping Method") > -1)){
      jQuery('input:button[id=submitter]').unbind('click',trackActionShippingMethod);
      jQuery('input:button[id=submitter]').bind('click',trackActionShippingMethod);
    } else if(isSet(_temp) && (_temp.indexOf("Payment Information") > -1)){
      jQuery('input:button[id=submitter]').unbind('click',trackActionPaymentInfo);
      jQuery('input:button[id=submitter]').bind('click',trackActionPaymentInfo);
    } else if(isSet(_temp) && (_temp.indexOf("Review") > -1 )){
      jQuery('input:button[id=submitter]').unbind('click',trackActionReviewOrder);
      jQuery('input:button[id=submitter]').bind('click',trackActionReviewOrder);
    } else if(isSet(_temp) && ( _temp.indexOf("Returning Customers") > -1 ) ){
      jQuery('input:button[id=submitter]').unbind('click',trackActionReturningCustomer);
      jQuery('input:button[id=submitter]').bind('click',trackActionReturningCustomer);
	}
  });  
});
function setCookie(c_name,value,exdays){
  var exdate=new Date();exdate.setDate(exdate.getDate() + exdays);
  var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
  document.cookie=c_name + "=" + c_value;
}
function getCookie(c_name){
  var i,x,y,ARRcookies=document.cookie.split(";");
  for (i=0;i<ARRcookies.length;i++){
    x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
    y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
    x=x.replace(/^\s+|\s+$/g,"");
    if (x==c_name){return unescape(y);}
  }
}
var cartTheme=getCookie("cartTheme");
if( cartTheme == null || cartTheme=="" ){setCookie("cartTheme","outdoor",30);}
