
var settingsUpdater = Class.create();
//var cake = 'I like Cake';
settingsUpdater.prototype = {
	initialize: function(formID) {
		this.form = $(formID);
		this.autoload = this.form['audioSettings'];
		//this.script = this.form['script'];
		
		//alert(this.autoload);
		//if(this.autoload.value == 0) {
			//alert(performers);
			//location.hash = 'autoload=0';
			//performers.autoload = 'false';
		//}
		this.setup(this.form);
		/*
		else if($F(this.autoload) == 1) {
			performers.autoload = 'true';
		}
		if($F(this.script) == 0) {
			performers = '';
			mainTabs = '';
			peopleTabs = '';
			performerTabs = '';
			optionsTabs = '';	
		}
		else if($F(this.script) == 1) {
			performers = new audio('performerTabs');
			mainTabs = new Fabtabs('tabs');
			peopleTabs = new Fabtabs('peopleTabs');
			performerTabs = new Fabtabs('performerTabs');
			optionsTabs = new Fabtabs('optionsTabs');
		}
		*/
		//alert(cake);
		//Event.observe(this.form,'submit',this.prevent,false);
		
		//this.prevent.bind(this);
	},
	setup: function(elm) {
		Event.observe(elm,'submit',this.update.bindAsEventListener(this),false);
		
	},
	update: function(ev) {
		Event.stop(ev);
		var style;
		var js;
		this.autoload = Form.getInputs('settingsform','radio','audioSettings').find(function(radio) { return radio.checked; }).value;
		this.script = Form.getInputs('settingsform','radio','script').find(function(radio) { return radio.checked; }).value;
		location.hash = 'autoload='+this.autoload;
		if(this.script == 'false') {
			
			var pageScripts = $A(document.getElementsByTagName('script'));
			var scripts = pageScripts.each(function(current) {
				if(current.src.include('performers.js')) {
					
					js = Element.remove(current);
					Element.remove($('settingsform'));
					Element.remove($('performerTabs'));
					Element.remove($('peopleTabs'));
					Element.remove($('tabs'));
					Element.remove($('optionsTabs'));
					//alert(js);
				}

			});
			
			var css = $A(document.getElementsByTagName('link'));
			var styles = css.each(function(current) {
				if(current.href.include('sportsNutrition.css')) {
					style = Element.remove(current);
					//alert(style);
				}
			});
		}
			
		else if((this.script == 'true') && (style != null)) {
			Element.insert(document.head,style)
		}
		
		//audio.autoload=autoload;
	}
}
Event.observe(window,'load',function() {var settings = new settingsUpdater('settingsform');},false);

