function NewsLetterSubs(containerId){
		this.body = $(containerId);
		var html;
		var errorMsg;
		var input;
		var inputStatus = "";
		this.initialize();
		var email;
	
	}
	
	NewsLetterSubs.prototype={	
	
	/* ******************************** INITIALIZE ******************************** */
		initialize:function(){
		
					this.html = "<form id='newsletterForm'>";
						this.html += "<div id='nlFormMSg'> </div>";
						this.html += "<input type='text' id='newsletterInput' name='newsletterEmail' value='enter your email' />"; //onfocus='this.value=\"\";'
						this.html += "<div id='newsletterSubmitIcon'><input type='image' src='../images/submitBtn.gif' border='0' id='nlSubmitBtn' onmouseover='swapImage(\"nlSubmitBtn\", \"../images/submitBtn_ovr.gif\");' onmouseout='swapImage(\"nlSubmitBtn\", \"../images/submitBtn.gif\");'/></div>";
					this.html += "</form>";	
					
			this.body.innerHTML=this.html;
			this.errorMsg = $('nlFormMSg');
			this.input = $('newsletterInput');
			
			// mouseout observer for the menu
			Event.observe(			  
				this.body,
				"submit",
				this.submitHandler.bindAsEventListener(this)
			); 
			
			// mouseout observer for the menu
			Event.observe(			  
				this.input,
				"focus",
				this.inputFocusHandler.bindAsEventListener(this)
			); 
			
		},
		
		inputFocusHandler:function(event){
			if (this.inputStatus != "initialized"){$
				this.input.value= "";
				this.inputStatus = "initialized";
			}
			
		},
		
		//action thrown upon submission of the form
		submitHandler:function(event){
			if(($F('newsletterInput') == "") || this.inputStatus !=  "initialized"){
				//alert("its empty dude");
				this.errorMsg.innerHTML = "<span class='smallErrorMsg'>Enter your email</span>"; 
				Event.stop(event);
			}else{
				Event.stop(event);
				this.email = $F('newsletterInput');
				this.saveEmail();
				
			}
		
		},
		
		saveEmail:function(){
		
			var params=$H({newsletterEmail:this.email}).toQueryString();
						
			new Ajax.Request( 
				"../commonphp/newsletter.php",
				{
					method:"post",
					parameters: params,
					onSuccess:this.onAjaxLoad.bind(this),
					onFailure:this.onAjaxError.bind(this)
				}
			); //ajax request
					
		},//saveemail
		
		onAjaxLoad:function(returnedXml){
  			var msg ="";
			
			var xmlDoc = returnedXml.responseXML;
			xmlDoc=xmlDoc.documentElement;
			var strStatus = xmlDoc.getElementsByTagName('status')[0].firstChild.nodeValue;
			var strMsg = xmlDoc.getElementsByTagName('msg')[0].firstChild.nodeValue;
			
			if (strStatus == 'OK'){
				this.errorMsg.innerHTML = "<span class='smallSuccessMsg'>Email added succefully</span>";
			}else if (strStatus =='ERR1'){
				this.errorMsg.innerHTML = "<span class='smallErrorMsg'>Error : unable to add email</span>";
			}else if (strStatus =='ERR2'){
				this.errorMsg.innerHTML = "<span class='smallErrorMsg'>Email already registered</span>";
			}else if (strStatus =='ERR3'){
				this.errorMsg.innerHTML = "<span class='smallErrorMsg'>Invalid email</span>";
			}
			
			//msg += strStatus;
		}, //onAjaxError
		
		onAjaxError:function(returnedXml){
  			this.errorMsg.innerHTML = "server error ["+returnedXml.httpStatus+"]";
		} //onAjaxError
		
	}		  
