
// breaks the site out of frames if loaded in someone elses site
// -------------------------------------------------------------
if (self.location.href != top.location.href) {
top.location.href = self.location.href;
}


// used to communicate to flash home page movie \
// so we can stop it if we open the player
function thisMovie(movieName) {
		var isIE = navigator.appName.indexOf("Microsoft") != -1;
		return (isIE) ? window[movieName] : document[movieName];
	}

	function makeCall(s) {
		if(s == "endNoise") {
			thisMovie("mainMovie").endNoise();
		}
}

// turns the navigation on when the page loads
function showPrimaryNav() {
	var myNavs = document.getElementById("topnav");
	myNavs.style.visibility = "visible";
}

// css stylesheet switcher
// -------------------------------------------------------------
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);



// for opening pop-up windows
// -------------------------------------------------------------
function openPopup( url, name, widgets, openerUrl )
{
	var host = location.hostname;
	var popupWin = window.open( url, name, widgets );
	
	if ( openerUrl )
	{
		popupWin.opener.location = openerUrl;
	}

	if ( !( is_aol6 || is_aol3 || is_aol4 || is_aol5 || is_compie || is_comp2000) )
	{
		popupWin.opener.top.name = "opener";
		popupWin.focus();
	}
}



// validator for the Weather By Zip form
// -------------------------------------------------------------
function weatherVal(theForm)
	{
	var bRet;
	var goodZIP = /^([0-9]{5})+$/
	if (!goodZIP.test(theForm.query.value))
	{
		alert("Please enter a valid 5-digit U.S. zip code.");
		theForm.query.focus();
		bRet = false;
	}
	else
	{
		oWin = window.open("", "weatherWin", "width=750,height=500,location,toolbar,status,scrollbars,resizable");
		theForm.target="weatherWin";
		bRet = true;
	}

	return bRet;
}



// validator for the Ht://Dig Site Search form
// -------------------------------------------------------------
function searchVal(theForm)
	{
	var goodKEYWORD = /^([a-zA-Z0-9\s\-\,\.\']{3,})+$/
	if (!goodKEYWORD.test(theForm.words.value))
	{
		alert("Please enter a valid search term.");
		theForm.words.focus();
		return (false);
	}

	return (true);
}



// validator for the Atomz Site Search form
// -------------------------------------------------------------
function searchValOLD(theForm)
	{
	var goodKEYWORD = /^([a-zA-Z0-9\s\-\,\.\']{3,})+$/
	if (!goodKEYWORD.test(theForm['sp-q'].value))
	{
		alert("Please enter a valid search term.");
		theForm['sp-q'].focus();
		return (false);
	}

	return (true);
}



// image swap for galleries
// -------------------------------------------------------------
function showPic (whichpic) {
	if (document.getElementById) {
		document.getElementById('detail').src = whichpic.href;
		return false;
	} else {
		return true;
	}
}



// generate random number and insert into DoubleClick banner ad
// -------------------------------------------------------------
rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
	rnd.seed = (rnd.seed*9301+49297) % 233280;
	return rnd.seed/(233280.0);
};

function rand(number) {
	return Math.ceil(rnd()*number);
};
rnd.today=new Date();



// display the current date (Month Day, Year)
// -------------------------------------------------------------
function GetMonth(intMonth){
	var MonthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") 
	return MonthArray[intMonth]
	}
function getDateStr(){
	var today = new Date()
	var year = today.getYear()
	if(year<1000) year+=1900
	var todayStr = GetMonth(today.getMonth()) + " " + today.getDate()
	todayStr += ", " + year
	return todayStr
	}
