document.observe("dom:loaded", setup_my_account);
function setup_my_account(e) {
  setup_about_me();
  setup_my_bag();
  setup_light_window();
  setup_login_reg();
  setup_registration();
  setup_invite();
}

function setup_registration() {
    $$('#interests a.countries').invoke('observe', 'click', expand_fields_interests);
    $$('#interests a.country_options').invoke('observe', 'click', expand_fields_country);    
    $$('#intl_interest > div').invoke('show');
	  $$('#intl_interest > h1 > a').invoke('addClassName', 'expand');	   
}

function setup_about_me() {
	if( $('cell_phone') )
		$('cell_phone').observe('focus', clear_cell_phone_number);
}

function setup_my_bag() {
 $$('.in-my-bag a.add').invoke('observe', 'click', expand_fields); 
}

function setup_invite() {
    if($('invite_link'))
	new FancyZoom('invite_link');
}

function expand_fields(e)
{
	e.stop();
	var div = this.next('div');
	
	
	if(!div)
		return;
	
	this.hide();
	Effect.SlideDown(div);

	//div.show();
}

function expand_fields_interests(e)
{
	e.stop();
	var divIntl = $('intl_interest');
	var divLocal = $('local_interest');
	
	if(divLocal && divIntl)
	{
		divLocal.down(0).show();
		this.hide();
	
		if(Prototype.Browser.IE)
			divIntl.show();
		else
			Effect.SlideDown(divIntl);	 
	}
}

function expand_fields_country(e)
{
	e.stop();
	var div = this.up(0).next('div');
	
	if(!div)
		return;	
		
	if(this.hasClassName('expand'))
	{
	    this.removeClassName('expand');
	    Effect.SlideUp(div);
	}
	else
	{
	    this.addClassName('expand');	    
	    Effect.SlideDown(div);    
	}
}

function setup_light_window()
{	
	try{	
	new FancyZoom('update_status_link');  
	new FancyZoom('update_photo_link');  
  
  } catch(e) { alert(e.message); }
}

function setup_login_reg()
{
	if( !$$('div.register #team_video') )
		return;
	
	var vidInfo = 'video_url=http://media.titleist.com/images/titleist/videoplayer/flvs/US/Team_Titleist_Video.mov&track_as=TeamTitleist&autoPlay=false&video_image=http://media.titleist.com/images/titleist/videoplayer/thumbnails/US/team_titleist.jpg'
	var params = { wmode: "opaque", allowScriptAccess: "sameDomain", allowFullScreen: "true"   };	
	swfobject.embedSWF("/flash/vidplayer.swf?" + vidInfo , "team_video", "386", "210", "9.0.0", false, false, params);
}
