// **************************************************************
// Set up calendar popups
// **************************************************************
var calStart = new CalendarPopup( "calendarDIV" );
calStart.setReturnFunction( "setMultipleValuesStart" );

var calEnd = new CalendarPopup( "calendarDIV" );
calEnd.setReturnFunction( "setMultipleValuesEnd" );

// **************************************************************
// Function:    setMultipleValuesStart( y, m, d )
// Description: set multiple dropdown box values
// Inputs:      y
//              m
//              d
// Outputs:     none
// **************************************************************
function setMultipleValuesStart( y, m, d )
{
  document.contactform.arriveyear.value = y;
  document.contactform.arrivemonth.selectedIndex = (m - 1);
  document.contactform.arriveday.selectedIndex = (d - 1);
}

// **************************************************************
// Function:    setMultipleValuesEnd( y, m, d )
// Description: set multiple dropdown box values
// Inputs:      y
//              m
//              d
// Outputs:     none
// **************************************************************
function setMultipleValuesEnd( y, m, d )
{
  document.contactform.leaveyear.value = y;
  document.contactform.leavemonth.selectedIndex = (m - 1);
  document.contactform.leaveday.selectedIndex = (d - 1);
}

// **************************************************************
// Function:    getDateString( y_obj, m_obj, d_obj )
// Description: get date strings from objects
// Inputs:      y_obj
//              m_obj
//              d_obj
// Outputs:     date string
// **************************************************************
function getDateString( y_obj, m_obj, d_obj )
{
  var y = y_obj.options[y_obj.selectedIndex].value;
  var m = m_obj.options[m_obj.selectedIndex].value;
  var d = d_obj.options[d_obj.selectedIndex].value;

  if ( y == "" || m == "" )
  {
    return null;
  }

  if ( d == "" )
  {
    d = 1;
  }

  return str = y+'-'+m+'-'+d;
}

// **************************************************************
// Function:    areYouSure()
// Description: confirm user action
// Inputs:      none
// Outputs:     true or false
// **************************************************************
function showTitle()
{
    var which = Math.random() * 100;
    if ( which > 9 )
      which /= 10;
    if ( which > 3 )
      which /= 3;
    which = Math.round( which );

    var swf = "title";
    swf = swf + which + ".swf";

    var so = new SWFObject( swf, "wfmovie", "740", "100", "7", "#fff" );
    so.write( "picture" );
}

// **************************************************************
// Function:    areYouSure()
// Description: confirm user action
// Inputs:      none
// Outputs:     true or false
// **************************************************************
function changedate(link)
{
  var month = document.dates.month.options[document.dates.month.selectedIndex].value;
  var year = document.dates.year.options[document.dates.year.selectedIndex].value;
  window.location.href=link+'?month='+month+'&year='+year;
}

// **************************************************************
// Function:    areYouSure()
// Description: confirm user action
// Inputs:      none
// Outputs:     true or false
// **************************************************************
function showMapPopup()
{
  document.getElementById( "locationmap" ).style.visibility = "visible";
}

// **************************************************************
// Function:    areYouSure()
// Description: confirm user action
// Inputs:      none
// Outputs:     true or false
// **************************************************************
function hideMapPopup()
{
  document.getElementById( "locationmap" ).style.visibility = "hidden";
}

// **************************************************************
// Function:    areYouSure()
// Description: confirm user action
// Inputs:      none
// Outputs:     true or false
// **************************************************************
function areYouSure()
{
  return confirm("Are you sure you want to delete this item?")
}

// **************************************************************
// Function:    sfHover
// Description: fudge for crappy IE < 7
// Inputs:      none
// Outputs:     none
// **************************************************************
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

