//Copyright (c) 2005 Service First Webmasters, Inc. All Rights Reserved.
function throwAlert(){
    alert("hello from throwAlert");
}
function setVisible(id, visible){// expects id and either yes or no
	if (testObject(id)){
		var el = document.getElementById(id);
		var adel = document.getElementById('bottomAds');
		if (visible == "yes") {
			el.style.display = 'block';
			el.style.visibility = 'visible';
			//hide bottom ads because they punch through the add comment, email to friend and comment windows
			if (id != 'linkTo') {
			adel.style.display = 'none';
			adel.style.visibility = 'hidden';
			}
			//WCH.Apply(id);
			//uncomment if you have flyouts that go over dropdowns, checkboxes or radio buttons. Be sure to add the WCH.js link to the head of each page.
		} else {
			el.style.display = 'none';
			el.style.visibility = 'hidden';
			if (id != 'linkTo') {
			adel.style.display = 'block';
			adel.style.visibility = 'visible';
			}
			//WCH.Discard(id);
			//uncomment if you have flyouts that go over dropdowns, checkboxes or radio buttons. Be sure to add the WCH.js link to the head of each page.
		}
	}
}
function centerMe(myID,height,width,sourceID,offsetX,offsetY) {
//expects myID = id of the div to center, height and width of the div to center, 
//and sourceID=id of the a tag you click to open the div, assuming it is very near the actual div in the html.
  var myWidth = 0, myHeight = 0;
  //find the dimensions of the browser window
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }        
  
  //find the current position on the page of the div
  var currentTop = 0;
  var currentLeft = 0;  
  
  if(testObject(sourceID)){
        var src = document.getElementById(sourceID);
        //find it's position, which remains fixed for a given page load
        var newPositions = getPosition(src);
        currentTop = newPositions[1]-offsetY;
        currentLeft = newPositions[0]-offsetX;
        //alert(" currentTop was " + currentTop + " and currentLeft was " + currentLeft);
  }
  
   if (testObject(myID)){
        var el = document.getElementById(myID);
        //find the current scroll position
        var currScrollX = 0;
        var currScrollY = 100;
        var scrollpos = getScrollingPosition();
        currScrollX=scrollpos[0];
        currScrollY=scrollpos[1];
        //alert(" currScrollX was " + currScrollX + " and currScrollY was " + currScrollY);
        //calculate the new position
        var newLeft = Math.round(((myWidth-width)/2)-currentLeft+currScrollX);
        var newTop = Math.round(((myHeight-height)/2)-currentTop+currScrollY);
        //alert(" newTop was currentTop: " + currentTop + " plus currScrollY" +currScrollY + " giving a newTop of " + newTop);
        //el.style.border = "5px solid red";
        el.style.top = "" + newTop + "px";
        el.style.left = "" + newLeft + "px";
	}
}
    
function centerMeGrid(myID,myIndex,height,width) {
//expects myID = id of the sending link, index of this one in the grid, height and width of the div to center, 
//and we build the ID of the div to center from myID and the index. The div to center must have it's id built the same way as the id for 
//the sending link, plus the index. The div to center should be very near the sending link in the Html.
  //alert(" id was " + id);
  var myWidth = 0, myHeight = 0;
  //find the dimensions of the browser window
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }        
  
  //find the current position on the page of the div
  var currentTop = 0;
  var currentLeft = 0;  
  
  if(testObject(myID)){
        var src = document.getElementById(myID);
        //find it's position, which remains fixed for a given page load
        var newPositions = getPosition(src);
        currentTop = newPositions[1];
        currentLeft = newPositions[0];
        //alert(" currentTop was " + currentTop + " and currentLeft was " + currentLeft);
  }
  
   if (testObject(myID+myIndex)){
        var el = document.getElementById(myID+myIndex);
        //find the current scroll position
        var currScrollX = 0;
        var currScrollY = 100;
        var scrollpos = getScrollingPosition();
        currScrollX=scrollpos[0];
        currScrollY=scrollpos[1];
        //alert(" currScrollX was " + currScrollX + " and currScrollY was " + currScrollY);
        //calculate the new position
        var newLeft = Math.round(((myWidth-width)/2)-currentLeft+currScrollX);
        var newTop = Math.round(((myHeight-height)/2)-currentTop+currScrollY);
        //alert(" newTop was currentTop: " + currentTop + " plus currScrollY" +currScrollY + " giving a newTop of " + newTop);
        //el.style.border = "5px solid red";
        el.style.top = "" + newTop + "px";
        el.style.left = "" + newLeft + "px";
	}
}
    
function getPosition(theElement)
{
  var positionX = 0;
  var positionY = 0;

  while (theElement != null)
  {
    positionX += theElement.offsetLeft;
    positionY += theElement.offsetTop;
    theElement = theElement.offsetParent;
  }
  
  return [positionX, positionY];
}

function getScrollingPosition()
{
  var position = [0, 0];

  if (typeof window.pageYOffset != 'undefined')
  {
    position = [
        window.pageXOffset,
        window.pageYOffset
    ];
  }

  else if (typeof document.documentElement.scrollTop != 'undefined'
      && (document.documentElement.scrollTop > 0 ||
      document.documentElement.scrollLeft > 0))
  {
    position = [
        document.documentElement.scrollLeft,
        document.documentElement.scrollTop
    ];
  }

  else if (typeof document.body.scrollTop != 'undefined')
  {
    position = [
        document.body.scrollLeft,
        document.body.scrollTop
    ];
  }

  return position;
}


function setVisibleGrid(id, index, visible){// expects id and either yes or no
//alert(" id was " + id);
	if (testObject(id+index)){
		var el = document.getElementById(id+index);
		if (visible == "yes") {
			el.style.display = 'block';
			el.style.visibility = 'visible';
			//WCH.Apply(id);
			//uncomment if you have flyouts that go over dropdowns, checkboxes or radio buttons. Be sure to add the WCH.js link to the head of each page.
		} else {
			el.style.display = 'none';
			el.style.visibility = 'hidden';
			//WCH.Discard(id);
			//uncomment if you have flyouts that go over dropdowns, checkboxes or radio buttons. Be sure to add the WCH.js link to the head of each page.
		}
	}
}
//to use the following function, add to the page's body tag: onkeypress="sendForm(event);"
function sendForm(evt){//submits the one form on the page upon pressing Enter
	var key = (evt) ? evt.which : evt.keyCode;
	if ( key == 13 || evt.keyCode==13){
		//test if search box has anything in it besides "Search this blog"
		//if yes, redirect to search_results.aspx?keywords= with the contents of the box url encoded
		if (document.getElementById('c1_keywords').value != "Search this blog"){
			__doPostBack('c1$goButton','');
		}
	}
}
//to use the following function, add to the page's body tag: onkeypress="sendFormBS(event);"
function sendFormBS(evt){//submits the one form on the page upon pressing Enter
	var key = (evt) ? evt.which : evt.keyCode;
	if ( key == 13 || evt.keyCode==13){
		if (document.getElementById('c2_txtSearchTerm').value != ""){
			__doPostBack('c2$btnSearch','');
		}
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function testObject(objectID){
	return document.getElementById(objectID);
}
function changeFont(copyId, textClass, toggleId, doWhat) {
	if (testObject(copyId)) {
		document.getElementById(copyId).className = textClass;
		
		if (textClass == "smallText"){
		document.getElementById('c1_textToLarge').className = "textSizeLink";
		document.getElementById('c1_textToMedium').className = "textSizeLink";	
		}
		if (textClass == "mediumText"){
		document.getElementById('c1_textToLarge').className = "textSizeLink";
		document.getElementById('c1_textToSmall').className = "textSizeLink";	
		}
		if (textClass == "largeText"){
		document.getElementById('c1_textToMedium').className = "textSizeLink";
		document.getElementById('c1_textToSmall').className = "textSizeLink";	
		}
		//set the style of the one just clicked to the YAH
		if (toggleId) { 
		document.getElementById(toggleId).className = doWhat;
		}
	}
}

function sendCookie(textClass){
	//alert("textClass is " + textClass);
	var expdate = new Date ();
    FixCookieDate (expdate); // Correct for Mac date bug - call only once for given Date object!
    expdate.setTime (expdate.getTime() + (24*60*60*1000*365*5)); // 5 years from now 
	SetCookie('textSize', textClass, expdate, "/", null, false);
}
function findSetCookie(){
var savedTextSize = GetCookie("textSize");
var savedSizeButton;
	if (savedTextSize!=null) {		
	//set the style of the button so we can use changeFont()
		if (savedTextSize == "smallText"){
			savedSizeButton = "textToSmall";
			} else if (savedTextSize == "mediumText"){
			savedSizeButton = "textToMedium";
			} else {
			savedSizeButton = "textToLarge";
		}
	//set the text size according to the saved value in the cookie
	    if (testObject('bodyCopy')){
	        changeFont('bodyCopy',savedTextSize,savedSizeButton,'textSizeLinkYAH');
	    }
	    if (testObject('c2_GridView2')){
	        changeFont('c2_GridView2',savedTextSize,savedSizeButton,'textSizeLinkYAH');
	    }
	} else {
	//set the text size to medium
	    if (testObject('bodyCopy')){
		    document.getElementById('bodyCopy').className = "mediumText";
	    }
	    if (testObject('c2_GridView2')){
		    document.getElementById('c2_GridView2').className = "mediumText";
	    }
	}
}
function setClass(objectID,newClass){
	var object = document.getElementById(objectID);
	object.className = newClass;
}

<!-- begin script
//
//  Cookie Functions -- "Night of the Living Cookie" Version (25-Jul-96)
//
//  Written by:  Bill Dortch, hIdaho Design <bdortch@hidaho.com>
//  The following functions are released to the public domain.
//
//  This version takes a more aggressive approach to deleting
//  cookies.  Previous versions set the expiration date to one
//  millisecond prior to the current time; however, this method
//  did not work in Netscape 2.02 (though it does in earlier and
//  later versions), resulting in "zombie" cookies that would not
//  die.  DeleteCookie now sets the expiration date to the earliest
//  usable date (one second into 1970), and sets the cookie's value
//  to null for good measure.
//
//  Also, this version adds optional path and domain parameters to
//  the DeleteCookie function.  If you specify a path and/or domain
//  when creating (setting) a cookie**, you must specify the same
//  path/domain when deleting it, or deletion will not occur.
//
//  The FixCookieDate function must now be called explicitly to
//  correct for the 2.x Mac date bug.  This function should be
//  called *once* after a Date object is created and before it
//  is passed (as an expiration date) to SetCookie.  Because the
//  Mac date bug affects all dates, not just those passed to
//  SetCookie, you might want to make it a habit to call
//  FixCookieDate any time you create a new Date object:
//
//    var theDate = new Date();
//    FixCookieDate (theDate);
//
//  Calling FixCookieDate has no effect on platforms other than
//  the Mac, so there is no need to determine the user's platform
//  prior to calling it.
//
//  This version also incorporates several minor coding improvements.
//
//  **Note that it is possible to set multiple cookies with the same
//  name but different (nested) paths.  For example:
//
//    SetCookie ("color","red",null,"/outer");
//    SetCookie ("color","blue",null,"/outer/inner");
//
//  However, GetCookie cannot distinguish between these and will return
//  the first cookie that matches a given name.  It is therefore
//  recommended that you *not* use the same name for cookies with
//  different paths.  (Bear in mind that there is *always* a path
//  associated with a cookie; if you don't explicitly specify one,
//  the path of the setting document is used.)
//  
//  Revision History:
//
//    "Toss Your Cookies" Version (22-Mar-96)
//      - Added FixCookieDate() function to correct for Mac date bug
//
//    "Second Helping" Version (21-Jan-96)
//      - Added path, domain and secure parameters to SetCookie
//      - Replaced home-rolled encode/decode functions with Netscape's
//        new (then) escape and unescape functions
//
//    "Free Cookies" Version (December 95)
//
//
//  For information on the significance of cookie parameters, and
//  and on cookies in general, please refer to the official cookie
//  spec, at:
//
//      http://www.netscape.com/newsref/std/cookie_spec.html    
//
//******************************************************************
//
// "Internal" function to return the decoded value of a cookie
//
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
//
//  Function to correct for 2.x Mac date bug.  Call this function to
//  fix a date object prior to passing it to SetCookie.
//  IMPORTANT:  This function should only be called *once* for
//  any given date object!  See example at the end of this document.
//
function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}
//
//  Function to return the value of the cookie specified by "name".
//    name - String object containing the cookie name.
//    returns - String object containing the cookie value, or null if
//      the cookie does not exist.
//
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}
//
//  Function to create or update a cookie.
//    name - String object containing the cookie name.
//    value - String object containing the cookie value.  May contain
//      any valid string characters.
//    [expires] - Date object containing the expiration data of the cookie.  If
//      omitted or null, expires the cookie at the end of the current session.
//    [path] - String object indicating the path for which the cookie is valid.
//      If omitted or null, uses the path of the calling document.
//    [domain] - String object indicating the domain for which the cookie is
//      valid.  If omitted or null, uses the domain of the calling document.
//    [secure] - Boolean (true/false) value indicating whether cookie transmission
//      requires a secure channel (HTTPS).  
//
//  The first two parameters are required.  The others, if supplied, must
//  be passed in the order listed above.  To omit an unused optional field,
//  use null as a place holder.  For example, to call SetCookie using name,
//  value and path, you would code:
//
//      SetCookie ("myCookieName", "myCookieValue", null, "/");
//
//  Note that trailing omitted parameters do not require a placeholder.
//
//  To set a secure cookie for path "/myPath", that expires after the
//  current session, you might code:
//
//      SetCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);
//
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

//  Function to delete a cookie. (Sets expiration date to start of epoch)
//    name -   String object containing the cookie name
//    path -   String object containing the path of the cookie to delete.  This MUST
//             be the same as the path used to create the cookie, or null/omitted if
//             no path was specified when creating the cookie.
//    domain - String object containing the domain of the cookie to delete.  This MUST
//             be the same as the domain used to create the cookie, or null/omitted if
//             no domain was specified when creating the cookie.
//
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

//
//  Examples
//
//var expdate = new Date ();
//FixCookieDate (expdate); // Correct for Mac date bug - call only once for given Date object!
//expdate.setTime (expdate.getTime() + (24*60*60*1000*365)); // one year from now 
//SetCookie ("ccpath", "http://www.hidaho.com/colorcenter/", expdate);
//SetCookie ("login", "kirk", expdate);
//SetCookie ("tempvar", "This is a temporary cookie.");
//SetCookie ("ubiquitous", "This cookie will work anywhere in this domain",null,"/");
//SetCookie ("paranoid", "This cookie requires secure communications",expdate,"/",null,true);
//SetCookie ("goner", "This cookie must die!");
//document.write (document.cookie + "<br>");
//DeleteCookie ("login");
//document.write ("ccpath = " + GetCookie("ccpath") + "<br>");
//document.write ("login = " + GetCookie("login") + "<br>");
//document.write ("tempvar = " + GetCookie("tempvar") + "<br>");
// end script -->

function testObject(objectID){
	return document.getElementById(objectID);
}
//start of code that allows menus to click on and off
//if you do not have dropdowns or flyouts, delete from here down
var level1On = "";
var level2On = "";
var stopper = false;

function setStopper(){
	stopper = true;// prevents clicks on second and third levels from having an effect on the first level
}
function clearStopper(){
	stopper = false;
}


function toggleTopLevel(list) {
//prevent this function from working if stopper is set
//alert("level1On is " + level1On + "; level2On is " + level2On);
//alert("stopper is " + stopper);
	if (!stopper) {
	// turn off the open menus
		if (level1On != "") {
			setVisible(level1On,'no');
			level1On = "";
		}
		if (level2On != "") {
			setVisible(level2On,'no');
			level2On = "";
		}
	//save the incoming list
		level1On = list;
	//turn on the incoming
		setVisible(list,'yes');
	}
//alert("level1On is " + level1On + "; level2On is " + level2On);
}

function toggle2ndLevel(list) {
//prevent this function from working if stopper is set
	if (!stopper) {
	// turn off the open menus
		if (level2On != "") {
			setVisible(level2On,'no');
			level2On = "";
		}
	//save the incoming list
		level2On = list;
	//turn on the incoming
		setVisible(list,'yes');
	// prevent the next click (automatically generated on top level) from doing anything for 1/10 sec.
		setStopper();
		timerID = setTimeout("clearStopper()",100);
	}
}

function hideLists() {
		//alert("level1On is " + level1On + "; level2On is " + level2On);
		if (level1On != "") {
			setVisible(level1On,'no');
			level1On = "";
		}
		if (level2On != "") {
			setVisible(level2On,'no');
			level2On = "";
		}
		//alert("level1On is " + level1On + "; level2On is " + level2On);
}
// level 1 menus and level 2 menus get ids
// click top level and it: 1.) checks to see if any saved menus are open; closes them 2.) saves the new level1 that is now being opened 3.) opens the new level1.
// click second level and it 1.) checks for level 2 saved open and closes it if any 2.) saves new level 2 and opens new level 2
// a settimeout function prevents the click on level 2 from triggering on level 1.
// mouseover level 3 and the stopper flag is set to true, preventing any clicks from happening at level 2 or 1.
// mouseout level 3 and the stopper flag is cleared, allowing clicks to happen. 
// or click level 3 and go to a page.
// or if you have moused out of level 3, you can click the content area and close the 2 saved menus.
// it all happens in js without any hovers.