function form_Validator(form)
{
	if (form.name.value == "")
	{
		alert(" Por favor, introduza o seu nome. ");
		form.name.focus();
		return (false);
	}
	
	if (form.email.value == "")
	{
		alert("Por favor, introduza o seu e-mail.");
		form.email.focus();
		return (false);
	}

	if (form.message.value == "")
	{
		alert("Por favor, introduza a súa mensaxe.");
		form.message.focus();
		return (false);
	}
	return (true);
}

function jumpToAnchor(arg_sAnchor)
{ 
	window.location.hash= arg_sAnchor; 
};

window.addEvent('domready', function(){
  	var pl = new Preloader();
  	$$('img').each(function(img) {
  		pl.addEventOnLoad(img.get('src'), function() {
  			img.getParent().setStyle('background', 'none');
  			img.setStyle('opacity', 0)
  			img.setStyle('display', 'block');
  			img.effect('opacity').start(0,1);
  		});
  		pl.addToQueue(img.get('src'));
  	});

	$$('[id$=toggle]').each(function(el){ // returns array of elements with ID ending in "toggle"
		var toggle = el.get('id').split('_'); // split on the _
		$(toggle[0]).set('slide', {duration: 2500}); // assign the slide to the element itself
		if(!Browser.Engine.trident)
		{
			$(toggle[0]).slide('hide');	// hide it on load
		}

		el.addEvent('click', function(e){
			new Event(e).stop();
			$(toggle[0]).slide(); // toggle the slide
		});
	});

	$$('[id^=id_]').each(function(el){ // returns array of all elements that have an ID that begins with "id_"
		var showID = el.get('id').split('_'); // we're going to utilize this in two aspects below
		el.addEvent('click', function(e){
			new Event(e).stop();
			$(showID[0]+showID[1]).slide('show'); // returns the ID without the '_' and toggles it
			jumpToAnchor(showID[1]); // jumps to the href which matches after '_'
		});
	});

});
window.addEvent('load', function(){
	if(Browser.Engine.trident)
	{
		$$('[id$=toggle]').each(function(el){ // returns array of elements with ID ending in "toggle"
			var toggle = el.get('id').split('_'); // split on the _
			$(toggle[0]).slide('hide');	// hide it on load
		});
	}
});

