/* 
Town of Hempstead Online (version 3.3)
Website by LaMa Media
Copyright (c) 1997-2008 - All rights reserved
*/


// ****************************************************************
// GLOBALS
// ****************************************************************

var vCCYear = '10',
	vFeature = '0',
	vFName = '',
	vFImage = '',
	vFLink = '',
	vFWidth = 328,
	vFHeight = 74;


// ****************************************************************
// HOME START
// ****************************************************************

function fHomeStart(rCenterLinks) {
	var t, tCenStr, tCenText, tCenLink, tCenColor, tCenLen = rCenterLinks.length,
		tSuperAlt = "Supervisor Kate Murray",
		tWelcomeAlt = (tSuperAlt + " welcomes you to the official website of the Town of Hempstead, Long Island, New York");

	fBodyStart();
	
	fButtonPath("home/home_b_");
	fNewButton(0, "Contact Town Hall", "contact", 166, 29, "home/contact");
	fNewButton(1, "Town News", "news", 166, 29, "home/news");
	fNewButton(2, "Town Calendar", "calendar", 166, 29, "home/calendar");
	fNewButton(3, "Links", "links", 166, 29, "home/links");
	fNewButton(4, "Supervisor Kate Murray", "supervisor", 159, 35, "tb/supervisor");
	fNewButton(5, "Welcome Message", "message", 159, 29, "home/message");
	fNewButton(6, "Special Events", "events", 159, 29, "home/events");
	fNewButton(7, "Video Gallery", "videogallery", 166, 29, "home/videogallery");
	
	document.open();
	document.write('<table width="100%" cellpadding="0" cellspacing="0" border="0">');
	document.write('<tr align="center" valign="top">');
	document.write('<td class="index-left"><table width="100%" cellpadding="0" cellspacing="0" border="0">');
	document.write('<tr align="center" valign="middle"><td class="index-weather" width="200" height="160">');
	// Weather/Promo
	document.write('</td></tr>');
	document.write('<tr align="center"><td>');
	document.write('<div class="home-leftspace-top">&nbsp;</div>');
	fShowButton(0);
	document.write('<div class="home-leftspace">&nbsp;</div>');
	fShowButton(1);
	document.write('<div class="home-leftspace">&nbsp;</div>');
	fShowButton(2);
	document.write('<div class="home-leftspace">&nbsp;</div>');
	fShowButton(3);
	document.write('<div class="home-leftspace">&nbsp;</div>');
	fShowButton(7);
	document.write('<br><img src="media/all/blank.gif" width="182" height="1" alt="" border="0"></td></tr>');
	document.write('</table></td>');
	document.write('<td class="index-center"><table width="100%" cellpadding="0" cellspacing="0" border="0">');
	
	if (tCenLen <= 1) {
		document.write('<tr align="center"><td class="welcome"><img src="media/home/home_g_welcome.gif" alt="' + tWelcomeAlt + '" width="340" height="232" border="0"><br>');
	} else {
		document.write('<tr align="center"><td class="welcome"><img src="media/home/home_g_welcome_clink.gif" alt="' + tWelcomeAlt + '" width="340" height="201" border="0"><br>');
		for (t=0; t<tCenLen-1; t++) {
			tCenStr = rCenterLinks[t];
			tCenText = fGetItem(tCenStr, 0, vDelim);
			tCenLink = fGetItem(tCenStr, 1, vDelim);
			tCenColor = fGetItem(tCenStr, 2, vDelim);
			tCenColor = tCenColor.toLowerCase();
			document.write('<table class="ctable" width="' + (vFWidth - 4) + '" cellpadding="0" cellspacing="0" border="0">');
			document.write('<tr class="cback_' + tCenColor + '" align="center" valign="middle">');
			document.write('<td class="clink" align="center"><a href="' + tCenLink + '">' + tCenText + '</a></td>');
			document.write('</tr></table>');
		}
	}
}


// ****************************************************************
// HOME END
// ****************************************************************

function fHomeEnd() {
	document.write('</td></tr></table></td>');
	document.write('<td class="index-right" width="200"><table width="100%" cellpadding="9" cellspacing="0" border="0">');
	document.write('<tr align="center"><td><img src="media/all/blank.gif" width="182" height="201" alt="Supervisor Kate Murray" border="0"><br>');
	fShowButton(4);
	document.write('</td></tr><tr align="center"><td>');
	fShowButton(5);
	document.write('</td></tr><tr align="center"><td>');
	fShowButton(6);
	document.write('</td></tr>');
	document.write('</table></td></tr>');
	document.write('</table>');
	fGoogleAnalytics();
	document.close();
}


// ****************************************************************
// HOME BOTTOM
// ****************************************************************

function fHomeCredit() {
	document.open();
	document.write('<a href="javascript:fOffSite(\'http://www.lamamedia.com\')">Website by LaMa Media</a>');
	document.close();
}

function fHomePrivacy() {
	document.open();
	document.write('<a href="content/home/privacy.html">Privacy Policy</a>');
	document.close();
}


// ****************************************************************
// HOME PROMO
// ****************************************************************

var vWPLeft, vWPTop, vWPTime, vWPFlipable, vFlipDo;
var vWPFLipSteps, vWPFlipDelta, vWPFlipTime, vWPFLipSpeed;
var vWPFlipOut, vWPFlipIn, vWPPos, vWPCount, vWPFront, vWPBack;
var vHomePromoIDs = new Array();
var vHomePromoDOMs = new Array();

function fHomePromo() {
	var tID, tDOM, tOpacity;
	
	vWPLeft = 17;
	vWPTop = 96;
	vWPFLipSteps = 20;
	vWPFlipTime = 400;
	vWPFLipSpeed = (vWPFlipTime / vWPFLipSteps);
	vWPFlipDelta = (100 / vWPFLipSteps);

	vWPFlipable = 1;
	vWPTime = (3.5 * 1000);
	vWPPos = 0;
	vWPCount = 0;
	vWPFront = '998';
	vWPBack = '0';

	tID = 'home-swift911';
	fPromoSwift911(tID);
	fPromoAdd(tID);

	tID = 'home-weather';
	fPromoWeather(tID);
	fPromoAdd(tID);

//	tID = 'home-promo-map';
//	fPromoMap(tID);
//	fPromoAdd(tID);

//	tID = 'home-promo-dog';
//	fPromoDog(tID);
//	fPromoAdd(tID);

	fPromoBegin();
	if (vWPCount > 1) {
		vFlipDo = 0;
		setTimeout('fPromoFlip()', vWPTime);
	}
}

function fPromoAdd(rID) {
	var tDOM = fDOM(rID, 1);
	tDOM.left = vWPLeft; 
	tDOM.top = vWPTop;
	tDOM.visibility = 'hidden';
	tDOM.zIndex = vWPBack;
	tOpacity = 0;
	vHomePromoIDs[vWPCount] = rID;
	vHomePromoDOMs[vWPCount] = tDOM;
	fPromoFade(vWPCount, tOpacity);
	++vWPCount;
	vWPPos = vWPCount - 1;
}

function fPromoBegin() {
		vWPFlipOut = vWPPos;
		if (++vWPPos >= vWPCount) vWPPos = 0;
		vWPFlipIn = vWPPos;
		fPromoFadeIn();
} 

function fPromoFlip() {
	if (vWPFlipable) {
		vFlipDo = 0;
		vWPFlipOut = vWPPos;
		if (++vWPPos >= vWPCount) vWPPos = 0;
		vWPFlipIn = vWPPos;
		fPromoFadeOut();
		setTimeout('fPromoFlip()', vWPTime);
	} else {
		vFlipDo = 1;
	}
} 

function fPromoFadeOut() {
	for (t = 1; t <= vWPFLipSteps; t++) {
		tOpacity = (100 - (vWPFlipDelta * t));
		tTime = (vWPFLipSpeed * t);
		setTimeout("fPromoFade(" + vWPFlipOut + "," + tOpacity + ")", tTime); 
	}
	setTimeout("fPromoFadeIn()", vWPFlipTime); 
} 

function fPromoFadeIn() {
	var tOutDOM = vHomePromoDOMs[vWPFlipOut];
	var tInDOM = vHomePromoDOMs[vWPFlipIn];
	tOutDOM.visibility = 'hidden';
	tOutDOM.zIndex = vWPBack;
	tInDOM.visibility = 'visible';
	tInDOM.zIndex = vWPFront;

	for (t = 1; t <= vWPFLipSteps; t++) {
		tOpacity = (vWPFlipDelta * t);
		tTime = (vWPFLipSpeed * t);
		setTimeout("fPromoFade(" + vWPFlipIn + "," + tOpacity + ")", tTime); 
	}
} 

function fPromoFade(rPos, rOpacity) { 
    var tObject = document.getElementById(vHomePromoIDs[rPos]).style; 
    tObject.opacity = (rOpacity / 100); 
    //tObject.MozOpacity = (rOpacity / 100); 
    tObject.KhtmlOpacity = (rOpacity / 100); 
    tObject.filter = "alpha(opacity=" + rOpacity + ")"; 
} 

function fPromoOver() {
	vWPFlipable = 0;
}

function fPromoOut() {
	vWPFlipable = 1;
	if (vFlipDo) setTimeout('fPromoFlip()', 200);
}

function fPromoWeather(rID) {
	document.write('<div class="home-promobox" id="' + rID + '" align="center">');
	if (vOnline) {
		var tW1 = 'http://banners.wunderground.com/ban';
		var tW2 = 'ner/infoboxtr_both/language/www/US/NY/Hempstead.gif';
		document.write('<a href="javascript:fOffSite(\'http://www.wunderground.com/US/NY/Hempstead.html\');"><img src="' + tW1 + tW2 + '" alt="Hempstead Weather" border="0" onMouseOver="fPromoOver()" onMouseOut="fPromoOut()"></a>');
	} else {
		document.write('<br><div class="big">Town of Hempstead<br>Information Kiosk</span><br><br><span class="smallb">Visit us online at</span><br><span class="big">w w w . T O H . L I</div>');
	}
	document.write('</div>');
}

function fPromoSwift911(rID) {
	document.write('<div class="home-promobox" id="' + rID + '" align="center">');
	document.write('<img src="media/all/blank.gif" width="160" height="24" alt="" border="0"><br>');
	document.write('<a style="display: block; outline: none;" href="content/cs/swift911.html" onMouseOver="fPromoOver()" onMouseOut="fPromoOut()"><img src="media/home/feature/swift911.gif" width="120" height="38" alt="Swift911" border="0"><br><br>Add/Remove Yourself</a>');
	document.write('</div>');
}

function fPromoDog(rID) {
	var tBlank = '<img src="media/all/blank.gif" width="84" height="3" alt="" border="0">';
	var tImage = 'media/home/feature/dog_r/dog_r_';
	document.write('<div class="home-promobox" id="' + rID + '" align="center">');
	document.write(tBlank + '<br><a href="content/tr/animals.html" onMouseOver="fPromoOver()" onMouseOut="fPromoOut()">View adoptable pets<br>' + tBlank);
	document.write('<img name="dog" src="' + tImage + '1.gif" width="84" height="60" alt="Town of Hempstead Animal Shelter" border="0">');
	document.write('' + tBlank + '<span class="smalln"><br>available at our<br>Animal Shelter</span></a>');
	document.write('</div>');
	fAutoSlideShow("dog", tImage, 8, 100, ".gif");
}


function fPromoMap(rID) {
	var tBlank = '<img src="media/all/blank.gif" width="160" height="3" alt="" border="0">';
	var tImage = 'media/home/feature/tmap';
	var tNBSP = vCharNB;
	for (t=0; t<13; t++) {
		tNBSP = tNBSP + vCharNB;
	}
	document.write('<div class="home-promobox" id="' + rID + '" align="center">');
	document.write(tBlank + '<br><a href="content/home/townmap.html" onMouseOver="fPromoOver()" onMouseOut="fPromoOut()"><span class="smallb">' + tNBSP + 'Visit Our' + tNBSP + '</span><br>' + tBlank);
	document.write('<img name="map" src="media/home/feature/tmap.gif" width="160" height="70" alt="Town Map" border="0">');
	document.write('' + tBlank + '<br>&nbsp;&nbsp;&nbsp;Interactive Town Map&nbsp;&nbsp;&nbsp;<br>' + tBlank + '</a>');
	document.write('</div>');
}


// ****************************************************************
// HOME MESSAGE
// ****************************************************************

var vM0, vM1;
var vMFlash = 0;
var vMTime = 1500;

function fHomeMessage(rMsgLevel, rMsgText, rMsgLink, rMsgSize) {
	rMsgLevel = rMsgLevel.toLowerCase();
	rMsgSize = rMsgSize.toLowerCase();
	if (rMsgLevel == "n") {
		fHomeFeature();
	} else {
		var tMType = "";
		vM0 = new Image();
		vM1 = new Image();
		if (rMsgLevel == "e") {  // Emergency
			vM0.src = "media/home/home_b_emergency_0.gif";
			vM1.src = "media/home/home_b_emergency_1.gif";
			tMType = "emergency";
		} else if (rMsgLevel == "i") {  // Important
			vM0.src = "media/home/home_b_important_0.gif";
			vM1.src = "media/home/home_b_important_1.gif";
			tMType = "important";
		} else if (rMsgLevel == "m") {  // Message
			tMType = "message";
		}
		
		var tMClass = "elink-";
		var tMLen = rMsgText.length;
	
		document.write('<table class="ftable" cellpadding="0" cellspacing="0" border="0">');
		document.write('<tr class="fback" align="center" valign="top">');
		document.write('<td><img src="media/all/blank.gif" width="1" height="' + vFHeight + '" alt="" border="0"></td>');
		document.write('<td class="Xflink">');
		if (rMsgSize == "a") {
			if (tMLen <= 30) { rMsgSize = "x";
			} else if (tMLen <= 40) { rMsgSize = "l";
			} else  if (tMLen <= 50) { rMsgSize = "m";
			} else { rMsgSize = "s";
			}
		}
		tMClass = (tMClass + rMsgSize);
		if (tMType != "message") {
			setTimeout('fMessageFlash()', (vMTime * 2));
			if (rMsgLink == "") rMsgLink = ('content/home/' + tMType + '.html'); 
			document.write('<span class="' + tMClass + '"><a href="' + rMsgLink + '"><img name="message" src="media/home/home_b_' + tMType + '_0.gif" width="' + vFWidth + '" height="27" alt="" border="0"></a><br><img src="media/all/blank.gif" width="' + vFWidth + '" height="12" alt="" border="0"><br><a href="' + rMsgLink + '">' + rMsgText + '</a></span><br><img src="media/all/blank.gif" width="' + vFWidth + '" height="13" alt="" border="0">');
		} else {
			if (rMsgLink == "") {
				document.write('<br><span class="' + tMClass + '">' + rMsgText + '</span><br><img src="media/all/blank.gif" width="' + vFWidth + '" height="13" alt="" border="0">');
			} else {
				document.write('<br><span class="' + tMClass + '"><a href="' + rMsgLink + '">' + rMsgText + '</a></span><br><img src="media/all/blank.gif" width="' + vFWidth + '" height="13" alt="" border="0">');
			}
		}
		document.write('<br><img src="media/all/blank.gif" width="' + vFWidth + '" height="1" alt="" border="0"></td>');
		document.write('<td><img src="media/all/blank.gif" width="1" height="' + vFHeight + '" alt="" border="0"></td>');
		document.write('</tr></table>');
	}
}

function fMessageFlash() {
	vMFlash = !vMFlash;
	if (vMFlash) {
		document["message"].src = vM1.src;
		setTimeout('fMessageFlash()', (vMTime / 2));
	} else {
		document["message"].src = vM0.src;
		setTimeout('fMessageFlash()', vMTime);
	}
}


// ****************************************************************
// FEATURE
// ****************************************************************

var vFSlides = new Array();
var vFNumSlides, vFSlideSpeed, vFCurSlide, vFSlideSide;

function fHomeFeature() {
	if (vFeature == '0') {
		fCalendarContest(vCCYear);
	} else if (vFeature == '9') {
		fNameKids();
	} else {
		fButtonPath("home/feature/");
		fNewButton(42, vFName, vFImage, 326, 74, vFLink, 0, 0, 1);
		document.write('<table class="ftable" width="' + vFWidth + '" cellpadding="0" cellspacing="0" border="0">');
		document.write('<tr><td>');
		fShowButton(42);
		document.write('</td></tr></table>');
	}
}

function fNameKids() {
	var tCount, tPath;
	var tLinkPage = 'content/home/news/namekids.html';
	var tSlidePath = 'media/photos/namekids/kid_sm_';
	var tBlurb = 'Help Name Nine New "Kids"';
	var tAlt = 'Help Name Nine New "Kids"';
	var tWidth = 117;
	var tHeight = 74;
	vFNumSlides = 9;
	vFSlideSpeed = 1500;
	vFCurSlide = (Math.floor(Math.random()*(vFNumSlides-1))+1);
	if (!(vFCurSlide - (parseInt(vFCurSlide/2) * 2))) vFCurSlide-=1;
	vFSlideSide = 1;

	for (tCount = 0; tCount < vFNumSlides; tCount++) {
		vFSlides[tCount] = new Image(); vFSlides[tCount].src = (tSlidePath + (tCount + 1) + ".jpg");
	}

	document.write('<table class="ftable" width="' + vFWidth + '" cellpadding="0" cellspacing="0" border="0">');
	document.write('<tr class="fback" align="center" valign="middle">');
	document.write('<td align="left"><a href="' + tLinkPage + '"><img name="side0" src="' + tSlidePath + vFCurSlide + '.jpg" width="' + tWidth + '" height="' + tHeight + '" alt="' + tAlt + '" border="0"></a></td>');
	document.write('<td class="flink" align="center"><a href="' + tLinkPage + '">' + tBlurb + '</a></td>');
	document.write('<td align="right"><a href="' + tLinkPage + '"><img name="side1" src="' + tSlidePath + (vFCurSlide+1) + '.jpg" width="' + tWidth + '" height="' + tHeight + '" alt="' + tAlt + '" border="0"></a></td>');
	document.write('</tr></table>');
	setTimeout('fFeatureSlide()', (vFSlideSpeed * 2));
}

function fCalendarContest(rYear) {
	var tCount, tPath;
	var tLinkPage = 'content/home/news/pcon20' + rYear + '.html';
	var tSlidePath = 'media/photos/pcon20' + rYear + '/pcon' + rYear + '_sm_';
	var tBlurb = '20' + rYear + ' Town<br>Calendar<br>Photo<br>Contest';
	var tAlt = '20' + rYear + ' Town Calendar Photo Contest';
	var tWidth = 117;
	var tHeight = 74;
	vFNumSlides = 14;
	vFSlideSpeed = 1500;
	vFCurSlide = (Math.floor(Math.random()*vFNumSlides)+1);
	if (!(vFCurSlide - (parseInt(vFCurSlide/2) * 2))) vFCurSlide-=1;
	vFSlideSide = 1;

	for (tCount = 0; tCount < vFNumSlides; tCount++) {
		vFSlides[tCount] = new Image(); vFSlides[tCount].src = (tSlidePath + (tCount + 1) + ".jpg");
	}

	document.write('<table class="ftable" width="' + vFWidth + '" cellpadding="0" cellspacing="0" border="0">');
	document.write('<tr class="fback" align="center" valign="middle">');
	document.write('<td align="left"><a href="' + tLinkPage + '"><img name="side0" src="' + tSlidePath + vFCurSlide + '.jpg" width="' + tWidth + '" height="' + tHeight + '" alt="' + tAlt + '" border="0"></a></td>');
	document.write('<td class="flink" align="center"><a href="' + tLinkPage + '">' + tBlurb + '</a></td>');
	document.write('<td align="right"><a href="' + tLinkPage + '"><img name="side1" src="' + tSlidePath + (vFCurSlide+1) + '.jpg" width="' + tWidth + '" height="' + tHeight + '" alt="' + tAlt + '" border="0"></a></td>');
	document.write('</tr></table>');
	setTimeout('fFeatureSlide()', (vFSlideSpeed * 2));
}

function fFeatureSlide() {
	if (vFSlideSide == 0) vFSlideSide = 1; else vFSlideSide = 0;
	if (++vFCurSlide >= vFNumSlides) vFCurSlide = 0;
	document["side" + vFSlideSide].src = vFSlides[vFCurSlide].src;
	setTimeout('fFeatureSlide()', vFSlideSpeed);
}

