// JavaScript Document

var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/

function overtime(o) { o.style.backgroundImage='url(img/navbuttons_hover_grad.png)'; }
function outtime(o) { o.style.backgroundImage='url(img/navbuttons_grad.png)'; }

(function () {
	var homecarousel;
			
	YAHOO.util.Event.onDOMReady(function (ev) {
		var homecarousel    = new YAHOO.widget.Carousel("homecarousel", {
					animation: { speed: 0.5 }, numVisible: 1
			});
		homecarousel.set("isCircular", false);		
		homecarousel.render(); // get ready for rendering the widget
		homecarousel.show();   // display the widget
	});
})();

(function () {
	var topiccarousel;
			
	YAHOO.util.Event.onDOMReady(function (ev) {
		var topiccarousel    = new YAHOO.widget.Carousel("topiccarousel", {
					animation: { speed: 0.5 }, numVisible: 1
			});
		topiccarousel.set("isCircular", false);		
		topiccarousel.render(); // get ready for rendering the widget
		topiccarousel.show();   // display the widget
	});
})();

function init(t) {
	if (t == 'newsletter') {
		document.getElementById('user_add_form').onkeyup = validateReg;	
	}
}

function validateReg() {

	var email, firstname, lastname = false;

	email = emailFilter.test((document.getElementById('user_add_email').value));
	firstname = document.getElementById('user_add_firstname').value.length != 0;
	lastname = document.getElementById('user_add_lastname').value.length != 0;
	
	document.getElementById('email_validate').src = email ? 
		'../../silk/icons/accept.png' : '../../silk/icons/stop.png';
	document.getElementById('firstname_validate').src = firstname ? 
		'../../silk/icons/accept.png' : '../../silk/icons/stop.png';
	document.getElementById('lastname_validate').src = lastname ? 
		'../../silk/icons/accept.png' : '../../silk/icons/stop.png';

	document.getElementById('user_add_submit').disabled = 
		!(email && firstname && lastname);
}