function addPopLinks() {
	if (!document.getElementsByTagName) return false;
	var links = document.getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {
		if (links[i].className == "pop") {
			links[i].onclick = function() {
				pop=window.open(this.href,'popWindow','width=510,height=410,scrollbars=yes,resizable=yes'); pop.focus(); return false;
			}
		}
	}
}

function smallPop() {
	if (!document.getElementsByTagName) return false;
	var links = document.getElementsByTagName("a");
	for (var i=0, j=links.length; i<j; i++) {
			var link = links[i]
			if (link.getAttribute("href") && (link.getAttribute("rel") == "pop")) {
				if (!link.getAttribute("title")) {
					var theText = link.firstChild.nodeValue;
					if (theText != null) {
						link.setAttribute("title", "Open " + theText + " in a new window");
					}
					else {
						link.setAttribute("title", "Opens in a new window");
					}
				}
				link.onclick = function() {
				pop=window.open(this.href,'popWindow','height=160,width=240,toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes'); pop.focus(); return false;
			}
		}
	}
}

function navHeaders () {
	if ((!document.getElementById) || (!document.getElementsByTagName)) return false;
	var theBody = document.getElementsByTagName("body");
	var whatList = document.getElementById("whatLinks");
	whatList.onmouseover = function() { theBody[0].id = 'whatBody'; }
	whatList.onmouseout = function() { theBody[0].id = ''; }
	var whyList = document.getElementById("whyLinks");
	whyList.onmouseover = function() { theBody[0].id = 'whyBody'; }
	whyList.onmouseout = function() { theBody[0].id = ''; }
	var howList = document.getElementById("howLinks");
	howList.onmouseover = function() { theBody[0].id = 'howBody'; }
	howList.onmouseout = function() { theBody[0].id = ''; }
}

function getCookie(searchName) {
	var cookies = document.cookie.split(";");
	for (var i=0; i<cookies.length; i++) {
		var cookieCrumbs = cookies[i].split('=');
		var cookieName = cookieCrumbs[0];
		// Strip the leading space off
		while (cookieName.charAt(0)==' ') cookieName = cookieName.substring(1,cookieName.length);
		var cookieValue = cookieCrumbs[1];
		if (cookieName == searchName) {
			return cookieValue;
		}
	}
	return false;
}

function podWindow() {
	var visitCookie = getCookie("prevVisit");
	if (!visitCookie) {
		var cookieName = "prevVisit";
		var cookieValue = "false";
		var theCookie = cookieName + "=" + cookieValue;
		document.cookie = theCookie;
	}
	visitCookie = getCookie("prevVisit");
	if (visitCookie == 'false') {
		windoid = new Window('window_id',{className: "dialog", title: "Holiday Special", width:390, height:200})
		windoid.getContent().innerHTML = "<div style='padding:12px;'><img src=\"images/hol_sale_360.gif\" alt=\"Holday Special\" width=\"360\" height=\"42\"><p style='margin-top:12px;'><strong>Now through December 31st, 5 Wash Premium Package Discount Cards are available for only $40.</strong></p><p style='padding-bottom:20px;'>Kaady's Premium Package (includes Kaady Quality Wash, Clearcoat Shield&trade;, Liquid Polish&trade; and underbody rinse) <strong>now also includes window cleaner!</strong> (A $12 value)</p></div>";
		windoid.setDestroyOnClose();
		windoid.showCenter();
		cookieName = "prevVisit";
		cookieValue = "true";
		theCookie = cookieName + "=" + cookieValue;
		document.cookie = theCookie;
	}
}

window.onload = function() {
	addPopLinks();
	smallPop();
	navHeaders();
	//podWindow();
}

