// JavaScript Document
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

	function medimg (img) {
		if (!isviewing) {
			//set new imgbg
			var boxDiv = document.getElementById('medimga');
			boxDiv.src = imgL[img].src;
			boxDiv = document.getElementById('medimgdiv');
			curimg = img;
			//get placeX/Y
			//loop parents until get x,y
			var curChild = document.getElementById('galitem' + img);
			var curX = curChild.offsetLeft;
			var curY = curChild.offsetTop;
			var curW = parseInt(boxDiv.offsetWidth) / 2;
			var curH = parseInt(boxDiv.offsetHeight) / 2;
			curChild = document.getElementById('galitem' + img);
			curX = (curX + (curChild.offsetWidth / 2)) - curW;
			curY = (curY + (curChild.offsetHeight / 2)) - curH;
			curChild = document.getElementById('medimgdiv');
			curChild.style.left = curX + 'px';
			curChild.style.top = curY + 'px';
			//show medimg
			curChild.style.visibility = 'visible';
		}
	}
	
	function hideimg () {
		if (!isviewing) {
			var boxDiv = document.getElementById('medimgdiv');
			boxDiv.style.visibility = 'hidden';
			boxDiv.style.left = '-500px';
			boxDiv.style.top = '-500px';
			curimg = null;
		}
	}
	
	function hidebigimg () {
		isviewing = false;
		hideimg();
		var boxDiv = document.getElementById('largeimg');
		//boxDiv.style.visibility = 'hidden';
		boxDiv.style.visibility = 'hidden';
		boxDiv.style.left = '-700px';
		boxDiv.style.top = '-700px';
	}
	
	var curimg = null;
	var boxnum = 1;
	var isviewing = false;
	var ismoving = false;
	var finalX;
	var slidespeed = 20;
	var slidechange = 5;
	function showimg (img) {
		if (!isviewing) {
			if (img) {
				curimg = img;
			}
			if (curimg) {
				//show large img
				//there are two boxes to animate sliding images
				//when first show image, just show first box, hide second box
				var boxDiv = document.getElementById('bigimg1i');
				isviewing = true;
				boxnum = 1;
				boxDiv.src = imgL[curimg].src;
				boxDiv = document.getElementById('bigimg2');
				boxDiv.style.left = '-600px';
				boxDiv.style.top = '-600px';
				boxDiv.style.display = 'none';
				var arWinSize = getWindowDims();
				boxDiv = document.getElementById('largeimg');
				var curW = boxDiv.offsetWidth;
				var curH = boxDiv.offsetHeight;
				var curX = (arWinSize[0] / 2) - (curW / 2);
				var curY = (arWinSize[1] / 2) - (curH / 2);
				boxDiv.style.left = curX + 'px';
				boxDiv.style.top = curY + 'px';
				boxDiv.style.visibility = 'visible';
				curX = curX + 33;
				curY = curY + 21;
				//document.getElementById('bigimgbound').style.left = curX + 'px';
				//document.getElementById('bigimgbound').style.top = curY + 'px';
				document.getElementById('bigimgbound').style.left = 33 + 'px';
				document.getElementById('bigimgbound').style.top = 21 + 'px';
				boxDiv = document.getElementById('bigimg1');
				boxDiv.style.left = 0 + 'px';
				boxDiv.style.top = 0 + 'px';
				//boxDiv.style.visibility = 'visible';
				boxDiv.style.display = 'block';
			}
		}
	}
	
	function getWindowDims () {
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		return [windowWidth,windowHeight];
	}
	
	function moveimg (direction) {
		if (isviewing == true && ismoving == false) {
			ismoving = true;
			if (direction > 0) {
				if (curimg + 1 <= maximgs) {
					curimg = curimg + 1;
				} else {
					curimg = 1;
				}
			} else {
				if (curimg - 1 > 0) {
					curimg = curimg - 1;
				} else {
					curimg = maximgs;
				}
			}
			var boxDiv1;
			var boxDiv2;
			var boxName1;
			var boxName2;
			if (boxnum == 1) {
				boxName1 = 'bigimg1';
				boxName2 = 'bigimg2';
				boxnum = 2;
			} else {
				boxName1 = 'bigimg2';
				boxName2 = 'bigimg1';
				boxnum = 1;
			}
			boxDiv2 = document.getElementById(boxName2 + 'i');
			boxDiv2.src = imgL[curimg].src;
			boxDiv1 = document.getElementById(boxName1);
			boxDiv2 = document.getElementById(boxName2);
			//do slide animation
			finalX = parseInt(boxDiv1.style.left);
			var curX = parseInt(boxDiv1.style.left) + (parseInt(boxDiv2.style.width) * direction * -1);
			var curY = parseInt(boxDiv1.style.top);
			boxDiv2.style.display = 'block';
			boxDiv2.style.left = curX + 'px';
			boxDiv2.style.top = curY + 'px';
			window.setTimeout('animateslide(\'' + boxName1 + '\', \'' + boxName2 + '\', ' + direction + ')', slidespeed);
		}
	}
	
	var testint = 1;
	function animateslide (boxName1, boxName2, direction) {
		if (ismoving) {
			var boxDiv1 = document.getElementById(boxName1);
			var boxDiv2 = document.getElementById(boxName2);
			var thediff = parseInt(boxDiv2.style.left) - finalX;
			thediff = Math.abs(thediff);
			var curX = parseInt(boxDiv1.style.left) + ((thediff / slidechange) * direction);
			//alert ('1st curx: ' + curX);
			boxDiv1.style.left = curX + 'px';
			curX = parseInt(boxDiv2.style.left) + ((thediff / slidechange) * direction);
			//alert ('2nd curx: ' + curX + 'finalx: ' + finalX);
			if (direction > 0) {
				if (curX >= finalX - slidechange) {
					curX = finalX;
					ismoving = false;
				}
			} else {
				if (curX <= finalX + slidechange) {
					curX = finalX;
					ismoving = false;
				}
			}
			boxDiv2.style.left = curX + 'px';
			if (!ismoving) {
				boxDiv1.style.left = '-600px';
				boxDiv1.style.top = '-600px';
				boxDiv1.style.display = 'none';
			} else {
				window.setTimeout('animateslide(\'' + boxName1 + '\', \'' + boxName2 + '\', ' + direction + ')', slidespeed);
			}			
		}
	}
	
	function setsizes () {
		var boxName1 = 'bigimg1';
		var boxName2 = 'bigimg2';
		document.getElementById(boxName1).style.width = '600px';
		document.getElementById(boxName1).style.height = '480px';
		document.getElementById(boxName2).style.width = '600px';
		document.getElementById(boxName2).style.height = '480px';
	}
	
	//top nav link array
	var menulinks = new Array(6);
	for (var i=0; i<menulinks.length; i++) {
		menulinks[i] = new Array(2);
		for (var e=0; e<menulinks[i].length; e++) {
			menulinks[i][e] = new Array(10);
		}
	}
	menulinks[1][0][0] = '<p class="dropdwn"><a href="about.cfm?p=1" class="dropdwnlink">Why Sun Design Pools?</a></p>';
	menulinks[1][0][1] = '<p class="dropdwn"><a href="about.cfm?p=2" class="dropdwnlink">Our Team</a></p>';
	menulinks[1][0][5] = '<p class="dropdwn"><a href="about.cfm?p=5" class="dropdwnlink">Customer Testimonials</a></p>';
	menulinks[1][0][2] = '<p class="dropdwn"><a href="about.cfm?p=3" class="dropdwnlink">Our Awards</a></p>';
	menulinks[1][0][3] = '<p class="dropdwn"><a href="about.cfm?p=4" class="dropdwnlink">Pool FAQs</a></p>';
	menulinks[1][0][4] = '<p class="dropdwn"><a href="contact.cfm?p=1" class="dropdwnlink">Request Info Form</a></p>';
	menulinks[1][1][0] = '<a href="about.cfm?p=1" class="whitelink">Why Sun Design Pools?</a>';
	menulinks[1][1][1] = '<a href="about.cfm?p=2" class="whitelink">Our Team</a>';
	menulinks[1][1][5] = '<a href="about.cfm?p=5" class="whitelink">Customer Testimonials</a>';
	menulinks[1][1][2] = '<a href="about.cfm?p=3" class="whitelink">Our Awards</a>';
	menulinks[1][1][3] = '<a href="about.cfm?p=4" class="whitelink">Pool FAQs</a>';
	menulinks[1][1][4] = '<a href="contact.cfm?p=1" class="whitelink">Request Info Form</a>';
	
	menulinks[2][0][0] = '<p class="dropdwn"><a href="service.cfm?p=1" class="dropdwnlink">Sun Design TURNKey</a></p>';
	menulinks[2][0][1] = '<p class="dropdwn"><a href="service.cfm?p=2" class="dropdwnlink">Services</a></p>';
	menulinks[2][0][2] = '<p class="dropdwn"><a href="service.cfm?p=3" class="dropdwnlink">Products</a></p>';
	menulinks[2][0][3] = '<p class="dropdwn"><a href="service.cfm?p=4" class="dropdwnlink">Installation</a></p>';
	menulinks[2][0][7] = '<p class="dropdwn"><a href="service.cfm?p=6" class="dropdwnlink">Pool and Patio Choices</a></p>';
	menulinks[2][0][4] = '<p class="dropdwn"><a href="service.cfm?p=5" class="dropdwnlink">Remodeling</a></p>';
	menulinks[2][0][6] = '<p class="dropdwn"><a href="contact.cfm?p=1" class="dropdwnlink">Service Request Form</a></p>';
	menulinks[2][1][0] = '<a href="service.cfm?p=1" class="whitelink">Sun Design TurnKey</a>';
	menulinks[2][1][1] = '<a href="service.cfm?p=2" class="whitelink">Services</a>';
	menulinks[2][1][2] = '<a href="service.cfm?p=3" class="whitelink">Products</a>';
	menulinks[2][1][3] = '<a href="service.cfm?p=4" class="whitelink">Installation</a>';
	menulinks[2][1][7] = '<a href="service.cfm?p=6" class="whitelink">Pool and Patio Choices</a>';
	menulinks[2][1][4] = '<a href="service.cfm?p=5" class="whitelink">Remodeling</a>';
	menulinks[2][1][6] = '<a href="contact.cfm?p=1" class="whitelink">Service Request Form</a>';
	
	menulinks[3][0][0] = '<p class="dropdwn"><a href="gallery.cfm?p=1" class="dropdwnlink">Album 1</a></p>';
	menulinks[3][0][1] = '<p class="dropdwn"><a href="gallery.cfm?p=2" class="dropdwnlink">Album 2</a></p>';
	menulinks[3][0][2] = '<p class="dropdwn"><a href="gallery.cfm?p=3" class="dropdwnlink">Album 3</a></p>';
	//menulinks[3][0][3] = '<p class="dropdwn"><a href="gallery.cfm?p=4" class="dropdwnlink">Album 4</a></p>';
	menulinks[3][1][0] = '<a href="gallery.cfm?p=1" class="whitelink">Album 1</a>';
	menulinks[3][1][1] = '<a href="gallery.cfm?p=2" class="whitelink">Album 2</a>';
	menulinks[3][1][2] = '<a href="gallery.cfm?p=3" class="whitelink">Album 3</a>';
	//menulinks[3][1][3] = '<a href="gallery.cfm?p=4" class="whitelink">Album 4</a>';
	
	menulinks[4][0][0] = '<p class="dropdwn"><a href="newsletter.cfm?p=1" class="dropdwnlink">Mitch\'s Letter</a></p>';
	menulinks[4][0][1] = '<p class="dropdwn"><a href="newsletter.cfm?p=2" class="dropdwnlink">Sun Design Tool Box</a></p>';
	menulinks[4][0][2] = '<p class="dropdwn"><a href="newsletter.cfm?p=5" class="dropdwnlink">Useful Tips</a></p>';
	menulinks[4][0][3] = '<p class="dropdwn"><a href="newsletter.cfm?p=3" class="dropdwnlink">Newsletter Archive</a></p>';
	menulinks[4][0][4] = '<p class="dropdwn"><a href="contact.cfm?p=1" class="dropdwnlink">Sign Up for Newsletter</a></p>';
	menulinks[4][1][0] = '<a href="newsletter.cfm?p=1" class="whitelink">Mitch\'s Letter</a>';
	menulinks[4][1][1] = '<a href="newsletter.cfm?p=2" class="whitelink">Sun Design Tool Box</a>';
	menulinks[4][1][2] = '<a href="newsletter.cfm?p=5" class="whitelink">Useful Tips</a>';
	menulinks[4][1][3] = '<a href="newsletter.cfm?p=3" class="whitelink">Newsletter Archive</a>';
	menulinks[4][1][4] = '<a href="contact.cfm?p=1" class="whitelink">Sign Up for Newsletter</a>';
	
	menulinks[5][0][0] = '<p class="dropdwn"><a href="contact.cfm?p=1" class="dropdwnlink">Request Info Form</a></p>';
	menulinks[5][0][1] = '<p class="dropdwn"><a href="map.cfm?p=1" class="dropdwnlink">Our Showroom<br>(Map & Directions)</a></p>';
	menulinks[5][1][0] = '<a href="contact.cfm?p=1" class="whitelink">Request Info Form</a>';
	menulinks[5][1][1] = '<a href="map.cfm?p=1" class="whitelink">Our Showroom<br>(Map & Directions)</a>';
	//top nav menu functions
	function showmenu (p) {
		var newhtml = '';
		for (i in menulinks[p][0]) {
			newhtml = newhtml + menulinks[p][0][i];
		}
		var boxDiv = document.getElementById('dropdwnbox');
		boxDiv.innerHTML = newhtml;
		var newX = document.getElementById('tab' + p).offsetLeft;
		var newY = document.getElementById('tab' + p).offsetTop;
		var pnode = document.getElementById('tab' + p).parentNode;
		while (pnode) {
			if (pnode.nodeType == 1 && pnode.nodeName != 'TR') {
				if (pnode.id != 'igid') {
					newX = newX + pnode.offsetLeft;
					newY = newY + pnode.offsetTop;
				}
			}
			pnode = pnode.parentNode;
		}
		if (p == 5) {
			//also adjust X b/c off page
			newX = (newX + document.getElementById('tab' + p).offsetWidth) - 183;
		}
		//newY = newY + document.getElementById('tab' + p).offsetHeight;
		boxDiv.style.left = newX + 'px';
		boxDiv.style.top = newY + 'px';
		boxDiv.style.display = 'block';
	}
	
	function showmenu2 () {
		var boxDiv = document.getElementById('dropdwnbox');
		boxDiv.style.display = 'block';
	}
	
	function hidemenu () {
		var boxDiv = document.getElementById('dropdwnbox');
		boxDiv.style.display = 'none';
	}
	
	function crcont (p) {		
		var newhtml = '';
		for (i in menulinks[p][1]) {
			newhtml = newhtml + menulinks[p][1][i] + '<p></p>';
		}
		var boxDiv2 = document.getElementById('leftnav');
		boxDiv2.innerHTML = newhtml;
	}
	
	// Detect if the browser is IE or not.
	// If it is not IE, we assume that the browser is NS.
	//var IE = document.all?true:false;
	// If NS -- that is, !IE -- then set up for mouse capture
	//if (!IE) document.captureEvents(Event.MOUSEMOVE);
	//document.onmousemove = getMouseXY;
	var tempX;
	var tempY;
	function getMouseXY(e) {
	  if (IE) { // grab the x-y pos.s if browser is IE
		//tempX = event.clientX + document.body.scrollLeft;
		//tempY = event.clientY + document.body.scrollTop;
		tempX = event.clientX;
		tempY = event.clientY;
	  } else {  // grab the x-y pos.s if browser is NS
		//tempX = e.pageX;
		//tempY = e.pageY;
		tempX = e.clientX;
		tempY = e.clientY;
	  }  
	  // catch possible negative values in NS4
	  if (tempX < 0){tempX = 0; }
	  if (tempY < 0){tempY = 0; }  
	}