var ssmConfirm = Class.create();
ssmConfirm.prototype = {
	initialize: function(text, yescallback, nocallback, elementId)
	{
		this.text = text;
		this.yescallback = yescallback;
		this.nocallback = nocallback;
		this.confirmElement = $0('#' + elementId);
	},

	confirm: function ()
	{
		//debugger
		this.confirmElement.css('display', 'block');
		
		if (document.all)
		{
			$0('html').css('overflow', 'hidden');
			this.confirmElement.css('position', 'absolute');
			$0('select','#profileInfoContainer').each(function(i){this.style.visibility = 'hidden';});
			x = document.documentElement.clientWidth/2 + (document.documentElement.scrollLeft );
			y = document.documentElement.clientHeight/2 + (document.documentElement.scrollTop);
		}
		else
		{
			this.confirmElement.css('position', 'fixed');
			x = document.documentElement.clientWidth/2;
			y = document.documentElement.clientHeight/2;
		}
		
		$0(window).resize(this.relocateConfirmBox.bind(this));
		$0(window).resize(this.showShield.bind(this));
		$0(window).resize(this.hideShield.bind(this));
		$0(window).resize(this.recalcShieldDimensions.bind(this));

		this.showShield();
		
		$0('#ssmConfirmText').html(this.text);
		
		this.confirmElement.css('top', (y - this.confirmElement.height()/2) + 'px');
		this.confirmElement.css('left', (x - this.confirmElement.width()/2) + 'px');
		
		if (typeof(this.yescallback) == 'function')
		{
			$0('#ssmConfirmYesButton').click(this.yescallback);
		}
		if (typeof(this.nocallback) == 'function')
		{
			$0('#ssmConfirmNoButton').click(this.nocallback);
		}
		$0('#ssmConfirmCancelButton').click(this.hideSsmConfirm);
		$0('#ssmConfirmCloseButton').click(this.hideSsmConfirm);
	},
	
	relocateConfirmBox: function()
	{
		this.confirmElement.css('top', document.documentElement.clientHeight/2 + (document.documentElement.scrollTop) - this.confirmElement.height()/2);
		this.confirmElement.css('left', document.documentElement.clientWidth/2 + (document.documentElement.scrollLeft) - this.confirmElement.width()/2);
	},

	showShield: function()
	{
		$0('#modalShield').css("width",($0('body').width()));
		$0('#modalShield').css("height", Math.max($0('body').height(), document.documentElement.clientHeight));
		$0('#modalShield').css("display", "block");
	},

	hideShield: function()
	{
		$0('#modalShield').css("display", "none");
	},

	recalcShieldDimensions: function()
	{
		$0('#modalShield').css("width",($0('body').width()));
		$0('#modalShield').css("height", Math.max($0('body').height(), document.documentElement.clientHeight));
	},

	hideSsmConfirm: function ()
	{
		$0('#ssmConfirmYesButton').unbind('click');
		$0('#ssmConfirmNoButton').unbind('click');
		$0(window).unbind('scroll');
		$0(window).unbind('resize');
		
		$0('#ssmConfirm').css('display', 'none');
		$0('#modalShield').css("display", "none");
		if (document.all)
		{
			$0('select','#profileInfoContainer').each(function(i){this.style.visibility = 'visible';});
			$0('html').css('overflow', 'auto');
		}
	}
}