/**
 * @classDescription Implements the flash gadget
 * @author lucas.gunn
 */

(function() {
	// Flash loader
	var loader = window.rfQS_FlashLoader = {
		id: '',
		insertBox: document.getElementById('rfQS_Insert'),
		swfURL: 'http://gadgets.roamfree.com/general-qs/flash/1.0/general-aff-gadget.swf',
		
		init: function() {
			var flashHTML = 
				'<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://macromedia.com/cabs/swflash.cab#version=7,0,0,0"\n'+   
				'  ID=rfQS_flaMovie WIDTH=220 HEIGHT=160>\n'+
				'  <PARAM NAME=movie VALUE="'+this.swfURL+'">\n'+
				'  <PARAM NAME=FlashVars VALUE="webID=' + this.id +'">\n'+
				'  <EMBED src="'+this.swfURL+'" FlashVars="webID=' + this.id +'"\n'+
				'    WIDTH=220 HEIGHT=160 \n'+
				'    TYPE="application/x-shockwave-flash">\n'+
				'  </EMBED>\n'+
				'</OBJECT>\n';
			this.insertBox.innerHTML = flashHTML;
		}
	};
	
	// Slurp up ID, set onload event, clean up
	window.rfQS_AffiliateID = function(inStr) {
		loader.id = inStr;
		// Pin if current onload events
		if(typeof window.onload == 'undefined') {
			window.onload = function(){
				loader.init();
			}
		} else if (typeof window.onload == 'function') {
			var currentOnLoad = window.onload;
			window.onload = function() {
				currentOnLoad();
				loader.init();
			}
		} else {
			window.onload = function(){
				loader.init();
			}
		}
	};
})();
