// --------------------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------------------
// behaviours - Detect version of flash and prepare images for carousels as steria need dynamic images for flash;
// depends: 	jQuery library;
// author:		ah;
// --------------------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------------------

// -- define namespace;
if (typeof Barclaycard !== 'object') var Barclaycard={};

Barclaycard.detectFlash = new (function(){
	
	this.version = function(flashObj) {
	
		var ver = deconcept.SWFObjectUtil.getPlayerVersion();
	
		if (ver["major"] < flashObj.getAttribute('version').major) return false;
		if (ver["major"] > flashObj.getAttribute('version').major) return true;
		if (ver["minor"] < flashObj.getAttribute('version').minor) return false;
		if (ver["minor"] > flashObj.getAttribute('version').minor) return true;
		if (ver["rev"] < flashObj.getAttribute('version').rev) return false;
		return true;
		
	};
	
	this.prepareImages = function(elem) {

		// steria patch, to swap in flash images
		$("div#" + elem + " ul.itemList img").each(function(){
			var src = $(this).attr('src');							
			
			// FOR STERIA								
			//$(this).attr('src', src + '_FLASH');
			
			// TO RUN LOCALLY
			var index = src.lastIndexOf('/');
			$(this).attr('src', src.substring(0,index + 1) + src.substring(index + 1));
		
		});			
		
	};
	
	this.prepareLinks = function(elem) {
		// prepare links to open new windows from within flash
		$("div#" + elem + " a.newSizedWindow").each(function(){
			var url = $(this).attr('href');
			$(this).attr('href',"javascript: Barclaycard.newWindow.openWindow('"+ url +"');");
			$(this).removeAttr('target');
		});		
		
	};
	
	this.prepareStandardLinks = function(elem) {
		// prepare links to open new windows from within flash
		$("div#" + elem + " a.newStandardWindow").each(function(){
			var url = $(this).attr('href');
			$(this).attr('href',"javascript: Barclaycard.newWindow.openStandardWindow('"+ url +"');");
			$(this).removeAttr('target');
		});		
		
	};
	

});

// --------------------------------------------------------------------------------------------------------------------------------
// --- end of file --- 
// -------------------------------------------------------------------------------------------------------------------------------
