function signup_popup()
{
	this.url = "/includes/landing/signup_popup.php";
	this.submit_url = "/includes/landing/signup_popup_form_submit.php";
	this.ajax_id = "";
	this.aff_id = "";
	
	this.open = function( profile_id, ajax_id, l, type, aff_id )
	{	
		this.ajax_id = ajax_id;
		this.aff_id = aff_id;
				
		params = {};
		params.profile_id = profile_id;
		params.l = l;
		params.type = type;
		
		ele_name = "#" + ajax_id;
		
		$( ele_name ).load( this.url, params, this.open_callback );		
	}
	
	this.close = function()
	{
		document.getElementById( this.ajax_id ).innerHTML = "";
	}
	
	this.open_callback = function( res_text, res_code, http_request )
	{
	}
	
	this.submit_form = function()
	{
		form = document.signup_form;
		
		if ( !form.terms.checked )
		{
			alert( "You must agree to the terms before submitting." );
			return;
		}
		
		document.getElementById( "submit_div" ).className = "hidden";
		document.getElementById( "wait_div" ).className = "visible";
		
		params = {};
		params.phone1 = form.phone1.value;
		params.phone2 = form.phone2.value;
		params.phone3 = form.phone3.value;
		params.carrier_id = form.carrier_id.value;
		params.captcha = form.captcha.value;
		params.profile_id = form.profile_id.value;
		
		ele_name = "#result_div";		
		$( ele_name ).load( this.submit_url, params, this.submit_callback );
	}
	
	this.submit_callback = function( responseText, textStatus, XMLHttpRequest )
	{
		document.getElementById( "submit_div" ).className = "visible";
		document.getElementById( "wait_div" ).className = "hidden";
		
		explode = explodeParamStr( responseText );
		cell = explode[ "cell" ];
		font_class = ( explode[ "res_code" ] == 0 ) ? ( "sp_result_fail" ) : ( "sp_result_success" );
		
		msg = urldecode( explode[ "res_msg" ] );
		document.getElementById( "result_div" ).innerHTML = "<font class='" + font_class + "'>" + msg + "</font>";
		
		if ( explode[ "res_code" ] == 1 )
			track_pixel( signup_popup.aff_id, "join", cell );
	}
}

signup_popup = new signup_popup;
