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

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


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 sendToFriend()
{
	var postData = $('sendToFriendForm').serialize();
	postData += "&action=sendToFriend";
	new Ajax.Request(
		"/include/action.php", {
			method    : "post",
			postBody    : postData,
			onSuccess: function(transport)
			{
				//alert(transport.responseText);
				if (transport.responseText.match(/success/))
				{
					$('sendToFriendDiv').hide();
					$('sendToFriendSyntaxError').hide();
					$('sendToFriendOk').show();
				}
				else
				{
					$('sendToFriendSyntaxError').show();
				}
			}
		}
	);
}



function contactForm()
{
	var postData1 = $('form1').serialize();
	postData1 += "&action=postForm";
	new Ajax.Request(
		"/include/action.php", {
			method    : "post",
			postBody    : postData1,
			onSuccess: function(transport)
			{
				//alert(transport.responseText);
				if (transport.responseText.match(/success/))
				{
					$('formDiv').hide();
					$('formError').hide();
					$('formOk').show();
				}
				else
				{
					$('formError').show();
				}
			}
		}
	);
}




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);
}

var pages = new Array();
