// JavaScript Document
$(document).ready(function(){ 
		// on clicking button
		$('#nw_button').click(function(){ 
			email_id = $('#nw_input').val();
			dft = 'your email address';
			if($.trim(email_id)==dft.toLowerCase()){ return false; }
			params = {
					'email_id' : email_id,
					'ts'       : new Date().getTime()
				}
			$.post('newsletter/save_email.php',params,function(response){
							erp.nl.showAlert(); 	
							$('#nw_input').val('your email address');
			})
		 })
		$('#overlay_ctnr > *').live('click',function(){ $('#nw_input').val('your email address'); $('#overlay_ctnr').remove() })
		
		//onclicking textbox
		$('#nw_input').focus(function(){  
			 if($.trim($(this).val())!='your email address'){
				 return false;
			 } else {
				 $(this).val('');
			 }
		 }) // end on clicking textbox
		
		$('#nw_input').blur(function(){ 
				if($.trim($(this).val())==''){
					$(this).val('your email address');
				} else {
					return false;
				}
		});
		
	});
	
	var erp = {};
	erp.nl = {
		showAlert:function(){
			w_height = document.body.offsetHeight;
			w_width  = document.body.offsetWidth; 
			$(document.body).append(
			$('<div id="overlay_ctnr" />').append('<div id="the_overlay" />')
						.css({ 'height': w_height,'width':w_width, })
				.append($('<div id="contentArea">Thank you for signing up <br/> for our product updates, latest trends, etc<br/><a id="button_ok" href="javascript:;">OK</a></div>').css({ 'top': Math.round(window.innerHeight / 2)  - 65 +'px' }))
				.fadeIn(600)
			)
			
			/*$('html, body').animate({
				scrollTop: $('#contentArea').offset().top
			}, 2000);*/
			//$(document.body).scrollTo($('#contentArea').offset().top);
		} // end function show alert
	}
	
	function doFocus(){
		var txtEmail = document.getElementById('nw_input')
		if(txtEmail.value=='your email address'){
			txtEmail.value = '';
		} else {
			return false;
		}
	}
	
	function doCheck(){
		var txtEmail = document.getElementById('nw_input');
		if(txtEmail.value==''){
			txtEmail.value = 'your email address';
		} else {
			return false;
		}
	}
