$(function() {
       $('#leeftijd-ja').change(function(){
           if (this.checked)
           {
               $('#leeftijdseis').fadeIn();
           }
      }).trigger('change');
      
       $('#leeftijd-nee').change(function(){
           if (this.checked)
           {
                $('#leeftijdseis').fadeOut();
           }
           
      }).trigger('change');
      
       $('#termijn-opgeven').change(function(){
           if (this.checked)
           {
               $('#termijnanders').fadeIn();
           }
      }).trigger('change');
      
       $('#termijn-direct').change(function(){
           if (this.checked)
           {
                $('#termijnanders').fadeOut();
           }
           
      }).trigger('change');      
      
       $('#pgbadmin').change(function(){
           if (this.checked)
           {
               $('#hulpbij').fadeIn();
           }
           else
           {
               $('#hulpbij').fadeOut();
           }
      }).trigger('change');
     
     $('a').click(function() {
         if (!this.href.match(/^https?:\/\//)) {
             // relatieve url
             return;
         }
         
         var urlHost = this.href.replace(/^http:\/\/(www\.)?([^\/]+).*/, '$2');
         var myHost = window.location.host.replace(/^www\./, '');
         if (urlHost.toLowerCase() == myHost.toLowerCase()) {
             return;
         }
         
        window._gaq.push(['_trackEvent', 
            'Externe link', // Category
            urlHost.toLowerCase(),   // Actie (domein)
            this.href.replace(/^http:\/\/([^\/]+)(.*)/, '$2'), // Label (url)
        ]);
     });
});

function eventHandler(evt) { 
    if (evt.type == 'addthis.menu.share') { 
        $.post('../hulpzoeker/geef-extra-garantie/', { service: evt.data.service}, function(response)
        {
            alert(response);
        });

    }
        //alert(evt.data.service); // evt.data.service is specific to the "addthis.menu.share" event
}



function wijzigOntvangFactuur(contractid, keuze){
     $.post('../factuur/ontvangfactuur/', {contractid:contractid, keuze:keuze}, function(response)
        {
            if (response == 1)
            {
                $("#ontvangfactuurja"+contractid).attr('checked', true);
                $("#ontvangfactuurnee"+contractid).attr('checked', false);
            }
            else
            {
                $("#ontvangfactuurja"+contractid).attr('checked', false);
                $("#ontvangfactuurnee"+contractid).attr('checked', true);
            }
     });
}

function stoppenOfDoorgaan(zorgaanvraagid, keuze)
{
        $.post('../matchen/stoppenofdoorgaan/', {zorgaanvraagid:zorgaanvraagid, keuze:keuze, toelichting: $("#toelichting"+zorgaanvraagid).val()}, function(response)
        {
            if (response == true)
            {
                $('#stoppendoorgaan'+zorgaanvraagid).html('<b>Uw bericht is verstuurd!</b>');
            }
            else
            {
                $('#toelichting_error'+zorgaanvraagid).html('<b>Geef een toelichting!</b>');                        
            }

     });    
    
}

function logLinkWerkzoeker()
{
//    window._gaq.push(['_setCustomVar',
//        1,                   // This custom var is set to slot #1.  Required parameter.
//        'Doorgeklikt naar werkzoeker-site',     
//                             // The name acts as a kind of category for the user activity.  Required parameter.
//        'Ja',                // This value of the custom variable.  Required parameter.
//        2                    // Sets the scope to session-level.  Optional parameter.
//    ]);
//    window._gaq.push(['_trackEvent', 
//        'Externe link', // Category
//        'http://www.ikzoekeenzorgzamebijbaan.nl/',   // Actie
//    ]);
}
