function hide(y)
{
	for (i=1; i<y+1; ++i)
	{
		el = "panel"+i;
  		document.getElementById(el).style.display = 'none';
	}
}

function show(x,y)
{
		hide(y);
		el = "panel"+x;
  		document.getElementById(el).style.display = 'block';
	
}


var imagesArray = new Array('images/home_photo.jpg');
function randomHero()
{
	var ran_number=Math.floor(Math.random()*1);
	document.getElementById('homeHero').src=imagesArray[ran_number];	
}

function setRequiredColors(fieldName)
{
	var label = fieldName + "Label";
	if (document.getElementById(fieldName).value == "")
	{
		document.getElementById(label).style.color="#C00";
	}
	else
	{
		document.getElementById(label).style.color="#000";
	}
}

function checkFields() {
	var fieldsArray	= new Array();
		fieldsArray	= Array('firstName','lastName','comments','email','phone');
	for (var i=0; i<fieldsArray.length; i++)
	{
		var label = fieldsArray[i] + "Label";
		if(document.getElementById(fieldsArray[i]).value == "")
		{
			// set form action to nothing
			document.forms.contactForm.action= "";
			// alert the problem
			alert ("You are missing one or more required field(s).");
			// loop through all fields for text color change
			for (var j=0; j<fieldsArray.length; j++)
			{
				setRequiredColors(fieldsArray[j]);
			}
			return(false);
		}
		else
		{
			document.forms.contactForm.action="contact_us.php";
		}
	}
}

function shownewsimage(thisnewsid, thiswidth, thisheight) {
	if (thisnewsid != '') {
		window.open('newsimage.php?article=' + thisnewsid, 'shownewsimage', 'width=' + thiswidth + ',height=' + thisheight + ',scrollbars,resizable');
	}
}

function showtvad() {
	window.open('tvad.php', 'showtvad', 'width=500,height=350,scrollbars,resizable');
}
