// NEWS TICKER
 //rotation speed
var speed = 4000
var activeDiv=0
var divCount=0

  //hide ticker divs
function hideAllDivs()
{
	var x=0
		while (document.getElementById("news"+x))
				{
					document.getElementById("news"+x).style.display="none"
					x++
				}
}

  //getting the next news ticker div
function showDiv()
{
	var selectedDivObj = document.getElementById("news" + activeDiv)
		hideAllDivs()
		selectedDivObj.style.display = "block"
		activeDiv =(activeDiv < divCount - 1 )? activeDiv + 1 : 0
		setTimeout("showDiv()", speed)
}

 //when to start ticker
function beginTicking()
{
	while (document.getElementById("news" + divCount)!=null)
			divCount++
			showDiv()
}

 //loading divs
	if (window.addEventListener)
		window.addEventListener("load", beginTicking, false)
	else if (window.attachEvent)
		window.attachEvent("onload", beginTicking)





function isAlpha(data) {
if(typeof(data) !="string")
{data = data.value;
}
alphaRegEx = /^[a-zA-Z]+$/;
if(data.match(alphaRegEx) )
{return true;}
else{return false;}
}	  

function isNum(data) {
	if(typeof(data) !="string")
	{
		data = data.value;
	}
	numRegEx = /^[0-9]+$/;
	
	if(data.match(numRegEx) )
	{
		return true;}
		else {
		return false;
		}
}

function isAlphaNum(data) {
if(isAlpha(data) || isNum(data) )
{return true;}
else{return false;}
}

  
function contactValidate(form) {
	if (form.name.value.length == 0) {
	alert('Please enter your first name');
	return false;
	}
	
	if (form.email.value.length == 0) {
	alert('Please enter your contact email');
	return false;
	
	} else if (!/^\w+@\w+\.\w{2,4}$/.test(form.email.value)) {
	alert('Please enter a valid contact email');
	return false;	
	}
	
	if (form.response.value.length == 0) {
	alert('Please enter a message');
	return false;
	}
	
}

