
var optionDB = { 
       // target:        '#risposta',   // target element(s) to be updated with server response 
		dataType : 		'json',
        //beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse  // post-submit callback 
};

var optionsBlockCss = { 
	 textAlign:'center', color:'#FFF', backgroundColor:'#7b97b7', border:'2px solid #7d7d7d', fontFamily:'verdana', fontSize:'11px', padding:'5px'
}; 

function ctrlEmail (){
	
	if (!validEmail($('#email').val())) {
		$('#msg').html("Inserire un indirizzo email valido")
		
	}
	else {
		//$.blockUI('<strong>Attendere</strong>',optionsBlockCss);
		$('#containerScelte').block("<strong>Attendere...<\/strong>",optionsBlockCss);
		document.formemail.ToDo.value="checkEmail";
		document.formemail.action="getJson.asp";
		$('#formemail').ajaxForm(optionDB);
		$('#formemail').submit();	
	}
	
	
}

function validEmail(email){
	if (email=="") return false;
	if (email.indexOf("@")==-1) return false;
	if (email.indexOf("@")>email.lastIndexOf(".")) return false;
	return true;
	
}

function showResponse(responseText, statusText){
	$('#containerScelte').unblock();
	if (responseText.messaggio!=""){
		$('#msg').html(responseText.messaggio)
		
	}else{
		document.formemail.ToDo.value = "";
		document.formemail.action=responseText.action;
		document.formemail.submit();
	}
}