
var ProgramsDropDownMenu= {
	divclass:"dropDownMenu",
	inlinestyle:"width:160px",
	linktarget:""
}
;
ProgramsDropDownMenu.items=[
	["Sailing Instruction","/programs/instruction.html"],
	["Seminars and Workshops","/programs/seminar.html"]
]
;

var RacingDropDownMenu= {
	divclass:"dropDownMenu",
	inlinestyle:"width:80px",
	linktarget:""
}
;
RacingDropDownMenu.items=[
	["Results","/racing/results/results.html"],
	["Crew List","/racing/crew.html"],
	["Handicaps","/racing/phrf/handicaps.html"],
	["Documents","/racing/documents/documents.html"],
	["Spud Cup","/spudCup/sc.html"]
]
;

var PhotosDropDownMenu= {
	divclass:"dropDownMenu",inlinestyle:"width:165px",linktarget:"_blank"
}
;
PhotosDropDownMenu.items=[
	["Sailing Lessons - July","http://gallery.sandpointsailing.com/2011/lessons/index.htm"],
	["Sailing Lessons - August","http://gallery.sandpointsailing.com/2011/Lessons2/index.htm"],
	["Sailing Lessons - August","http://www.flickr.com/photos/62667167@N07/sets/72157627440286463"],
	["Thursday Evening Racing","http://gallery.sandpointsailing.com/2011/ThursdayEvening/index.htm"],
	["Helen Gloor Moonlight Race","http://gallery.sandpointsailing.com/2011/MoonlightRace/index.htm"],
	["Singlehanded Race","http://www.flickr.com/photos/62667167@N07/sets/72157627231177115"],
	["Long Distance Buoy Race","http://www.flickr.com/photos/62667167@N07/sets/72157627439799471"],
	["LOTS more fun pics!","http://www.facebook.com/groups/354047240485/photos/"]
]
;

var MembershipDropDownMenu= {
	divclass:"dropDownMenu",inlinestyle:"width:120px",linktarget:""
}
;
MembershipDropDownMenu.items=[
	["About Our Club","/ssa/history.html"],
	["Join SSA","/ssa/join.html"],
	["Member Directory","/ssa/members.html"],
	["Board Members","/ssa/directors.html"],
	["Contacts","/ssa/contacts.html"],
	["Classified Ads","/ssa/classifieds.html"],
	["Newsletters","/ssa/newsletters.html"]
]
;

var SandpointDropDownMenu= {
	divclass:"dropDownMenu",inlinestyle:"width:80px",linktarget:""
}
;
SandpointDropDownMenu.items=[
	["Services","/sandpoint/services.html"],
	["Restaurants","/sandpoint/restaurants.html"],
	["Map","/sandpoint/map.html"]
]
;

var LinksDropDownMenu= {
	divclass:"dropDownMenu",inlinestyle:"",linktarget:"_blank"
}
;
LinksDropDownMenu.items=[
	["SSA on Facebook","http://www.facebook.com/groups/354047240485/#!/groups/354047240485/"],
	["Lake Pend Oreille Conditions","http://lpo.dt.navy.mil"],
	["Lake Pend Oreille Level At Hope","http://www.nwd-wc.usace.army.mil/nws/hh/basins/data.html?pnd+hopi"],
	["Lake Pend Oreille Level Prediction","http://water.weather.gov/ahps2/hydrograph.php?wfo=otx&gage=hopi1&view=1,1,1,1,1,1,1,1"],
	["Lake Pend Oreille Yacht Club","http://www.lpoyc.org"],
	["Lewis-Clark Sailing Association","http://lewisclarksailing.org"],
	["MacDonalds's Hudson Bay Resort","http://www.macdonaldsresort.com"],
	["PHRF-NW","http://www.phrf-nw.org"],
	["Sandpoint Marina Weather","http://www.wonderfulsandpoint.com/MyLinks/SandpointMarinaWeatherStation/tabid/2731/Default.aspx"],
	["Sandpoint Weather","http://forecast.weather.gov/MapClick.php?CityName=Sandpoint&state=ID&site=OTX&textField1=48.2767&textField2=-116.552&e=0A"],
	["West Marine","http://www.westmarine.com"]

]
;



var dropDownMenu= {
	menusmap: {
	}
	,effects: {
		delayhide:200,shadow: {
			enabled:true,opacity:0.3,depth:[5,5]
		}
		,fade: {
			enabled:false,duration:500
		}
	}
	,dimensions: {
	}
	,getoffset:function(b,a) {
		return(b.offsetParent)?b[a]+this.getoffset(b.offsetParent,a):b[a]
	}
	,getoffsetof:function(a) {
		a._offsets= {
			left:this.getoffset(a,"offsetLeft"),top:this.getoffset(a,"offsetTop"),h:a.offsetHeight
		}
	}
	,getdimensions:function(a) {
		this.dimensions= {
			anchorw:a.anchorobj.offsetWidth,anchorh:a.anchorobj.offsetHeight,docwidth:(window.innerWidth||this.standardbody.clientWidth)-20,docheight:(window.innerHeight||this.standardbody.clientHeight)-15,docscrollx:window.pageXOffset||this.standardbody.scrollLeft,docscrolly:window.pageYOffset||this.standardbody.scrollTop
		}
		;
		if(!this.dimensions.dropmenuw) {
			this.dimensions.dropmenuw=a.dropmenu.offsetWidth;
			this.dimensions.dropmenuh=a.dropmenu.offsetHeight
		}
	}
	,isContained:function(a,b) {
		var b=window.event||b;
		var d=b.relatedTarget||((b.type=="mouseover")?b.fromElement:b.toElement);
		while(d&&d!=a) {
			try {
				d=d.parentNode
			}
			catch(b) {
				d=a
			}
		}
		if(d==a) {
			return true
		} else {
			return false
		}
	}
	,setopacity:function(a,b) {
		a.style.opacity=b;
		if(typeof a.style.opacity!="string") {
			a.style.MozOpacity=b;
			if(a.filters) {
				a.style.filter="progid: DXImageTransform.Microsoft.alpha(opacity ="+b*100+")"
			}
		}
	}
	,showmenu:function(b) {
		var c=dropDownMenu.menusmap[b];
		clearTimeout(c.hidetimer);
		this.getoffsetof(c.anchorobj);
		this.getdimensions(c);
		var a=c.anchorobj._offsets.left+(c.orientation=="lr"?this.dimensions.anchorw:0);
		var d=c.anchorobj._offsets.top+this.dimensions.anchorh-(c.orientation=="lr"?this.dimensions.anchorh:0);
		if(a+this.dimensions.dropmenuw+this.effects.shadow.depth[0]>this.dimensions.docscrollx+this.dimensions.docwidth) {
			a=a-this.dimensions.dropmenuw+(c.orientation=="lr"?-this.dimensions.anchorw:this.dimensions.anchorw)
		}
		if(d+this.dimensions.dropmenuh>this.dimensions.docscrolly+this.dimensions.docheight) {
			d=Math.max(d-this.dimensions.dropmenuh-(c.orientation=="lr"?-this.dimensions.anchorh:this.dimensions.anchorh),this.dimensions.docscrolly)
		}
		if(this.effects.fade.enabled) {
			this.setopacity(c.dropmenu,0);
			if(this.effects.shadow.enabled) {
				this.setopacity(c.shadow,0)
			}
		}
		c.dropmenu.setcss( {
			left:a+"px",top:d+"px",visibility:"visible"
		}
		);
		if(this.effects.shadow.enabled) {
			c.shadow.setcss( {
				left:a+dropDownMenu.effects.shadow.depth[0]+"px",top:d+dropDownMenu.effects.shadow.depth[1]+"px",visibility:"visible"
			}
			)
		}
		if(this.effects.fade.enabled) {
			clearInterval(c.animatetimer);
			c.curanimatedegree=0;
			c.starttime=new Date().getTime();
			c.animatetimer=setInterval(function() {
				dropDownMenu.revealmenu(b)
			}
			,20)
		}
	}
	,revealmenu:function(b) {
		var c=dropDownMenu.menusmap[b];
		var a=new Date().getTime()-c.starttime;
		if(a<this.effects.fade.duration) {
			this.setopacity(c.dropmenu,c.curanimatedegree);
			if(this.effects.shadow.enabled) {
				this.setopacity(c.shadow,c.curanimatedegree*this.effects.shadow.opacity)
			}
		} else {
			clearInterval(c.animatetimer);
			this.setopacity(c.dropmenu,1);
			c.dropmenu.style.filter=""
		}
		c.curanimatedegree=(1-Math.cos((a/this.effects.fade.duration)*Math.PI))/2
	}
	,setcss:function(a) {
		for (prop in a) {
			this.style[prop]=a[prop]
		}
	}
	,hidemenu:function(a) {
		var b=dropDownMenu.menusmap[a];
		clearInterval(b.animatetimer);
		b.dropmenu.setcss( {
			visibility:"hidden",left:0,top:0
		}
		);
		b.shadow.setcss( {
			visibility:"hidden",left:0,top:0
		}
		)
	}
	,getElementsByClass:function(a) {
		if(document.querySelectorAll) {
			return document.querySelectorAll("."+a)
		} else {
			var e=new RegExp("(^|\\s+)"+a+"($|\\s+)","i");
			var d=[];
			var c=document.all?document.all:document.getElementsByTagName("*");
			for (var b=0;b<c.length;b++) {
				if(typeof c[b].className=="string"&&c[b].className.search(e)!=-1) {
					d[d.length]=c[b]
				}
			}
			return d
		}
	}
	,addDiv:function(d,c,a) {
		var b=document.createElement("div");
		if(d) {
			b.id=d
		}
		b.className=c;
		if(a!=""&&typeof b.style.cssText=="string") {
			b.style.cssText=a
		} else {
			if(a!="") {
				b.setAttribute("style",a)
			}
		}
		document.body.appendChild(b);
		return b
	}
	,getmenuHTML:function(c) {
		var a=[];
		var d="";
		for (var b=0;b<c.items.length;b++) {
			d+='<li><a href="'+c.items[b][1]+'" target="'+c.linktarget+'">'+c.items[b][0]+"</a></li>\n";
			if(c.items[b][2]=="efc"||b==c.items.length-1) {
				a.push(d);
				d=""
			}
		}
		if(typeof c.cols=="undefined") {
			return"<ul>\n"+a.join("")+"\n</ul>"
		} else {
			d="";
			for (var b=0;b<a.length;b++) {
				d+='<div class="'+c.cols.divclass+'" style="'+c.cols.inlinestyle+'">\n<ul>\n'+a[b]+"</ul>\n</div>\n"
			}
			return d
		}
	}
	,addEvent:function(a,d,b) {
		if(a.length>0) {
			var c=a.shift();
			if(c.addEventListener) {
				c.addEventListener(b,d,false)
			} else {
				if(c.attachEvent) {
					c.attachEvent("on"+b,function() {
						return d.call(c,window.event)
					}
					)
				}
			}
			this.addEvent(a,d,b)
		}
	}
	,setupmenu:function(a,d,g) {
		this.standardbody=(document.compatMode=="CSS1Compat")?document.documentElement:document.body;
		var b=d.getAttribute("rel");
		dropmenuid=b.replace(/\[(\w+)\]/,"");
		var c=window[dropmenuid];
		var f=this.addDiv(null,c.divclass,c.inlinestyle);
		f.innerHTML=this.getmenuHTML(c);
		var e=this.menusmap[a+g]= {
			id:a+g,anchorobj:d,dropmenu:f,revealtype:(b.length!=dropmenuid.length&&RegExp.$1=="click")?"click":"mouseover",orientation:d.getAttribute("rev")=="lr"?"lr":"ud",shadow:this.addDiv(null,"dropDownMenuShadow",null)
		}
		;
		e.anchorobj._internalID=a+g;
		e.anchorobj._isanchor=true;
		e.dropmenu._internalID=a+g;
		e.shadow._internalID=a+g;
		e.dropmenu.setcss=this.setcss;
		e.shadow.setcss=this.setcss;
		e.shadow.setcss( {
			width:e.dropmenu.offsetWidth+"px",height:e.dropmenu.offsetHeight+"px"
		}
		);
		this.setopacity(e.shadow,this.effects.shadow.opacity);
		this.addEvent([e.anchorobj,e.dropmenu,e.shadow],function(h) {
			var j=dropDownMenu.menusmap[this._internalID];
			if(this._isanchor&&j.revealtype=="mouseover"&&!dropDownMenu.isContained(this,h)) {
				dropDownMenu.showmenu(j.id)
			} else {
				if(typeof this._isanchor=="undefined") {
					clearTimeout(j.hidetimer)
				}
			}
		}
		,"mouseover");
		this.addEvent([e.anchorobj,e.dropmenu,e.shadow],function(h) {
			if(!dropDownMenu.isContained(this,h)) {
				var j=dropDownMenu.menusmap[this._internalID];
				j.hidetimer=setTimeout(function() {
					dropDownMenu.hidemenu(j.id)
				}
				,dropDownMenu.effects.delayhide)
			}
		}
		,"mouseout");
		this.addEvent([e.anchorobj,e.dropmenu],function(h) {
			var j=dropDownMenu.menusmap[this._internalID];
			if(this._isanchor&&j.revealtype=="click") {
				if(j.dropmenu.style.visibility=="visible") {
					dropDownMenu.hidemenu(j.id)
				} else {
					dropDownMenu.showmenu(j.id)
				}
				if(h.preventDefault) {
					h.preventDefault()
				}
				return false
			} else {
				j.hidetimer=setTimeout(function() {
					dropDownMenu.hidemenu(j.id)
				}
				,dropDownMenu.effects.delayhide)
			}
		}
		,"click")
	}
	,init:function(a) {
		var c=this.getElementsByClass(a);
		for (var b=0;b<c.length;b++) {
			this.setupmenu(a,c[b],b)
		}
	}
}
;
function loadXml(b,c) {
	var a=null;
	if(window.XMLHttpRequest) {
		a=new XMLHttpRequest()
	} else {
		if(window.ActiveXObject) {
			try {
				a=new ActiveXObject("Msxml2.XMLHTTP")
			}
			catch(d) {
				try {
					a=new ActiveXObject("Microsoft.XMLHTTP")
				}
				catch(d) {
					a=null
				}
			}
		}
	}
	if(a!=null) {
		a.onreadystatechange=function() {
			if(c!=null) {
				try {
					if(a.readyState==4) {
						if(a.status==200) {
							c(a)
						} else {
							alert("Unable to process AJAX request at this time.")
						}
					}
				}
				catch(f) {
					alert("AJAX exception: "+f.description)
				}
			}
		}
		;
		a.open("GET",b,(c!=null));
		a.send("")
	} else {
		alert("AJAX is not supported by your browser.\nTo view this site, please upgrade your browser.")
	}
	return a
}
function UpcomingEvents(a) {
	var d=function(j) {
		var l="";
		var m=14;
		var h=4;
		var k=f(j,m,h);
		if(k!=null&&0<k.length) {
			l+="<p><strong>Upcoming Events</strong><br /></p>";
			l+="<ul>"+k+"</ul>"
		}
		return l
	}
	;
	var f=function(p,v,w) {
		var h="";
		if(p!=null) {
			var r=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
			var m=new Date();
			var t=r[m.getMonth()]+" "+m.getDate()+", "+m.getFullYear();
			var k=Date.parse(t);
			var q=k+v*24*60*60*1000;
			var l=0;
			var u=p.getElementsByTagName("CalendarItem");
			for (var o=0;o<u.length;o++) {
				var j=e(u,o);
				if(j.date!=null&&0<j.date.length) {
					var s=Date.parse(j.date);
					if(k<=s&&s<=q) {
						h+=c(j);
						l++
					} else {
						if(k<=s&&l<w) {
							h+=c(j);
							l++
						} else {
							if(q<s) {
								o=u.length
							}
						}
					}
				}
			}
		}
		return h
	}
	;
	var e=function(j,k) {
		var h= {
			name:b(j,k,"Event"),date:b(j,k,"StartDate"),time:b(j,k,"Time"),place:b(j,k,"Place"),description:b(j,k,"Description"),link:b(j,k,"Link"),url:b(j,k,"Url"),target:b(j,k,"Target")
		}
		;
		return h
	}
	;
	var b=function(j,l,k) {
		var o="";
		var n=null;
		var h=j[l].getElementsByTagName(k);
		try {
			n=h[0].firstChild.nodeValue
		}
		catch(m) {
			n=o
		}
		return n
	}
	;
	var c=function(n) {
		var h="";
		var l="<li>";
		var k="</li>";
		var j=g(n.date);
		if(j&&0<j.length) {
			l='<li style="list-style-type: none"><table cellpadding="0" cellspacing="0"><tr style="padding: 0px; margin: 0px"><td style="vertical-align:middle; width: 30px; font-style:normal; font-size: 10px">'+j+"</td><td>";
			k="</td></tr></table></li>"
		}
		var m=n.name;
		if(n.link!=null&&0<n.link.length) {
			m=n.link
		}
		if(n.url!=null&&0<n.url.length) {
			if(n.target==null||0==n.target.length) {
				n.target="_top"
			}
			h=l+'<a href="'+n.url+'" target="'+n.target+'">'+m+"</a>"+k
		} else {
			h=l+'<a href="javascript: void(0)" onclick="showEvent(\''+n.name+"', '"+n.date+"', '"+n.time+"', '"+n.place+"', '"+n.description+"', event.screenX, event.screenY)\">"+m+"</a>"+k
		}
		return h
	}
	;
	var g=function(k) {
		var h="";
		var l=Date.parse(k);
		if(0<l) {
			var j=new Date(k);
			h=j.getMonth()+1+"-"+j.getDate()
		}
		return h
	}
	;
	return d(a)
}
var popUpWindow=0;
function showEvent(w,z,f,g,v,l,k) {
	var u=250;
	var m=Math.ceil(w.length/19);
	var n=Math.ceil(f.length/24);
	var o=Math.ceil(g.length/24);
	var r=Math.ceil(v.length/36);
	var d=85;
	var A=20;
	var s=d+m*25;
	if(0<n) {
		s+=n*20
	}
	if(0<o) {
		s+=A+o*20
	}
	if(0<r) {
		s+=A+r*15
	}
	var c=(screen.width-u)/2;
	var q=(screen.height-s)/2;
	if(l) {
		c=l+100
	}
	if(k) {
		q=k
	}
	if(1<r) {
		v="<p style='text-align:left'>"+v+"</p>"
	} else {
		if(0<r) {
			v="<p>"+v+"</p>"
		}
	}
	var B=navigator.appName;
	var e=navigator.appVersion;
	var b=parseFloat(e);
	if(B=="Microsoft Internet Explorer"&&4<=b) {
		var a=window.createPopup();
		v+="<p style='font-size:8pt'>Click outside of this window to close.</p>";
		s+=10;
		writePopUp(a,w,z,f,g,v);
		c=120;
		q=100;
		a.show(c,q,u,s,navigation)
	} else {
		var a=popUp("",u,s,c,q);
		a.document.title=w;
		writePopUp(a,w,z,f,g,v);
		var j=8;
		if(0<j) {
			var h=j*1000;
			var p=setTimeout("closePopUp()",h)
		}
	}
}
function writePopUp(b,a,g,e,h,o) {
	var f=b.document.body;
	var m="<p style='font-size: 16pt; font-weight:bold'>";
	var k="</p>";
	var j="<p style='font-size: 12pt; font-weight:bold'>";
	var n="</p>";
	var d="<p style='font-size: 12pt; font-weight:bold'>";
	var l="</p>";
	var p="<span style='font-size: 10pt'>";
	var c="</span>";
	f.style.backgroundColor="#6c6656";
	f.style.color="#ffffff";
	f.style.fontFamily="Arial, Helvetica, sans-serif";
	f.style.border="solid #d8d3c7 3px";
	f.style.margin="12px";
	f.style.textAlign="center";
	f.innerHTML=m+a+k+j+g+"</br>"+e+n+d+h+l+p+o+c
}
function popUp(b,c,a,e,d) {
	if(popUpWindow) {
		closePopUp()
	}
	var g="eventPopUpId";
	var f="width="+c+", height="+a;
	f+=", top="+d+", left="+e;
	f+=", directories=no";
	f+=", location=no";
	f+=", menubar=no";
	f+=", resizable=no";
	f+=", scrollbars=no";
	f+=", status=no";
	f+=", titlebar=no";
	f+=", toolbar=no";
	popUpWindow=window.open(b,g,f);
	if(window.focus) {
		popUpWindow.focus()
	}
	return popUpWindow
}
function closePopUp() {
	if(popUpWindow.closed==false) {
		popUpWindow.close()
	}
}
function NavBar(b) {
	var c=function(o) {
		var n=[l,k];
		document.getElementById(o).innerHTML=f(n);
		for (var m=0;m<n.length;m++) {
			loadXml(n[m].xml,n[m].handler)
		}
	}
	;
	var l= {
		title:"Upcoming Events",id:"navEvents",xml:"/calendar/calendar.xml",handler:function(m) {
			return d(m,l.title,l.id)
		}
	}
	;
	var k= {
		title:"Race Results",id:"navRacing",xml:"/racing/nav.xml",handler:function(m) {
			return j(m,k.title,k.id)
		}
	}
	;
	var f=function(n) {
		var o="<p>&nbsp;</p>";
		for (var m=0;m<n.length;m++) {
			o+='<div id="'+n[m].id+'"></div>'
		}
		return o
	}
	;
	var d=function(m,n,o) {
		if(m!=null) {
			document.getElementById(o).innerHTML=UpcomingEvents(m.responseXML)
		}
	}
	;
	var j=function(p,q,r) {
		if(p!=null) {
			var n=p.responseXML;
			var o="";
			var m=h(n);
			if(m!=null&&0<m.length) {
				o="<p><strong>"+q+"</strong><br /></p>";
				o+="<ul>"+m+"</ul>"
			}
			document.getElementById(r).innerHTML=o
		}
	}
	;
	var h=function(p) {
		var o="";
		if(p!=null) {
			var m=p.getElementsByTagName("item");
			for (i=0;i<m.length;i++) {
				var n=g(m,i);
				o+=a(n)
			}
		}
		return o
	}
	;
	var g=function(n,o) {
		var m= {
			link:e(n,o,"link"),url:e(n,o,"url"),target:e(n,o,"target")
		}
		;
		return m
	}
	;
	var e=function(n,p,o) {
		var s="";
		var r=null;
		var m=n[p].getElementsByTagName(o);
		try {
			r=m[0].firstChild.nodeValue
		}
		catch(q) {
			r=s
		}
		return r
	}
	;
	var a=function(m) {
		var n="";
		if(m.link!=null&&0<m.link.length&&m.url!=null&&0<m.url.length) {
			if(m.target==null||0==m.target.length) {
				m.target="_top"
			}
			n='<li><a href="'+m.url+'" target="'+m.target+'">'+m.link+"</a></li>"
		}
		return n
	}
	;
	return c(b)
}
function credits(b) {
	var a=new Date();
	var c=a.getFullYear();
	var d="Copyright &#169; "+c+" "+b+". All rights reserved.";
	document.write(d)
}
;
