/*		mainmenu.js	*/

var SearchDate		= "24/01/2001"
var HomeDate			= "24/01/2001"
var AboutDate 		= "20/12/2011"
var TTDate 				= "28/12/2011"
var LRDate 				= "19/10/2011"
var OPDate 				= "28/12/2011"
var RRDate 				= "19/09/2011"
var CCDate 				= "18/12/2002"
var AUKDate 			= "29/12/2011"
var MTBDate 			= "29/09/2010"
var ContactDate 	= "20/12/2011"
var HistoryDate 		= "31/12/2000"
var ClubroomDate	= "31/12/2000"
var BungalowDate	= "15/04/2003"
var DinnerDate		= "19/03/2002"
var TechnicalDate	= "27/02/2001"
var MarketDate		= "13/06/2008"
var ReportsDate 	= "20/07/2010"
var GalleryDate		= "24/04/2005"
var NewsletterDate	= "05/05/2001"
var InternationalDate	= "17/03/2008"
var MembershipDate	= "02/01/2007"

var LogoutDate		= "01/01/2009"
var LoginDate			= "13/10/2011"
var MemberDate		= "13/10/2011"
var DataDate			= "13/10/2011"
var	loc = ""
var latest = ""

//	loc = "tt/EV10.html"
//	loc = "tt/weekend.html"
//	loc = "tt/open_results.html"
// loc = "cyclocross.html"

function latestResult() {
	if (loc != "") {
		parent.main.document.location.href = loc
		window.setTimeout("initMenu()", ((self.document.location.href.toLowerCase().indexOf('http') != -1) ? 5000 : 1000))
	}
}

var barTop = 32	//	38
var cVisited = 'blue', cActive = 'black', cLink = 'red', cbActive = '#00ffff', cbNormal = "#ffff99", cbMembers = "#ffdfdf"

function writeData() {
	document.write(this.cText)
}

function mnuBar(no, name, id, url, date, hint) {
	var cText, newText
	this.no = no
	this.name = name
	this.id = id
	this.url = url
	this.recent = isNew(date,10)
	this.hint = ((hint != '') ? 'Click ' + ((name.substring(0,3)=='Log') ? 'to ' : 'for ') + hint : '')
	if (hint.substring(0,6) == 'Search') { this.hint = hint }
	if (hint.substring(0,5) == 'Click') { this.hint = hint }
	this.visited = false
	this.active = false
	this.top = barTop
	this.left = ((isIE) ? 5 : 4 )
	barTop += ((this.recent) ? 38 : 24)	//  was 52 : 23, previously 55 : 27
//	this.bar = 'position:absolute; left:'+this.left+'px; width:100px; height:18px; z-index:' + (5 + no) + '; top:'+this.top+'px; '
//		+ ' border:red 1 solid; border-bottom:2 red groove; border-right:2 red groove;'
	this.bar = 'position:absolute; left:'+this.left+'px; width:92px; height:18px; z-index:' + (5 + no) + '; top:'+this.top+'px; '
		+ ' border-color:red; border-width:thin; border-style:solid; border-bottom-width:thin; border-bottom-style:groove; '
		+ ' border-right-width:thin; border-right-style:solid;'
	if ((name=='Login') || (name=='Logout') || (name=='Members') || (name=='Database')) {
		this.bar += ' background-color:' + cbMembers + ';'
	} else {
		this.bar += ' background-color:' + cbNormal + ';'
	}
	this.txt = ' text-align:center; vertical-align:top; padding:' + ((isIE) ? '0px 2px 0px 2px;' : '2px 5px 2px 0px;')
	cText = '<span class="menu" onclick="mouse(' + no + ', \'' + id + '\',\'down\'); return false;"' 
		+ ' onmouseover="mouse(' + no + ', \'' + id + '\',\'over\')" onmouseout="mouse(' + no + ', \'' + id + '\',\'out\')"'
		+ ((this.hint != '') ? ' title="' + this.hint + '">' : '>')
		+ '<div id="' + id + '" style ="' + this.bar + this.txt + ' ">'
	if (!isIE) { cText += '<a href="javascript: //">' + name + '<\/a>' }
	else { cText += name }
	cText += '<\/div>\n'
	if (this.recent) {
		cText += '<div style="position:absolute; left:'+this.left+'px; width:100px; height:18px; z-index:100; top:'+(this.top+18)+'px;">' 
			+ '<img src="'+getDir()+'images/new4a.gif" height="20px" border="0" alt="" /><\/div>'
	}
	cText += '<\/span>'
	this.cText = cText 
//alert(cText)
	this.writeData = writeData
}

function mnuBar2(no, name, id, url, date, hint) {
	var cText, newText
	this.no = no
	this.name = name
	this.id = id
	this.url = url
	this.recent = isNew(date,10)
	this.hint = (hint != '') ? 'Click for ' + hint : ''
	if (hint.substring(0,6) == 'Search') { this.hint = hint }
	if (hint.substring(0,5) == 'Click') { this.hint = hint }
	this.visited = false
	this.active = false
	this.top = barTop
	this.left = ((isIE) ? 5 : 4 )
	barTop += ((this.recent) ? 52 : 23)	// previously 55 : 27
alert(getDir())
	newText = ((this.recent) ? '<br><img src="'+getDir()+'images/new4.gif" width="50%" height="30" border="0" />' : '')
	this.bar = 'position:absolute; left:'+this.left+'px; width:100px; height:25px; z-index:' + (5 + no) + '; top:'+this.top+'px; '
	this.txt = ' text-align:center; vertical-align:middle; padding:' + ((isIE) ? '3px 3px 1px 3px; ' : '2px 5px 2px 0px; ')
	cText = '<span class=menu onclick="mouse(' + no + ', \'' + id + '\',\'down\'); return false;"' 
		+ ' onmouseover="mouse(' + no + ', \'' + id + '\',\'over\')" onmouseout="mouse(' + no + ', \'' + id + '\',\'out\')"'
		+ ((this.hint != '') ? ' title="' + this.hint + '">' : '>')
		+ '<div id=bar' + no + ' style ="' +this.bar +' "><img id=img' + no + ' src="images/menu_box2.gif"></div>'
		+ '<div id=' + id + ' style ="' + this.bar + this.txt + ' ">'
	if (!isIE) { cText += '<a href="javascript: //">' + name + newText + '</a>' }
	else { cText += name + newText }
	cText += '</div>\n</span>'
	this.cText = cText
alert(cText)
	this.writeData = writeData
}

var mnuArray = new Array()
var item = 0

function loadMenu() {
//if (window.createPopup) { mnuArray[item] = new mnuBar(item++, 'Search', 'SEARCH', 'search.html', SearchDate, 'Search our Website') }
//alert(thisUser)
if (thisUser!='') {
//	mnuArray[item] = new mnuBar(item++, 'Logout', 'LOGOUT', 'http://www.ShaftesburyCC.co.uk/database/logout.php', LogoutDate, 'Logout of Members  Section')
	mnuArray[item] = new mnuBar(item++, 'Logout', 'LOGOUT', 'database/logout.php', LogoutDate, 'Logout of Members Section')
//	mnuArray[item] = new mnuBar(item++, 'Members', 'MEMBERS', 'members.html', MemberDate, 'Members')
//	mnuArray[item] = new mnuBar(item++, 'Members', 'MEMBERS', 'http://www.ShaftesburyCC.co.uk/database/members.php', MemberDate, 'Members')
//	mnuArray[item] = new mnuBar(item++, 'Database', 'DATABASE', 'http://www.ShaftesburyCC.co.uk/database/database.html', DataDate, 'Members\'  Database')
	mnuArray[item] = new mnuBar(item++, 'Members', 'MEMBERS', 'database/members.php', MemberDate, 'Members')
	mnuArray[item] = new mnuBar(item++, 'Database', 'DATABASE', 'database/database.html', DataDate, 'Members\' Database')
} else {
//	mnuArray[item] = new mnuBar(item++, 'Login', 'LOGIN', 'http://www.ShaftesburyCC.co.uk/database/login.html', LoginDate, 'Login to Members Section')
	mnuArray[item] = new mnuBar(item++, 'Login', 'LOGIN', 'database/login.html', LoginDate, 'Login to Members Section')
}

mnuArray[item] = new mnuBar(item++, 'News', 'HOME', 'homepage.html', HomeDate, 'latest Club News')
mnuArray[item] = new mnuBar(item++, 'About Us', 'ABOUT', 'details.html', AboutDate, 'details of Club Meetings, Officials, etc.')
mnuArray[item] = new mnuBar(item++, 'Membership', 'MEMBERSHIP', 'membership.html', MembershipDate, 'Membership Details & Application Form')
mnuArray[item] = new mnuBar(item++, 'Time Trials', 'TT', 'timetrials.html', TTDate, 'over 1000 pages of Time Trial information and Entry Forms')
if (loc != "") {
	mnuArray[item] = new mnuBar(item++, 'Latest Result', 'LR', 'javascript: latestResult()', LRDate, 'result of the last Club Time Trial')
}
mnuArray[item] = new mnuBar(item++, 'Open Events', 'OP', 'tt/open events.html', OPDate, 'Open Events information')
mnuArray[item] = new mnuBar(item++, 'Road Races', 'RR', 'roadraces.html', RRDate, 'Road Racing information')
mnuArray[item] = new mnuBar(item++, 'Cyclo-Cross', 'CC', 'cyclocross.html', CCDate, 'results and reports of Club\'s Off-road Series')
//mnuArray[item] = new mnuBar(item++, 'MTB', 'MTB', 'mtb.html', MTBDate, 'Mountain Biking information')
mnuArray[item] = new mnuBar(item++, 'Audax', 'AUK', 'audax.html', AUKDate, 'Randonn&eacute;e information and Inter-active Entry Form')
//mnuArray[item] = new mnuBar(item++, 'Randonn&eacute;es', 'AUK', 'audax.html', AUKDate, 'Randonn&eacute;e information and Inter-active Entry Form')
mnuArray[item] = new mnuBar(item++, 'Gallery', 'GALLERY', 'javascript: Photos()', GalleryDate, 'Click to see Photos taken in Shaftesbury CC events')
mnuArray[item] = new mnuBar(item++, 'Contacts', 'CONTACT', 'contacts_frame.html', ContactDate, 'Club Contacts and Links to other Cycling sites')
mnuArray[item] = new mnuBar(item++, 'Reports', 'REPORTS', 'reports.html', ReportsDate, 'Reports on many Club activities')
//mnuArray[item] = new mnuBar(item++, 'Market', 'MARKET', 'forsale.php', MarketDate, 'Articles for Sale')
mnuArray[item] = new mnuBar(item++, 'Market', 'MARKET', 'forsale.html', MarketDate, 'Articles for Sale')
mnuArray[item] = new mnuBar(item++, 'Newsletter', 'NEWSLETTER', 'newsletter.html', NewsletterDate, 'Gems from the Club\'s Newsletter')
mnuArray[item] = new mnuBar(item++, 'International', 'INTERNATIONAL', 'scc_international.html', InternationalDate, 'Details on Shaftesbury International')
mnuArray[item] = new mnuBar(item++, 'Help', 'TECHNICAL', 'technical.html', TechnicalDate, 'Help on our site')
mnuArray[item] = new mnuBar(item++, 'Club History', 'HISTORY', 'history.html', HistoryDate, 'First 100 years\' of Club History' )
mnuArray[item] = new mnuBar(item++, 'Bungalow', 'BUNGALOW', 'bungalow.html', BungalowDate, 'Bungalow Details')
mnuArray[item] = new mnuBar(item++, 'Clubroom', 'CLUBROOM', 'clubroom.html', ClubroomDate, 'Clubroom Details')
}

//var cVisited = 'blue', cActive = 'black', cLink = 'red', cbActive = 'cyan', cbInactive = #ffff99

function initMenu(home) {
	var i = 0, obj1 = '', homeobj = 'homepage.html', homebar = -1, imgID, activeBar = -1
	if ((thisUser!='') && (myVisits<4)) { homeobj = 'members.html' }
	if ((parent.frames == null) || (parent.frames.length == 0)) { return }
	if (parent.main) { 
//alert(parent.main.location.href)
		if (parent.main.location.href=="") { alert('no location');return }
		obj1 = parent.main.location.href
//alert(obj1)
		i =obj1.lastIndexOf('/')
//alert(i)
		if (i <= 0) { i = obj1.lastIndexOf('\\') }
//alert(i)
	}
//alert(i)
	obj1 = ((i <= 0) ? homeobj : obj1.substr(i+1))
	if (obj1=="members.html") { obj1 = "members.php" }
	if (homeobj=="members.html") { homeobj = "members.php" }
//alert(obj1)
//alert(homeobj)
	for (i = 0; i < mnuArray.length; i++) {
		if (mnuArray[i].url.indexOf(obj1) != -1) { activeBar = i }
		if (mnuArray[i].url.indexOf(homeobj) != -1) { homebar = i }
		imgID = eval("document.images.img" + i)
//		if (imgID != null) { imgID.src = "images/menu_box.gif" }
	}
//alert(homebar)
//if (homebar==-1) { homebar=1 }
	if ((home != null) && (home != "undefined") && (home == true)) { i = homebar }
	else { i = ((activeBar >= 0) ? activeBar : homebar) } 
	getObj(mnuArray[i].id).style.color = cActive
	getObj(mnuArray[i].id).style.backgroundColor = cbActive
//alert(homebar)
	mnuArray[i].visited=true
	mnuArray[i].active=true
//	eval("document.images.img" + i + ".src = 'images/menu_box2.gif' ")
//alert(isNav)
//alert(i+' - '+homebar)
	if (isNav && (i == homebar) && (typeof parent.main.startPage == 'function')) { parent.main.startPage() }
}

function mouse(no, id, typ) {
	var colour, image
	switch (typ) {
		case 'over':
			colour = 'magenta'
			break
		case 'out':
			colour = cLink
			if (mnuArray[no].visited) { colour = cVisited }
			if (mnuArray[no].active) { colour = cActive }
			break
		case 'down':
			if (parent.banner && parent.banner.document.f) { parent.banner.document.f.msg1.value = "" }
			mnuArray[no].visited = true
			if (id == 'SEARCH') { popupMenu() }
			else if (mnuArray[no].url.toLowerCase().indexOf('javascript') >=0) { eval(mnuArray[no].url) }
			else { 
				clearTimeout(myTimer)
				parent.main.location.href = mnuArray[no].url 
			}
			if (mnuArray[no].id == "GALLERY") { colour = cVisited }
			else { 
				for (var i = 0; i < mnuArray.length; i++ ) {
					mnuArray[i].active = false
					id=mnuArray[i].id
					colour = ((mnuArray[i].visited) ? cVisited : cLink)
					getObj(mnuArray[i].id).style.color = colour
					if ((id=='LOGIN') || (id=='LOGOUT') || (id=='MEMBERS') || (id=='DATABASE')) {
						getObj(mnuArray[i].id).style.backgroundColor = cbMembers
					} else {
						getObj(mnuArray[i].id).style.backgroundColor = cbNormal
					}
//					eval("document.images.img" + i + ".src = 'images/menu_box.gif' ")
				}
				mnuArray[no].active = true
				colour = cActive
				getObj(mnuArray[no].id).style.backgroundColor = cbActive
//				eval("document.images.img" + no + ".src = 'images/menu_box2.gif' ")
			}
			break
	}
	getObj(id).style.color = colour
}

function showMenu() {
	latest = parent.side.latestEvent	
//alert('sm '+latest)
	if (latest == 'EV') { 
		loc = "tt/EV10.html" 
	} else {
		if (latest == 'WE') { 
			loc = "tt/weekend.html" 
		} else {
			if (latest == 'OP') { loc = "tt/open_results.html" }
		}
	}

	thisUser = parent.side.User
	if (parent.side.document.users) { 
		thisUser=parent.side.document.users.username.value
		myVisits=parent.side.document.users.visits.value
//		alert(thisUser+'  '+myVisits)
	}

	loadMenu()
	var counterSrc
	var preload = new Image()
//	counterSrc="http://counter.digits.com/wc/-d/4/-c/18/-f/000000/-b/ffff00/ShaftesburyCyclingClub"  // character (-c/) sets 3, 15, 18, 20 are interesting
	counterSrc="http://counter.digits.com/wc/-d/4/-c/3/-f/ff0000/-b/ffff00/ShaftesburyCyclingClub"
	counterSrc="http://www.elogicwebsolutions.com/cgi-bin/statimage.pl?s=7258"
	preload.src = counterSrc

	var cText = '<div id="pic0"><img name="vlines" src="images/scc_vlines1.gif" width="60" border="0" /></div>'
		+ '<div id="col1"><img src="images/menu_box.gif" /></div>'
	if (self.document.location.href.toLowerCase().indexOf('http') != -1) {
		cText += '<div id="col1a"><img id="counter" src="' + preload.src + '" width="60" height="20" align="middle" title="Number of Visitors since November 2000" /></div>'
	}
//alert(cText)
//	document.write(cText)

	for (var i = 0; i < mnuArray.length; i++) { 
		mnuArray[i].writeData() 
	}
	cText = '<div style="position:absolute; left:0px; width:100px; height:30px; z-index:' + (5 + i) + '; top:'+(barTop+10)+'px; background-color:yellow;">'
		+ '<a href="http://www.digits.com" target="_blank" title="Link to our Webcounter">'
		+ '<img width="110px" height="30px" src="images/wc-01a.gif" border="0" /></a></div>'
//	document.write(cText)
	barTop += 5
	if (self.document.location.href.toLowerCase().indexOf('http') != -1) { 
		cText = '<div style="position:absolute; left:3px; width:100px; z-index:' + (5 + i) + '; top:'+(barTop+20)+'px; background-color:#ffffcc;">'
			+'<table width="100" border="0" cellspacing="0" cellpadding="0" align=left><tr><td align="center" class="counter" style="line-height:105%;">'
			+'Counter provided by <a href="http://www.elogicwebsolutions.com" target="_blank" title="SEO">SEO</a> company.</font></td></tr></table></div>'
		document.write(cText) 
	}
	document.images[0].height = Math.max(barTop + 8, ((isIE) ? document.body.clientHeight : window.innerHeight))
	barTop += 30	//	45
	if (self.document.location.href.toLowerCase().indexOf('http') != -1) {
		cText = '<div style="position:absolute; left:3px; width:100px; z-index:' + (5 + i) + '; top:'+(barTop+10)+'px; background-color:#ffffcc;padding-bottom:10px;">'
			+'<table style="width:100px; background-color:#ffffcc; text-align:center;" border="0" cellspacing="0" cellpadding="2">'
			+'<tr><td align="center">'
			+'<a href="http://www.elogicwebsolutions.com/login.php" target="_blank"><img src="'+preload.src+'" alt="" border="0"></a>'
			+'</td></tr>'
			+'<tr><td align="center" class="counter" style="line-height:100%;">'
			+'<a href="http://www.elogicwebsolutions.com/login.php" target="_blank" style="color:black;"  title="website optimization company">'
			+'website optimization company</a></td></tr></table></div>'
	 	document.write(cText)
/*
			+'<table style="width:100px; background-color:#ffffcc; text-align:center;" border="0" cellspacing="0" cellpadding="2"><tr><td align="center"><a href="http://www.elogicwebsolutions.com/login.php" target="_blank"><img src="http://www.elogicwebsolutions.com/cgi-bin/statimage.pl?s=7258" alt="" border="0"></a></td></tr><tr><td align="center"><font style="font-family:Geneva,Arial,Helvetica,sans-serif;font-size:8px;color:#000000; line-height:100%;"> <a href="http://www.elogicwebsolutions.com/login.php" target="_blank" style="font-family:Geneva,Arial,Helvetica,sans-serif;font-size:9px;color:#000000 display:none;" title="website optimization company">website optimization company</a> </font></td></tr></table></div>'
	 	document.write(cText)
*/
	}
//	barTop += 80
/*
	cText='<a href="http://www.statistics.001.c-o-u-n-t.com?count=shaftesbury" target="_blank">'
		+ '<img src="http://001.c-o-u-n-t.com/count-002.pl?count=shaftesbury&type=greenyelo&prog=unique" border="0" '
		+ 'alt="Statistics" title="Statistics" /></a>'
		+ '<noscript>The following text will not be seen after you upload your website, please keep it in order to retain your counter functionality<br />'
		+ '<a href="http://www.family-ancestry.co.uk/genealogy/" target="_blank">Family Ancestry</a><br />'
		+ '<a href="http://www.free-stuff.me.uk/free/music" target="_blank">Free Music</a><br /></noscript>'
	document.write(cText)
*/
//	document.images[0].height = Math.max(barTop + 8, ((isIE) ? document.body.clientHeight : window.innerHeight))
//	window.setTimeout("initMenu()", ((self.document.location.href.toLowerCase().indexOf('http') != -1) ? 5000 : 1000))
	myTimer = window.setTimeout("initMenu()", ((self.document.location.href.toLowerCase().indexOf('http') != -1) ? 3000 : 1000))
}

function showVisitors() {
	return
	var host = document.location.href.toLowerCase() 
//alert(host)
	var isWeb = (host.indexOf("http") != -1) 
isWeb=true
	var obj=eval('parent.side.document.' + ((ns6) ? 'getElementById' : 'all') + '("col1a")')
//alert(isWeb)
/*
<!-- Start of Globel Code -->
<a href="http://www.statistics.001.c-o-u-n-t.com?count=shaftesbury" target="_blank">
<img src="http://001.c-o-u-n-t.com/count-002.pl?count=shaftesbury&type=greenyelo&prog=unique" border="0" alt="Statistical" title="Statistical" \></a>
<!--<br><a href="http://www.c-o-u-n-t.com" target="_blank">-->
<font size="1">Statistical</font></a>
<noscript>The following text will not be seen after you upload your website,
please keep it in order to retain your counter functionality 
<br /><a href="http://www.family-ancestry.co.uk/genealogy/" target="_blank">Family Ancestry</a><br /> <a href="http://www.free-stuff.me.uk/free/music" target="_blank">Free Music</a><br />
</noscript>
<!-- End of Globel Code -->
*/
	var counterText='<a href="http://www.statistics.001.c-o-u-n-t.com?count=shaftesbury" target="_blank">'
		+ '<img src="http://001.c-o-u-n-t.com/count-002.pl?count=shaftesbury&type=greenyelo&prog=unique" border="0" '
		+ 'alt="Statistics" title="Statistics" /><\/a>'
		+ '<noscript>The following text will not be seen after you upload your website, please keep it in order to retain your counter functionality<br />'
		+ '<a href="http://www.family-ancestry.co.uk/genealogy/" target="_blank">Family Ancestry</a><br />'
		+ '<a href="http://www.free-stuff.me.uk/free/music" target="_blank">Free Music</a><br /><\/noscript>'
//alert(counterText)
	if (obj && isWeb) { 
		with (obj.style) {
			position="absolute"
			top="12px"
			top="6px"
			left="5px"
			width="100px"
			height="25px"
			visibility = "visible"; 
		}
//alert('t='+obj.style.top+'  l='+	obj.style.left+'  v='+	obj.style.visibility)
		obj.innerHTML=counterText; 
//alert(obj.innerHTML)
	}
}

function popupMenu() {
	if (window.createPopup) {
		var cText = ''
		cText = '<table width=100% border=1 cellspacing=0>\n<tr><th colspan=2>Selections</th></tr>'
		for (var i = 0; i < mnuArray.length; i++) {
			if (mnuArray[i].name.substr(0,6) == 'Search') {continue }
			cText += '<tr><th width=50%><font size=2>&nbsp;' + mnuArray[i].name + '&nbsp;</font></th><td width=50%><br></td></tr>\n'
		}
		cText += '</table>'
		cText += 'Click outside of <b>Popup</b> to close'
		oPopup = window.createPopup()
		var oPopupBody = oPopup.document.body
		with (oPopupBody.style) {
			fontFamily = "Arial, san-serif"
			fontSize = "10.0pt"
			backgroundColor = "beige"
			border = "solid red 3px"
		}
		oPopupBody.innerHTML = cText
		oPopup.show(125,0,220,400,document.body)
		window.setTimeout("oPopup.hide()", 50000)
	}
}

///  isNew checks to see if startDate is within <interval> days of today 

var Months = new Array ("January","February","March","April","May","June","July","August","September","October","November","December")

function isNew(startDate, interval) {
	if (isNaN(interval)) { interval = 7 }
	var Today, elapsed, secs1, secs2, cDay, cYear, cMonth, nMonth, x, firstDay, diff
	Today = new Date()
	tDay = Today.getDate()
	tMonth = Today.getMonth()
	tYear = Today.getFullYear()
	elapsed = interval * 24 * 3600 * 1000
	elapsed = Math.abs(elapsed)
	Today.toUTCString()
	secs1=Date.parse(Today)
	if (startDate.indexOf(' ') > 0) {
		for (x = 0; x < startDate.length; x++) {
			if ((!isNaN(startDate.substr(x,1))) && (startDate.substr(x,1) != ' ')) {
				startDate = startDate.substr(x)
				break
			}
		}
		cDay = parseInt(startDate).toString()
		x = startDate.lastIndexOf(' ')
		if (x <= 0) { return true }
		cYear = startDate.substr(x + 1)
		startDate = startDate.substring(0,x)
		x = startDate.indexOf(' ')
		if (x <= 0) return true
		cMonth = startDate.substr(x+1)
		for (x = 0, nMonth = -1; x < 12; x++) { if (Months[x] == cMonth) { nMonth = x; break } }
	} else {
		cYear=startDate.substr(6,4)
		cDay=startDate.substr(0,2)
		nMonth=startDate.substr(3,2)-1	// has to be -1 as arrays start from position 0 (zero)
		cMonth = Months[nMonth]
	}
	if ((interval == 0) && ((tDay == parseInt(cDay)) && (tMonth == nMonth) && (tYear == parseInt(cYear)))) { return false }
	firstDay = new Date(cMonth+' '+cDay+', '+cYear)
	firstDay.toUTCString()
	secs2=Date.parse(firstDay)
	if (interval <= 0) { diff =(secs2 - secs1) }
	else { diff = (secs1 - secs2) }
//alert(diff+'  '+elapsed)
	return  ( diff < elapsed ) 
}

