function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


Ext.form.XmlErrorReader = function(){
    Ext.form.XmlErrorReader.superclass.constructor.call(this, {
            record : 'field',
            success: '@success'
        }, [
            'id', 'msg'
        ]
    );
};
Ext.extend(Ext.form.XmlErrorReader, Ext.data.XmlReader);

//register vtypes
Ext.apply(Ext.form.VTypes, {
    checkuser : function(val, field) {
                                Ext.Ajax.request({
				        url : 'ajax.php' , 
					  params : { op : 'checkuser' , user : val },
					  method: 'POST',
					  success: function ( result, request ) { 
					  	if (result.responseText == 0) {
                                      myvar = 0;
                                      }
                                    else {
                                      myvar = 1;
                                      }
					  },
					  failure: function ( result, request) { 
					  	Ext.MessageBox.alert('Failed', result.responseText); 
					  } 

					  });
    return myvar;

    },

    checkuserText : 'The user already exists',

    passwordmatch : function(val, field) {
        if (field.initialPassField) {
            var pwd = Ext.getCmp(field.initialPassField);
            return (val == pwd.getValue());
        }
        return true;
    },

    passwordmatchText : 'Passwords do not match'
} 
);

Ext.onReady(function() {

    //Ext.fly('loading').remove();
    //Ext.fly('loading-mask').remove();
    Ext.QuickTips.init();
	var loading = Ext.get('loading');
	var mask = Ext.get('loading-mask');
	mask.setOpacity(0.8);
	mask.shift({
		 xy: loading.getXY()
		,width: loading.getWidth()
		,height: loading.getHeight() 
		,remove: true
		,duration: 2.5
		,opacity: 0.3
		,easing: 'bounceOut'
		,callback: function(){
			loading.fadeOut({
				 duration: 0.2
				,remove: true
			});
		}
	});
});
