﻿
$(document).ready(function () {
    //check to see if there is a cookie
    if (GetCookie("GCGHcampaign") != null) {
        $(".gc_mainContent a").each(function () {
            var anchor = $(this).attr("href");
            var linkText = $(this).text();
            //alert("a: "+anchor);
            if (anchor.toLowerCase().indexOf("gatesfoundation.org") != -1 || anchor.toLowerCase().indexOf("/gatesfoundation/") != -1) {
                //alert($(this).attr("href"));
                if (anchor.toLowerCase().indexOf("mailto:") > -1) {
                }
                else if (anchor.indexOf("?") != -1) {
                    $(this).attr("href", anchor + '&extid=' + GetCookie("GCGHcampaign"));
                    $(this).text(linkText);
                }
                else {
                    $(this).attr("href", anchor + '?extid=' + GetCookie("GCGHcampaign"));
                    $(this).text(linkText);
                }
                //alert($(this).attr("href"));
                //alert($(this).text());
            }
        });
    }
});



