// JavaScript Document
var f;

var validate = function()
{
	if( f.name.value == "" )
	{
		Ext.MessageBox.alert("Oops!","Please enter your name. ");		
		return false;
	}
	
	if( f.email.value == "" )
	{
		Ext.MessageBox.alert("Oops!","Please enter your email address.");
		return false;
	}

	if( f.email.value != "" )
	{
		if(!check_email(f.email.value))
		{
			Ext.MessageBox.alert("Oops!","Please enter a valid email address.");
			return false;
		}
	}
	
	if( (f.password.value == "") || (f.password.value.length < 5) )
	{
		Ext.MessageBox.alert("Oops!","Please enter a password. It must be at least 5 characters long.");
		return false;
	}
	else
	{
		// confirm
		if( f.password.value != f.confirm_password.value )
		{
			Ext.MessageBox.alert("Oops!","Your passwords don't match. Please try again.");
			return false;
		}
	}
	
	if( f.gender.value == "" )
	{
		Ext.MessageBox.alert("Oops!","Please select your gender. ");
		return false;	
	}
	
	if( f.ethnicity.value == "" )
	{
		Ext.MessageBox.alert("Oops!","Please select your ethnicity. ");
		return false;
	}
	
	if( f.bday_month.value == "" )
	{
		Ext.MessageBox.alert("Oops!","Please select the month you were born.");
		return false;		
	}
	
	if( f.bday_day.value == "" )
	{
		Ext.MessageBox.alert("Oops!","Please select the day you were born. ");
		return false;	
	}
	
	if( f.bday_year.value == "" )
	{
		Ext.MessageBox.alert("Oops!","Please select the year that you were born. ");
		return false;	
	}
	
	if( f.profile_type.value == "" )
	{
		Ext.MessageBox.alert("Oops!","Please choose a selection from the list of reasons you are here. ");
		return false;	
	}
	
	/*if( f.invite_code.value == "" )
	{
		
		Ext.MessageBox.alert("Oops!","Please enter your invitation code. ");
		return false;
	}*/

	

}


Ext.BLANK_IMAGE_URL = '/common/images/s.gif';
Ext.onReady(function(){
	f = document.registerForm;
	var button = Ext.get("infoBtn");
	button.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        if(!win){
            win = new Ext.Window({
                el:'hello-win',
                layout:'fit',
				width: 400,
                height: 200,
                closeAction:'hide',
                plain: true,				
                buttons: [{                    
                    text: 'Close',
                    handler: function(){
                        win.hide();
                    }
                }]
            });
        }
        win.show(this);
    });
	
});