function loggedIn(destUrl, nonPopUp) {
	var ajaxUrl = 'ajax_logged_in_check';
	var i = Math.round(1000000*Math.random());
	
	new Ajax.Request(ajaxUrl, {
	  method: 'get',
	  parameters: "rand="+i,
	  onSuccess: function(transport) {
	    if (transport.responseText.match(/1/))
	      nonPopUp == 1 ? window.open(destUrl,'','') : openVideoWindow(destUrl);
	    else {
		  var redirect = location.href;
		  redirect = redirect.replace(/\//g, '%2F');
		  window.location = "/member/login?destination="+redirect;
		}
	  }
	});
	
	return false;
}

function loggedIn2(destUrl, linkid, nonPopUp) {
	var ret_val = "";
	var ajaxUrl = '/other/ajax_logged_in_check';
	var i = Math.round(1000000*Math.random());

	new Ajax.Request(ajaxUrl, {
	  method: 'get',
	  parameters: "rand="+i,
	  onSuccess: function(transport) {
	    if (transport.responseText.match(/1/)) {
			if (nonPopUp == 1)
				$(linkid).href = destUrl;
			else {
				$(linkid).onclick = function(){
					openVideoWindow(destUrl);
					return false;
				}
			}
		}
	    else {
		  var redirect = location.href;
		  redirect = redirect.replace(/\//g, '%2F');
			$(linkid).href = "/member/login?destination="+redirect;
		}
	  }
	});
}



function loggedIn3(destUrl, linkid, nonPopUp) {
	var ret_val = "";
	var ajaxUrl = '/other/ajax_logged_in_check';
	var i = Math.round(1000000*Math.random());

	new Ajax.Request(ajaxUrl, {
	  method: 'get',
	  parameters: "rand="+i,
	  onSuccess: function(transport) {
	    if (transport.responseText.match(/1/)) {
			if (nonPopUp == 1)
				$(linkid).href = destUrl;
			else {
				$(linkid).onclick = function(){
					openOtherWindow(destUrl,'',0,0,'');
					return false;
				}
			}
		}
	    else {
		  var redirect = location.href;
		  redirect = redirect.replace(/\//g, '%2F');
			$(linkid).href = "/member/login?destination="+redirect;
		}
	  }
	});
}


function checkLoggedIn(parent_div_id, redirect_link){
	var i = Math.round(1000000*Math.random())
	var ret_val = "0"
	new Ajax.Request('/other/ajax_logged_in_check', {
		method:'get',
		parameters: "rand="+i,
		onSuccess: function(transport) {
			if (transport.responseText != "1")
				notLoggedInLinks(parent_div_id, redirect_link);
		}
	});
}

function notLoggedInLinks(parent_div_id, redirect_link) {
	var links = $(parent_div_id).getElementsByTagName('a');
	if(redirect_link == "") 
		redirect_link = "%2Fmembers%2fmypage";
	for(var i = 0; i < links.length; i++) {
		link = links[i];
		link.href="/member/login?destination="+redirect_link;
		link.onclick = null;
	}
}