

$(document).ready(function() { 

$('.noScriptDiv').hide(); 

$('#responceRow').hide();
var t = setTimeout("$('#flashMessage').fadeOut();", 3000);
var x = setTimeout("$('.formError').fadeOut();", 3000);

$("a#buttonNewRecord").click(function() {
	$('#alertBox').show();
	$('#addNewRecord').hide();
	$("input:first").focus();
});

$("a#buttonClose").click(function() {
	$('#alertBox').hide();
	$('#addNewRecord').fadeIn(2000);
});


var options = { 
        target:        '#messageFlash',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse  // post-submit callback 
    }; 
    $('#formNotepad').submit(function() { 
        $(this).ajaxSubmit(options); 
        return false; 
    }); 
}); 

function validate(formData, jqForm, options) { 
    var titleValue = $('input[name=title]').fieldValue(); 
    var urlTitleValue = $('input[name=url_title]').fieldValue(); 
    if (!titleValue[0] || !urlTitleValue[0]) { 
        alert('Attenzione, devi riempire tutti i campi visualizzati'); 
        return false; 
    } 
}
function validate_user(formData, jqForm, options) { 
    var user = $('input[name=username]').fieldValue(); 
    var pwd = $('input[name=password]').fieldValue(); 
    var cpwd = $('input[name=cpassword]').fieldValue(); 
    if (!user[0] || !pwd[0] || !cpwd[0]) { 
        alert('Attenzione, devi riempire tutti i campi visualizzati'); 
        return false; 
    } 
}
function showRequest(formData, jqForm, options) { 
		$('#messageFlash').hide();    
		$('#loading').show();   
		return true; 
} 
function showResponse(statusText)  { 
		$('#loading').hide();   
		$('#messageFlash').show();
		$('#messageFlash').fadeOut(2500);
} 
function showRows(id){
		$('#optionRow'+id).toggle();
}
function showPictureDetails(id)
{
	$("#img_cmd_" + id).toggle();
}
function deletePictureBox(codEntry, id){
	 $.ajax({
	  type: "POST",
	  url:  base_url + "ee-admin/entries/delete_photo/"+codEntry+'/'+id,
	  data: " ",
	  success: function(msg){
		$("#image_box_" + id).fadeOut();
		$("#image_box_" + id).remove();
		//$("#image_box_"+ id).show('highlight').css("background", "#f9f9f9");
	  }
	});
   return false;
}
function maskedNumber(numero){
	numero=numero.toString().replace(/[\D^+]/g,"");
	for (i=numero.length;i>0;i-=3)
		numero=numero.substring(0,i)+"."+numero.substr(i)
	return numero.replace(/\.+$/,"");
}

function newGeocodesValues(newCityString, newAddress) { 
document.getElementById("citiesInput").value = newCityString; 
document.getElementById("addressInput").value = newAddress; 
} 