// BABY CUSTOMIZE *********************
var babyCustom = {
	eyecolor:null,
	haircolor:null,
	skincolor:null,
	mouthshape:null,
	eyeshape:null,
	hairshape:null,
	sex:null,

	init: function() {
		this.eyecolor = 'color1';
		this.haircolor = 'color1';
		this.skincolor = 'caucasian';
		this.mouthshape = 'shape1';
		this.eyeshape = 'shape1';
		this.hairshape = 'shape1';
	},

	setBody: function(color) {
		this.skincolor = color;
		$('signUpSkincolor').value = color;

		$('caucasian-hair').hide();
		$('african-hair').hide();
		$('asian-hair').hide();
		$(color+'-hair').show();

		this.setHair('color1', 'shape1');
	},

	setEye: function(color, shape) {
		this.eyecolor = color;
		$('signUpEyecolor').value = color;

		this.eyeshape = shape;
		$('signUpEyesshape').value = shape;

		this.updateFlash();
	},

	setHair: function(color, shape) {
		this.haircolor = color;
		$('signUpHaircolor').value = color;

		this.hairshape = shape;
		$('signUpHairshape').value = shape;

		this.updateFlash();
	},

	updateFlash: function() {

		if($('signUpSexBoy').checked == true) {
			this.sex = 'boy';
		} else {
			this.sex = 'girl';
		}

		var babyStr = 'age:0-6|sex:'+this.sex+'|body:'+this.skincolor+'|eye:'+this.eyeshape +'-'+this.eyecolor+'|hair:'+this.hairshape +'-'+this.haircolor+'|mouth:'+this.mouthshape;
		try{
			getFlash('baby').loadByStr(babyStr);
		} catch(e) {}
	}

}

function gotoBaby(id) {
	document.location.href = '/baby/'+id;
}

// ONLOAD EVENT ***********************
Event.observe(window, 'load', function() {
	// Init the menu system
	//m0	= new module_tab_object('module-tab-0', ['module-0', 'module-1', 'module-2'], 0);
	//n0	= new module_tab_object('module-tab-1', newsTab, 0);
	//healthrecord.init();

	babyCustom.init();

	Event.observe($('signUpSexBoy'), 'click', function() {
		babyCustom.updateFlash();
	});

	Event.observe($('signUpSexGirl'), 'click', function() {
		babyCustom.updateFlash();
	});	

	p0	= new mouseOverModule(
		'module-tab-0',
		['module-0', 'module-1', 'module-2'],
		{
			default_value:	null,
			reset:			true,
			reset_to:		null
		}
	);
		
	// News	
	q0	= new mouseOverNews(
		'module-tab-1',
		['news-0', 'news-1', 'news-2'],
		{
			cycle:			true,
			cycle_delay:	10
		}
	);	
			
	// Healthrecord
	 h0	= new mouseOverSwitch(
		$$('#healthrecord td.col-2 ul').first(),
		$$('#healthrecord td.col-3 img').toArray(),
		{
			cycle:			true
		}
	);	
	
});
