
	function createNewWindow(sUrl)
	{
		window.open(sUrl);
		return false;
	}
	
//	var leftFirstPage = null;
//	var leftSecondPage = null;
//	var rightFirstPage = null;
//	var rightSecondPage = null;
	
	function switchText()
	{
		var leftFirstPage = document.getElementById('leftFirstPage');
		var leftSecondPage = document.getElementById('leftSecondPage');
		var rightFirstPage = document.getElementById('rightFirstPage');
		var rightSecondPage = document.getElementById('rightSecondPage');

		if (leftSecondPage.style.display == "none" && leftFirstPage.style.display == "")
		{
			leftSecondPage.style.display = "";
			leftFirstPage.style.display = "none";
			
			rightSecondPage.style.display = "";
			rightFirstPage.style.display = "none";
			
			document.getElementById("textLink").innerHTML = 'Vorige pagina';
		}
		else
		{
			leftSecondPage.style.display = "none";
			leftFirstPage.style.display = "";
			
			rightSecondPage.style.display = "none";
			rightFirstPage.style.display = "";
			
			document.getElementById("textLink").innerHTML = 'Volgende pagina';
		}
		
	}

	function checkCountry()
	{
		var oBelgiumRadioButton = getElement('be_country_box');
		var oBelgiumDiv 		= getElement('belgium_address');
		var oDutchDiv 			= getElement('dutch_address');
		//var oBelgiumDivQ 		= getElement('belgium_address_quick');
		//var oDutchDivQ 			= getElement('dutch_address_quick');

		var oTelephoneRow		= getElement('telephone_part');

		oDutchDiv.style.display 	= '';
		oBelgiumDiv.style.display 	= 'none';
		//oDutchDivQ.style.display 	= '';
		//oBelgiumDivQ.style.display 	= 'none';
		if (null !== oTelephoneRow)
		{
			oTelephoneRow.style.display = 'none';
		}

		if (true === oBelgiumRadioButton.checked)
		{
			oBelgiumDiv.style.display 	= '';
			oDutchDiv.style.display 	= 'none';
			//oBelgiumDivQ.style.display 	= '';
			//oDutchDivQ.style.display 	= 'none';
			if (null !== oTelephoneRow)
			{
				oTelephoneRow.style.display = '';
				getElement('telephone').value = '';
			}
		}
	}

	function getElement(sElementName)
	{
		return document.getElementById(sElementName);
	}

	function getAllElements(sTagName)
	{
		return document.getElementsByTagName(sTagName);
	}

	function Redirect(sUrl)
	{
		document.location.href = sUrl;
	}

	function isset(sVarname)
	{
		return sVarname != undefined;
	}

	function isNumeric(sText)
	{
	   var ValidChars = "0123456789.";
	   var IsNumber=true;
	   var Char;
	   var i;

	   for (i = 0; i < sText.length && IsNumber == true; i++)
	      {
	      Char = sText.charAt(i);
	      if (ValidChars.indexOf(Char) == -1)
	         {
	         IsNumber = false;
	         }
	      }
	   return IsNumber;

	}

	function empty(sText)
	{
		if (sText === "" || sText === null)
		{
			return true;
		}
		return false;
	}

	function strlen(sText)
	{
		return sText.length;
	}

	function strtoupper(sText)
	{
		if ("undefined" !== typeof(sText))
		{
			return sText.toUpperCase();
		}
		return sText;
	}

	function strtolower(sText)
	{
		return sText.toLowerCase();
	}
	
	function ucfirst(sText)
	{
		var sFirstChar = sText.substr(0,1);
		var sResponse = sFirstChar.toUpperCase() + sText.substr(1);
		if (sResponse.substr(0,2) == 'S ')
		{
			sResponse = "'S "+ sText.substr(2,1).toUpperCase() + sText.substr(3);
		}
		return sResponse;
	}

	function trim(sText)
	{
  		sText = sText.replace(/^\s+/,'');
  		sText = sText.replace(/\s+$/,'');
  		return sText;
	}

	function strpos(sHayStack, sNeedle)
	{
		return sHayStack.indexOf(sNeedle);
	}

	function checkdate( sMonth, sDay, sYear )
	{
	    var sMyDate = new Date();
    	sMyDate.setFullYear( sYear, (sMonth - 1), sDay );
	    return ( (sMyDate.getMonth()+1) == sMonth );
	}

	function ReverseString(sString)
	{
		var sNewString = '';
		for (i = strlen(sString); i >= 0; i--)
		{
			sNewString += sString.substr(i,1);
		}
		return sNewString;
	}

	function is_array(mArray)
	{
		return typeof(mArray).toLowerCase() === 'array';
	}

	function showHideAdditionalData(oFormObj)
	{
		var aAllElements = getAllElements('div');
		var iAllElementsCount = aAllElements.length;
		var pCount = 0;
		var oOptionObj;
		if (oFormObj === null)
		{
			for (pCount = 0; pCount < iAllElementsCount; pCount++)
			{
				if (aAllElements[pCount].id.indexOf('additional_block') !== -1)
				{
					oOptionObj = getElement(aAllElements[pCount].id.replace("additional_block_", "").replace("_answer", ""));
					if (oOptionObj !== null && (oOptionObj.checked == true || oOptionObj.checked == "checked"))
					{
						aAllElements[pCount].style.display = '';
					}
					else
					{
						aAllElements[pCount].style.display = 'none';
					}
				}
			}
		}
		else
		{
			var sElementGroupName = oFormObj.getAttribute('name').split('_');
			var sElementGroupName = sElementGroupName[0]+'_'+sElementGroupName[1];
			var sElementId = oFormObj.value;
			for (pCount = 0; pCount < iAllElementsCount; pCount++)
			{
				if (aAllElements[pCount].id.indexOf('additional_block') !== -1 && aAllElements[pCount].id.indexOf(sElementGroupName) !== -1)
				{
					if (aAllElements[pCount].id.indexOf('answer_'+sElementId) !== -1)
					{
						aAllElements[pCount].style.display = '';
					}
					else
					{
						aAllElements[pCount].style.display = 'none';
					}
				}
			}
		}
	}

	function showHideQuickEditForm(bShowQuickly)
	{
		if (null !== getElement('signup_form_holder_fill') && null !== getElement('signup_form_holder_quick'))
		{
			var pCount = 0;
			var sTmp = '';
			for (sTmp in aErrors)
			{
				pCount++;
			}
			BELGIUM = 'BE';
			NETHERLANDS = 'NL';
			eCountry = null !== getElement('be_country_box') && (true === getElement('be_country_box').checked || "checked" === getElement('be_country_box').checked) ? BELGIUM : NETHERLANDS;
			
			if (null !== getElement('telephone') && getElement('telephone').value !== "" && true !== isValidTelephoneNumber(getElement('telephone').value, eCountry))
			{
				pCount++;
			}
			if (null !== getElement('signup_form_holder_fill'))
			{
				getElement('signup_form_holder_fill').style.display = '';
				getElement('signup_form_holder_quick').style.display = 'none';
	
				if (bShowQuickly === false)
				{
					if (pCount <= 0)
					{
						if (getElement('firstname').value !== '' && getElement('surname').value !== '')
						{
							getElement('signup_form_holder_fill').style.display = 'none';
							getElement('signup_form_holder_quick').style.display = '';
						}
					}
				}
			}
		}
	}

	function uncheckOthers(oCurrentObject, iQuestionId, bUncheck)
	{
		var aObjects 		= getAllElements('input');
		var iObjectCount	= aObjects.length;

		for (pCount = 0; pCount < iObjectCount; pCount++)
		{
			if (aObjects[pCount].name.indexOf('question_'+iQuestionId) !== -1)
			{
				if (aObjects[pCount].checked == true || aObjects[pCount].checked == "checked")
				{
					if ('true' === bUncheck && (oCurrentObject.checked === true || oCurrentObject.checked === "checked") && oCurrentObject.id != aObjects[pCount].id)
					{
						aObjects[pCount].checked = false;
					}
					if ('false' === bUncheck && (oCurrentObject.checked === true || oCurrentObject.checked === "checked") && oCurrentObject.id != aObjects[pCount].id)
					{
						if (aObjects[pCount].getAttribute('onclick').toString().indexOf('true') !== -1)
						{
							aObjects[pCount].checked = false;
						}
					}
				}
			}
		}
	}

	function uncheckDropdown(oCurrentObject, iQuestionId)
	{
		/**
			To be defined when needed
		*/
		/*
		var aObjects 		= getAllElements('input');
		var iObjectCount	= aObjects.length;

		for (pCount = 0; pCount < iObjectCount; pCount++)
		{
			if (aObjects[pCount].name.indexOf('question_'+iQuestionId) !== -1)
			{
				if (aObjects[pCount].checked == true || aObjects[pCount].checked == "checked")
				{
					if ('true' === bUncheck && (oCurrentObject.checked === true || oCurrentObject.checked === "checked") && oCurrentObject.id != aObjects[pCount].id)
					{
						aObjects[pCount].checked = false;
					}
					if ('false' === bUncheck && (oCurrentObject.checked === true || oCurrentObject.checked === "checked") && oCurrentObject.id != aObjects[pCount].id)
					{
						if (aObjects[pCount].getAttribute('onclick').toString().indexOf('true') !== -1)
						{
							aObjects[pCount].checked = false;
						}
					}
				}
			}
		}
		*/

	}

	function uncheckOtherPets(oCurrentObject)
	{
		if (oCurrentObject.name === 'client_data_pets_none')
		{
			var aObjects 		= getAllElements('input');
			var iObjectCount	= aObjects.length;
			for (pCount = 0; pCount < iObjectCount; pCount++)
			{
				if (aObjects[pCount].name.indexOf('client_data_pets') !== -1 && aObjects[pCount].name !== 'client_data_pets_none')
				{
					aObjects[pCount].checked = false;
				}
			}
		}
		else
		{
			getElement('client_data_pets_none').checked = false;
		}
	}
	
	function uncheckOtherDecides(oCurrentObject)
	{
		if (oCurrentObject.name === 'client_data_decide_none')
		{
			var aObjects 		= getAllElements('input');
			var iObjectCount	= aObjects.length;
			for (pCount = 0; pCount < iObjectCount; pCount++)
			{
				if (aObjects[pCount].name.indexOf('client_data_decide') !== -1 && aObjects[pCount].name !== 'client_data_decide_none')
				{
					aObjects[pCount].checked = false;
				}
			}
		}
		else
		{
			getElement('client_data_decide_none').checked = false;
		}
	}

	function uncheckOtherMobilePhone(oCurrentObject)
	{ 
		if( "undefined" !== typeof( oCurrentObject ) )
		{
			var aObjects 		= getAllElements('input');
			var iObjectCount	= aObjects.length;
			for (pCount = 0; pCount < iObjectCount; pCount++)
			{
				if (aObjects[pCount].name.indexOf('client_data_mobile_phone') !== -1 && aObjects[pCount].name !== oCurrentObject.name)
				{
					aObjects[pCount].checked = false;
				}
			}
		}
		else
		{
			getElement('client_data_mobile_phone_none').checked = false;
		}
	}


	function prepFriends()
	{
		if (null !== aInviteData)
		{
			for (var iNumber in aInviteData)
			{
				checkFriends();
				aAllInputs[iNumber]['name'].value			=	aInviteData[iNumber]['name'];
				aAllInputs[iNumber]['email'].value			=	aInviteData[iNumber]['email'];
				aAllInputs[iNumber]['message'].innerHTML	=	'&nbsp;'+aInviteData[iNumber]['message'];
				aAllInputs[iNumber]['message'].style.color	=	aInviteData[iNumber]['color'];
			}
		}
	}
	
	function checkFriends()
	{
		var iAllLength		=	aAllInputs.length - 1;
		var pFilledCount	=	0;
		var pEmptyCount		=	0;
		var iLastElement	=	null;
		var iLastFilled		=	1;
		for (var pCount = 1; pCount <= iAllLength; pCount++)
		{
			if (null !== aAllInputs[pCount])
			{
			
				if (null !== aAllInputs[pCount] && 
					(
						("undefined" !== typeof(aAllInputs[pCount]['name']) && "" !== aAllInputs[pCount]['name'].value) ||
						("undefined" !== typeof(aAllInputs[pCount]['email']) && "" !== aAllInputs[pCount]['email'].value)
					)
				)
				{
					if (null !== iLastElement)
					{
						/* move data up*/
						aAllInputs[iLastElement]['name'].value = aAllInputs[pCount]['name'].value;
						aAllInputs[iLastElement]['email'].value = aAllInputs[pCount]['email'].value;
						aAllInputs[pCount]['name'].value = '';
						aAllInputs[pCount]['email'].value = '';
						iLastFilled = iLastElement;
						iLastElement = pCount;
					}
					else
					{
						iLastFilled = pCount;
					}
					pFilledCount++;
				}
				else
				{
					if (null !== iLastElement)
					{
						aAllInputs[pCount]['row'].parentNode.removeChild(aAllInputs[pCount]['row']);
						aAllInputs[pCount] = null;
					}
	
					if (pCount !== iAllLength)
					{
						iLastElement = pCount;
					}
					else
					{
						if (null !== aAllInputs[pCount])
						{
							pEmptyCount++
						}
					}
	
				}
			}
		}

		if (null !== iLastElement)
		{
			pEmptyCount++;
		}
		
		if (0 === pEmptyCount && pFilledCount <= 9)
		{
			var iNext	= iLastFilled + 1;
			aAllInputs[iNext] = new Array();
			aAllInputs[iNext]['row'] = document.createElement("div");
			aAllInputs[iNext]['row'].className = "tellAFriendRow";
			aAllInputs[iNext]['row'].id = 'inviteRow_'+iNext;

			var oChildDiv		=	document.createElement("div");
			oChildDiv.className =	'tellAFriendChildRow';
			oChildDiv.innerHTML	=	'<strong>Vriend / Vriendin '+iNext+':</strong> (optioneel)';
			aAllInputs[iNext]['row'].appendChild(oChildDiv);

			var oChildDiv	=	document.createElement("div");
			oChildDiv.className = 'tellAFriendChildRow';
			aAllInputs[iNext]['row'].appendChild(oChildDiv);

			var oLabelDiv	=	document.createElement('div');
			oLabelDiv.className = 'tellAFriendLabelDiv';
			oChildDiv.appendChild(oLabelDiv);

			var oLabel		=	document.createElement('label');
			oLabel.setAttribute("for", "name_"+iNext);
			oLabel.innerHTML = "Naam:";
			oLabelDiv.appendChild(oLabel);

			var oInputDiv	=	document.createElement('div');
			oInputDiv.className = 'tellAFriendInputDiv';
			oChildDiv.appendChild(oInputDiv);

			aAllInputs[iNext]['name'] = document.createElement("input");
			aAllInputs[iNext]['name'].onkeyup	=	function() { checkFriends(); }
			aAllInputs[iNext]['name'].type		=	'text';
			aAllInputs[iNext]['name'].id		=	'name_'+iNext;
			aAllInputs[iNext]['name'].name		=	'name[]';
			aAllInputs[iNext]['name'].value	=	'';
			oInputDiv.appendChild(aAllInputs[iNext]['name']);
			
			var oChildDiv	=	document.createElement("div");
			oChildDiv.className = 'tellAFriendChildRow';
			aAllInputs[iNext]['row'].appendChild(oChildDiv);

			var oLabelDiv	=	document.createElement('div');
			oLabelDiv.className = 'tellAFriendLabelDiv';
			oChildDiv.appendChild(oLabelDiv);

			var oLabel		=	document.createElement('label');
			oLabel.setAttribute("for", "email_"+iNext);
			oLabel.innerHTML = "Email:";
			oLabelDiv.appendChild(oLabel);

			var oInputDiv	=	document.createElement('div');
			oInputDiv.className = 'tellAFriendInputDiv';
			oChildDiv.appendChild(oInputDiv);

			aAllInputs[iNext]['email'] = document.createElement("input");
			aAllInputs[iNext]['email'].onkeyup	=	function() { checkFriends(); }
			aAllInputs[iNext]['email'].type		=	'text';
			aAllInputs[iNext]['email'].id		=	'email_'+iNext;
			aAllInputs[iNext]['email'].name		=	'email[]';
			aAllInputs[iNext]['email'].value	=	'';
			oInputDiv.appendChild(aAllInputs[iNext]['email']);

			aAllInputs[iNext]['message'] = document.createElement("span");
			oInputDiv.appendChild(aAllInputs[iNext]['message']);


			getElement('additionalInvitees').appendChild(aAllInputs[iNext]['row']);	
		}

	}

	function checkPersonalMessage()
	{
		var oMessageContainer	=	getElement('personalMessage');
		var oMessageTextArea	=	getElement('personalMessageText');
		var oPersonalLeft		=	getElement('personalMessageTextLeft');
		if (null !== oMessageContainer && null !== oMessageTextArea)
		{
			oPersonalLeft.innerHTML	=	(1024 - oMessageTextArea.value.length) + " / 1024";
			if (oMessageTextArea.value === "")
			{
				oMessageContainer.innerHTML = "Voer een persoonlijk bericht in!<br /><br />";
			}
			else
			{
				oMessageContainer.innerHTML	=	oMessageTextArea.value.replace(/\r|\n|\r\n/g, "<br />")+'<br /><br />';
			}
		}
	}

