/*
*  A wrapper utility for Coremetrics
*/

var tagged;

function nsCreatePageviewTag(pageId, categoryId, searchTerm, searchResults, isOnFlag, isProductionFlag) {
   if (isOnFlag == 'true') {
      if (isProductionFlag == 'true') {
         cmSetProduction();
         //alert('set to production');
      }

      cmCreatePageviewTag(pageId, categoryId, searchTerm, searchResults);
      //alert("called coremetrics cmCreatePageviewTag('" + pageId + "'...)");
      nsSetTagged();
   }
}

function nsCreateProductviewTag(productId, productName, categoryId, isOnFlag, isProductionFlag) {
   if (isOnFlag == 'true') {
      if (isProductionFlag == 'true') {
         cmSetProduction();
         //alert('set to production');
      }

      cmCreateProductviewTag(productId, productName, categoryId);
      //alert("called coremetrics cmCreateProductviewTag('" + productId + "'...)");
      nsSetTagged();
   }
}

function nsCreateTechPropsTag(pageId, categoryId, isOnFlag, isProductionFlag) {
   if (isOnFlag == 'true') {
      if (isProductionFlag == 'true') {
         cmSetProduction();
         //alert('set to production');
      }

      cmCreateTechPropsTag(pageId, categoryId);
      //alert("called coremetrics cmCreateTechPropsTag('" + pageId + "'...)");
      nsSetTagged();
   }
}

function nsCreateShopAction5Tag(productId, productName, quantity, unitPrice, categoryId, isOnFlag, isProductionFlag) {
   if (isOnFlag == 'true') {
      if (isProductionFlag == 'true') {
         cmSetProduction();
         //alert('set to production');
      }

      cmCreateShopAction5Tag(productId, productName, quantity, unitPrice, categoryId);
      //alert("called coremetrics cmCreateShopAction5Tag('" + productId + "'...)");
      nsSetTagged();
   }
}

function nsCreateShopAction9Tag(productId, productName, quantity, unitPrice, customerId, orderId, orderSubTotal, categoryId, isOnFlag, isProductionFlag) {
   if (isOnFlag == 'true') {
      if (isProductionFlag == 'true') {
         cmSetProduction();
         //alert('set to production');
      }

      cmCreateShopAction9Tag(productId, productName, quantity, unitPrice, customerId, orderId, orderSubTotal, categoryId);
      //alert("called coremetrics cmCreateShopAction9Tag('" + productId + "'...)");
      nsSetTagged();
   }
}

function nsCreateOrderTag(orderId, orderSubTotal, orderShipping, customerId, customerCity, customerState, customerZip, isOnFlag, isProductionFlag) {
   if (isOnFlag == 'true') {
      if (isProductionFlag == 'true') {
         cmSetProduction();
         //alert('set to production');
      }

      cmCreateOrderTag(orderId, orderSubTotal, orderShipping, customerId, customerCity, customerState, customerZip);
      //alert("called coremetrics cmCreateOrderTag('" + orderId + "'...)");
      nsSetTagged();
   }
}

function nsCreateRegistrationTag(customerId, customerEmail, customerCity, customerState, customerZip, newsLetterName, subscribedFlag, isOnFlag, isProductionFlag) {
   if (isOnFlag == 'true') {
      if (isProductionFlag == 'true') {
         cmSetProduction();
         //alert('set to production');
      }

      cmCreateRegistrationTag(customerId, customerEmail, customerCity, customerState, customerZip, newsLetterName, subscribedFlag);
      //alert("called coremetrics cmCreateRegistrationTag('" + customerId + "'...)");
      nsSetTagged();
   }
}

function nsCreateErrorTag(pageId, categoryId, isOnFlag, isProductionFlag) {
   if (isOnFlag == 'true') {
      if (isProductionFlag == 'true') {
         cmSetProduction();
         //alert('set to production');
      }

      cmCreateErrorTag(pageId, categoryId);
      //alert("called coremetrics cmCreateErrorTag('" + pageId + "'...)");
      nsSetTagged();
   }
}

function nsDisplayShop5s(isOnFlag) {
   if (isOnFlag == 'true') {
      cmDisplayShop5s();
      //alert("called coremetrics cmDisplayShop5s()");
      nsSetTagged();
   }
}

function nsDisplayShop9s(isOnFlag) {
   if (isOnFlag == 'true') {
      cmDisplayShop9s();
      //alert("called coremetrics cmDisplayShop9s()");
      nsSetTagged();
   }
}

function nsSetTagged() {
   tagged = true;
}

function nsSetUntagged() {
   tagged = false;
}

function nsIsTagged() {
   return tagged;
}