

function Subscribe(IdInput, IdSubmit, ActionValue){	
    this.Id = IdInput;    
    this.IdSubmit = IdSubmit;    
    this.ObjInput = $(this.Id);       
    this.ObjSubmit = $(this.IdSubmit);
    this.ActionValue = ActionValue;
    var objThis = this;
    

       
    this.ObjSubmit.addEvents({
        'click': function(event){                        
	        objThis.SubscribeUser();
        }
    });
    
    this.ObjInput.addEvents({
        'keyup': function(event){                        
            //var c = event.code;
            switch(event.code)
            {	      
	        case 13: //Enter	            
	            objThis.SubscribeUser();
	            break;        	    
	        default: 	            
	            break;
            }        
        }
    });
    
    this.SubscribeUser = function()
    {    	
        if(objThis.isValidEmail(this.ObjInput.value))
        {
            
            var f = new Array(0);            
            f[0] = { name: this.Id+'_email', value: this.ObjInput.value};        
            
            if(this.ActionValue)
                theForm.action = this.ActionValue;
            theForm.submit();
                        
//            __doCallBack(this.Id, "",
//                        function(responseText, responseXML, context) {                            
//                            alert(responseText);
//                            //context.innerHTML = responseText;
//                            //var echoDiv = context.createItems(responseText);                                                 
//                            //$(context.Id + '_stws_show_res').innerHTML = echoDiv; 
//                            
//                        }, f, $('2subscribe'));
           
        }
        else
        {
            alert('E-mail введен неправильно!');
            return;
        }
    }   
    
    this.isValidEmail = function(email, strict)
    {
        if ( !strict ) email = email.replace(/^\s+|\s+$/g, '');
        return (/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i).test(email);
    }

}




