window.name="aboutBQ";

window.addEvent('domready',function() {
	var randomNum = $random(1,20);
	$('didYouKnow').getElements('span.bubble').setStyle('background-image', 'url(/diy/jsp/corporate/images/footer/bubble'+randomNum+'.png)');

	var accessCopy = ['',
					  'B&amp;Q employs over 30,000 people',
					  'We have 321 stores in the UK and 9 in Ireland',
					  'Our eldest employee is 95',
					  'B&amp;Q was founded by Richard Block &amp; David Quayle'	,
					  'Our first store opened in 1969 in Portswood Road, Southampton',
					  'B&amp;Q is listed in The Times Top 50 places for women to work',
					  'More than 60% of B&Q staff work flexible hours',
					  'We are a founder member of the Employers Forum for Age',
					  'We offer a grant to community groups',
					  'We have an eco-store at New Malden, Surrey',
					  'We have a range of eco products named One Planet Home',
					  'We offer a Diamond Discount card to customers aged over 60',
					  'B&amp;Q employs more than 30,000 people',
					  'We have introduced furniture to our range',
					  'We run a diy skills programme for schools called Job Done!',
					  'We are the largest home improvement retailer in the UK',
					  'Our eldest apprentice is 70 years old',
					  'More than a quarter of our staff are over 50',
					  'We stock more than 40,000 products in store',
					  'We are the largest home improvement retailer in Europe'
					  ];
	
	$('didYouKnow').getElements('span.access').set('html', accessCopy[randomNum]);
});

window.onload = function() {
	if(!document.getElementsByTagName) return false;
	
	var linksArray = document.getElementsByTagName("a");
	
	var winName = "popup";
	var features = "scrollbars=yes, resizable=yes";
	var width = 800;
	var height = 600;
	
	for (var i=0; i < linksArray.length; i++) {
		if (linksArray[i].className.match("defaultPopup")) {
			linksArray[i].onclick = function() {
				openPopup(this.href, winName, features, width, height);	
				return false;
			}
		}  else	if (linksArray[i].className.match("newWindow")) {
			linksArray[i].onclick = function() {
				winName = "BQ";
				features = "toolbar=yes, location=yes, status=yes, scrollbars=yes, resizable=yes";
				width = 1024;
				height = 768;
				openPopup(this.href, winName, features, width, height);
				return false;
			}
		}
	}
};
function openPopup(u, n, f, w, h) {
	windowOpen = window.open(u, n, f + ", width=" + w + ", height=" + h);
	windowOpen.focus();
	return windowOpen;
};

window.addEvent('domready', function(){
	var myAccordion = new Accordion($('dropdown-container'), 'a.dropdown-toggle', 'div.dropdown-content', {
		alwaysHide: true,
		onActive: function(toggler) {
			toggler.getParent('li').addClass('open');
			
			var hasClass = toggler.getParent('ul').hasClass('read-more-js-generic');
			if (hasClass) {
				toggler.getFirst('span').set('text', 'Close');
			}
		},
		onBackground: function(toggler) {
			toggler.getParent('li').removeClass('open');
			var hasClass = toggler.getParent('ul').hasClass('read-more-js-generic');
			if (hasClass) {
				toggler.getFirst('span').set('text', 'Read more...');
			}
		}
	});  
});
