function valiidateNewsletter(){
	var email = $('#email');
	
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var valemail = document.getElementById('email').value;
	
	var flag=(valemail.match(pattern));
	
	if(!flag){
		alert("Please enter a valid email address.");
		email.select();
		return false;
	}
	
	return true;
}


var numtoshow=5;
var delay=9000;
function initializeHomeGal(){
	
	$('#image').html(images[1]);
	$('#title').html(title[1]);
	$('#loc').html(loc[1]);
	var buttons='';
	var arrayLen=images.length;
	for(var i=1;i<arrayLen;i++){
		buttons+="<div style='float:left;width:25px;height:25px;text-align:center;padding:3px 3px 0 0;' id='but_"+i+"' onclick='showProject("+i+")' class='off'>"+i+"</div>";
	}
	
	$('#button').html(buttons);
	$('div#but_1').removeClass('off');
	$('div#but_1').addClass('on');

	$('#button div[id*=but]').mouseover(function(){
		$(this).removeClass('off').addClass('on')
	});
	$('#button div[id*=but]').mouseout(function(){
		$(this).removeClass('on').addClass('off')
	});
	rotate();
}

var j=1;
var g='';
function rotate(){
	$('#image').html(images[j]);
	$('#image').fadeIn('slow');
	$('#title').html(title[j]);
	$('#loc').html(loc[j]);
	$('#button div[id*=but]').removeClass('on');
	$('#button div[id*=but]').addClass('off');
	$('div#but_'+j).removeClass('off');
	$('div#but_'+j).addClass('on');
	j++;
	if(j>numtoshow)j=1;
	g = setTimeout("rotate()",delay);
}
function showProject(count){
	$('#image').html(images[count]);
	$('#title').html(title[count]);
	$('#loc').html(loc[count]);
	$('#button div[id*=but]').removeClass('on');
	$('#button div[id*=but]').addClass('off');
	$('div#but_'+count).removeClass('off');
	$('div#but_'+count).addClass('on');
	$('div#but_'+count).mouseover(function(){
		$(this).removeClass('off').addClass('on');
	});
	$('div#but_'+count).mouseout(function(){
		$(this).removeClass('off').addClass('on');
	});
	clearTimeout(g);
}