function showAdvertisePage(bid,action)
{
	var show = 'adtext';
	view = "advertise";
	if(action)
	{
		show = 'adform';
	}
	$('.blockcontainer').animate(
		{opacity:0},
		function(){
			$('#firstpos').load(
				'/block.php?b='+show,
				function(response)
				{
					$(".accordion").accordion({
						autoHeight: false,
						navigation: true
					});
					$('#firstpos').animate(
						{opacity:1}
					);
				}
			);
			$('#secondpos').html('');
			$('#thirdpos').html('');
		}
	);
	
	

}

function setupAdForm(pid,bid)
{
	if(readCookie('userid') && readCookie('sessid'))
	{
		setupSubmit('#checkoutForm');
		$('#checkoutForm').submit(
			function(){
				alert('Failed to submit. Payment Processor not configured');
				$.ajax({
					type: 'POST',
					url: '/block.php?b=register',
					data: $('#checkoutForm').serialize(),
					dataType: 'json',
					success: function(data, textStatus, jqXHR){
						if(data.status == 201)
						{
							bid = data.bid;
							fancyvars['afterShow'] = function() { selectCoupon(); };
							fancyvars['afterClose'] = function() { 
								var url = '/#!page=profile&bid='+bid;
								alert(url);
								$.history.load(url);
							};
							fancyvars['content'] = jqXHR.responseText;
							fancyvars['autosize'] = true;
							fancyvars['padding'] = 18;
							fancyvars['margin'] = 10;
							fancyvars['wrapCSS'] = 'fb_signup';
							$.fancybox.open(fancyvars);
						}
					}
				});
				return false;
			}
		);
		$('#advertise-wrap a').live('click',function(){
			$('#membershiplevel').val($(this).attr('rel'));
			return false;
		});
	}else{
		window.location = '/signup?redirect=advertis&oid=' + pid + '&do=' + bid;
	}
}
