$(function() {
    $("input[type=text].ucfirst").change(function() {
        this.value = this.value.ucfirst();
    });

    $("input[type=text].upper-case").change(function() {
        this.value = this.value.toUpperCase();
    });

    $('form.registration_form #gp_details').click(function(){
        this.checked ? showGp() : hideGp();
    });
    $('form.registration_form #gp_details').attr('checked') ? showGp() : hideGp();

    $('#refer_to_admin').click(function() {
        if (!confirm("Send message to Dr Fox admin?")) { return false; } ;
        window.location = ASSET_URL + "/admin/correspondence/refertoadmin?patient_id=" + $(".correspondence_form #patient_id").val();
    });

});

String.prototype.ucfirst = function()
{
    return this.charAt(0).toUpperCase() + this.substring(1);
}

function showGp() {
    $("#gp-info").show();
}

function hideGp() {
    $("#gp-info").hide().find("input[type=text]").val('');
}

function setCookie(name, value) {
    var expire = new Date();
    expire.setTime(expire.getTime() + 3600000*24);
    document.cookie = name + "="+escape(value)+ ";expires="+expire.toGMTString()+"; path=/";
}

// google plus one
  window.___gcfg = {lang: 'en-GB'};

  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();

