<!--
var _default_promo = "228937";
var baseURL= "https://webreg.aol.co.uk/narrowband/NBWebReg";
var bbmsURL= "https://bbms.aol.co.uk/webreg/startOrder!execute.action?isRunningFitTest=no";
var bbmsURLSilver= "https://bbms.aol.co.uk/webreg/startOrder!execute.action?bb=170&isRunningFitTest=no";
var bbmsURLGold= "https://bbms.aol.co.uk/webreg/startOrder!execute.action?bb=175&isRunningFitTest=no";
var bbmsURLPlatinum= "https://bbms.aol.co.uk/webreg/startOrder!execute.action?bb=160&isRunningFitTest=no";
var bbmsURLSwitch= "https://bbms.aol.co.uk/webreg/startOrder!execute.action?sw=y&isRunningFitTest=no";
function getParam (key, loc){

	var result ="";
	if(!loc) loc = parent.location.href;

	if(loc.indexOf('?') != -1){

		param = loc.split('?');
		var arguments = new Array;
		arguments = param[1].split('&');

		var upper_limit =arguments.length;
		for(x =0; x<upper_limit;x++){
			var holder = new Array;
			holder = arguments[x].split('=');
			var a = unescape(holder[0]);
			var b = unescape(holder[1]);
			if(a== key)	
			{
			result=b;
			}

		}

	}

	return result;
}

function validate_promo (promo) {
	//promo must be 7 numerics
	var numerics ="0123456789";
	var promo_length = 6;
	
	if(!promo) return;	//not received a promo

	if( promo.length == promo_length){
		//alert(promo.length);
		for(x=0; x < promo_length; x++){

			if( numerics.indexOf( promo.charAt(x) ) < 0 ){
				//non numeric
				return 0;
			}
		}
	
		return 1;
	}
		//alert('here 1');
	return 0;
}

function _getPromo () {

	var promo = getParam('promo'); //get the promo passed to this page
	if(!promo) {
		//try promoCode instead		
		promo = getParam('promoCode');
	}
	if(!promo) {
		//if not there try to get referrer		
		promo = getParam('promo', document.referrer);
	}
	if(promo.indexOf('#') >-1){
		promo= promo.substring(0,promo.indexOf('#'));
	
	}
	if(!promo){
	//set the default promo
	promo = _default_promo;
	}
	
	return promo;
}

function _setLinks() {
	var anchors = document.links;	
	var promo = _getPromo();	
	if(promo)
	{
		for (x =0; x< anchors.length; x++)
		{
			var current_loc = anchors[x].getAttribute('href');

			if(current_loc.indexOf(bbmsURLSilver) == 0)
			{
				anchors[x].setAttribute("href",bbmsURLSilver+"&promoCode="+promo);
			}
			else if(current_loc.indexOf(bbmsURLGold) == 0)
			{
				anchors[x].setAttribute("href",bbmsURLGold+"&promoCode="+promo);
			}
			else if(current_loc.indexOf(bbmsURLPlatinum) == 0)
			{
				anchors[x].setAttribute("href",bbmsURLPlatinum+"&promoCode="+promo);
			}
			else if(current_loc.indexOf(bbmsURLSwitch) == 0)
			{
				anchors[x].setAttribute("href",bbmsURLSwitch+"&promoCode="+promo);
			}
			else if(current_loc.indexOf(bbmsURL) == 0)
			{
				anchors[x].setAttribute("href",bbmsURL+"&promoCode="+promo);
			}
			else if( (current_loc)
					&& (current_loc.indexOf('javascript:') < 0 )    /*not a javascript function */
					&& (current_loc.indexOf('#') < 0)				/*not an internal link */
					&& (current_loc.indexOf('tradedoubler') < 0)				/*not an internal link */
					&& (current_loc.indexOf(baseURL) < 0)			/*not a register link */
					&& (current_loc.indexOf('promo=') < 0)			/*not already a promo link */
					&& (current_loc.indexOf('deeplink=') < 0)		/*not already a promo link */
					&& (current_loc.indexOf('aol:') < 0)			/*not an aol link */
					&& (current_loc.indexOf('atwola') < 0)			/*not an ads server link */
					&& (current_loc.indexOf('@')< 0)        		/*not a mailto link*/	
					&& (current_loc.indexOf('/shop') <0 )){			/*not a shop@ url */
									
				//set the link URL to include the promo
				anchors[x].setAttribute("href", current_loc+"?promo="+promo+"&promoCode="+promo);

			}
			else if(current_loc.indexOf(baseURL) == 0)
			{
				anchors[x].setAttribute("href",current_loc+"?promo="+promo);
			}
		}
	}
}



function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=360');");
}
function popTalk(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=420');");
}
// End -->
