/* Initialize Registration Form Validation */
var board_names =[
['00N700000025NRP','00N700000025NRl'],
['00N700000025NRU','00N700000025NRG'],
['00N700000025NRZ','00N700000025NRo'],
['00N700000025NRe','00N700000025NRt'],
['00N700000025NRj','00N700000025NRy'],
['00N700000025NRV','00N700000025NRW'],
['00N700000025NRQ','00N700000025NRf'],
['00N700000025NRk','00N700000025NS3']
];
	
var page_load = window.onload;
window.onload = function()
{
	page_load();

	var reg = new Form('Registration');
	reg.addRequired(
	'first_name',
	'last_name',
	'street',
	'00N700000025NRF',
	'city',
	'state',
	'company',
	'zip',
	'email',
	'country',
	'phone',
	'00N700000025NRP', //Temp Board 1
	'00N700000025NRl',//Temp Board 1 Title
//	'board_title[]',
//	'board_position[]',
	'00N700000025OuQ',
	'00N700000025Ou1',
	'00N700000025NL3',
	'00N700000023thY',
	'00N700000025NcX',
	'00N700000023thh',
	'00N700000023tha',
	'00N700000023thS',
	'00N700000023thZ',
	'00N700000023thT',
	'00N700000023thX',
	'00N700000023thc',
	'confirmterms')
	
	reg.addFieldCheck('email','email');
	reg.addFieldCheck('00N700000023thh','email');
	reg.addFieldCheck('phone','phone');
	reg.addFieldCheck('00N700000023tha','phone');
	reg.addFieldCheck('zip','integer');
	reg.addFieldCheck('00N700000023thc','integer');
	reg.toggleField('title','status_ex','status_ret',false,true,false,false)
	function billingcopy(obj)
	{
		if(obj.checked == "true") return;
		var o = reg.object;
		o['00N700000023thY'].value = o.first_name.value;
		o['00N700000025NcX'].value = o.last_name.value;
		o['00N700000023thh'].value = o.email.value;
		o['00N700000023tha'].value = o.phone.value;
		o['00N700000023thS'].value = o.street.value;
		o['00N700000025Otw'].value = o['00N700000025Otr'].value;
		o['00N700000023thZ'].value = o.country.value;
		o['00N700000023thT'].value = o.city.value;
		o['00N700000023thX'].value = o.state.value;
		o['00N700000023thc'].value = o.zip.value;
	}
	reg.toggleField('attendeebill','00N700000025OuG','00N700000025OuG',false,false,true,billingcopy);
	new ExpandTable('boardtable', document.Registration,6);

	//reg.preValidate = function(){}
	
	reg.postValidate = function(complete)
	{
		if(!complete) return;
		var titles = this.exists('board_title[]');
		var positions = this.exists('board_position[]');
		if(!(titles && positions)) return
		board_array = new Array(8);
		if(titles.length)
		{
			for(var i=0;i<titles.length;i++)
			{
				board_array[i] = [titles[i],positions[i]];
			}
		}
		else
		{
			board_array[0] = [titles,positions];
		}
		for(var j=0;j<board_array.length;j++)
		{
			if(!board_array[j]) break;
			board_array[j][0].name = board_names[j][0];
			board_array[j][1].name = board_names[j][1];
		}
	}
}