var TAF_ITEM = {}



function taf(){
	sendPopupRequest( 'taf');
	
	//hiding the registration option boxes
	$('#province').hide();
	$('#dd').hide()
	$('#mm').hide()
	$('#yyyy').hide()
	$('#other_children').hide()
	$('#option_right').hide()
	$('#heinz_refer').hide()
	$('#number_children').hide()
	//end hiding the registration option boxes
	
}


function sendtaf(){
	TAF_ITEM[ 'your_name' ]  =  $('#your_name_inp').val();
	TAF_ITEM[ 'your_email' ] =  $('#your_email_inp').val();	
	TAF_ITEM[ 'your_message' ] =  $('#your_message_inp').val();	
	
	var friende_name;
	var friende_mail;
	for (var x=1;x<=5;x++){
		friend_name  = "friend_name_inp"+x;
		friend_email = "friend_email_inp"+x;
		TAF_ITEM[ friend_name ]  =  $('#'+friend_name).val();
		TAF_ITEM[ friend_email ] =  $('#'+friend_email).val();	
	}

	$.post( "/en_ca/taf/ajax_response/taf_response.php", TAF_ITEM, TafResponse, "json" );

}

function TafResponse(data){
	
	if(data[0] == "true"){
		//Display confirmation table//
		$('#taf_error_text').html("Thanks for sharing the Heinz Baby Club with your friends!<br><br>Your email has been sent.");
		$('#taf_error_button').html("<img src='/en_ca/products/includes/images/helpful_tools/bt_ok.jpg' onclick=\"javascript:hideTools();\" width='70' height='26' >");
		showTafError();	
		TAF_ITEM  = {};			
	}	
	else{
		//This condition is met if the user updates to a product with already exists
		var error_text_full = data[1];
		$('#taf_error_text').html(error_text_full);
		showTafError();	
	}		
}

function showTafError()
{
  //this function shows the menu planner error and hides the main content area
  $('#taf_error_content').show()
  $('#taf_content').hide()
}

function hidetafError(){
	$('#taf_error_content').hide();
	$('#taf_content').show();
}

function hideTools()
{
	BAM_AD_hide();
	
	//showing the registration option boxes
	$('#province').show();
	$('#dd').show()
	$('#mm').show()
	$('#yyyy').show()
	$('#other_children').show()
	$('#option_right').show()
	$('#heinz_refer').show()
	$('#number_children').show()
	//end showing the registration option boxes
}

	


