var Class = {
   create: function() {
     return function() {
//       if (this.initialize) {
//         this.initialize();
//       }
return this;
     }
   }
 }  
 
 	function checkMail( userMail, noempty )
	{
		if( ( noempty == true && userMail == '' ) || userMail != '' && userMail.search( /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,4}$/ ) == -1 ) return false;
		else return true;
	}

	
	function checkEmpty( check, message )
	{
		if( check != '' ) return true;
		
		if( message ) alert( message );
		return false;
	}

 
 
 	function parseText( text )
	{
		text = text.replace(/%/gi, "%25");
		text = text.replace(/ /gi, "%20");
		text = text.replace(/!/gi, "%21");
		text = text.replace(/\"/gi, "%22"); //"
		text = text.replace(/#/gi, "%23");
		text = text.replace(/\$/gi, "%24");
		text = text.replace(/&/gi, "%26");
		text = text.replace(/\'/gi, "%27"); //'
		text = text.replace(/\(/gi, "%28");
		text = text.replace(/\)/gi, "%29");
		text = text.replace(/\*/gi, "%2a");
		text = text.replace(/\+/gi, "%2b");
		text = text.replace(/\,/gi, "%2c");
		text = text.replace(/-/gi, "%2d");
		text = text.replace(/\./gi, "%2e");
		text = text.replace(/\//gi, "%2f");
		text = text.replace(/:/gi, "%3a");
		text = text.replace(/;/gi, "%3b");
		text = text.replace(/</gi, "%3c");
		text = text.replace(/=/gi, "%3d");
		text = text.replace(/>/gi, "%3e");
		text = text.replace(/\?/gi, "%3f");
		text = text.replace(/@/gi, "%40");
		text = text.replace(/\[/gi, "%5b");
		text = text.replace(/\\/gi, "%5c");
		text = text.replace(/\]/gi, "%5d");
		text = text.replace(/\^/gi, "%5e");
		text = text.replace(/_/gi, "%5f");
		text = text.replace(/`/gi, "%60");
		text = text.replace(/\{/gi, "%7b");
		text = text.replace(/\|/gi, "%7c");
		text = text.replace(/\}/gi, "%7d");
		text = text.replace(/~/gi, "%7e");
		return text;
	}	
	
	
var overlayClass = Class.create();
overlayClass.prototype = {
	
	alertId			: 'overlay',
	backgroundId	: 'grayBackground',
	overlay			: null,
	coef 			: 1,
	message : function( mess )
	{
		$( '#alertRequestMSG' ).attr( 'innerHTML', mess );
	},
	
	setHeader : function( content )
	{
		$( '#' + this.alertId + 'Header' ).attr( 'innerHTML', content );
	},

	setContent : function( content )
	{
		$( '#' + this.alertId + 'Content' ).attr( 'innerHTML', content );
	},
	setAltContent : function( content )
	{
		$( '#' + this.alertId + 'AltContent' ).attr( 'innerHTML', content );
	},
	
	setPosition : function()
	{
		$( '#grayBackground' ).css( { width : screen.availWidth + 'px', height : screen.availHeight + 'px' } ); 
//		return;
		var left = parseInt( $( 'body' ).css().width() / 2 ) - parseInt( $( '#' + this.alertId ).css().width() / 2 );
		var top = parseInt( screen.availHeight / 2 ) - parseInt( $( '#' + this.alertId ).css().height() * this.coef );
		if( top < 0 ) top = 0;
		
//				alert( $( 'body' ).css().height() );
		$( '#' + this.alertId ).css( { left :  left + 'px', top : top + 'px', display : 'block' } );
		
	},
	
	show : function( width )
	{
		this.message( '' );
		if( !( !width ) )
		{
			$( '#' + this.alertId ).css( { width : width + 'px' } );
		}
		this.setPosition();
		
//		this.overlay.load();
		
		$( '#' + this.backgroundId ).show();
		$( '#' + this.alertId ).show();
//		this.overlay.onLoad = function(){ 
//			$( '#backOv' ).css( { display : 'none' } ); 
//			$( '#overlay' ).css( { background : '#2c2c2c url(/_images/bg_overlay.jpg) repeat top left' } ); 
//		}
	},
	
	init : function()
	{
//		this.overlay =  $("#overlay").overlay({ effect: 'apple', api:true, top: 'center'  } );
//		this.overlay.onClose = function(){ $( '#grayBackground' ).hide(); }
	},
	
	close : function()
	{
//		this.overlay.close();
				$( '#' + this.backgroundId ).hide();
				$( '#' + this.alertId ).hide();
		this.setHeader( '' );
		this.setContent( '' );
		this.setAltContent( '' );
		
	}
}		
	