CCharityProfileWindow = Class.create();
CCharityProfileWindow.prototype = Object.extend( (new CCnfDialog('charity-selector-window')), {
    initialize: function(config)
    {
        this.options = config;
		/*
		this.signInContainer = '';
		this.signUpContainer = '';
		this.backButtonTimer = false;
		this.hideButtonTimeOut = 2500;
		this.hideDetailsTimeOut = 2000;
		this.charityFormRequest = null;
		this.timer = false;
		this.alreadyRequestedAlerts = false;
		this.currentHotPoint = null;
		*/ 
    },
    
    init: function()
    {
    	this.showWindow('popup-profile-charity-container')
    },
    
	showWindow: function( sCountentBlockId  )
	{
		var sPageSize = Element.getPageSize();
		
		this.okButtonTitle = this.options.btnYes;
		this.cancelButtonTitle =  this.options.btnNo;
		this.initCnfButtons();
		
		var X = (sPageSize[2]/2-150);
		if(sPageSize[3] > 300){
        	var Y = Math.ceil( sPageSize[3]/2-150 );
		} else {
			var Y = Math.ceil( sPageSize[3]/2);
		}
            
        this.displayDialog ($(sCountentBlockId) , X, Y, {'title':$(sCountentBlockId).innerHTML,'ok':this.submitCharityForm.bind(this),'rel':'confirm'} );
        
        
		$$('form#'+this.options.sFormId).each(function(el) {
            el.onsubmit = function() { return false; }
            Event.observe(el, "submit", this.submitCharityForm.bindAsEventListener(this) );
			
			var submits = el.getInputs('submit');
			submits.each(function(v) {
				v.onclick = function() { 
				    if (v.alt)
					{
						this.clearCharityConfirmation(v);
						return false;
					}
					return true;
				}.bind(this);
			}.bind(this)); 
        }.bind(this));
        
        
        return false;
	},
	
	submitCharityForm: function(evt)
	{
		f = $(this.options.sFormId);
		Utils.setLoadingEffect($('charity-selector-window'), 'charity-selector-window_loading', 'commonLoadingEffect');
        this.charityFormRequest = f.request({
       	 	'onComplete':this.successFormLoading.bind(this)
        });
			
		return false;
	},
	
	successFormLoading: function(response)
	{
		Utils.removeLoadingEffect($('charity-selector-window_loading'));
		this.hideCnf();
	}	
    
});