//!!depends on lib/jquery/jquery.combined.js

/*
 * The following three variables should be set on the page calling this
 * function using server-side code to output the variable values. go_url
 * is the url the user was originally aiming to hit.  if this doesn't exist,
 * use straight_url for straight links and gay_url for gay links. 
 * */
var go_url="";
var straight_url="";
var gay_url="";

/*
 * Any link that needs to provide the adult pass should have the adult_pass
 * class.  Straight links should also have the straight class, and gay links
 * the gay class.  The code below uses those selectors to determine the redirection
 * target.
 * */
 if(document.cookie){
 $(function(){
	$("a.adult_pass") //add the following click event hander to all adult_pass class links
		.click(function(){
			document.cookie="ADULT_PASS=1; path=/";
			if(go_url!="")
				window.location=go_url;
			else if($(this).hasClass("straight"))
				window.location=straight_url;
			else if($(this).hasClass("gay"))
				window.location=gay_url;
			//this prevents the execution of the link, 
			// so our window.location call works
			return false;
		});
});
}