/*
Cookies

*/
var now = new Date();
var expdate = new Date(now.getTime() + 14 * 24 * 60 * 60 * 1000);

function makeCookie (fn) {
	document.cookie = "fn = " + fn+";expires="+expdate.toGMTString();
	window.location = "index1.shtml";
}

function findCookie(val) {
	var cookie = null
	var findVal = val + "=";
	var dc = document.cookie;
	if (dc.length > 0) {
		var start = dc.indexOf(findVal);
		if (start >=0){
			start += findVal.length;
			lastVal = dc.indexOf(";",start);
			if (lastVal == -1) {
				lastVal = dc.length;
			}
			cookie = (dc.substring(start, lastVal));
		} else {
			return cookie;
		}
	}
		return cookie;
}

fn = findCookie("fn");
ln = findCookie("ln");
user = findCookie("user");
pswd = findCookie("pswd");


function zapOrder() {
	deldate = "Thu, 01-Jan-70 00:00:01 GMT";
	for (i=0;i<=4;i++) {
		document.cookie ="fn = " + fn+";expires= "+deldate+";";
	}
}
		


function checkForm(){
	var fn = document.form.fn.value;
	if(fn == "")
		{
			alert("Please fill out all input fields on this form.");
			return false;
		}
		else if (checkName (document.form.fn.value) ==false)
		{alert("You must enter a valid Name");
		return false;}
	else
		{
			makeCookie(fn);
		}
}

function checkName(fn) {
	re = /^[a-zA-Z''-'\s]{1,40}$/gi;
	return re.test(fn);
}
if(fn == null)
	{
		fn = "";
	}
	


/*
Animation

*/
function xCoord(id) {
   object=document.getElementById(id);
   xc=parseInt(object.style.left);
   return xc;
}

function yCoord(id) {
   object=document.getElementById(id);
   yc=parseInt(object.style.top);
   return yc;
}

function placeIt(id, x, y) {
   object=document.getElementById(id);
   object.style.left =x+"px";
   object.style.top=y+"px";
}

function shiftIt(id, dx, dy) {
   object=document.getElementById(id);
   object.style.left=xCoord(id)+dx+"px";
   object.style.top=yCoord(id)+dy+"px";
}

function hideIt(id) {
   object=document.getElementById(id);
   object.style.visibility="hidden";
}

function showIt(id) {
   object=document.getElementById(id);
   object.style.visibility="visible";
}

function winWidth() {
   if (window.innerWidth) return window.innerWidth;
   else if (document.documentElement) return document.documentElement.offsetWidth;
   else if (document.body.clientWidth) return document.body.clientWidth;
}

function winHeight() {
   if (window.innerHeight) return window.innerHeight;
   else if (document.documentElement) return document.documentElement.offsetHeight;
   else if (document.body.clientHeight) return document.body.clientHeight;
}


function placeObjects() {
		placeIt("water",  -490,420);
		placeIt("architecture", -500, 330);
		moveArch();
}

function moveArch() {
	var x=xCoord("architecture");
	moveWater();
	if (x <=0) {
		shiftIt("architecture",10, 0);
		setTimeout("moveArch()" , 5);
		} else {
		
		}
}

function moveWater() {
	var x=xCoord("water");
	if (x <=315) {
		shiftIt("water",10,0);
		setTimeout("moveWater()",100);
		} else {
		//showObjects();
		}
	}


/*
Arrays, Loops and Conditions


*/



function waterPix () {
document.write("<table style='margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;border:0px;border-spacing:0px'>")
var colorpixw = new Array("ocean_swim", "night_swim", "north_shore", "interlaken","koi"); 
var j = 0;
	rowtotal = 1;
	while (rowtotal < 3) {
		document.write("<tr>");
		colltotal = 1;
		while (colltotal < 6) {
			if (rowtotal %  2 != 0) {
			document.write("<td  style='margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;border:0px;background:none;border-spacing:0px'><a href='gallery.shtml?" + colorpixw[j] +"' title='" + colorpixw[j] +"'>" +"<img src='images_band/" + colorpixw[j] +".jpg' />"  + "</a></td>");
			colltotal++;
			j++;
			}else{
			var j = 0;
			colltotal = 1;
			while (colltotal <6) {
			document.write("<td style='margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;border:0px;border-spacing:0px'>" +"</td>");
			colltotal++;
			j++;
			}
			}
		}
		document.write("</tr>");
		rowtotal++;
	}
	document.write("</table>")
}


function colortablePix () {
document.write("<table style='margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;border:0px;border-spacing:0px'>")
var colorpix = new Array("eiffel", "guggenheim", "pisa", "boulevard_tower", "paris_opera", "W_T_C", 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); 
var j = 0;
	rowtotal = 1;
	while (rowtotal < 3) {
		document.write("<tr>");
		colltotal = 1;
		while (colltotal < 7) {
			if (rowtotal %  2 != 0) {
			document.write("<td  style='margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;border:0px;border-spacing:0px'><a href='gallery.shtml?" + colorpix[j] +"' title='" + colorpix[j] +"'>" + "<img src='images_band/" + colorpix[j] +".jpg' />"  + "</a></td>");
			colltotal++;
			j++;
			}else{
			var j = 0;
			colltotal = 1;
			while (colltotal <7) {
			document.write("<td style='margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;border:0px;border-spacing:0px'>" + "</td>");
			colltotal++;
			j++;
			}
			}
		}
		document.write("</tr>");
		rowtotal++;
	}
	document.write("</table>")
}

// 	ImgOver and Preloader
if (document.images) {
	var ImgOver = new Array();
	ImgOver[0] = new Image ();
	ImgOver[1] = new Image ();
	ImgOver[2] = new Image ();
	ImgOver[3] = new Image ();
	ImgOver[4] = new Image ();
	ImgOver[5] = new Image ();
	ImgOver[6] = new Image ();
	ImgOver[7] = new Image ();
	ImgOver[8] = new Image ();
	ImgOver[9] = new Image ();
	ImgOver[10] = new Image ();
	ImgOver[11] = new Image ();
	ImgOver[12] = new Image ();
	ImgOver[13] = new Image ();
 	 ImgOver[0].src = "images/button_home_over.jpg" ;
	 ImgOver[1].src = "images/button_gallery_over.jpg";
	 ImgOver[2].src = "images/button_random_over.jpg";
	 ImgOver[3].src = "images/button_rate_over.jpg";
	  ImgOver[4].src = "images/button_register_over.jpg";
	  ImgOver[5].src = "images/button_contact_over.jpg";
	ImgOver[6].src = "images/button_animate_over.jpg";
	ImgOver[7].src = "images/button_architecture_over.jpg";
	ImgOver[8].src = "images/button_water_over.jpg";
	ImgOver[9].src = "images/rate.jpg";
	ImgOver[10].src = "images/animate_arch.jpg";
	ImgOver[11].src = "images/animate_water.jpg";
	ImgOver[12].src = "images/background_arch.jpg";
	ImgOver[13].src = "images/background_water.jpg";


	 var ImgOut = new Array();
	ImgOut[0] = new Image ();
	ImgOut[1] = new Image ();
	ImgOut[2] = new Image ();
	ImgOut[3] = new Image ();
	ImgOut[4] = new Image ();
	ImgOut[5] = new Image ();
	ImgOut[6] = new Image ();
	ImgOut[7] = new Image ();
	ImgOut[8] = new Image ();
	 ImgOut[0].src = "images/button_home.jpg";
	 ImgOut[1].src = "images/button_gallery.jpg";
	 ImgOut[2].src = "images/button_random.jpg";
	 ImgOut[3].src = "images/button_rate.jpg";
	  ImgOut[4].src = "images/button_register.jpg";
	   ImgOut[5].src = "images/button_contact.jpg";
	    ImgOut[6].src = "images/button_animate.jpg";
		 ImgOut[7].src = "images/button_architecture.jpg";
		  ImgOut[8].src = "images/button_water.jpg";
}
function RollOver(i) {
	if (document.images) document.images[i].src = ImgOver[i].src;
	hideActive();
}

function RollOverb(i) {
	if (document.images) document.images[i].src = ImgOver[i].src;
}

function RollOut(i) {
	if (document.images) document.images[i].src = ImgOut[i].src;
}

var ActiveMenu = null;
	
	function hideActive() {
	if (ActiveMenu !== null) {
			hideIt(ActiveMenu);
			ActiveMenu = null;
		}
	}
	function popMenu(M) {
		hideActive();
		ActiveMenu = document.getElementById(M);
		showIt(ActiveMenu);
		}

function hideIt(object) {
   object.style.visibility="hidden";
}

function showIt(object) {
   object.style.visibility="visible";
}


/*
Math and Date functions

*/

function imagerandom(size) {
   return Math.floor((size+1)*Math.random());
}
function showDateTime(time) {
   date = time.getDate();
   month = time.getMonth()+1;
   year = time.getFullYear();

   second = time.getSeconds();
   minute = time.getMinutes();
   hour = time.getHours();

   ampm = (hour < 12) ? " am" : " pm";
   hour = (hour > 12) ? hour - 12 : hour;
   hour = (hour == 0) ? 12 : hour;

   minute = minute < 10 ? "0"+minute : minute;
   second = second < 10 ? "0"+second : second;

   return month+"/"+date +"/"+year+" at "+hour+":"+minute+":"+second+ampm;
}
function changeYear(stoday, holiday) {
	year = stoday.getFullYear(); //extract 4-digit value from today variable
	holiday.setFullYear(year); //set full year value of Holiday to Year Variable
	year = (holiday < stoday) ? year + 1 : year;
	holiday.setFullYear(year);//set full year value of holiday to year variable

}
function countsdown(start, stopp) {
	var time = stopp - start;
	var days = time / (1000*60*60*24);
	var hours = (days - Math.floor(days))*24;
	var minutes = (hours - Math.floor(hours))*60;
	var seconds = (minutes - Math.floor(minutes))*60;
	return Math.floor(days) + " days, " + Math.floor(hours) + " hrs, " + Math.floor(minutes) + " min, " + Math.floor(seconds) + " sec"   
}
function photo() {
var sizer = 11;
var imgNumber = imagerandom(sizer);
document.write("<img src='images_random/" + imgNumber + ".jpg' alt='hawaii' />");
}