function open_lightbox_arrange()
{
	Mediabox.open('http://www.parkholidaysuk.com/forms/how-can-we-help-you.php?arrange=1', 'Arrange A Park Visit', '600 500');
}

function open_lightbox_win()
{
	Mediabox.open('http://www.parkholidaysuk.com/forms/how-can-we-help-you.php?win_caravan=1', 'Win A Caravan', '600 600');
}

function open_lightbox_brochure()
{
	Mediabox.open('http://www.parkholidaysuk.com/forms/brochure-and-newsletter.php?type=caravansales&brochures=1', 'Request A Sales Brochure', '600 500');
}

function open_lightbox_newsletter(email)
{
	Mediabox.open('http://www.parkholidaysuk.com/forms/brochure-and-newsletter.php?type=caravansales&newsletter=1&email=' + email, 'Request A Newsletter', '600 500');
}

function validateEmail(email)
{
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   
   if(reg.test(email) == false)
   {
      return false;
   }
   else return true;
}

function showNewsletterForm()
{
	document.getElementById('newsletterLink').style.display = 'none';
	document.getElementById('formNewsletter').style.display = '';
	
}

function submitFormNewsletter()
{
	var formNewsletter = document.getElementById('formNewsletter').value;
	var emailInput = document.getElementById('emailInput').value;
	
	if (validateEmail(emailInput))
	{
		open_lightbox_newsletter(emailInput);
	}
	else alert('Please enter a valid e-mail address.');
}

window.addEvent('domready', function(){

	/* this is for the fading gallery */
	$$('.fade').each(function(el){
        // Set initial opacity level
        el.getFirst().setStyle('opacity',0.5);
        
        el.addEvent('mouseenter', function() {
            this.getFirst().fade(1); 
        }).addEvent('mouseleave', function() {
            this.getFirst().fade(0.5);
        });
    },this);
	
	/* this is for the questions and answers */
	var accordion = new Accordion($$('.toggler'),$$('.element'), { 
		opacity: 0,  
		onActive: function(toggler) { toggler.setStyle('color', '#B30F0F'); }, 	  
		onBackground: function(toggler) { toggler.setStyle('color', '#003366'); }   
	}); 
});
