//3dCart specific additions and client settings

//Namespace for all 4-Tell code
(function( _4TellBoost, $, undefined ) {

	//Client settings
	_4TellBoost.SiteInfo = new _4TellBoost.Site({
		baseURL: 'www.angelicdreamz.com',
		alias: 'Angelic',
		GA_UA: '', //supplying UA number here will override the tracking type
		GATrackingType: '_gaq', //valid types: 'none', 'pageTracker', '_gaq'
		GATrackID: '4TellRecs',
		rotateTopSellers: true,
		showLogo: false,
		addCartMethod: '3dCartMoreDetails', //valid methods: '3dCartQuickCart', '3dCartMoreDetails'
		addCartBtnAtts: "input type='button' value='More Details' class='btn' onmouseout=this.className='btn' onmouseover=this.className='btn_over'", 
		//addCartBtnAtts: "img alt='Add to Cart'",
		addCartImage: '', //'assets/images/add-cart.png', //'assets/images/buy.gif', //use '' if type=button
		priceClass: 'price2',
		strikePriceClass: 'price-info',
		salePriceClass: 'price',
		pricePrefix: '',
		salePricePrefix: 'On Sale: ',
		includeBase: false
	});


	// Page Settings
	// Defaults	
	var tout1 = {
		orientation: 'vertical',
 		newDivID: 'main4TellContainer',
 		divSelect: '#main4TellContainer', // if class use '.' -- if id use '#'
 		divPosition: 'append', //valid settings are 'append', 'replace', 'above', or 'below'
 		showCaption: true,
		captionStyle: 'menu-headers product4TCaption',
		productStyle: 'product4T',
		imageSize: "&maxx=120&maxy=0",
		showRatings: true,
		showBuyButton: true,
 		wrapper: ''
	}; 
	var tout2 = {
		orientation: 'horizontal',
 		newDivID: 'second4TellContainer',
 		divSelect: '#second4TellContainer', // if class use '.' -- if id use '#'
 		divPosition: 'append', //valid settings are 'append', 'replace', 'above', or 'below'
 		showCaption: true,
		captionStyle: 'titles product4TCaption2',
		productStyle: 'product4T product4T2',
		imageSize: "&maxx=140&maxy=140",
		showRatings: true,
		showBuyButton: true,		
 		wrapper: ''
	}; 
	

	_4TellBoost.getPageSettings = function(pageType) {
		var inCart = false;
		
		// These are the tout settings for different pages of the site. 
		// You may add or remove page types here to match your site architecture.
		// Any settings not specified here will use the default values listed above
		switch (pageType) {
			case 'Home': //home page
			default: //any page not listed
				tout1.enable = true;
				tout1.resultType = 4; //Top-sellers
				tout1.numItems = 10;
				if (_4TellBoost.SiteInfo.rotateTopSellers) {
					var d = new Date();	
					tout1.startPos = d.getDay() + 1; //roatate start position by day of week
				}
				tout1.caption = 'Top Sellers';
				//tout1.captionStyle = 'menu-headers product4TCaption';
				tout2.enable = false;
				break;		
			case 'ProductDetail': //product detail page (PDP)
				tout1.enable = true;
				tout1.resultType = 0; //Cross-sell
				tout1.numItems = 10;
				tout1.caption = 'Our customers also bought...';
				tout2.enable = true;
				tout2.resultType = 3; //Similar
				tout2.numItems = 8;
				tout2.caption = 'Similar items...';
				break;		
			case 'Category': //category landing page 
				tout1.enable = true;
				tout1.resultType = 3; //Similar
				tout1.numItems = 10;
				tout1.caption = 'Related top sellers...';
				tout2.enable = false;
				break;
			case 'Search': //search results page 
				tout1.enable = true;
				tout1.resultType = 0; //Cross-sell
				tout1.numItems = 10;
				tout1.caption = 'You may also like...';
				tout2.enable = false;
				break;		
			case 'ViewCart': //intermediate add to cart page
				tout1.enable = false;
				tout2.enable = true;
				tout2.resultType = 0; //Cross-sell
				tout2.numItems = 6;
				tout2.caption = 'You may also like...';
				tout2.captionStyle = 'checkout-headers product4TCaption';
				tout2.productStyle = 'product4T product4T2';
				inCart = true;
				break;
			case 'ViewCartQuick': //intermediate add to cart page
				tout1.enable = false;
				tout2.enable = true;
				tout2.resultType = 0; //Cross-sell
				tout2.numItems = 4;
				tout2.caption = 'You may also like...';
				tout2.captionStyle = 'checkout-headers product4TCaption';
				tout2.productStyle = 'product4T product4T2';
				tout2.imageSize = "&maxx=100&maxy=100";
				tout2.showRatings = false;
				tout2.inFrame = true;
				inCart = true;
				break;
			case 'QuickView': //product view pop-up
				tout1.enable = false;
				tout2.enable = true;
				tout2.resultType = 0; //Cross-sell
				tout2.numItems = 4;
				tout2.showCaption = false;
				tout2.productStyle = 'product4T product4TSmall';
				tout2.imageSize = "&maxx=100&maxy=100";
				tout2.showRatings = false;
				tout2.showBuyButton = false;
				tout2.inFrame = true;
				_4TellBoost.DelayHandler.toutDiv = '#second4TellContainer';
				delayToGetItems();
				break;
			case 'OrderShipping': //intermediate add to cart page
				tout1.enable = false;
				tout2.enable = false;
				tout2.resultType = 0; //Cross-sell
				tout2.numItems = 5;
				tout2.startPos = 1 + tout2.numItems; //second block
				tout2.caption = 'You may also like...';
				tout2.captionStyle = 'checkout-headers product4TCaption';
				inCart = true;
				break;
			case 'OrderPayment': //payment options page
				tout1.enable = false;
				tout2.enable = false;
				tout2.resultType = 2; //Blended
				tout2.numItems = 5;
				tout2.caption = 'You may also like...';
				tout2.captionStyle = 'checkout-headers product4TCaption';
				inCart = true;
				break;
			case 'OrderConfirm': //order confirmation page
				tout1.enable = false;
				tout2.enable = false;
				tout2.resultType = 2; //Blended
				tout2.numItems = 5;
				tout2.startPos = 1 + tout2.numItems; //second block
				tout2.caption = 'You may also like...';
				tout2.captionStyle = 'checkout-headers product4TCaption';
				inCart = true;
				break;
			case 'OrderComplete': //checkout complete page
				tout1.enable = false;
				tout2.enable = false;
				tout2.resultType = 2; //Blended
				tout2.numItems = 5;
				tout2.startPos = 1 + (2 * tout2.numItems); //second block
				tout2.caption = 'You may also like...';
				tout2.captionStyle = 'checkout-headers product4TCaption';
				break;
		}
		//update public variables with the new settings
		$.extend(_4TellBoost.FirstTout, tout1);
		$.extend(_4TellBoost.SecondTout, tout2);
		
		//setup toutType for GA tracking
		_4TellBoost.FirstTout.setToutType(pageType);
		_4TellBoost.SecondTout.setToutType(pageType);		
		
		return inCart;
	};

	_4TellBoost.getRatingImage = function(rating) {
		var rateVal = parseFloat(rating);
		if (isNaN(rateVal)) return ''; //not a number
		if (rateVal < 0) rateVal = 0;
		else if (rateVal > 5) rateVal = 5;
		
		var star = String(Math.floor(rateVal));
		var imagePath = 'assets/templates/common/images/star' + star + '.png';
		return imagePath;
	}; 
	
	function delayToGetItems() { //use in page settings above to delay for third-party results to load
		var delayContainer = $('#tablist');
		if (!delayContainer) return;
		
		//ananomous call-back funtion is called after delayed container changes
		_4TellBoost.DelayHandler.callback = function() {
			var toutDiv = $(_4TellBoost.DelayHandler.toutDiv);
			if (!toutDiv || !(toutDiv.length)) //see if the toutDiv is visible
				_4TellBoost.DelayHandler.ended = false;			
		};
		_4TellBoost.SiteInfo.delay = true;
		_4TellBoost.delayUntilLoaded(delayContainer);
	};


}( window._4TellBoost = window._4TellBoost || {}, jQuery )); 
//self-invoked namespace that protects $ and undefined internally


