/* Promo Toolkit behaviour
swapImage and restoreImage apply to the start page, from where the Toolkit is loaded
other functions deal with behaviour in the Tooolkit eg tabbed browsing
*/


var pT = { //promoToolkit

	addEvent: function(elm, evType, fn, useCapture) {
	// cross browser event handling
	if (elm.addEventListener) {
	elm.addEventListener(evType, fn, useCapture);
	return true;
	} else if (elm.attachEvent) {
	var r = elm.attachEvent('on' + evType, fn);
	return r;
	} else {
	elm['on' + evType] = fn;
	}
},

init: function() {
	
	if (!document.getElementsByTagName || !document.getElementById) return;
	pT.teaserUl = document.getElementById('toolkitIcons')
	var anchor_list = pT.teaserUl.childNodes;
	for (var i =0; i <anchor_list.length; i++) {
		//var anchor = anchor_list[i];
		//if (anchor.className && (' ' + anchor.className + ' ').indexOf(' ptTeaser ') != -1) {
	pT.addEvent(anchor_list[i], 'mouseover', pT.swapImage, false);
	pT.addEvent(anchor_list[i], 'mouseout', pT.restoreImage, false);		
	}

},
tabs: function(e) {
	alert("it works");
},
swapImage: function(e) {

	var el = window.event ? window.event.srcElement : e ? e.target : null;
	if (el.nodeType==3) {
		el = el.parentNode;	// Safari fix
	}	
	
	var ul = pT.teaserUl 
	var imageName = el.id

	var imageUrl = 	"url('/ukt/i/j/catalogue/general/" + imageName + "Teaser.jpg') 97% top no-repeat"
	ul.style.background = imageUrl;
	el.title = "Browse " + imageName + " in catalogue popup window"
},
restoreImage: function(e) {

	var el = window.event ? window.event.srcElement : e ? e.target : null;
	var ul = pT.teaserUl 
	var imageUrl = 	"url('/ukt/i/j/catalogue/general/promosTeaser.jpg')"
	ul.style.backgroundImage = imageUrl;
}
};
pT.addEvent(window, 'load', pT.init, false);
