function generatePass()
{
	plength = 8;
	var keylist = "abcdefghijklmnopqrstuvwxyz123456789";
	var temp = "";
	for (i=0;i<plength;i++)
	{
		temp += keylist.charAt(Math.floor(Math.random()*keylist.length));
	}
	return temp
}

function generatePassword()
{
	var pass = generatePass();
	$('passwordDiv').update('<input type="text" name="password" value="' + pass +'" style="width:250px" />');
	$('passwordDiv').innerHTML;
}

function clearDefault(id)
{
  if(id.defaultValue == id.value)
  {
  	id.value = "";
  }
}

function setDefault(id)
{
  if(id.value == "")
  {
  	id.value = id.defaultValue;
  }
}

function checkForInt(evt) 
{
	evt = ( evt ) ? evt : window.event;
	var charCode = ( evt.which ) ? evt.which : evt.keyCode
	return (charCode <= 31 || (charCode >= 48 && charCode <= 57))
}


function subscribeToMailing()
{
	var postData = $('subscribeToMailingForm').serialize();
	postData += "&action=subscribeToMailing";
	new Ajax.Request(
		"/include/action.php", {
			method    : "post",
			postBody    : postData,
			onSuccess: function(transport)
			{
				//alert(transport.responseText);
				if (transport.responseText.match(/success/))
				{
					$('subscribeToMailingDiv').hide();	
					$('subscribeToMailingOk').show();
				}
				else if(transport.responseText.match(/duplicate/))
				{
					$('subscribeToMailingDiv').hide();	
					$('subscribeToMailingSyntaxError').hide();
					$('subscribeToMailingDuplicateError').show();
				}
				else
				{
					$('subscribeToMailingSyntaxError').show();
				}
			}
		}
	);
}


function updateDurationForm()
{
	var postData = "";
	postData = $F('month');
	//alert(postData);

   if($F('month') != "reset")
   {
	   new Ajax.Request(
	        "/include/action.php?action=updateDurationForm&month=" + postData, {
	            method    : "get",
	            onSuccess: function(transport)
				{
					//alert(transport.responseText);
	              	$('durationDiv').update(transport.responseText);
					$('durationDiv').innerHTML;
				}
	        }
	    );
	}	
}



function zoekExact()
{
	var regionId = document.getElementById('regionId').value;
	var month = document.getElementById('month').value;

   document.location = "http://www.portugal-vivendas.com/houseSearchNew/?regionId=" + regionId + "&month=" + month;
}




var currentDiv = "";			
function toggleDiv(id)
{
	for (i=0;i<=pages.length;i++)
	{
		if(typeof(pages[i]) != "undefined")
		{
				
			if(pages[i] != id)
			{
				document.getElementById("div" + pages[i]).style.display = 'none';
			}
			else
			{
				if(currentDiv == id)
				{
					document.getElementById("div" + pages[i]).style.display = 'none';
					currentDiv = "";
				}
				else
				{
					document.getElementById("div" + id).style.display = 'block';
					currentDiv = id;
				}
			}	
		}
	}
	//alert(currentDiv);
}


function semOv(menu)
{
	document.getElementById('semMenuDiv').style.display = 'block';
}

function semOut(menu)
{
	document.getElementById('semMenuDiv').style.display = 'none';	
}



var pages = new Array();
