function readCookie(name) {
	var cookiename = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(cookiename) == 0) return c.substring(cookiename.length,c.length);
	}
	return null;
}
$(document).ready(function() {
	// Trk code
	trkv_temp = readCookie("trkv");
	trks_temp = readCookie("trks");
	if (trkv_temp != null & trks_temp != null ) {
		//alert("Referral cookie found: " + trkv_temp);
		$('a[href^="http"]').not('a[href^="http://www.hepatitis-central.com"]').each(function() {
			href_temp = $(this).attr('href');
			if (href_temp.indexOf('?') != -1) {
				$(this).attr('href',href_temp + '&trkv=' + trkv_temp + '&trks=' + trks_temp);
			} else {
				$(this).attr('href',href_temp + '?trkv=' + trkv_temp + '&trks=' + trks_temp);
			}
		});
	}

});

