// JavaScript Document



//array of images for loop
var thumbs = new Array(
					   'imgs/thumbs/thumb1.gif',
					   'imgs/thumbs/thumb2.gif',
					   'imgs/thumbs/thumb3.gif',
					   'imgs/thumbs/thumb4.gif',
					   'imgs/thumbs/thumb5.gif',
					   'imgs/thumbs/thumb6.gif',
					   'imgs/thumbs/thumb7.gif',
					   'imgs/thumbs/thumb8.gif'
					   );
//end image array

//array of names for thumbnail ids
var thumb = new Array(
					  'thumb1',
					  'thumb2',
					  'thumb3',
					  'thumb4',
					  'thumb5',
					  'thumb6',
					  'thumb7',
					  'thumb8'
					  );
//end thumbnail name array

/*slideshow code*/

//array for images to display
var slideshowImgs = new Array( 
						  'imgs/img01.jpg', 
						  'imgs/img02.jpg', 
						  'imgs/img03.jpg', 
						  'imgs/img04.jpg', 
						  'imgs/img05.jpg', 
						  'imgs/img06.jpg', 
						  'imgs/img07.jpg', 
						  'imgs/img08.jpg'
						  );
//end array

//counter variable
var countMe = 0;

//functions for next and previous buttons
function nextImg()
{
	countMe ++;
	if( countMe >= slideshowImgs.length )
	{
		countMe = 0;
	}
	document.slideshow.src = slideshowImgs[countMe];
};

function previousImg()
{
	countMe --;
	if( countMe < 0 )
	{
		countMe = 7;
	} 
	document.slideshow.src = slideshowImgs[countMe];
};
/* end slideshow code */


// function to create news headlines
function headers ( title, number )
{
	document.write('<h' + number + '>');
	document.write( title );
	document.write('</h' + number + '>');
};
// end headlines

// date and time for if statement
var now = new Date();
var day = now.getDay();
var hour = now.getHours();



// end date and time


/* form validation code */
function validate()
{	
	// check name
	nameRegEx = /^[a-zA-Z\s\-]{4,50}$/;
	if (document.contact.name.value == "")
	{
		alert( 'please tell us your name' );
		document.contact.name.focus();
		return false;
	}

	else if (nameRegEx.test(document.contact.name.value) == false)
	{
		alert( 'that is not a real name' );
		document.contact.name.focus();
		return false;
	}
	
	//check city
	cityRegEx = /^[a-zA-Z\s\-]{3,50}$/;
	if (document.contact.city.value == "")
	{
		alert( 'please tell us where you reside' );
		document.contact.city.focus();
		return false;
	}
	else if (cityRegEx.test(document.contact.city.value) == false)
	{
		alert( 'that is not a real place' );
		document.contact.city.focus();
		return false;
	}
	
	//check email
	emailRegEx = /^([A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4})$/;
	if (document.contact.email.value == "")
	{
		alert( 'please give us your email address' );
		document.contact.email.focus();
		return false;
	}
	else if (emailRegEx.test(document.contact.email.value) == false)
	{
		alert( 'that is not a valid email address - name@domain.com is' );
		document.contact.email.focus();
		return false;
	}
	
	
};


/* end form validation */

