/*--------------------------
file: js/ajax_profiles.js
----------------------------
*/

/********** vars *************************************/
var recaptchaDisplayed = 0;

/********** test *************************************/
$(document).ready(function(){
//  $("a").click(function(event){
//    alert("As you can see, the link no longer took you to jquery.com");
//    event.preventDefault();
//  });
});

/********** ajax *************************************/
function submit_signup()
{
	submit_div = document.getElementById( "submitdiv" );
	if ( submit_div )
		submit_div.className = "hidden";

	wait_div = document.getElementById( "waitdiv" );
	if ( wait_div )
		wait_div.className = "visible";
	
	document.myForm.submit();
}

function ajax_carrier_terms( carrier_id )
{
	if ( carrier_id == -1 )
		return;
	
	$( "#att_acct_holder_message").hide();
	chat_url = "ajax_carrier_terms.php?carrier_id=" + carrier_id;
	params = { "carrier_id" : carrier_id				
			 };

	document.getElementById( "carrier_terms_top" ).innerHTML = "";
	$( "#carrier_terms_bottom").load( chat_url, params, ajax_carrier_terms_callback );
	
	// if it's att display the acct holder message
	if (carrier_id == 2)
		$( "#att_acct_holder_message").show();
}

function ajax_carrier_terms_callback()
{
	bottom_html = document.getElementById( "carrier_terms_bottom" ).innerHTML;
	document.getElementById( "carrier_terms_top" ).innerHTML = bottom_html;
}

function ajax_full_bio( profile_id )
{
	chat_url = "ajax_full_bio.php?profile_id=" + profile_id;
	params = { "profile_id" : profile_id				
			 };
	
	more_bio_ele = document.getElementById( "more_bio" );
	if ( more_bio_ele.innerHTML == "" )
	{
		$( "#more_bio").load( chat_url, params, ajax_full_bio_callback );
	}
	else
	{
		ajax_full_bio_callback();
	}
}

function bio_toggle( more )
{
	less_bio_ele = document.getElementById( "less_bio" );
	less_bio_ele.className = ( more ) ? ( "hidden" ) : ( "visible" );
	
	more_bio_ele = document.getElementById( "more_bio" );
	more_bio_ele.className = ( more ) ? ( "visible" ) : ( "hidden" );
	
	less_link_ele = document.getElementById( "less_bio_link" );
	less_link_ele.className = ( more ) ? ( "visible" ) : ( "hidden" );
}

function ajax_full_bio_callback()
{
	bio_toggle( true );
}

function less_bio()
{
	bio_toggle( false );
}

/********** reCaptcha API *************************************/

function showRecaptcha(element) {
	if (recaptchaDisplayed != 1) {
		Recaptcha.create("6LehxQcAAAAAAAh3L7nID6l6LTmutLQWahtnazWl", 'dynamic_reCaptcha');
	};
	recaptchaDisplayed = 1;
}

function hideSubmitButtons() {
  //document.getElementById('submit_button_1').style.visibility = "hidden";
 // document.getElementById('submit_button_2').style.visibility = "hidden";
 // document.getElementById('submit_button_3').style.visibility = "hidden";
}

function destroyRecaptchaWidget() {
  hideSubmitButtons();
  Recaptcha.destroy();
}


