/*
	the Orange shop
	AKQA Analyst Tracking


	functions
		isCatalog(Section)
		isExtra(Section)
		getSection()
		getSubSection()
		containsPath(ValueIfFalse, ValueIfTrue, LookInPath, ArrayOfPaths)

	Developed by Stephen Brown, SDB, stephen.brown@akqa.com
	1st December 2004
*/
function isGateway(Section) {
	if (Section == 'homepage' ||
		Section == 'landing') {
		return true;
	}
	return false;
}
function isOffer(Section) {
	if (Section == 'offers') {
		return true;
	}
	return false;
}
function isYourPlan(Section) {
	if (Section == 'devices' ||
		Section == 'yourplan') {
		return true;
	}
	return false;
}
function isPayment(Section) {
	if (Section == 'payment') {
		return true;
	}
	return false;
}
function isBasket(Section) {
	if (Section == 'basket') {
		return true;
	}
	return false;
}
function isStoreLocator(Section) {
	if (Section == 'stores') {
		return true;
	}
	return false;
}

function getSection(Section) {
	var strPath = document.location.pathname;
	var sSection = '';

	// HOME
	sSection = containsPath(sSection, 'homepage', strPath, new Array('/index'));
	// LANDING
	sSection = containsPath(sSection, 'landing', strPath, new Array('/phones','/plans','/upgrade','/help','/accessories'));
	// OFFERS
	sSection = containsPath(sSection, 'offers', strPath, new Array('/offer'));
	// DEVICES
	sSection = containsPath(sSection, 'devices', strPath, new Array('/handset'));
	// YOURPLAN
	sSection = containsPath(sSection, 'yourplan', strPath, new Array('/buildyourplan','/premier','/yourplan','/processyourplan'));
	// PAYMENT
	sSection = containsPath(sSection, 'payment', strPath, new Array('/payment'));
	// BASKET
	sSection = containsPath(sSection, 'basket', strPath, new Array('/basket'));
	// CONFIRMATION
	sSection = containsPath(sSection, 'confirmation', strPath, new Array('/payment/thankyou'));
	// STORES
	sSection = containsPath(sSection, 'stores', strPath, new Array('/store'));

	// REMOVING SUB PAGES WHERE NECESSARY
	sSection = containsPath(sSection, '', strPath, new Array('/accessories/'));

	return sSection;
}

function getSubSection() {
	var strPath = document.location.pathname;
	var sSection = 'none';

	// ERRORS
	sSection = containsPath(sSection, 'shop errors', strPath, new Array('/failure','/toomanyphones','/iteminbasketnotinstock','/paymnentsessiontimedout','/yourplansessiontimedout'));
	// TERMS AND CONDITIONS
	sSection = containsPath(sSection, 'terms and conditions', strPath, new Array('/terms'));
	// STORES
	sSection = containsPath(sSection, 'stores', strPath, new Array('/store'));
	// PAYMENT
	sSection = containsPath(sSection, 'payment', strPath, new Array('/payment'));
	// CONTACT
	sSection = containsPath(sSection, 'contact', strPath, new Array('/contact'));
	// YOURPLAN
	sSection = containsPath(sSection, 'yourplan', strPath, new Array('/buildyourplan','/yourplan','/processyourplan'));
	sSection = containsPath(sSection, 'premier', strPath, new Array('/premier'));
	// PAY AS YOU GO
	sSection = containsPath(sSection, 'pay as you go', strPath, new Array('/pay_as_you_go','/payg','/text_saver','/talk_saver','/sim_connection','/proposition_popup'));
	// PLANS
	sSection = containsPath(sSection, 'plans', strPath, new Array('/plans','/3g_plans','/all_plans','/all_payg_plans'));
	// PHONES & DEVICES
	sSection = containsPath(sSection, 'phones and devices', strPath, new Array('/phones','/shopfront','/handset','/compatiblehandset'));
	// UPGRADES
	sSection = containsPath(sSection, 'upgrades', strPath, new Array('/upgrade'));
	// HOLOMATIX
	sSection = containsPath(sSection, 'holomatix', strPath, new Array('/holomatix'));
	// BASKET
	sSection = containsPath(sSection, 'basket', strPath, new Array('/basket'));
	// ACCESSORIES
	sSection = containsPath(sSection, 'accessories', strPath, new Array('/accessories','/data_products'));
	// HELP
	sSection = containsPath(sSection, 'help', strPath, new Array('/help','/lost_your_phone','/safer_driving','/businessstandards','/switch'));
	// OFFERS
	sSection = containsPath(sSection, 'offers', strPath, new Array('/offer','/accessory_offers'));
	// BUY OTHER
	sSection = containsPath(sSection, 'buy', strPath, new Array('/buy'));
	// HOME
	sSection = containsPath(sSection, 'homepage', strPath, new Array('/index'));
	sSection = containsPath(sSection, 'homepage', strPath, new Array('shop/','index/'), true);
	// JSP REDIRECTOR
	sSection = containsPath(sSection, 'jsp redirect', strPath, new Array('/redirect'));
	// OTHER HTML
	sSection = containsPath(sSection, 'html', strPath, new Array('.html'));

	return sSection;
}

function containsPath(returnFalse, returnTrue, strPath, tempArray, exactMatch) {
	for (var i=0; i<tempArray.length; i++) {
		if (exactMatch) {
			if (strPath.lastIndexOf("/") != -1 && strPath.toLowerCase().substring(strPath.lastIndexOf("/")) == tempArray[i].toLowerCase()) {
				return returnTrue;
			}
		} else if (strPath.toLowerCase().indexOf(tempArray[i].toLowerCase()) != -1) {
			return returnTrue;
		}
	}
	return returnFalse;
}