//create global cookie function
cookie = $.cookie;
$(document).ready(function() {
  
  $("#cancel").click(function () {
      log("In 'click' for cancel.");
  });
  
  $("#accept").click(function () {
      log("In 'click' for accept");;
      // Set a cookie to expire in 90 days.
      cookie("dl_tos", "accepted", { path: '/', domain: ".hmpdacc.org", expires: 90 });
      //cookie("dl_tos", "accepted", { path: '/', domain: ".umaryland.edu", expires: 90 });
      log("Redirecting to " + cur_href);
      if (cur_href) {
    	  document.location.href=cur_href;
      }
      if (cur_obj_link) {
    	  downloadFile(cur_obj_link);
      }
  });

  $('#facebox').overlay({
					top: '20%',
					mask: '#000',
					closeOnClick: false
				}
		);
  
  $(".download a").click(function() {
		//if they have already accepted the cookie, send them onto the file
		if (cookie("dl_tos") == 'accepted') {
			return null;
		}
		
		//remove the file link and save it in a global variable
		cur_href = $(this).attr('href');
		//$(this).attr('href','javascript:void(0);');
		// load the overlay
		$('#facebox').overlay({}).load();
		return false;
	});
});

