
/***** 
	SLIDE SHOW ROTATION ON HOMEPAGE
******/


/*** VARIABLES : DO NOT CHANGE ***/
var CurrentItem = 0; //default item to view
var TimerObj = 0;
var InRotation = Array();
/*** END VARIABLES ***/

/******** CONFIG *********/
/* UPDATABLE AREA : CHANGES HERE ONLY*/

var timer = 5000; /* time interval for rotation in ms */

/** Elements to Rotate**/
InRotation[0] = './images/slideshowimages/1.jpg'; //slide image 1
InRotation[1] = './images/slideshowimages/2.jpg'; //slide image 2
InRotation[2] = './images/slideshowimages/3.jpg'; //slide image 3
InRotation[3] ='./images/slideshowimages/4.jpg' ; //slide image 4
InRotation[4] = './images/slideshowimages/5.jpg'; //slide image 5	
InRotation[5] = './images/slideshowimages/6.jpg'; //slide image 6
InRotation[6] = './images/slideshowimages/7.jpg'; //slide image 7
InRotation[7] = './images/slideshowimages/8.jpg'; //slide image 8
InRotation[8] = './images/slideshowimages/9.jpg'; //slide image 9

/* to add an element, uncomment a line below, and change the file name */

/*** END CONFIG (END UPDATABLE AREA)***/


/*** DO NOT CHANGE BELOW ***/
var TotItems= InRotation.length; // number of items in slideshow

/* Preload Images */
for(var j=0;j<InRotation.length;j++){		
	 var imgs = new Image();
    imgs.src = InRotation[parseInt(j)];					
}


/* Function managing rotation */
function Slide(action){
	// DOM Element to update
	var BgDiv = document.getElementById('Core');
	
	clearTimeout(TimerObj); //compulsory in case of 2nd click on link (would double the setTimeout trigger)
	
	switch(action){
		case "previous":
			(CurrentItem<1)?CurrentItem=parseInt(TotItems-1):CurrentItem--; //update index : -1 or back to start=max
		break;	
		case "next":
			(CurrentItem>TotItems-2)?CurrentItem=parseInt(0):CurrentItem++; //update index : +1 or back to start=0
		break;	
		case "stop":
			return;
		break;	
	}
	
	// loop
	TimerObj = setTimeout("Slide('"+action+"')",timer); 
	/* update images */
	BgDiv.style.backgroundImage="url('"+InRotation[CurrentItem]+"')";

}


/****** END SLIDE SHOW ******/



/**** OTHER FUNCTIONS IN SITE ****/

/** Check fields in contact form **/

function checkForm(){
var ErrorMsg="";

	if(document.getElementById('FirstName').value==''){ErrorMsg+=" -  First Name.\n";}
	if(document.getElementById('LastName').value==''){ErrorMsg+=" -  Last Name.\n";}
	if(document.getElementById('Street').value==''){ErrorMsg+=" -  Street Address.\n";}
	if(document.getElementById('City').value==''){ErrorMsg+=" -  City.\n";}
	if(document.getElementById('State').value==''){ErrorMsg+=" -  State/Region.\n";}
	if(document.getElementById('Zip').value==''){ErrorMsg+=" -  Zip/Postal Code.\n";}
	if(document.getElementById('Email').value==''){ErrorMsg+=" -  Email.\n";
		}else{
			var EmailRE=/^[a-z0-9._-]+@+[a-z0-9._-]+\.+[a-z]{2,4}$/i;
			if(!EmailRE.test(document.getElementById('Email').value)){ErrorMsg+=" - A valid Email.\n";}
	}

	if(ErrorMsg!=''){alert("Please provide the following information :\n\n"+ErrorMsg);}
	else{document.getElementById('ContactForm').submit();}

}

/** Check fields in story submision form **/
function checkIt(){
var ErrorMsg="";

	if(document.getElementById('FirstName').value==''){ErrorMsg+=" -  First Name.\n";}
	if(document.getElementById('LastName').value==''){ErrorMsg+=" -  Last Name.\n";}
	if(document.getElementById('Date').value==''){ErrorMsg+=" -  Date.\n";}
	if(document.getElementById('City').value==''){ErrorMsg+=" -  City.\n";}
	if(document.getElementById('State').value==''){ErrorMsg+=" -  State/Region.\n";}
	if(document.getElementById('Email').value==''){ErrorMsg+=" -  Email.\n";
		}else{
			var EmailRE=/^[a-z0-9._-]+@+[a-z0-9._-]+\.+[a-z]{2,4}$/i;
			if(!EmailRE.test(document.getElementById('Email').value)){ErrorMsg+=" - A valid Email.\n";}
	}

	if(ErrorMsg!=''){alert("Please provide the following information :\n\n"+ErrorMsg);}
	else{document.getElementById('StoryForm').submit();}

}


/** character counter for textarea boxes
-- Original:  Ronnie T. Moore -->
<!-- Web Site:  The JavaScript Source -->
<!-- Dynamic 'fix' by: Nannette Thacker -->
<!-- Web Site: http://www.shiningstar.net -->
<!-- Begin **/
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) 
field.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - field.value.length;
}

/** Open new windows for news stories - set size with scrolling **/

/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/

function NewWindow(mypage,myname,w,h,scroll,pos){
var win=null;
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
win=window.open(mypage,myname,settings);}







