// js for nigelnewman.co.uk/index.html

var now = new Date; //date

// ===== THIS SECTION FOR PRE-LOADING AND DISPLAYING PHOTOS AT START =====

// If not IE then automatic slide show	
   
function loadimages()
		{
		pic1 = new Image ; pic1.src="./images/p1.jpg";
		pic2 = new Image ; pic2.src="./images/p2.jpg";
		pic3 = new Image ; pic3.src="./images/p3.jpg";
		pic4 = new Image ; pic4.src="./images/p4.jpg";
		pic5 = new Image ; pic5.src="./images/p5.jpg";
		pic6 = new Image ; pic6.src="./images/p6.jpg";
		pic7 = new Image ; pic7.src="./images/p7.jpg";
				
		pictures = new Array (pic1,pic2,pic3,pic4,pic5,pic6,pic7);}
		
function checkload(){
		if (pic7.complete == false)
		setTimeout("checkload()", 100)}	

thisPhoto = 0; imgCt = 7;

function rotate(){
				 if (document.images){
				 		 thisPhoto++; 
						 if (thisPhoto == imgCt) {thisPhoto = 0};
						 document.display.src=pictures[thisPhoto].src;
						 setTimeout("rotate()", 8*1000);
						 } // end of if
				 } // end of rotate
	 
// End of not IE

// If is IE then can do fading photos. Blend Photos start  p=336 Advanced DHTML
	 var ie = 1;
	 if (navigator.appName!="Microsoft Internet Explorer") {ie=0};

// specify interval between slide (in milliseconds)
	 var slidespeed=4000

// specify images
	 var latestimage=0;
	 var imageholder=new Array();
	 imageholder[latestimage]=new Image();
	 var ie=document.all;

// function
	 function slideit(){
	 
	 pictotal = 7; // this is the number of pics 

			if (latestimage>0)
			{
			if (!ie) {if (document.layers) {document.layers['layer0'].document.images.im1.src="./images/p" + latestimage + ".jpg";} else {document.images.im1.src="pics/fpics/p" + latestimage + ".jpg";};}
			if (ie) document.images.im1.filters[0].apply()
			if (ie) document.images.im1.src=imageholder[latestimage].src
			if (ie) {document.images.im1.filters[0].play()}
			}

			// turn latestimage = 2 into latestimage = 3;
			latestimage=latestimage+1;
			
			// reset latestimage;
			if (latestimage>pictotal) latestimage=1;

			imageholder[latestimage]=new Image()
			imageholder[latestimage].src="./images/p" + latestimage + ".jpg";
			setTimeout("slideit()",slidespeed+blenddelay);
		}
		
// End of Fade Box

// ======= STOP MULTIPLE SENDING OF E-MAILS =====

function multiple(){

// the entire cookie string
	 var dc = document.cookie;

// if no cookies at all ; must be first visit
	 if	 (dc.length==0) {var visit=0;}
	 
// there is a cookie, 	 
	 else {
	 
// where does "sent=" begin
	 begin = dc.indexOf("sent888=");
	 
// if there are cookies, but sent888 isn't one of them, must be first visit
	 if (begin == -1) {var visit=0;}
	 
// if sent999 is found (ie begin != -1) 
	 else {

// we know "sent999=" is 8 characters long, so the value will be postion 8
	 var visit = dc.charAt(begin + 8);

	 } // close else
	 } // close else

// set expire to 24 hours. Note setDay() v. getDay()
	 var emailexp = new Date();
	 emailexp.setTime(emailexp.getTime()+(60*60*1000*24));
	 emailexp = emailexp.toGMTString(); //convert to readable string

// go through the options
	 if (visit==0){
	 		document.cookie="sent888=1;expires="+emailexp;
			return true;}
			
	 else if (visit==1){
	 		alert("Note: For security reasons only 2 emails are allowed from this site per day.");
	 		document.cookie="sent888=2;expires="+emailexp;
			return true;}
			
	 else {
			alert("Sorry, only 2 emails per day from this site. Please try again tomorrow");
			return false;}

} // end of checkform for Branch page

// ====== THIS SECTION DISPLAY THE HOUR OF THE DAY (for reference) =====

/*
var hours = now.getHours();
		 	 if (hours<10){hours = "0" + hours};
		 	 document.write("[eg, updated: " +hours +":00hrs]");
			 
*/

// ======= AWAITS =====

function awaits(){alert ("Temp suspended for upgrade across all sites. Ready by end of Sept");}

// ======= POP UP News Page ====

function popup() {
alert('Press and hold the Ctrl button when clicking the News Page link')}

