var $j = jQuery.noConflict();
	
$j(window).load(function(){
	var productBanner = new ProductBanner();
});

/**************************************************************
PRODUCTBANNER // CLASS
**************************************************************/
function ProductBanner(){ 
	
	var flashBannerContent = $j('#flashBannerContent');
	var generalDictionnary = new Object();
	var indexList = new Array(2,3,4,5,9,6);
	init();
	
	/*-------------------------------------------------------------
	init - private //  
	-------------------------------------------------------------*/
	function init(){
		flashBannerContent.show();
		prepareDictionnary(flashBannerContent.attr('lang'));
		
		var index = flashBannerContent.attr('index');
		if(index == 11) return;
		flashBannerContent.html('');
		if(index == -1){
			var defaultQuote = flashBannerContent.attr('defaultQuote');
			createBanner(index, defaultQuote);
		}else{
			assocIndex = findCorrectIndex(index);
			createBanner(assocIndex, "No quote");
		}
	}
	
	/*-------------------------------------------------------------
	prepareDictionnary - private //  
	-------------------------------------------------------------*/
	function prepareDictionnary(lang){
		if(lang == "en"){
			generalDictionnary.videoButton = "Installation \nvideos";
			generalDictionnary.menuListNames = "pavers,slabs,walls,edges,carved imagery,masonry";
			generalDictionnary.videoButtonLink = "http://www.techo-bloc.com/contractors/videos-list.php";
			
			generalDictionnary.catalogButton = "Online \nCatalog";
			generalDictionnary.catalogButtonLink = "http://techo-bloc.com/contractors/index.php?p=Catalog&lang=EN&rr=1";			
			
		}
		if(lang == "fr"){
			generalDictionnary.videoButton = "Vidéos \nd'installations";
			generalDictionnary.menuListNames = "pavés,dalles,murets,bordures,pierres gravées,maçonnerie";
			generalDictionnary.videoButtonLink = "http://www.techo-bloc.com/contractors/videos-list-fr.php";
			
			generalDictionnary.catalogButton = "\nCatalogue";
			generalDictionnary.catalogButtonLink = "http://techo-bloc.com/contractors/index.php?p=Catalog&lang=FR&rr=1";
			
			
		}
	}
	
	/*-------------------------------------------------------------
	findCorrectIndex - private //  
	-------------------------------------------------------------*/
	function findCorrectIndex(rawIndex){
		for(var x=0; x<indexList.length; x++){
			if(rawIndex == indexList[x]){
				return x;
			}
		}
	}
	
	/*-------------------------------------------------------------
	createBanner - private //  
	-------------------------------------------------------------*/
	function createBanner(index, defaultQuote){
		flashBannerContent.append('<td width="777"><div id="contentFlash"></div></td>');
		var so = new SWFObject("../flash/banner/swf/banner.swf" , "flashVideo","777","336", "9", "#FFFFFF", "false");
		so.addParam("menu", "false");
		so.addParam("allowScriptAccess", "always");
		so.addVariable("menuListNames", generalDictionnary.menuListNames);
		so.addVariable("menuListLinks", "index.php?p=Products%26e=view%26categoryId=2,index.php?p=Products%26e=view%26categoryId=3,index.php?p=Products%26e=view%26categoryId=4,index.php?p=Products%26e=view%26categoryId=5,index.php?p=Products%26e=view%26categoryId=9,index.php?p=Products%26e=view%26categoryId=6");
		so.addVariable("currentIndex", index);
		so.addVariable("defaultQuote", defaultQuote);
		so.addVariable("videoButton", generalDictionnary.videoButton);
		so.addVariable("videoButtonLink", generalDictionnary.videoButtonLink);
		so.addVariable("catalogButton", generalDictionnary.catalogButton);
		so.addVariable("catalogButtonLink", generalDictionnary.catalogButtonLink);		
		so.addVariable("xmlPath", "../flash/banner/xml/imgPaths.xml");
		so.write("contentFlash");
		flashBannerContent.append('<div id="debug" style="display:none;">'+index+'</div>');
	}
}

