function mailInUseErrorEditProfile()
{
	
	alert("E-mailadressen er allerede i brug");
};	

function postalCodeNotNumberErrorEditProfile()
{

	$('nProfilePostalCode').className='half_field_error';
	
	alert("Postnummer må kun indeholde tal");
};


function loginLayerOpenForgotPassword()
{
	$('travelClubLoginLayerFieldContainer').hide();
	$('travelClubLoginLayerLoginContainer').hide();


	$('travelClubLoginLayerForgotPasswordContainer').show();
	
}


function loginLayerOpenLogin()
{
	$('travelClubLoginLayerFieldContainer').show();
	$('travelClubLoginLayerLoginContainer').show();


	$('travelClubLoginLayerForgotPasswordContainer').hide();
	
}

function sendPasswordFromLoginLayer()
{
	
	if($('loginLayerForgotPassword').value == $('loginLayerForgotPassword').defaultValue)
	{
		alert(token_javascript_input_email_address);
		
	}
	else if(! checkIsEmail($('loginLayerForgotPassword').value))
	{
		alert(token_javascript_invalid_email);
	}
	else
	{
		new Ajax.Request("/ajax.cfm", 
		{
			method: 'post',
			parameters: 
			{
				action: 'requestProfilePassword',
				sLogin: $('loginLayerForgotPassword').value,
				sAjaxPath: '/inc/ajax/profile_ajax_requests.cfm',
				uniqueValue: makeUniqueValue()
			},
			onLoading: function(){
			
			},
			onSuccess: function(transport){
				// Success
				var response = transport.responseText || "no response text";
				var splitArray = response.split("[TM_SPLIT]", 2);
				
				if(parseInt(splitArray[0],10) == 0  )
				{
					alert('Email med password sendt');
					loginLayerOpenLogin();
					
				}
				else if(parseInt(splitArray[0],10) == 1  )
				{
					alert(token_javascript_email_not_found);
					
					
				}
				
			}
		});
		
		
	}
	
	
		
}





function toggleGouda()
{
	if($('goudaCheckBox').checked)
	{
		$('profileCreateButtonMiddle').update(token_javascript_save_and_action1);
	
	}
	else
	{
		$('profileCreateButtonMiddle').update(token_javascript_save_profile);
	}
}


function unknownErrorEditProfile()
{
	alert(token_javascript_unhandled_error_occurred);
};


function savedOkEditProfile()
{
	alert(token_javascript_profiled_saved);
};

function changePasswordEditProfile()
{
	new Ajax.Request("/ajax.cfm", 
	{
		method: 'post',
		parameters: 
		{
			action: 'changePassword',
			sAjaxPath: '/inc/ajax/profile_ajax_requests.cfm',
			sPasswordNow: $('sPasswordNow').value,
			sPasswordNew: $('sPasswordNew').value,
			sPasswordNewRepeat: $('sPasswordNewRepeat').value,
			uniqueValue: makeUniqueValue()
		},
		onLoading: function(){
		
		},
		onSuccess: function(transport){
			// Success
			var response = transport.responseText || "no response text";
			
			var splitArray = response.split("[TM_SPLIT]", 2);
			if (parseInt(splitArray[0], 10) == 0) 
			{
				alert(token_javascript_password_changed);
				 $('sPasswordNow').value = '';
				 $('sPasswordNew').value = '';
				 $('sPasswordNewRepeat').value = '';
				 $('changePasswordBox').hide();
			}
			else if(parseInt(splitArray[0], 10) == 1)
			{
				alert(token_javascript_current_password_wrong);
			}
			else if(parseInt(splitArray[0], 10) == 2)
			{
				alert(token_javascript_new_password_and_repeat_new_password_mismatch);
			}
			else if(parseInt(splitArray[0], 10) ==3)
			{
				alert(token_javascript_new_password_length_error);
			}
			else 
			{
				alert(token_javascript_unhandled_error_occurred);
				
			}
			
		}
	});
}


function profileLogOut()
{
	new Ajax.Request("/ajax.cfm", 
	{
		method: 'post',
		parameters: 
		{
			action: 'logout',
			sAjaxPath: '/inc/ajax/profile_ajax_requests.cfm',
			uniqueValue: makeUniqueValue()
		},
		onLoading: function(){
		
		},
		onSuccess: function(transport){
			// Success
			var response = transport.responseText || "no response text";
			window.location.reload(true);
		}
	});
	
}

function toggleLoginLayer()
{
	if(bTravelClubLayerOpen)
	{
		
		bTravelClubLayerOpen = 0;
		$('travelClubLoginContainer').className="closed";
		$('travelClubLoginLayer').hide();
	}
	else
	{
		
		bTravelClubLayerOpen = 1;
		$('travelClubLoginContainer').className="open";
		$('travelClubLoginLayer').show();
	}
}

function loginFromLoginLayer()
{
	new Ajax.Request("/ajax.cfm", 
	{
		method: 'post',
		parameters: 
		{
			action: 'doProfileLoginFromLoginLayer',
			sLogin: $('loginLayerLogin').value,
			sAjaxPath: '/inc/ajax/profile_ajax_requests.cfm',
			sPassword: $('sLoginLayerPassword').value,
			bRememberMe: $('rememberMeLayerCheckbox').checked,
			uniqueValue: makeUniqueValue()
		},
		onLoading: function(){
		
		},
		onSuccess: function(transport){
			// Success
			var response = transport.responseText || "no response text";
			var splitArray = response.split("[TM_SPLIT]", 2);
			
			if (parseInt(splitArray[0], 10) == 0) 
			{				
				/*window.open(splitArray[1],'_self');*/
				/*alert('Logged in');*/
				window.location.reload(true);
				
			}
			else if(parseInt(splitArray[0], 10) == 1)
			{
				if(confirm(token_javascript_login_not_activated))
				{
					doSendActivationEmail();
				}
						
			}
			else if(parseInt(splitArray[0], 10) == 2)
			{
			
				alert(token_javascript_login_or_password_incorrect);
			}	
		}
	});
}




function doProfileLoginAndPopClickThrough()
{
	var bLoggedIn = false;
	
	new Ajax.Request("/ajax.cfm", 
	{
		method: 'post',
		asynchronous: false,
		parameters: 
		{
			action: 'doProfileLoginAndGoToPayment',
			sLogin: $('sLoginEmail').value,
			sAjaxPath: '/inc/ajax/profile_ajax_requests.cfm',
			sPassword: $('sLoginPassword').value,
			bRememberMe: $('rememberMeCheckbox').checked,
			uniqueValue: makeUniqueValue()
		},
		onLoading: function()
		{

		},
		onSuccess: function(transport){
			// Success
			var response = transport.responseText || "no response text";
			var splitArray = response.split("[TM_SPLIT]", 2);
			
			if (parseInt(splitArray[0], 10) == 0) 
			{	
				ShowClickThroughPage();
				backToOfferPage();
			}
			else if(parseInt(splitArray[0], 10) == 1)
			{
				if(confirm(token_javascript_login_not_activated))
				{
					doSendActivationEmail();
					
				}			
			}
			else if(parseInt(splitArray[0], 10) == 2)
			{
				alert(token_javascript_login_or_password_incorrect);
				
			}	
		}
	});
	
	
}


function doProfileLoginAndGoToPayment()
{
	/*
	 *  /tmcomponents/modules/tm_profile/public/templates/template4/ajax/profile4.cfm
	 * */
	new Ajax.Request("/ajax.cfm", 
	{
		method: 'post',
		parameters: 
		{
			action: 'doProfileLoginAndGoToPayment',
			sLogin: $('sLoginEmail').value,
			sAjaxPath: '/inc/ajax/profile_ajax_requests.cfm',
			sPassword: $('sLoginPassword').value,
			bRememberMe: $('rememberMeCheckbox').checked,
			uniqueValue: makeUniqueValue()
		},
		onLoading: function(){
		
		},
		onSuccess: function(transport){
			// Success
			var response = transport.responseText || "no response text";
			var splitArray = response.split("[TM_SPLIT]", 2);
			
			/*$('travelClubProfileLoginBoxTop').update(response);*/
			if (parseInt(splitArray[0], 10) == 0) 
			{	
				
						
				/*window.open(splitArray[1],'_self');*/
				
				doCalculatePrice(3);
				/*$('travelClubProfileCreateForm').submit();*/
				
				
			}
			else if(parseInt(splitArray[0], 10) == 1)
			{
				if(confirm(token_javascript_login_not_activated))
				{
					doSendActivationEmail();
				}
						
			}
			else if(parseInt(splitArray[0], 10) == 2)
			{
				alert(token_javascript_login_or_password_incorrect);
				
			}	
		}
	});
	
}

function doSendActivationEmail()
{
	new Ajax.Request("/ajax.cfm", 
	{
		method: 'post',
		parameters: 
		{
			action: 'sendActivationEmail',
			sLogin: $('sLoginEmail').value,
			sAjaxPath: '/inc/ajax/profile_ajax_requests.cfm',
			sPassword: $('sLoginPassword').value,
			uniqueValue: makeUniqueValue()
		},
		onLoading: function(){
		
		},
		onSuccess: function(transport){
			// Success
			var response = transport.responseText || "no response text";
			
			var splitArray = response.split("[TM_SPLIT]", 2)
			
			
			if (parseInt(splitArray[0], 10) == 0) 
			{
				alert(token_javascript_activation_email_sent);
			}else if (parseInt(splitArray[0], 10) == 1) 
			{
				alert(token_javascript_unhandled_error_occurred);
			}
			
			
			
			
			
			
		}
	});
}


function requestProfilePassword()
{
	
	if($('sForgotEmail').value == $('sForgotEmail').defaultValue)
	{
		alert(token_javascript_input_email_address);
		
	}
	else if(! checkIsEmail($('sForgotEmail').value))
	{
		alert(token_javascript_invalid_email);
	}
	else
	{
		new Ajax.Request("/ajax.cfm", 
		{
			method: 'post',
			parameters: 
			{
				action: 'requestProfilePassword',
				sLogin: $('sForgotEmail').value,
				sAjaxPath: '/inc/ajax/profile_ajax_requests.cfm',
				uniqueValue: makeUniqueValue()
			},
			onLoading: function(){
			
			},
			onSuccess: function(transport){
				// Success
				var response = transport.responseText || "no response text";
				var splitArray = response.split("[TM_SPLIT]", 2);
				
				if(parseInt(splitArray[0],10) == 0  )
				{
					
					$('travelClubProfileLogin').show();
					$('travelClubProfileForgotPassword').hide();
					$('sLoginEmail').value=$('sForgotEmail').value;
					$('sLoginEmail').className='field';
					alert('Email med password sendt');
					$('sLoginPassword').className = 'field_selected';
					$('sLoginPasswordLoad').className = 'field_selected';
				}
				else if(parseInt(splitArray[0],10) == 1  )
				{
					alert(token_javascript_email_not_found);
					
					
				}
				
			}
		});
		
		
	}
}



function saveEditProfile1()
{
	if(validateEditProfile1())
	{
		$('travelClubProfileEditForm').submit();
	}
	else
	{
		
	}
	
	
}



function saveProfile1()
{
	
	if(validateSaveProfile1())
	{
		$('travelClubProfileCreateForm').submit();
	}	
	else
	{
		
	}
}
;

function validateEditProfile1()
{
	var nCriticalErrors  = 0;
	if ($('sProfileFirstName').value == '') 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_please_input_firstname);
		
		$('sProfileFirstName').className = 'half_field_error';
	}
	else if ($('sProfileLastName').value == '') 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_please_input_lastname);
		
		$('sProfileLastName').className = 'half_field_error';
	}		
	else if ($('sProfileLogin').value == '') 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_please_input_email);
		$('sProfileLogin').className = 'half_field_error';
	}
	else if (!checkIsEmail($('sProfileLogin').value)) 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_invalid_email);
		$('sProfileLogin').className = 'half_field_error';
	}
	else if($('goudaStep') && $('goudaCheckBox') && $('goudaCheckBox').checked)
	{
		if($('sProfileAdress1').value == '')
		{
			nCriticalErrors = nCriticalErrors + 1;
			alert(token_javascript_adress_required_for_action1);
		}
		else if($('nProfilePostalCode').value == "")
		{
			nCriticalErrors = nCriticalErrors + 1;
			alert(token_javascript_postalcode_required_for_action1);
			
		}	
		else if($('sProfileCity').value == "")
		{
			nCriticalErrors = nCriticalErrors + 1;
			alert(token_javascript_city_required_for_action1);
			
		}	
		
	}	
	if(nCriticalErrors != 0)
	{
		return false;
	}
	else
	{
		return true;
	}
	
}


function validateSaveProfile1()
{
	var nCriticalErrors  = 0;
	if ($('sProfileFirstName').value == '') 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_please_input_firstname);
		
		$('sProfileFirstName').className = 'half_field_error';
	}
	else if ($('sProfileLastName').value == '') 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_please_input_lastname);
		
		$('sProfileLastName').className = 'half_field_error';
	}		
	else if ($('sProfileLogin').value == '') 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_please_input_email);
		$('sProfileLogin').className = 'half_field_error';
	}
	else if ($('sProfileLoginRepeat').value == '') 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_please_input_email_repeat);
		$('sProfileLoginRepeat').className = 'half_field_error';
	}
	else if ($('sProfileLoginRepeat').value != $('sProfileLogin').value) 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_email_email_repeat_mismatch);
		$('sProfileLoginRepeat').className = 'half_field_error';
	}
	else if ($('sProfilePassword').value.length < 6) 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_password_invalid_lenght);
		$('sProfilePassword').className = 'half_field_error';
	}	
	else if ($('sProfilePassword').value == '') 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_please_input_password);
		$('sProfilePassword').className = 'half_field_error';
	}
	else if ($('sProfilePasswordRepeat').value == '') 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_please_input_password_repeat);
		$('sProfilePasswordRepeat').className = 'half_field_error';
	}
	else if (!checkIsEmail($('sProfileLogin').value)) 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_invalid_email);
		$('sProfileLogin').className = 'half_field_error';
	}
	else if ($('sProfilePasswordRepeat').value != $('sProfilePassword').value) 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_password_password_repeat_mismatch);
		$('sProfilePasswordRepeat').className = 'half_field_error';
		$('sProfilePassword').className = 'half_field_error';
	}
	if(nCriticalErrors != 0)
	{
		return false;
	}
	else
	{
		return true;
	}
		
	
}




function saveProfile(type)
{
	var bContinueToSave = 0;

	if(validateProfileUser())
	{
		/*if($('sProfilePhoneMobile') && $('sProfilePhoneMobile').value=='')
		{
			if (confirm(token_javascript_sure_create_no_phone)) 
			{
				bContinueToSave = 1;
			}
			else
			{
				$('sProfilePhoneMobile').className = 'half_field_error';
				bContinueToSave = 0;
			}
			
		}
		else
		{
			bContinueToSave = 1;
		}*/
		bContinueToSave = 1;
	}
	
	
	
	
	

	
	if(bContinueToSave)
	{
	
		
		new Ajax.Request("/ajax.cfm", 
		{
			method: 'post',
			asynchronous: false,
			parameters: 
			{
				action: 'saveProfile',
				sAjaxPath: '/inc/ajax/profile_ajax_requests.cfm',
				sFirstName: $('sProfileFirstName').value,
				sLastName: $('sProfileLastName').value,
				sPhoneMobile: $('sProfilePhoneMobile').value,
				sLogin: $('sProfileLogin').value,
				sPassword: $('sProfilePassword').value,
				uniqueValue: makeUniqueValue()
			},
			onLoading: function()
			{
			},
			onSuccess: function(transport)
			{
				// Success
				var response = transport.responseText || "no response text";
				var splitArray = response.split("[TM_SPLIT]", 2)
			
				if (parseInt(splitArray[0], 10) == 0) 
				{
					if (type == 1) 
					{
						$('travelClubProfileCreateForm').submit();
					}
					else if(type == 2)
					{
						ShowClickThroughPage();
						backToOfferPage();
					}
				}
				else if (parseInt(splitArray[0], 10) == 1) 
				{
					alert(token_javascript_profile_exists);
				}
				else if (parseInt(splitArray[0], 10) == 2) 
				{
					alert(token_javascript_unknown_create_error_try_again);
				}
				else if (parseInt(splitArray[0], 10) == 3) 
				{
					alert(token_javascript_unhandled_error_occurred);
				}
				
			}
		});	
			
	
	}
	
	
	
		
	
}



function validateProfileUser()
{
	var nCriticalErrors = 0 ;
	
	try {
	if ($('sProfileFirstName').value == '') 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_please_input_firstname);
			
		$('sProfileFirstName').className = 'half_field_error';
	}
	else if ($('sProfileLastName').value == '') 
	{
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_please_input_lastname);
		$('sProfileLastName').className = 'half_field_error';
	}
			else 
				if ($('sProfileLogin').value == '') {
					nCriticalErrors = nCriticalErrors + 1;
					alert(token_javascript_please_input_email);
					
					$('sProfileLogin').className = 'half_field_error';
					
				}
				else 
					if ($('sProfileLoginRepeat').value == '') {
						nCriticalErrors = nCriticalErrors + 1;
						alert(token_javascript_please_input_email_repeat);
						
						$('sProfileLoginRepeat').className = 'half_field_error';
						
					}
				else 
					if ($('sProfileLoginRepeat').value != $('sProfileLogin').value) {
						nCriticalErrors = nCriticalErrors + 1;
						alert(token_javascript_email_email_repeat_mismatch);
						
						$('sProfileLoginRepeat').className = 'half_field_error';
						
					}	
					
					else if ($('sProfilePassword').value.length < 6) 
					{
						nCriticalErrors = nCriticalErrors + 1;
						alert(token_javascript_password_invalid_lenght);
						$('sProfilePassword').className = 'half_field_error';
					}	
					else 
						if ($('sProfilePassword').value == '') {
							nCriticalErrors = nCriticalErrors + 1;
							alert(token_javascript_please_input_password);
							
							$('sProfilePassword').className = 'half_field_error';
							
						}
						else 
							if ($('sProfilePasswordRepeat').value == '') {
								nCriticalErrors = nCriticalErrors + 1;
								alert(token_javascript_please_input_password_repeat);
								
								$('sProfilePasswordRepeat').className = 'half_field_error';
								
							}
							else 
								if (!checkIsEmail($('sProfileLogin').value)) {
									nCriticalErrors = nCriticalErrors + 1;
									alert(token_javascript_invalid_email);
									
									$('sProfileLogin').className = 'half_field_error';
									
								}
								else 
									if ($('sProfilePasswordRepeat').value != $('sProfilePassword').value) {
										nCriticalErrors = nCriticalErrors + 1;
										alert(token_javascript_password_password_repeat_mismatch);
										
										$('sProfilePasswordRepeat').className = 'half_field_error';
										$('sProfilePassword').className = 'half_field_error';
									}
									else 
										if (bOverBooked == 1) 
										{
											nCriticalErrors = nCriticalErrors + 1;
											alert(token_javascript_not_enough_offers_left);
										}
	} catch(err) {
		nCriticalErrors = nCriticalErrors + 1;
		alert(token_javascript_unhandled_error_occurred);
	}
	
	
	if(nCriticalErrors == 0)
	{
		return true;
		
	}
	else
	{
		return false;
	}
	
}


function goToBooking(type)
{
	$('travelClubProfileCreateForm').submit();
}


function submitProfileUser()
{
	var nCriticalErrors = 0;
	
	if ($('sProfileFirstName').value == '') 
	{
		alert('please fill in first name');
		nCriticalErrors = nCriticalErrors + 1;
		$('sProfileFirstName').className = 'half_field_error';
	}
	else if ($('sProfileLastName').value == '') 
	{
		alert('please fill in last name');
		nCriticalErrors = nCriticalErrors + 1;
		$('sProfileLastName').className = 'half_field_error';
			
	}
	else if ($('sProfileLogin').value == '') 
	{
		alert('please fill in e-mail address');
		nCriticalErrors = nCriticalErrors + 1;
		$('sProfileLogin').className = 'half_field_error';
			
	}
	else if ($('sProfileLoginRepeat').value == '') 
	{
		alert('please fill in repeat e-mail address');
		nCriticalErrors = nCriticalErrors + 1;
		$('sProfileLoginRepeat').className = 'half_field_error';
			
	}
	else if ($('sProfileLoginRepeat').value == '') 
	{
		alert('please fill in repeat e-mail address');
		nCriticalErrors = nCriticalErrors + 1;
		$('sProfileLoginRepeat').className = 'half_field_error';
			
	}
	else if ($('sProfilePassword').value == '') 
	{
		alert('please fill in password');
		nCriticalErrors = nCriticalErrors + 1;
		$('sProfilePassword').className = 'half_field_error';
			
	}
	else if ($('sProfilePasswordRepeat').value == '') 
	{
		alert('please fill in repeat password');
		nCriticalErrors = nCriticalErrors + 1;
		$('sProfilePasswordRepeat').className = 'half_field_error';
			
	}
	else if(!checkIsEmail($('sProfileLogin').value))
	{
		alert('email invalid');
		nCriticalErrors = nCriticalErrors + 1;
		$('sProfileLogin').className = 'half_field_error';
		
	}
	else if ($('sProfilePasswordRepeat').value != $('sProfilePassword').value) 
	{
		alert('Password and repeat password must the same');
		nCriticalErrors = nCriticalErrors + 1;
		$('sProfilePasswordRepeat').className = 'half_field_error';
		$('sProfilePassword').className = 'half_field_error';	
	}
	else if($('confirmTermsCheckbox') && !$('confirmTermsCheckbox').checked)
	{
		alert('You must accept the terms to continue');
		nCriticalErrors = nCriticalErrors + 1;
		
	}
	else if($('confirmTermsCheckbox') &&  bOverBooked)
	{	
		nCriticalErrors = nCriticalErrors + 1;
		alert("Not enough offers left");
	}
		
	
	
	
	
	if(nCriticalErrors == 0)
	{
		
		
		
		
		/*if($('sProfilePhoneMobile').value=='')
		{
			if (confirm("Are you sure you want to create without cellphone number?")) 
			{
				$('travelClubProfileCreateForm').submit();
			}
			else
			{
				$('sProfilePhoneMobile').className = 'half_field_error';
				
			}
			
		}
		else
		{
			$('travelClubProfileCreateForm').submit();
		}
		*/
		$('travelClubProfileCreateForm').submit();
		
	}	
	
}





function checkIsEmail(sString)
{
	/*var filter=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;*/
	var filter= /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if(filter.test(sString))
		{
			return true;
	}
	else
	{
		
		return false;
	}
	
}

function numbersonly(myfield, e, dec)
	{
		var key;
		var keychar;
		 
		if (window.event)
		  key = window.event.keyCode;
		else if (e)
		  key = e.which;
		else
		  return true;
		keychar = String.fromCharCode(key);
		 
		// control keys
		if ((key==null) || (key==0) || (key==8) || 
		    (key==9) || (key==13) || (key==27) )
		  return true;
		 
		// numbers
		else if ((("0123456789").indexOf(keychar) > -1))
		  return true;
		 
		// decimal point jump
		else if (dec && (keychar == "."))
		  {
		  myfield.form.elements[dec].focus();
		  return false;
		  }
		else
		  return false;
	}

	
	
	
	
	
	function calculatePrice(type)
	{
		try
        {
           window.clearTimeout(DataFetcher);
        }
        catch(err)
        {}
        DataFetcher = window.setTimeout("doCalculatePrice("+type+")",500);
		
	}
	
	
	function doCalculatePrice(type)
	{
		bOverBooked = 1;
		
		
		if(type != 1 && ($('numberOfOffers_1').value == '' || $('numberOfOffers_1').value == 0)) 
		{
			$('numberOfOffers_1').value = 1;
			
		}
		
		
		
			if ($('numberOfOffers_1').value == '' || $('numberOfOffers_1').value == 0) 
			{
				$('priceTotal_1').update("");
				
			}
			else {
				new Ajax.Request("/ajax.cfm", {
					method: 'post',
					parameters: {
						action: 'calculatePrice',
						sAjaxPath: '/inc/ajax/profile_ajax_requests.cfm',
						product_id: $('product_id_1').value,
						numberOfOffers: $('numberOfOffers_1').value,
						uniqueValue: makeUniqueValue()
					},
					onLoading: function(){
					
					},
					onSuccess: function(transport){
						// Success
						var response = transport.responseText || "no response text";
						var splitArray = response.split("[TM_SPLIT]", 2)
						
						
						
						$('priceTotal_1').update(splitArray[0]);
						
						if (parseInt(splitArray[1], 10) == 1) {
						
							bOverBooked = 1;
						}
						else {
							bOverBooked = 0;
						}
						
						
						if (type == 2) 
						{
							
							saveProfile(1);
						}
						
						if (type == 3) 
						{
							
							goToBooking(1);
						}
						
					}
				});
			}
			
		
		
			
	}	
		
		
	function doCreateAndPopClickThrough()
	{
		
		
		saveProfile(2);
		
		
		
		
		
		
		
		
	}
		
		
		
	
	
		
		function mailInUseError()
		{
			
			alert(token_javascript_email_in_use);
			$('sLoginEmail').value = $('sProfileLogin').value;
			$('sLoginEmail').className = 'field_selected';
			$('sLoginEmail').focus();
		}
		
		

	
