if (typeof MY10 == "undefined" || !MY10) {
	var MY10 = {};
}



if (typeof flashpath == "undefined" || !flashpath){
	var flashpath;
}
// variables
var YUC = YAHOO.util.Connect;
var YUD = YAHOO.util.Dom; 
var YUE = YAHOO.util.Event;
var YUS = YAHOO.util.StyleSheet;

// Default values
var locale;
var market;
var market_type;
var language;
var pricing_file_ext;
var pvsView = [0];
var dwp_price;
var dwp_active;
var dwp;
var flaDwpShowPrice;

var my10Wrapper = "my10_wrapper";
var my10Container = "my10_container";
var my10SideCar = "my10_sidecar_wrapper";
var my10MarketCookie = "my10Market_";
var marketSelectorData = "marketSelectorDataContainer";
var my10CompareContainer = "my10_compare_wrapper";
var my10EstimatePaymentContainer = "my10_estimatePayment_wrapper";
var my10Loader = "my10_loader";
var my10Promos = "MY10_Promos";

// Deep Links
var isCompareDeepLink;
var isEstPayDeepLink;

// SWFAddress
var prevSWFAddress;


// set temp styles to hide main container
YUS('MY10Temp').set("#" + my10Container, {
    display : "none"
});

// locales that need a market selector
var marketSelectorLocales = ["en_xx", "en_au", "de_de", "nl_be", "fr_be", "en_aa"];

// hash table were key is locale and value
// is the market type of that locale
var localeHash = new Object();
localeHash["en_us"] = "dom";
localeHash["en_aa"] = "int";
localeHash["en_au"] = "int";
localeHash["en_ca"] = "dom";
localeHash["en_gb"] = "int";
localeHash["en_in"] = "int";
localeHash["en_xx"] = "int";
localeHash["en_zz"] = "int";
localeHash["da_dk"] = "int";
localeHash["de_de"] = "int";
localeHash["de_ch"] = "int";
localeHash["es_es"] = "int";
localeHash["es_mx"] = "dom";
localeHash["fr_be"] = "int";
localeHash["fr_ca"] = "dom";
localeHash["fr_ch"] = "int";
localeHash["fr_fr"] = "int";
localeHash["it_ch"] = "int";
localeHash["it_it"] = "int";
localeHash["nl_be"] = "int";
localeHash["no_no"] = "int";
localeHash["pt_br"] = "int";
localeHash["pl_pl"] = "int";

// market type hash
var marketTypeHash = new Object();
marketTypeHash["ca"] = "ca";
marketTypeHash["mx"] = "camx";
marketTypeHash["gb"] = "hde";
marketTypeHash["us"] = "us";
marketTypeHash["ar"] = "la";
marketTypeHash["aw"] = "la";
marketTypeHash["at"] = "hde";
marketTypeHash["bs"] = "la";
marketTypeHash["bh"] = "hde";
marketTypeHash["be"] = "hde";
marketTypeHash["bz"] = "la";
marketTypeHash["br"] = "la";
marketTypeHash["bn"] = "ap";
marketTypeHash["ky"] = "la";
marketTypeHash["cl"] = "la";
marketTypeHash["co"] = "la";
marketTypeHash["cr"] = "la";
marketTypeHash["hr"] = "hde";
marketTypeHash["cy"] = "hde";
marketTypeHash["cz"] = "hde";
marketTypeHash["dk"] = "hde";
marketTypeHash["do"] = "la";
marketTypeHash["ec"] = "la";
marketTypeHash["eg"] = "hde";
marketTypeHash["sv"] = "la";
marketTypeHash["fi"] = "hde";
marketTypeHash["fr"] = "hde";
marketTypeHash["de"] = "hde";
marketTypeHash["uk"] = "hde";
marketTypeHash["gr"] = "hde";
marketTypeHash["gu"] = "us";
marketTypeHash["gt"] = "la";
marketTypeHash["hn"] = "la";
marketTypeHash["hk"] = "ap";
marketTypeHash["hu"] = "hde";
marketTypeHash["is"] = "hde";
marketTypeHash["id"] = "ap";
marketTypeHash["ie"] = "hde";
marketTypeHash["il"] = "hde";
marketTypeHash["it"] = "hde";
marketTypeHash["jm"] = "la";
marketTypeHash["kp"] = "ap";
marketTypeHash["kw"] = "hde";
marketTypeHash["lv"] = "hde";
marketTypeHash["lu"] = "hde";
marketTypeHash["my"] = "ap";
marketTypeHash["ma"] = "hde";
marketTypeHash["nl"] = "hde";
marketTypeHash["nz"] = "aunz";
marketTypeHash["ni"] = "la";
marketTypeHash["no"] = "hde";
marketTypeHash["om"] = "hde";
marketTypeHash["pa"] = "la";
marketTypeHash["pl"] = "hde";
marketTypeHash["pt"] = "hde";
marketTypeHash["pr"] = "us";
marketTypeHash["qa"] = "hde";
marketTypeHash["ru"] = "hde";
marketTypeHash["sa"] = "hde";
marketTypeHash["sg"] = "ap";
marketTypeHash["sk"] = "hde";
marketTypeHash["si"] = "hde";
marketTypeHash["za"] = "hde";
marketTypeHash["es"] = "hde";
marketTypeHash["se"] = "hde";
marketTypeHash["ch"] = "hde";
marketTypeHash["tw"] = "ap";
marketTypeHash["th"] = "ap";
marketTypeHash["tr"] = "hde";
marketTypeHash["ae"] = "hde";
marketTypeHash["ua"] = "hde";
marketTypeHash["uy"] = "la";
marketTypeHash["ve"] = "la";
marketTypeHash["vg"] = "la";
marketTypeHash["au"] = "aunz";
marketTypeHash["ap"] = "ap";
marketTypeHash["la"] = "la";
marketTypeHash["zz"] = "hde";

// Pricing Hash
var pricingHash = new Object();
pricingHash["ca"] = "default";
pricingHash["mx"] = "default";
pricingHash["gb"] = "uk";
pricingHash["us"] = "us";
pricingHash["ar"] = "default";
pricingHash["aw"] = "default";
pricingHash["at"] = "at";
pricingHash["bs"] = "default";
pricingHash["bh"] = "default";
pricingHash["be"] = "be";
pricingHash["bz"] = "default";
pricingHash["br"] = "default";
pricingHash["bn"] = "default";
pricingHash["ky"] = "default";
pricingHash["cl"] = "default";
pricingHash["co"] = "default";
pricingHash["cr"] = "default";
pricingHash["hr"] = "default";
pricingHash["cy"] = "default";
pricingHash["cz"] = "default";
pricingHash["dk"] = "dk";
pricingHash["do"] = "default";
pricingHash["ec"] = "default";
pricingHash["eg"] = "default";
pricingHash["sv"] = "default";
pricingHash["fi"] = "default";
pricingHash["fr"] = "fr";
pricingHash["de"] = "de";
pricingHash["uk"] = "uk";
pricingHash["gr"] = "default";
pricingHash["gu"] = "default";
pricingHash["gt"] = "default";
pricingHash["hn"] = "default";
pricingHash["hk"] = "default";
pricingHash["hu"] = "default";
pricingHash["is"] = "default";
pricingHash["id"] = "default";
pricingHash["ie"] = "default";
pricingHash["il"] = "default";
pricingHash["it"] = "it";
pricingHash["jm"] = "default";
pricingHash["kp"] = "default";
pricingHash["kw"] = "default";
pricingHash["lv"] = "default";
pricingHash["lu"] = "lu";
pricingHash["my"] = "default";
pricingHash["ma"] = "default";
pricingHash["nl"] = "nl";
pricingHash["nz"] = "nz";
pricingHash["ni"] = "default";
pricingHash["no"] = "no";
pricingHash["om"] = "default";
pricingHash["pa"] = "default";
pricingHash["pl"] = "default";
pricingHash["pt"] = "default";
pricingHash["pr"] = "default";
pricingHash["qa"] = "default";
pricingHash["ru"] = "default";
pricingHash["sa"] = "default";
pricingHash["sg"] = "default";
pricingHash["sk"] = "default";
pricingHash["si"] = "default";
pricingHash["za"] = "default";
pricingHash["es"] = "es";
pricingHash["se"] = "default";
pricingHash["ch"] = "ch";
pricingHash["tw"] = "default";
pricingHash["th"] = "default";
pricingHash["tr"] = "default";
pricingHash["ae"] = "default";
pricingHash["ua"] = "default";
pricingHash["uy"] = "default";
pricingHash["ve"] = "default";
pricingHash["vg"] = "default";
pricingHash["au"] = "au";
pricingHash["ap"] = "default";
pricingHash["la"] = "default";
pricingHash["zz"] = "default";

YAHOO.util.Event.onDOMReady(function(){			
	MY10.initPage();
	
	//************************************************//
	// attach onClick methods can be removed after dev
	//************************************************//		
	YUE.addListener("specs_printable", "click", function(){
		
		var swfResults = MY10.util.getSWFAddressHash();		
		if(swfResults[0] == "model")		
			MY10.openPrintableSpecs(swfResults[1]);		
		else	
			MY10.openPrintableSpecs("xl883l");
	});
	YUE.addListener("specs_compare", "click", function(){			
		MY10.openCompareSpecs("xl883l");		
	});		
	YUE.addListener("estimate_payments", "click", function(){			
		MY10.openEstimatePayments("");		
	});	
	YUE.addListener("open_sidecar", "click", function(){			
		MY10.app.tools("tools_SC", "tle");		
	});
	if(market == 'us'){
		YUE.addListener("seoHeaderEN", "click", function(){			
			document.location = "/en_US/Content/Pages/2010_Motorcycles/2010_Motorcycles.html?locale=en_US";		
		});	
	}
	//************************************************//
	//************************************************//	
			
});

MY10 = {
	
	
	util: {
	
		getLocale : function(){
			
		},
		
		/**
		 * This method checks the current url to see if it contains a match to the 
		 * passed in name. 
		 * 
		 * @method getRequestParam
		 * @param  {String} name  the url that we are parsing
		 * @return {String}       the match
		 */
		getRequestParam : function (name) {
			if (!name) {return;}
			zname = name.replace(/\[/g,"\[").replace(/\]/g,"\]");
			var regexS = "[\\?&]"+name+"=([^&#]*)";
			var regex = new RegExp(regexS);
			var results = regex.exec(window.location.href);
			var res = results == null ? null : results[1];
			return !!res && res.match(/^(true|1)$/) ? true :
				(!!res && res.match(/^(false|0)$/) ? false : 
				(!!res && res.match(/^(null|undefined)$/) ? null : res));
		},
		
		getSWFAddressHash : function () {
			var swfAddressPath = SWFAddress.getPath();			
			if(swfAddressPath == "/" || !swfAddressPath)			
				return [null, null];						
			else
				return swfAddressPath.split("/").splice(1,2);						
		},
		/**
		 * This method gets promo content and returns variable promos for mkt / model. Returns an array of 
		 * promos in pos 0 and a boolean in pos 1 to indicate if promos were matched for a particular model.
		 * @method getPromos
		 * @param {String} model
		 * @param {String} family
		 * @return {Array} promos object, model match Boolean 
		 */
		getPromos : function (view){
			var proCountry = {};
			var changePro = true;
			var country;
			var promos;
			
			switch(view[1]){
				case pvsView[1]:
				changePro = false;
				break;
			}
			pvsView = view;
			
			//set up possible country variations
			//proCountry['aa'] = "AA"; // -- daniel
			proCountry['au'] = "AU";
			proCountry['be'] = "BE";
			proCountry['ca'] = "CA";
			proCountry['ch'] = "CH";
			proCountry['de'] = "DE";
			proCountry['es'] = "ES";
			proCountry['fr'] = "FR";
			proCountry['mx'] = "MX"; // -- daniel
			proCountry['uk'] = "GB";
			proCountry['it'] = "IT";
			proCountry['us'] = "US";
			//proCountry['zz'] = "ZZ"; // -- daniel
			
			if(!proCountry[market])
				country = "XX";
			else
				country = proCountry[market];
				
			MY10.data.promos(language,country);
			
			if(country != "US" && country != "XX"){
				switch(view[0]){
					case "family":
						promos = proOtherVars['default_family'];
					break;
					
					case "model":
						promos = proOtherVars['default_model'];
					break;
					
					case undefined || "" || null:
						promos = proOtherVars['default_family'];
					break;
				}
			}
			else if(country == "XX"){
				promos = proOtherVars['default'];			
			}
			else{
				switch(view[0]){
					case "family":
						promos = proUsVars[view[1]];
					break;
					
					case "model":
						promos = proUsVars[view[1].toUpperCase()];
					break;
					
					case undefined || "" || null:
						promos = proUsVars['default'];
					break;
				}
			}
			//load default promos for mkt if no model specific ones are available
			if(null == promos || "" == promos){
					if (country !== "US") {
						promos = proOtherVars['default'];
					}
					else {
						promos = proUsVars['default'];
					}
					changePro = false;									
			}
			return [promos,changePro];
		}
		
	}, // end util
	
	/**
	 * This method will determine whether a market selector is needed or not
	 * and in turn display the appropiate content/flash
	 * 
	 * @method initPage	  
	 * @return none 
	 */
	initPage : function() {			
		
		// get the locale param		
		if(MY10.util.getRequestParam("locale")){						
			// check if it is valid locale if not set to en_US					
			if(localeHash[MY10.util.getRequestParam("locale").toLowerCase()])
				locale = MY10.util.getRequestParam("locale").toLowerCase();
			else 
				locale = "en_us";				
		}			
		else{
			locale = "en_us";	
		}	
		
		// set location parameters
		language = locale.substring(0,2);
		if(language == "da" || language == "no" || language == "pt"){
			language = "en"
		}
		market = locale.substring(3,5);	// will get reset if in marketSelector locale					
	
		// check if the locale needs a market selector
		var displayMarketSelector = MY10.isDisplayMarketSelector(locale);
		
		// check if there is a compare deep link if so set true
		isCompareDeepLink = MY10.util.getRequestParam("compare");
		
		// check if there is a estimate payment deep link if so set true
		isEstPayDeepLink = MY10.util.getRequestParam("estPay");			
		
		//check for dwp page variable and set pricing var in flash true if regex for msrp tests out
		if(typeof dwp == "undefined" || !dwp){
			dwp = false;
			dwp_active = false;
			dwp_price = false; // set hide flag to show = yes
		}

		if(dwp){
			dwp_active = true;
			dwp_price = false;
			flaDwpShowPrice = false;
		}
		
		if(/msrp/gi.test(dwp)){
			dwp_price = true;
			flaDwpShowPrice = true;
		}
		//end dwp param set
		
		// if the locale needs a market selector display it, if not display the flash
		if(displayMarketSelector){
			var cookieValue = MY10.getMarketCookie();	
			
			if (cookieValue) {
				// remove temp styles added earlier
				YAHOO.util.StyleSheet('MY10Temp').unset("#" + my10Container, 'display');
				market = MY10.getMarketCookie(); // reset market
				market_type = marketTypeHash[market];
				pricing_file_ext = pricingHash[market];				
				MY10.initFlash(my10Container, locale);								
			}
			else {				
				// make AJAX request to get the market selector data file
				var marketSelectorFileName = "/en_US/Media/data/Apps/2010_Motorcycles/utility/marketSelector_" + locale + ".webxml";		
				YUC.asyncRequest('GET', marketSelectorFileName, getMarketSelectorDataCallback);						
			}	
			
		}
		else {	
			// set global params
			market_type = marketTypeHash[market];
			pricing_file_ext = pricingHash[market];			
			
			// check if we should open the compare bike section			
			if(isCompareDeepLink)
				MY10.openCompareSpecs("");
			else if(isEstPayDeepLink && (locale == "en_us"))
				MY10.openEstimatePayments();					
			
			// init the flash		
			MY10.initFlash(my10Container, locale);
			
			// remove the temp stylesheet
			YAHOO.util.StyleSheet('MY10Temp').unset("#" + my10Container, 'display');	
		}							
		
	}, // end initPage
	
	/**
	 * This method checks if the selected locale is a locale that
	 * needs a market selector
	 * 
	 * @method isDisplayMarketSelector
	 * @param  {String} locale  current locale
	 * @return {boolean} display marketSelector
	 */
	isDisplayMarketSelector : function(locale){
					
		for(var x=0; x < marketSelectorLocales.length; x++){			
			if(marketSelectorLocales[x] == locale.toLowerCase())	
				return true;		
		}		
		return false;
		
	}, // end isDisplayMarketSelector
	
	/**
	 * This method checks if there is cookie set to which country
	 * the user has selected
	 * 
	 * @method getMarketCookie	
	 * @return {string} cookie value
	 */
	getMarketCookie : function(){
			
		var my10Market = document.cookie.indexOf(my10MarketCookie + locale);			
		
		if(my10Market < 0)
			return null;		
		else			
			return document.cookie.substring(my10Market+17, my10Market+19);	
		
	}, // end getMarketCookie			
	
	launchBikeFinder : function(){
		
			
	},	
	
	/**
	 * initFlash runs flash detection via swfObject 2.2 and creates a page embed if successful.
	 * 
	 * @method initFlash	
	 * @param (string)el - string of HTML element to fill with embed tag 
	 * @param (string)locale - locale 
	 * @return {string} cookie value
	 */
	initFlash : function(el, locale){
						
		//YUD.get("tempLogContainer").innerHTML = "<h4><span style='color:#FF0000'>FOR DEVELOPMENT:</span> Init Flash with locale=[" + locale + "] market=[" + market + "] market_type=[" + market_type + "] Language=[" + language + "] pricingFile=[" + pricing_file_ext + "]</h4>";		
		
		var strContainerId = el;
				
		//reset page vars to match flash data semantics
		var country = market;
		
	/*
	 * flashParmHash controls flash params for problem locales
	 */
		var flashParmHash = {};
		//array order locale,market,language,country
		flashParmHash["en_gb"] = ["en_uk","uk","en","uk"];
		flashParmHash["da_dk"] = ["en_dk","hde","en","dk"];
		flashParmHash["no_no"] = ["en_no","hde","en","no"];
		flashParmHash["en_aa"] = ["en_aa","hde","en","uk"];
		flashParmHash["en_zz"] = ["en_uk","hde","en","uk"];
		
		var flMarket = "";
		var flLocale = "";
		var flCountry = "";
		var flLanguage = "";
		
		//check locale for match to hash table and reset params if found
		if(flashParmHash[locale]) {
			flMarket = flashParmHash[locale][1];
			flLanguage = flashParmHash[locale][2];
			flCountry = flashParmHash[locale][3];
			flLocale = flashParmHash[locale][0];
		}
		else{
			flMarket = market;
			flLanguage = language;
			flCountry = country;
			flLocale = locale;			
		}
		
		var dwpPrice = "no";
		//set yes no based on true (true show price / no don't hide) or false (false hide price / yes hide price)
		switch(flaDwpShowPrice){
			case true:
			dwpPrice = "no";
			break;
			
			case false:
			dwpPrice = "yes";
			break;
		}
						
		var flashvars = {
			locale: flLocale,
			market: flMarket,
			market_type: market_type,
			language : flLanguage,
			country : flCountry,
			dwp_price: dwpPrice,
			dwp : dwp_active
		};
		
		var params = {
			wmode: 'opaque',
			bgcolor: '#333333',
			allowscriptaccess: "always"
		};
		
		var attributes = {
			id: 'MY10_flash',
			name: 'MY10_flash'
		};		
		
		var path = '/en_US/Media/flash/2010_Motorcycles/MY10.swf';
		
		if (true == flashpath){
			path = 'MY10.swf';
		}
		
		//embed statement should follow the format
		//swfobject.embedSWF(swfUrl, id, width, height, version, expressInstallSwfurl, flashvars, params, attributes, callbackFn)
		swfobject.embedSWF(path, strContainerId, '812', '546', '9.0.115.0', '', flashvars, params, attributes,MY10.flashCallback);
				
	}, // end initFlash	
	/**
	 * flachCallback responds to MY10 embed method and sends in deep link for SEO pages.
	 * @param {Object} response
	 */
	flashCallback : function (response){
		
		var url = SWFAddress.getBaseURL();
		
		expFam = /family/;
		expMod = /bike/;
		
		var urlPath = url.split("/");
		
		var viewLocation = urlPath[7];
		var deepLocation = urlPath[8];
		var linkVal;
		var curPath;

		var linkHash = {};
		//default case
		linkHash['default'] = "/home/NB";
		
		//family case
		linkHash['cvo'] = "/family/CV";
		linkHash['dyna'] = "/family/DY";
		linkHash['softail'] = "/family/SO";
		linkHash['sportster'] = "/family/SP";
		linkHash['touring'] = "/family/TO";
		linkHash['trike'] = "/family/TR";
		linkHash['vrsc'] = "/family/VR";
		
		//model case -- CVO
		linkHash['cvo_fat_fob'] = "/model/fxdfse2";
		linkHash['cvo_heritage_softail_convertible'] = "/model/flstse";
		linkHash['cvo_street_glide'] = "/model/flhxse";
		linkHash['cvo_ultra_classic'] = "/model/flhtcuse5";		
		
		//model case -- DYNA
		linkHash['super_glide'] = "/model/fxd";
		linkHash['super_glide_custom'] = "/model/fxdc";
		linkHash['street_bob'] = "/model/fxdb";
		linkHash['low_rider'] = "/model/fxdl";
		linkHash['wide_glide'] = "/model/fxdwg";
		
		//model case -- SOFTAIL
		linkHash['softail_standard'] = "/model/fxst";
		linkHash['softail_custom'] = "/model/fxstc";
		linkHash['fat_boy'] = "/model/flstf";
		linkHash['softail_deluxe'] = "/model/flstn";
		linkHash['heritage_softail_custom'] = "/model/flst";
		linkHash['heritage_softail_classic'] = "/model/flstc";
		linkHash['rocker_c'] = "/model/fxcwc";
		linkHash['cross_bones'] = "/model/flstsb";
		linkHash['fat_boy_lo'] = "/model/flstfb";
		
		//model case -- SPORTSTER
		linkHash['1200_custom'] = "/model/xl1200c";
		linkHash['1200_low'] = "/model/xl1200l";
		linkHash['883_low'] = "/model/xl883l";
		linkHash['883_roadster'] = "/model/xl883r";
		linkHash['iron_883'] = "/model/xl883n";
		linkHash['nightster'] = "/model/xl1200n";
		linkHash['xr1200'] = "/model/xr1200";
		linkHash['xr1200x'] = "/model/xr1200x";
		
		//model case -- TOURING
		linkHash['road_king'] = "/model/flhr";
		linkHash['road_king_classic'] = "/model/flhrc";
		linkHash['street_glide'] = "/model/flhx";
		linkHash['road_glide_custom'] = "/model/fltrx";
		linkHash['electra_glide_standard'] = "/model/flht";
		linkHash['electra_glide_classic'] = "/model/flhtc";
		linkHash['ultra_classic_electra_glide'] = "/model/flhtcu";
		linkHash['electra_glide_ultra_limited'] = "/model/flhtk";
		
		//model case -- TRIKE
		linkHash['tri_glide_ultra_classic'] = "/model/flhtcutg";
		linkHash['street_glide_trike'] = "/model/flhxxx";
		
		//model case -- VRSC
		linkHash['v-rod'] = "/model/vrscaw";
		linkHash['night_rod_special'] = "/model/vrscdx";
		linkHash['v-rod_muscle'] = "/model/vrscf";
		
        if (expFam.test(viewLocation) || expMod.test(viewLocation)) {
            linkVal = linkHash[deepLocation.split(".")[0]];
            if (undefined === linkVal || false === linkVal) {
                linkVal = linkHash["default"];
            }
        }
		
		curPath = SWFAddress.getPath();
		
		switch(curPath){
			case "/":
				SWFAddress.setValue(linkVal);
			break;	
		}
		
		//check for DWP before promo init, and display static promo if necessary
		switch(dwp_active){
			case true:
			var dealerId = MY10.util.getRequestParam("dwp_dealerid");
			
			var strPromo = '<img id="dwp_promo" border="0" src="/en_US/Media/images/Apps/2010_Motorcycles/promos/img_dwp_promos_2.jpg" alt="Contact Us For Additional Information"/>';
			YUD.get('my10_promos').innerHTML = strPromo;
			
			YUE.onAvailable('dwp_promo',function(){
				YUS('dwp_active').set("#" + 'dwp_promo', {
				    cursor : "pointer"
				});
				YUE.addListener('dwp_promo','click',function(){
					var url =  "/wcm/Content/Pages/2010_Motorcycles/dwp_2010_form.jsp?locale=en_US&dwp_dealerid=" + dealerId + "&dwp_pg=nb_model";
					//window.open (url,"dwp_contact","location=0,scrollbars=0,toolbar=0,menubar=0,resizable=0,width=500,height=600");
					document.location.href = url;
				});
			});
			
			break;
			case false:
			//call promo flash
			MY10.initPromos();
			break;
		}
		
	},
	/**
	 * This method initializes the promo flash. Also set up a listener to re-init promos based on app view state changes
	 * @method initPromos
	 * @param {Boolean} init controls whether method acts as init or callback
	 */
	initPromos : function (initSwitch){
		
		var strContainerId = "my10_promos";
		
		var flashvars = {};		
		
		var params = {
			wmode: 'opaque',
			bgcolor: '#333333',
			allowscriptaccess: "always"
		};
		
		var attributes = {
			id: 'MY10_Promos',
			name: 'MY10_Promos'
		};		
		
		var path = '/en_US/Media/flash/2010_Motorcycles/MY10_Promos.swf';
		
		//embed statement should follow the format
		//swfobject.embedSWF(swfUrl, id, width, height, version, expressInstallSwfurl, flashvars, params, attributes, callbackFn)
		
		swfobject.embedSWF(path, strContainerId, '817', '100', '9.0.115.0', '', flashvars, params, attributes);
		SWFAddress.addEventListener(SWFAddressEvent.CHANGE, MY10.app.updatePromos);
		return "init complete";
			
	},
	/**
	 * initNav runs flash embed code for page navigation.
	 */
	initFlashNav : function(){
		var hd_globalnav_0 = new SWFObj("globalnav_0_container","nav_EX_intl","/swf/","5","213","700","gray",false,"playerProductInstall","213","700"); 
		hd_globalnav_0.setAttribute("FlashVars","section=0&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_0.setAttribute("srcVars","section=0&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_0.setAttribute("style","z-index:10"); 
		hd_globalnav_0.outputHTML();
		document.getElementById("globalnav_0_container").style.visibility = "visible"; 
		postDetectionResults(hd_globalnav_0);
		
		var hd_globalnav_1 = new SWFObj("globalnav_1_container","nav_EX_intl","/swf/","5","213","700","gray",false,"playerProductInstall","213","700"); 
		hd_globalnav_1.setAttribute("FlashVars","section=1&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_1.setAttribute("srcVars","section=1&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_1.setAttribute("style","z-index:10"); 
		hd_globalnav_1.outputHTML();
		document.getElementById("globalnav_1_container").style.visibility = "visible"; 
		
		var hd_globalnav_2 = new SWFObj("globalnav_2_container","nav_EX_intl","/swf/","5","213","700","gray",false,"playerProductInstall","213","700"); 
		hd_globalnav_2.setAttribute("FlashVars","section=2&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_2.setAttribute("srcVars","section=2&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_2.setAttribute("style","z-index:10"); 
		hd_globalnav_2.outputHTML();
		document.getElementById("globalnav_2_container").style.visibility = "visible"; 
		
		var hd_globalnav_3 = new SWFObj("globalnav_3_container","nav_EX_intl","/swf/","5","213","700","gray",false,"playerProductInstall","213","700"); 
		hd_globalnav_3.setAttribute("FlashVars","section=3&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_3.setAttribute("srcVars","section=3&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_3.setAttribute("style","z-index:10"); 
		hd_globalnav_3.outputHTML();
		document.getElementById("globalnav_3_container").style.visibility = "visible"; 
		
		var hd_globalnav_4 = new SWFObj("globalnav_4_container","nav_EX_intl","/swf/","5","213","700","gray",false,"playerProductInstall","213","700"); 
		hd_globalnav_4.setAttribute("FlashVars","section=4&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_4.setAttribute("srcVars","section=4&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_4.setAttribute("style","z-index:10"); 
		hd_globalnav_4.outputHTML();
		document.getElementById("globalnav_4_container").style.visibility = "visible"; 
		
		var hd_globalnav_5 = new SWFObj("globalnav_5_container","nav_EX_intl","/swf/","5","213","700","gray",false,"playerProductInstall","213","700"); 
		hd_globalnav_5.setAttribute("FlashVars","section=5&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_5.setAttribute("srcVars","section=5&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_5.setAttribute("style","z-index:10"); 
		hd_globalnav_5.outputHTML();
		document.getElementById("globalnav_5_container").style.visibility = "visible"; 
		
		var hd_globalnav_6 = new SWFObj("globalnav_6_container","nav_EX_intl","/swf/","5","213","700","gray",false,"playerProductInstall","213","700"); 
		hd_globalnav_6.setAttribute("FlashVars","section=6&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_6.setAttribute("srcVars","section=6&bmLocale=en_US&id=0901473080648a64&tStamp=" + sTimestamp); 
		hd_globalnav_6.setAttribute("style","z-index:10"); 
		hd_globalnav_6.outputHTML();
		document.getElementById("globalnav_6_container").style.visibility = "visible";
		
	},

	/**
	 * This method will open up the printable specs popup 
	 * 
	 * @method openPrintableSpecs	
	 * @return none
	 */
	openPrintableSpecs : function(model){
		var params = "width=628, height=650, scrollbars=yes";	
		var url = "/en_US/Media/data/Apps/2010_Motorcycles/html/specs/printable_specs.html?model=" + model; 
		url	+= "&lang=" + language + "&market=" + market + "&market_type=" + market_type ;
		url	+= "&pricingExt=" + pricing_file_ext + "&dwp_price=" + dwp_price; 
		window.open(url,'', params);		
	}, // end openPrintableSpecs
	
	/**
	 * This method will open up the compare specs popup 
	 * 
	 * @method openCompareSpecs	
	 * @return none
	 */
	openCompareSpecs : function (model) {			
		MY10.openLoader();			
		MY10.initCompare(model);
		HD.util.Analytics.track();
		MY10.hbx.track.generateHbxCode("comparebikes", "", model);					
		
	}, // end openCompareSpecs
	
	/**
	 * This method close the compare overlay when the 
	 * actual browser back button is clicked
	 * 
	 * @method closeCompareSpecs	
	 * @return none
	 */
	closeCompareSpecs: function(e){
		YUD.setStyle(my10CompareContainer, "display", "none");
		YUD.setStyle(my10Wrapper, "display", "block");
		window.parent.closeCompare();
		MY10.compareSpecs.resetPageData();		
	}, // end compare listener
	
	/**
	 * This method will write the estimate payments display 
	 * to the DOM
	 * 
	 * @method writeEstimatePayment	
	 * @return none
	 */
	writeEstimatePayment: function(){		
		var src  = "/wcm/en_US/Content/Layouts/Pages/payment_estimator/PE_MY10.jsp?locale=en_US";
		var html = '<iframe id="estimatePaymentIframe" src="' + src + '" height="1240px" width="812px" frameborder="0" scrolling="no"></iframe>';
		
		// write to DOM
		YUD.get('my10_estimatePayment_wrapper').innerHTML = html;
		
		// since we don't have a handle on when the iFrame finishes loading
		// we will set a timeout before we remove the overlay
		window.setTimeout(function(){			
			MY10.closeLoader();
			YUD.setStyle(my10EstimatePaymentContainer, "display", "block");
		},3000);
		MY10.hbx.track.generateHbxCode("estimator");
	}, // end writeEstimatePayment
	
	/**
	 * This method will open up the estimate payments display 
	 * 
	 * @method openEstimatePayments	
	 * @return none
	 */
	openEstimatePayments : function (model) {			
		YUD.setStyle(my10Wrapper, "display", "none");// hide MY10 Flash	
		MY10.openLoader(); // open the loader overlay		
		MY10.writeEstimatePayment(); // write the estimate payment text	
	}, // end openEstimatePayments
	
	/**
	 * This method will close the estimate payments display
	 * and open the flash 
	 * 
	 * @method closeEstimatePayments	
	 * @return none
	 */
	closeEstimatePayments: function(){
		YUD.setStyle(my10EstimatePaymentContainer, "display", "none");	
		YUD.setStyle(my10Wrapper, "display", "block");		
	}, // end backEstimatePayments
	
	/**
	 * This method get the sidecar HTMl based on the args
	 * passed to the method, write the HTML into the page
	 * and init it
	 * 
	 * @method openSideCar	
	 * @param args - sidecar type
	 * @return none
	 */
	openSideCar: function(args){		
		YUD.setStyle(my10Wrapper, "display", "none"); // hide MY10 flash
		MY10.openLoader(); // open the loader overlay
		
		// sidecar base url
		var getURL = "/en_US/Media/data/Apps/2010_Motorcycles/html/sidecar/";
		
		// determine which sidecar to get
		if("tle" == args)
			getURL += "tleSidecar.html";
		else
			getURL += "tleUltraSidecar.html";
		
		// make ajax call to get sidecar html
		YUC.asyncRequest('GET', getURL, {
			success: function(o){
				YUD.get(my10SideCar).innerHTML = o.responseText;					
				YUE.onContentReady(my10SideCar, function(){
					SC.util.pageLoad();									
					YUD.setStyle(my10SideCar, "display", "block");
					MY10.closeLoader(); // close the loader overlay
					
					YUE.onContentReady("close", function(){
						YUE.addListener("close", "click", function(){										
							MY10.closeSideCar();	
						});						
					});
					
				});								
			}, 
			failure: function(o){
				// failure code
			}
		}, null);			
				
	}, // end openSidecar
	
	/**
	 * This method close the side car
	 * overlay
	 * 
	 * @method closeSideCar		
	 * @return none
	 */
	closeSideCar: function(){
		YUD.setStyle(my10SideCar, "display", "none");
		YUD.setStyle(my10Wrapper, "display", "block");
	},
	
	/**
	 * This method get the html content, via AJAX, of the compare bikes page
	 * and write it into the 2010 motorcyles page, and init the compare
	 * that content
	 * 
	 * @method initCompare	
	 * @return none
	 */
	initCompare: function(model){
		//compare bikes URL
		var getURL = "/en_US/Media/data/Apps/2010_Motorcycles/html/specs/compare_specs.html";
	
		// make ajax call to get compare html
		YUC.asyncRequest('GET', getURL, {
			success: function(o){
				YUD.get(my10CompareContainer).innerHTML = o.responseText;					
				YUE.onContentReady(my10CompareContainer, function(){					
					MY10.compareSpecs.init(model);	
					YUD.setStyle(my10Wrapper, "display", "none");									
				});								
			}, 
			failure: function(o){
				// failure code
			}
		}, null);		
	}, // end initCompare
	
	/**
	 * This method will open loader 
	 * 
	 * @method openLoader	 
	 */
	openLoader: function(){					
		loaderOpen = true;		
		YUD.setStyle(my10Promos, 'display', 'none');
		YUD.setStyle(my10Loader, 'display', 'block');				
	}, // end openLoader	
	
	/**
	 * This method will close loader 
	 * 
	 * @method closeLoader	 
	 */
	closeLoader: function(){					
		loaderOpen = false;
		YUD.setStyle(my10Loader, 'display', 'none');
		YUD.setStyle(my10Promos, 'display', 'block');								
	}, // end closeLoader
	
	/**
	 * This method preload images
	 * 
	 * @method preloadImages	
	 * @return none
	 */
	preloadImages: function(){
		compareBkg = new Image();
		compareBkg.src = "/en_US/Media/images/Apps/2010_Motorcycles/specs/bkg_compare_data.gif";
		compareHdr = new Image();
		compareHdr.src = "/en_US/Media/images/Apps/2010_Motorcycles/specs/bkg_compare_header.jpg";
		compareBlankImg = new Image();
		compareBlankImg.src = "/en_US/Media/images/Apps/2010_Motorcycles/specs/empty_dom_c01_sws_s.jpg";
		compareRowBkg = new Image();
		compareRowBkg.src = "/en_US/Media/images/Apps/2010_Motorcycles/specs/bkg_dataRowHdr.gif";		
		sideCarBkg = new Image();
		sideCarBkg.src = "/en_US/Media/images/Apps/2010_Motorcycles/sidecar/pnw_sidecar_bkgd.jpg";
		loaderImg = new Image();
		loaderImg.src = "/en_US/Media/images/Apps/2010_Motorcycles/shared/my10_loader.gif";		
	}	
	
};

/**
 * callback method for getting the market selector data file and writing
 * it into the container page
 */
var getMarketSelectorDataCallback = {	
	success: function(o){		
		
		YUE.onAvailable("marketSelector", function(){
						
			YUE.addListener("marketSelector", "change", function(){
				document.cookie = my10MarketCookie + locale + "=" + this.value;
				market = this.value; // reset market
				market_type = marketTypeHash[this.value];
				pricing_file_ext = pricingHash[market];								
				MY10.initFlash(my10Container, locale);
			});
			
		});
		
		YUD.get(my10Container).innerHTML = o.responseText;
			
		// remove temp styles added earlier
		YAHOO.util.StyleSheet('MY10Temp').unset("#" + my10Container, 'display');			
			
	},
	failure: function(o){
		// set failure logic if needed	
	}	
};

// Preload Images
MY10.preloadImages();
