/**
 * RockSpace.
 */
var rockspace = (function () {
	var
		/**
		 * The ID of the TEXTAREA that contains the code to embed the widget.
		 */
		TEXTAREA_ID = 'embedCode',
		/**
		 * The sprout id. We can set the sprout id by using rockspace.sproutID().
		 */
		SPROUT_ID = '',
		/**
		 * The account id of the Toyota – Rock the Space account.
		 */
		ACCOUNT_ID = '@TODO insert your account id here.',
		/**
		 * Gigya Configuration. You can generate your own by going to http://gigya.com/site/partners/api.aspx.
		 * Note that you would need to set the width and height of the gigya container (Item #5 on global.css) the same as the generated code.
		 * Post the gigya init function insite the init() function below.
		 */
		pconf = {
			defaultContent: 'TEXTAREA_ID', 
			UIConfig: '<config><display showEmail="true" useTransitions="true" showBookmark="true" codeBoxHeight="auto" showCodeBox="true" showCloseButton="false" networksWithCodeBox="" networksToShow="myspace, facebook, blogger, igoogle, yahoo, livejournal, orkut, bebo, tagged, livespaces, freewebs, myyearbook, vox, xanga, multiply, netvibes, migente, ameba, friendster, typepad"></display><body><background frame-color="#244891" background-color="#000000" frame-thickness="0" gradient-color-begin="#000000" gradient-color-end="#000000" corner-roundness="0;0;0;0"></background><controls color="#202020" corner-roundness="4;4;4;4" gradient-color-begin="#EAEAEA" gradient-color-end="#F4F4F4" bold="false"><snbuttons type="textUnder" frame-color="#D5D5D5" over-frame-color="#60BFFF" color="#B5B5B5" corner-roundness="0;0;0;0" gradient-color-begin="#FFFFFF" gradient-color-end="d4d6d7" size="10" buttonSize="50" bold="false" down-frame-color="#60BFFF" down-gradient-color-begin="#6DDADA" over-gradient-color-end="37c5f3" down-gradient-color-end="#F4F4F4" over-color="37c5f3" down-color="#52A4DA" over-bold="false"><more frame-color="#A4DBFF" over-frame-color="#A4DBFF" gradient-color-begin="#F4F4F4" gradient-color-end="#BBE4FF" over-gradient-color-begin="#A4DBFF" over-gradient-color-end="#F4F4F4"></more><previous frame-color="#BBE4FF" over-frame-color="#A4DBFF" gradient-color-begin="#FFFFFF" gradient-color-end="#A4DBFF" over-gradient-color-begin="#A4DBFF" over-gradient-color-end="#F4F4F4"></previous></snbuttons><textboxes frame-color="#CACACA" color="#AAAAAA" gradient-color-begin="#ffffff" bold="false"><codeboxes color="#757575" frame-color="#DFDFDF" background-color="#FFFFFF" gradient-color-begin="#ffffff" gradient-color-end="#FFFFFF" size="10"></codeboxes><inputs frame-color="#CACACA" color="#757575" gradient-color-begin="#F4F4F4" gradient-color-end="#ffffff"></inputs><dropdowns list-item-over-color="#52A4DA" frame-color="#CACACA"></dropdowns></textboxes><buttons frame-color="#CACACA" gradient-color-begin="#F4F4F4" gradient-color-end="#CACACA" color="#000000" bold="false" over-frame-color="#60BFFF" over-gradient-color-begin="#BBE4FF" down-gradient-color-begin="#BBE4FF" over-gradient-color-end="#FFFFFF" down-gradient-color-end="#ffffff"><post-buttons frame-color="#CACACA" gradient-color-end="#CACACA"></post-buttons></buttons><listboxes frame-color="#CACACA" corner-roundness="4;4;4;4" gradient-color-begin="#F4F4F4" gradient-color-end="#FFFFFF"></listboxes><checkboxes checkmark-color="#00B600" frame-color="#D5D5D5" corner-roundness="3;3;3;3" gradient-color-begin="#F4F4F4" gradient-color-end="#FFFFFF"></checkboxes><servicemarker gradient-color-begin="#ffffff" gradient-color-end="#D5D5D5"></servicemarker><tooltips color="#6D5128" gradient-color-begin="#FFFFFF" gradient-color-end="#FFE4BB" size="10" frame-color="#FFDBA4"></tooltips></controls><texts color="#202020"><headers color="#202020"></headers><labels color="#FFFFFF"></labels><messages color="#202020"></messages><links color="37c5f3" underline="false" over-color="c52c7e" down-color="#353535" down-bold="false"></links></texts></body></config>'
		},
		/**
		 * Fan Seed Page and Embed Code input box on-click event handler that highlights the whole input box.
		 * @param {event} e The event.
		 */
		input_onClick = function (e) {
			this.focus();
			this.select();
		},
		/**
		 * Fan Seed Page and Embed Code input box initialization.
		 */
		input_onInit = function () {
			var demoTape = document.getElementById('demoTape'),
				inputs,
				count,
				total;
			if (demoTape) {
				inputs = demoTape.getElementsByTagName('input');
				for (count = 0, total = inputs.length; count < total; count += 1) {
					inputs[count].onclick = input_onClick;
				}
			}
		},
		sIFR_onInit = function () {
		var arialBlack = 'http://cms.myspacecdn.com/cms/Rock_The_Space/arial_black.swf';
			
			if(typeof sIFR === 'function') {
				sIFR.setup();
				
				sIFR.replaceElement('#demoTape .header h1', named({sFlashSrc: arialBlack, sColor: '#2da5cc', sWmode: 'transparent'}));
				sIFR.replaceElement('#demoTape .header h2', named({sFlashSrc: arialBlack, sColor: '#ffffff', sWmode: 'transparent'}));
				sIFR.replaceElement('#demoTape .header h3', named({sFlashSrc: arialBlack, sColor: '#949494', sLinkColor: '#949494', sWmode: 'transparent'}));
				
				sIFR.replaceElement('#demoTape ol li', named({sFlashSrc: arialBlack, sColor: '#2da5cc', sWmode: 'transparent'}));
				
				sIFR.replaceElement('#demoTape label', named({sFlashSrc: arialBlack, sColor: '#2da5cc', sWmode: 'transparent'}));
				
				sIFR.replaceElement('#stats thead th span', named({sFlashSrc: arialBlack, sColor: '#ffffff', sWmode: 'transparent'}));
				sIFR.replaceElement('#stats table.totalViews tbody th span, #stats table.totalViews tbody td span', named({sFlashSrc: arialBlack, sColor: '#C52C7C', sCase : 'upper', sWmode: 'transparent'}));
				sIFR.replaceElement('#stats table.totalInstalls tbody th span, #stats table.totalInstalls tbody td span', named({sFlashSrc: arialBlack, sColor: '#2da5cc', sCase : 'upper', sWmode: 'transparent'}));
			}
		},
		/**
		 * Rock The Space initialization.
		 */
		init = function () {
			// input box.
			input_onInit();
			
			// gigya.
			pconf.cid = SPROUT_ID;
			pconf.defaultContent = TEXTAREA_ID;
			Wildfire.initPost(ACCOUNT_ID, 'divWildfirePost', 420, 150, pconf);
			
			// sifr
			sIFR_onInit();
		};
	
	return {
		/**
		 * Rock The Space initialization.
		 */
		init: init,
		/**
		 * Set or get the sprout id.
		 */
		sproutID: function (value) {
			if (value) {
				SPROUT_ID = value;
			}
			return SPROUT_ID;
		}
	};
}());
