var DCP3233eStoreFn = {
	init: function(type){
		if(type ==='cart'){
			// Cart - Hide all instances of the special planSKU for Kid Watch
			$('.cart-device-info-plan').each(function(){
				if($(this).attr('data-planskuid') === 'sku1352042186stgvha' || $(this).attr('data-planskuid') ===  'sku1352042185stgvha'){
					// $(this).hide();
					$(this).parent('.cart-background').find('.cart-device-info-title').text('Device');
				}
			});

			// Checkout - Hide all instances of the special planSKU for Kid Watch
			$('.dashed-border').each(function(){
				if($(this).attr('data-planskuid') === 'sku1352042186stgvha'|| $(this).attr('data-planskuid') ===  'sku1352042185stgvha'){
					// $(this).hide();
					$(this).parents('.accordion-body').find('.bundle-item-subheader').text('Device');
				}

			});
		}
		else if(type === 'device'){
			var breadcrumbsTxtEl = $('.breadcrumbs li').eq(0).find('a');
			breadcrumbsTxtEl.html(breadcrumbsTxtEl.text().replace('Phone', 'Device'));

			var headerTxtEl = $('.FreedomDevicePageWrapper__phone-detail-section .StepAccordion__header-title span');
			headerTxtEl.html(headerTxtEl.text().replace('phone', 'device'));

			var featureTxtEl = $('.FreedomDevicePageWrapper__phone-detail-section a.MobileDetail__learn-more');
			featureTxtEl.html(featureTxtEl.text().replace('Phone', 'Device'));

			var termTxtEl = $('.FreedomDevicePageWrapper__phone-detail-section .PostpaidDeviceContainer__terms-text > p');
			termTxtEl.html(termTxtEl.text().replace('phone', 'device'));

			$(document).on('click', '.PostpaidDeviceContainer__icon', function(){
				var lbTxtEl = $('.LightBoxModalV2__popup-content .title');
				lbTxtEl.html(lbTxtEl.text().replace('phone', 'device'));
				var pgTxtEl =  $('.LightBoxModalV2__popup-content .paragraph')
				pgTxtEl.html(pgTxtEl.text().replace('phone', 'device'));
			})


			var accTxtEl = $('.FreedomDevicePageWrapper__phone-detail-section .PostpaidDeviceContainer__features-container .Accordions__header-left');
			accTxtEl.html(accTxtEl.text().replace('Phone', 'Device'));


			var usageTxtEl = $('.FreedomDevicePageWrapper__plan-detail-section .FreedomDevicePageWrapper__plan-segment-selection .FreedomDevicePageWrapper__title');
			usageTxtEl.html(usageTxtEl.text().replace('phone', 'device'));

			$(document).on('click', '.ComparablePlanList__plan-container .ComparablePlanList__plan-list-item-container .ComparablePlanList__plan-list-item .ComparablePlanList__action-panel button', function(){
				var stickyTxtEl = $('.StickyAddToCart__header .StickyAddToCart__inner-container .StickyAddToCart__show-all');
				if(stickyTxtEl.text() === 'PhonePhone'){
					stickyTxtEl.text('Device');
				}
			})


		}
	}
}

var DCP3233eStoreSelectortimerHolder = setInterval(function () {
	if(document.URL.indexOf('/cart') > -1 || document.URL.indexOf('/checkout') > -1){
		if($('.cart-device-info-plan').length > 0 || $('.dashed-border').length > 0){
      clearInterval(DCP3233eStoreSelectortimerHolder);
      DCP3233eStoreSelectortimerHolder = null;
     	DCP3233eStoreFn.init('cart');
    }
	}
	else if(document.URL.indexOf('/alcatel-movetime-watch') > -1  | document.URL.indexOf('/alcatel-family-watch') > -1 ){
		if($('.FreedomDevicePageWrapper__phone-detail-section').length > 0 ){
			clearInterval(DCP3233eStoreSelectortimerHolder);
      DCP3233eStoreSelectortimerHolder = null;
     	DCP3233eStoreFn.init('device');
		}
	}
	else{
		clearInterval(DCP3233eStoreSelectortimerHolder);
		DCP3233eStoreSelectortimerHolder = null;
	}


}, 1000);