var cssdropdown={
disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseout
dropdownindicator: '', //specify full HTML to add to end of each menu item with a drop down menu
enablereveal: [true, 4], //enable swipe effect? [true/false, steps (Number of animation steps. Integer between 1-20. Smaller=faster)]
enableiframeshim: 0, //enable "iframe shim" in IE5.5 to IE7? (1=yes, 0=no)

//No need to edit beyond here////////////////////////

dropmenuobj: null, asscmenuitem: null, domsupport: document.all || document.getElementById, standardbody: null, iframeshimadded: false, revealtimers: {},

getposOffset:function(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
},

css:function(el, targetclass, action){
	var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig")
	if (action=="check")
		return needle.test(el.className)
	else if (action=="remove")
		el.className=el.className.replace(needle, "")
	else if (action=="add" && !needle.test(el.className))
		el.className+=" "+targetclass
},

showmenu:function(dropmenu, e){
	if (this.enablereveal[0]){
		if (!dropmenu._trueheight || dropmenu._trueheight<10)
			dropmenu._trueheight=dropmenu.offsetHeight
		clearTimeout(this.revealtimers[dropmenu.id])
		dropmenu.style.height=dropmenu._curheight=0
		dropmenu.style.overflow="hidden"
		dropmenu.style.visibility="visible"
		this.revealtimers[dropmenu.id]=setInterval(function(){cssdropdown.revealmenu(dropmenu)}, 10)
	}
	else{
		dropmenu.style.visibility="visible"
	}
	this.css(this.asscmenuitem, "selected", "add")
},

revealmenu:function(dropmenu, dir){
	var curH=dropmenu._curheight, maxH=dropmenu._trueheight, steps=this.enablereveal[1]
	if (curH<maxH){
		var newH=Math.min(curH, maxH)
		dropmenu.style.height=newH+"px"
		dropmenu._curheight= newH + Math.round((maxH-newH)/steps) + 1
	}
	else{ //if done revealing menu
		dropmenu.style.height="auto"
		dropmenu.style.overflow="hidden"
		clearInterval(this.revealtimers[dropmenu.id])
	}
},

clearbrowseredge:function(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=document.all && !window.opera? this.standardbody.scrollLeft+this.standardbody.clientWidth-15 : window.pageXOffset+window.innerWidth-15
		var dropmenuW=this.dropmenuobj.offsetWidth
		if (windowedge-this.dropmenuobj.x < dropmenuW)  //move menu to the left?
			edgeoffset=dropmenuW-obj.offsetWidth
	}
	else{
		var topedge=document.all && !window.opera? this.standardbody.scrollTop : window.pageYOffset
		var windowedge=document.all && !window.opera? this.standardbody.scrollTop+this.standardbody.clientHeight-15 : window.pageYOffset+window.innerHeight-18
		var dropmenuH=this.dropmenuobj._trueheight
		if (windowedge-this.dropmenuobj.y < dropmenuH){ //move up?
			edgeoffset=dropmenuH+obj.offsetHeight
			if ((this.dropmenuobj.y-topedge)<dropmenuH) //up no good either?
				edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
		}
	}
	return edgeoffset
},

dropit:function(obj, e, dropmenuID){
	if (this.dropmenuobj!=null) //hide previous menu
		this.hidemenu() //hide menu
	this.clearhidemenu()
	this.dropmenuobj=document.getElementById(dropmenuID) //reference drop down menu
	this.asscmenuitem=obj //reference associated menu item
	this.showmenu(this.dropmenuobj, e)
	this.dropmenuobj.x=this.getposOffset(obj, "left")
	this.dropmenuobj.y=this.getposOffset(obj, "top")
	this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
	this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
	this.positionshim() //call iframe shim function
},

positionshim:function(){ //display iframe shim function
	if (this.iframeshimadded){
		if (this.dropmenuobj.style.visibility=="visible"){
			this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
			this.shimobject.style.height=this.dropmenuobj._trueheight+"px"
			this.shimobject.style.left=parseInt(this.dropmenuobj.style.left)+"px"
			this.shimobject.style.top=parseInt(this.dropmenuobj.style.top)+"px"
			this.shimobject.style.display="block"
		}
	}
},

hideshim:function(){
	if (this.iframeshimadded)
		this.shimobject.style.display='none'
},

isContained:function(m, e){
	var e=window.event || e
	var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
	while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
	if (c==m)
		return true
	else
		return false
},

dynamichide:function(m, e){
	if (!this.isContained(m, e)){
		this.delayhidemenu()
	}
},

delayhidemenu:function(){
	this.delayhide=setTimeout("cssdropdown.hidemenu()", this.disappeardelay) //hide menu
},

hidemenu:function(){
	this.css(this.asscmenuitem, "selected", "remove")
	this.dropmenuobj.style.visibility='hidden'
	this.dropmenuobj.style.left=this.dropmenuobj.style.top="-1000px"
	this.hideshim()
},

clearhidemenu:function(){
	if (this.delayhide!="undefined")
		clearTimeout(this.delayhide)
},

addEvent:function(target, functionref, tasktype){
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false);
	else if (target.attachEvent)
		target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)});
},

startchrome:function(){
	if (!this.domsupport)
		return
	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
	for (var ids=0; ids<arguments.length; ids++){
		var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
		for (var i=0; i<menuitems.length; i++){
			if (menuitems[i].getAttribute("rel")){
				var relvalue=menuitems[i].getAttribute("rel")
				var asscdropdownmenu=document.getElementById(relvalue)
				this.addEvent(asscdropdownmenu, function(){cssdropdown.clearhidemenu()}, "mouseover")
				this.addEvent(asscdropdownmenu, function(e){cssdropdown.dynamichide(this, e)}, "mouseout")
				this.addEvent(asscdropdownmenu, function(){cssdropdown.delayhidemenu()}, "click")
				try{
					menuitems[i].innerHTML=menuitems[i].innerHTML+" "+this.dropdownindicator
				}catch(e){}
				this.addEvent(menuitems[i], function(e){ //show drop down menu when main menu items are mouse over-ed
					if (!cssdropdown.isContained(this, e)){
						var evtobj=window.event || e
						cssdropdown.dropit(this, evtobj, this.getAttribute("rel"))
					}
				}, "mouseover")
				this.addEvent(menuitems[i], function(e){cssdropdown.dynamichide(this, e)}, "mouseout") //hide drop down menu when main menu items are mouse out
				this.addEvent(menuitems[i], function(){cssdropdown.delayhidemenu()}, "click") //hide drop down menu when main menu items are clicked on
			}
		} //end inner for
	} //end outer for
	if (this.enableiframeshim && document.all && !window.XDomainRequest && !this.iframeshimadded){ //enable iframe shim in IE5.5 thru IE7?
		document.write('<IFRAME id="iframeshim" src="about:blank" frameBorder="0" scrolling="no" style="left:0; top:0; position:absolute; display:none;z-index:90; background: transparent;"></IFRAME>')
		this.shimobject=document.getElementById("iframeshim") //reference iframe object
		this.shimobject.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'
		this.iframeshimadded=true
	}
} //end startchrome

}


//clears the global search bar when users clicks -------->

function clearDefault(box) {
  if (box.defaultValue==box.value) box.value = ""
}


//Random image generator -------->

var theImages = new Array() 
 
theImages[0] = 'http://www.lhwmp.org/home/images/banner/banner1.jpg'
theImages[1] = 'http://www.lhwmp.org/home/images/banner/banner2.jpg'
theImages[2] = 'http://www.lhwmp.org/home/images/banner/banner3.jpg'
theImages[3] = 'http://www.lhwmp.org/home/images/banner/banner4.jpg'
theImages[4] = 'http://www.lhwmp.org/home/images/banner/banner5.jpg' 
theImages[5] = 'http://www.lhwmp.org/home/images/banner/banner6.jpg'
theImages[6] = 'http://www.lhwmp.org/home/images/banner/banner7.jpg'
theImages[7] = 'http://www.lhwmp.org/home/images/banner/banner8.jpg'
theImages[8] = 'http://www.lhwmp.org/home/images/banner/banner9.jpg'
theImages[9] = 'http://www.lhwmp.org/home/images/banner/banner10.jpg'
 
 
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}

//Google Map begins here --------------->

function initialize() {
  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map_canvas"),
   	  { size: new GSize(522,300) } );
    map.setCenter(new GLatLng(47.5975430, -122.1508850), 9);
 	map.addControl(new GLargeMapControl());
	var baseIcon = new GIcon(G_DEFAULT_ICON);
	baseIcon.shadow = "../images/mapMarkers/marker_shadow.png";
	baseIcon.iconSize = new GSize(39, 25);
	baseIcon.shadowSize = new GSize(51, 25);
	baseIcon.iconAnchor = new GPoint(11, 23);
	baseIcon.infoWindowAnchor = new GPoint(23, 11);
    function createMarker(point, content, number){
		var letter = String.fromCharCode("A".charCodeAt(0) + number);  
		var letteredIcon = new GIcon(baseIcon); 
		letteredIcon.image = "../images/mapMarkers/marker" + letter + ".png"; 
	 	markerOptions = { icon:letteredIcon };
        var marker = new GMarker(point, markerOptions); 
        GEvent.addListener(marker, "click", function() {   
          marker.openInfoWindowHtml(content);  
        });  
        return marker;
      }
  //Insert a new city by using this format below. Just copy and past this code and replace variable name. Be sure to get the proper    geocode before doing so otherwise marker will not show up
    var point1 = new GLatLng(47.4750908, -122.3338314);
    map.addOverlay(createMarker(point1, "<p class='content'><strong>Fred Meyer - Burien</strong> <br/>Aug 24 - Aug 26, 2010<br/>14300 1st Ave S.<br/> Burien, WA 98168 </p>", 0));
	
	var point2 = new GLatLng(47.3579699, -122.1338854);
    map.addOverlay(createMarker(point2, "<p class='content'><strong>Fire Station No. 75</strong> <br/>Mar 12 - Mar 14, 2010<br/>May 28 - May 30, 2010<br/>Aug 27 - Aug 29, 2010<br/>15635 SE 272nd St.<br/>Kent, WA 98042</p>", 1));
	
	var point3 = new GLatLng(47.7259217, -121.9868582);
    map.addOverlay(createMarker(point3, "<p class='content'><strong>Safeway Parking Lot</strong><br>Oct 8 - Oct 10, 2010<br>14020 Main St NE<br/>Duvall, WA 98019</p>", 2));
	
	var point4 = new GLatLng(47.6713496, -122.1013346);
    map.addOverlay(createMarker(point4, "<p class='content'><strong>Home Depot - Redmond</strong> <br>Apr 9 - Apr 11, 2010<br/>Aug 20 - Aug 22, 2010<br/>Oct 1 - Oct 3, 2010<br/>14020 Main St NE<br/>Duvall, WA 98019</p>", 3));
	
	var point5 = new GLatLng(47.6129643, -122.0353655);
    map.addOverlay(createMarker(point5, "<p class='content'><strong>Eastlake High School</strong> <br>Jul 23 - Jul 25, 2010<br/>400 - 228th Ave. NE<br/>Sammamish, WA 98074</p>", 4));
	
	var point6 = new GLatLng(47.4012112, -122.3283293);
    map.addOverlay(createMarker(point6, "<p class='content'><strong>Marina - Des Moines/Normandy Park</strong> <br>Mar 26 - Mar 28, 2010<br/>400 - 228th Ave. NE<br/>Des Moines, WA </p>", 5));
	
	var point7 = new GLatLng(47.7655970, -122.1772800);
    map.addOverlay(createMarker(point7, "<p class='content'><strong>Seattle Times Building - Bothell</strong> <br>Apr 23 - Apr 25, 2010<br/>Jul 9 - Jul 11, 2010<br>Aug 10 - Aug 12, 2010<br>400 - 228th Ave. NE<br/>Bothell, WA</p>", 6));
	
	var point8 = new GLatLng(47.4527203, -122.4711172);
    map.addOverlay(createMarker(point8, "<p class='content'><strong>Tjomsland Gravel Pit</strong> <br>Apr 30 - May 2, 2010<br>17001 107th Ave SW<br/>Vashon, WA</p>", 7));
	
	var point9 = new GLatLng(47.7564419, -122.1528064);
    map.addOverlay(createMarker(point9, "<p class='content'><strong>Park n Ride - Woodinville</strong> <br>May 14 - May 16, 2010<br>Jul 30 - Aug 1, 2010<br>Oct 22 - Oct 24, 2010<br>17800 140th Ave NE<br>Woodinville, WA</p>", 8));
	
	var point10 = new GLatLng(47.7084680, -122.1836540);
    map.addOverlay(createMarker(point10, "<p class='content'><strong>Fred Meyer</strong><br>Jun 11 - Jun 13, 2010<br>12221 120th Ave NE<br>Kirkland, WA</p>", 9));
	
	var point11 = new GLatLng(47.1955060, -121.9610140);
    map.addOverlay(createMarker(point11, "<p class='content'><strong>Enumclaw Expo Center</strong> <br>Jun 18 - Jun 20, 2010<br>45224 284th Ave SE<br>Enumclaw, WA</p>", 10));
	
	var point12 = new GLatLng(47.4775836,  -122.2184510);
    map.addOverlay(createMarker(point12, "<p class='content'><strong>Fred Meyer</strong> <br>Jun 25 - Jun 27, 2010<br>365 Renton Center Way<br>Renton, WA</p>", 11));
	
		var point13 = new GLatLng(47.5249246,  -121.8116437);
    map.addOverlay(createMarker(point13, "<p class='content'><strong>Snoqualmie Elementary</strong> <br>Aug 13 - Aug 18, 2010<br>39801 SE Park St<br>Snoqualmie, WA</p>", 12));
  }
 
}

// -----  Function for the year in the footer ------//

function Fullyear(){
	var d = new Date();
	document.write(d.getFullYear());
	
	
}

// ---- Function that controls the hover of subnav


function navHover(styleName){
 document.getElementById(styleName).style.backgroundColor="#969595";	
 document.getElementById(styleName).style.color="#fff";
  }
     
	 
// Master value validator routine 
function isValid(inputStr) {
	if (isEmpty(inputStr)) {
		alert("Please enter a number into the field before clicking the button.")
		return false 	} else {
		if (!isNumber(inputStr)) {
			alert("Please make sure entries are numbers only.")
			return false 		} 
	}
	return true }
// JavaScript sees numbers with leading zeros as octal values, so strip zeros
function stripZeros(inputStr) {
	var result = inputStr
	while (result.substring(0,1) == "0") {
		result = result.substring(1,result.length)
	}
	return result
}
 
// general purpose function to see if an input value has been entered at all
function isEmpty(inputStr) {
	if (inputStr == "" || inputStr == null) {
		return true 	}
	return false }
 
// general purpose function to see if a suspected numeric input 
// is a positive integer
function isNumber(inputStr) {
	theStr = parseInt(inputStr, 10)
	for (var i = 0; i < theStr.length; i++) {
		var oneChar = theStr.substring(i, i + 1)
		if (oneChar < "0" || oneChar > "9") {
			return false 		}
	}
	return true }
 
function  thisProject() {
 
	var height = parseFloat(document.projectpaintForm.wall_height.value)
	var width = parseFloat(document.projectpaintForm.wall_width.value)
	var windows = (parseInt(document.projectpaintForm.s_windows.value) * 15)
	var doors = (parseInt(document.projectpaintForm.s_doors.value) * 21)
	var cutouts = windows + doors
	var gals = 0
	if (parseFloat(document.projectpaintForm.projarea.value)) {
 
		var carryover = parseFloat(document.projectpaintForm.projarea.value)
	
		} else {
 
		var carryover = 0
 
		}
 
	var area = ((height * width) - cutouts )+ carryover
	var  gals= (area / 400)
	document.projectpaintForm.galbox.value = gals;
	document.projectpaintForm.projarea.value = area;
 
}
function  thisRoom() {
	var sqft = 0
	var gals = 0
	var ceiling = 0
	var windows = (parseInt(document.roompaintForm.r_windows.value) * 15)
	var doors = (parseInt(document.roompaintForm.r_doors.value) * 21)
	var cutouts = windows + doors
	var height = parseFloat(document.roompaintForm.room_height.value)
	var longwall = parseFloat(document.roompaintForm.width_long.value)
	var shortwall = parseFloat(document.roompaintForm.width_short.value)
 
	if (document.roompaintForm.ceiling.checked) {
		ceiling = (longwall * shortwall)
		} else {
		ceiling = 0
		}
 
	var sqft = (((((longwall + shortwall) * 2) * height) + ceiling) - cutouts)
	document.roompaintForm.roomarea.value = sqft;	
 
	var  gals= (sqft / 400)
	document.roompaintForm.roomgals.value = gals;
 
}
// End Script-->