function fnShowProps(obj, objName){
  var result = "";
  var aResult = new Array();
  if(!objName) objName = obj.id;
  for (var i in obj) aResult.push(objName + "." + i + " = " + obj[i]);
  aResult.sort();
  for(var i = 0 ; i < aResult.length ; i++ ) result += aResult[i] + "<br>\n";
  return result;
};
Miwok = new Object();
document.miwok = Miwok;
// CHECK FORM IS REQUIRED
/*
Miwok.checkFormIsRequired = function(form){
  form = $(form);
  var elements = form.getElements();
  for (var i = 0; i < elements.length; i++) {
    var element = elements[i];
    var required = element.getAttribute("reqired");
    if(required){
      var value = Form.Element.getValue(element);
      if (!value) return required;
    }
    return false;
}
*/

Miwok.onLoads = new Array();
Miwok.onUnloads = new Array();

Miwok.bodyOnLoad =function() {
	for ( var i = 0 ; i < this.onLoads.length ; i++ ){
	  if(this.onLoads[i]) this.onLoads[i]();
	}
}

Miwok.bodyOnUnload =function() {
	for ( var i = 0 ; i < this.onUnloads.length ; i++ ){
	  if(this.onUnloads[i]) this.onUnloads[i]();
	}
}

// PAINT WINDOW
// {title:'', contentstyle:'', help:'', icon:''}
Miwok.paintWindow = function(table, options){
  table = $(table);
  options = options||{};
  if((table==null)||(table.tagName==null)) return;
  if(table.tagName.toLowerCase() != 'table') return;
  var tr = table.rows[0];
  if(tr==null) return;
  var td = tr.cells[0];
  
  if(!options.contentstyle) options.contentstyle='win_content';
  td.className = options.contentstyle;
  td = tr.insertCell(0);
  td.className = 'win_left';
  td.innerHTML = '<div style="width:7px;height:1px;overflow:hidden;"></div>';
  td = tr.insertCell(-1);
  td.className = 'win_right';
  td.innerHTML = '<div style="width:9px;height:1px;overflow:hidden;"></div>';
  if(options.title){
    tr = table.insertRow(0);
    td = tr.insertCell(-1);
    td.className = 'win_left';
    td.innerHTML = '<div style="width:7px;height:1px;overflow:hidden;"></div>';
    td = tr.insertCell(-1);
    td.className = 'win_title';
    if(options.help || options.icon){
      var titleContent = '';
      titleContent += '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>';
      if(options.icon) titleContent += '<td><img src="'+options.icon+'"/></td>';
      titleContent += '<td class="win_title" style="padding:0px;">'+options.title+'</td>';
      if(options.help) titleContent += '<td class="win_help"><a href="'+options.help+'"><div class="win_help"style="overflow:hidden;background:none;cursor:pointer;"></div></a></td>';
      titleContent += '</tr></table>';
      td.innerHTML = titleContent;
    }
    else td.innerHTML = options.title;
    td = tr.insertCell(-1);
    td.className = 'win_right';
    td.innerHTML = '<div style="width:9px;height:1px;overflow:hidden;"></div>';
  }
  tr = table.insertRow(0);
  td = tr.insertCell(-1);
  td.innerHTML = '<div class="win_topleft"></div>';
  td = tr.insertCell(-1);
  td.className = 'win_top';
  td.innerHTML = '<div style="width:7px;height:7px;overflow:hidden;"></div>';
  td = tr.insertCell(-1);
  td.innerHTML = '<div class="win_topright"></div>';
  tr = table.insertRow(-1);
  td = tr.insertCell(-1);
  td.innerHTML = '<div class="win_bottomleft"></div>';
  td = tr.insertCell(-1);
  td.className = 'win_bottom';
  td.align = 'left';
  td.innerHTML = '<div class="win_bottomleft1"></div>';
  td = tr.insertCell(-1);
  td.innerHTML = '<div class="win_bottomright"></div>';
};
// PAINT PANEL
Miwok.paintPanel = function(table, bgscheme){
  var table = $(table);
  if((table==null)||(table.tagName==null)) return;
  if(table.tagName.toLowerCase() != 'table') return;
  if(bgscheme) table.className = bgscheme;
  var tr = table.rows[0];
  if(tr==null) return;
  var td = tr.cells[0];

  td.className = 'spnl_content';
  td = tr.insertCell(0);
  td.className = 'spnl_left';
  td.innerHTML = '<div class="spnl_left" style="overflow:hidden;"></div>';
  td = tr.insertCell(-1);
  td.className = 'spnl_right';
  td.innerHTML = '<div class="spnl_right" style="overflow:hidden;"></div>';
  tr = table.insertRow(0);
  td = tr.insertCell(-1);
  td.innerHTML = '<div class="spnl_topleft" style="overflow:hidden;"></div>';
  td = tr.insertCell(-1);
  td.className = 'spnl_top';
  td.innerHTML = '<div class="spnl_top" style="overflow:hidden;"></div>';
  td = tr.insertCell(-1);
  td.innerHTML = '<div class="spnl_topright" style="overflow:hidden;"></div>';
  tr = table.insertRow(-1);
  td = tr.insertCell(-1);
  td.innerHTML = '<div class="spnl_botleft" style="overflow:hidden;"></div>';
  td = tr.insertCell(-1);
  td.className = 'spnl_bot';
  td.align = 'left';
  td.innerHTML = '<div class="spnl_botleft1" style="overflow:hidden;"></div>';
  td = tr.insertCell(-1);
  td.innerHTML = '<div class="spnl_botright" style="overflow:hidden;"></div>';
};
// ROUND BUTTON
Miwok.printLinkRoundButton = function(label, bgscheme, href, title, target, onclick, top, left){
  if(!top && top!=0) top = 5;
  if(!left && left!=0) left = 20;
  document.write('<div style="position:relative;top:'+top+'px;left:'+left+'px;">');
  document.write('<table cellpadding="0" cellspacing="0" border="0" style="position:relative;">');
  document.write('<tr>');
  var a = '<a href="'+href+'" ';
  if(target) a += 'target="'+target+'" ';
  if(onclick) a += 'onclick="'+onclick+'" ';
  if(title) a += 'title="'+title+'" ';
  document.write('<td align="right" nowrap>'+a+'class="'+bgscheme+'RoundBtnLabel">'+label+'</a></td>');
  document.write('<td>'+a+'><span><div class="'+bgscheme+'RoundBtn" style="overflow:hidden;"></div></span></a></td>');
  document.write('</tr>');
  document.write('</table>');
  document.write('</div>');
}
Miwok.printFormRoundButton = function(name, title, bgscheme, button, onclick, top, left){
  if(!document.formRoundButton) document.formRoundButton = 10000;
  document.formRoundButton++;
  if(!top && top!=0) top = 5;
  if(!left && left!=0) left = 20;
  document.write('<div style="position:relative;top:'+top+'px;left:'+left+'px;">');
  document.write('<table cellpadding="0" cellspacing="0" border="0" style="position:relative;">');
  document.write('<tr>');
  document.write('<td nowrap><a href="'+title+'" title="'+title+'" class="'+bgscheme+'RoundBtnLabel" onclick="var btn=$('+name+document.formRoundButton+'); if(btn) btn.click(); return false;">'+title+'</a></td>');
  document.write('<td><input id="'+name+document.formRoundButton+'" name="'+name+'" type="'+(button?'button':'submit')+'" title="'+title+'" value="" class="'+bgscheme+'RoundBtn" style="border:none;"');
  if(onclick) document.write('onclick="'+onclick+'" ');
  document.write('/></td>');
  document.write('</tr>');
  document.write('</table>');
  document.write('</div>');
}
// MIWOK TABS
Miwok.tabAttachBehaviors = function(idRow, idDiv, select){
  var controlObject = {};
  controlObject.select=function(controlObject){
    if(document.activeProfileTab == controlObject) return;
    if(!controlObject.div) return;
    controlObject.div.style.display = "";
    controlObject.row.className='selected';
    if(document.activeProfileTab){
      controlObject.unselect(document.activeProfileTab);
    }
    document.activeProfileTab = controlObject;
  }
  controlObject.unselect=function(controlObject){
    if(!controlObject.div) return;
    controlObject.div.style.display = "none";
    controlObject.row.className='';
  }
  controlObject.row = $(idRow);
  controlObject.div = $(idDiv);
  controlObject.tdText = controlObject.row.cells[1];
  controlObject.bullet = controlObject.row.cells[0];
  controlObject.bullet.className = 'listred_bullet';
  controlObject.tdText.controlObject = controlObject;
  controlObject.tdText.className = 'listred_unhover';
  controlObject.tdText.onmouseover = function(){this.className='listred_hover'};
  controlObject.tdText.onmouseout = function(){this.className='listred_unhover'};
  controlObject.tdText.onclick = function(){
    this.controlObject.select(this.controlObject);
  };
  if(select) controlObject.select(controlObject);
  else controlObject.unselect(controlObject);
}
// USER MENU
Miwok.Usermenu = new Object();
Miwok.Usermenu.init = function(container, selected){
  this._container=$(container);
  this._allItems = new Object()
  this._attachBehaviors();
  this.select($(selected));
};
Miwok.Usermenu._attachBehaviors = function() {
  var panels = this._getDirectChilds(this._container);
  for ( var i = 0 ; i < panels.length ; i++ ) {
    var elements = this._getDirectChilds(panels[i]);
    this._allItems[elements[0].id] = elements[0];
    elements[0].innerHTML = '<div class="user_menu_root_unhover" nowrap>'+elements[0].innerHTML+'</div>';
    this._attachElementBehaviors(elements[0], 'user_menu_root_hover', 'user_menu_root_unhover');
    if(elements.length>1){
      elements[0]._subpanel = elements[1];
      elements[1].style.display='none'; 
      this._attachChildBehaviors(elements[1], elements[0]);
    }
  } 
};
Miwok.Usermenu._attachChildBehaviors = function(container, root) {
  var panels = this._getDirectChilds(container);
  for ( var i = 0 ; i < panels.length ; i++ ) {
    this._allItems[panels[i].id] = panels[i];
    panels[i]._container = container;
    panels[i]._root = root;
    panels[i].innerHTML = '<div class="user_menu_child_unhover" nowrap>'+panels[i].innerHTML+'</div>';
    this._attachElementBehaviors(panels[i], 'user_menu_child_hover', 'user_menu_child_unhover');
  } 
};
Miwok.Usermenu.isSelected = function(element){
  element = $(element);
  if(element._control) element = element._control;
  return this.selected == element;
}
Miwok.Usermenu._hover = function(element){
  var control = element._control;
  if(control._root) element.className = (control.getAttribute('href'))?'user_menu_child_hover':'user_menu_child_unhover';
  else element.className = (this.expanded == control)?'user_menu_root_unhover':'user_menu_root_hover';
}
Miwok.Usermenu._unhover = function(element){
  var control = element._control;
  if(control._root) element.className = 'user_menu_child_unhover';
  else element.className = 'user_menu_root_unhover';
}
Miwok.Usermenu._click = function(element){
  if(element._control) element = element._control;
  var href = element.getAttribute('href');
  if(href){
  	Miwok.Utils.redirect(href);
    return;
  }
  if(element._subpanel) this.expand(element);
//  else this.select(element);
}
Miwok.Usermenu._attachElementBehaviors = function(element) {
  element.childNodes[0]._control = element;
  element.childNodes[0].onmouseover = function(){if(document.miwok)document.miwok.Usermenu._hover(this);};
  element.childNodes[0].onmouseout = function(){if(document.miwok)document.miwok.Usermenu._unhover(this);};
  element.childNodes[0].onclick = function(){if(document.miwok)document.miwok.Usermenu._click(this);};
};
Miwok.Usermenu.expand = function(element){
  element = $(element);
  if(!element) return;
  if(element._control) element = element._control;
  var root = this._getRoot(element);
  if((root!=this.expanded)){
    if(this.expanded){
      this.expanded._subpanel.style.display='none';
      this.expanded.className='';
    }
    if(root._subpanel){
      root._subpanel.style.display='';
      root.className='expanded';
      this.expanded = root;
      this._unhover(root.childNodes[0]);
    }
    else this.expanded = null;
  }
}
Miwok.Usermenu.select = function(element){
  element = $(element);
  if(!element) return;
  if(element._control) element = element._control;
  if(this.isSelected(element)) return;

  element.className = 'selected';
  if(this.selected) this.selected.className = '';
  this.selected = element;
  var root = this._getRoot(element);
  if(root!=element) this.expand(root);
};
Miwok.Usermenu._getRoot = function(element){
  element = $(element);
  if(element._root) return element._root;
  return element;
};
Miwok.Usermenu._getDirectChilds = function(e) {
  var kids = new Array();
  var allKids = e.childNodes;
  for( var i = 0 ; i < allKids.length ; i++ )
    if ( allKids[i] && allKids[i].tagName && allKids[i].tagName.toUpperCase() == 'DIV') kids.push(allKids[i]);
 return kids;
};

//Form elements
Miwok.setValueFormElement=function(element, value){
	element = $(element);
	if(!element) return;
	if(element.tagName.toLowerCase()=='select'){
		for(var i=0;i<element.options.length;i++){
			if(element.options[i].value==value){
				element.selectedIndex = i;
				if(element.onchange) element.onchange(); 
				return;
			}
		}
	}
	if(element.tagName.toLowerCase()=='input'){
		element.value=value;
	}
	
}
//Utils
Miwok.Utils = {
  getPosition : function(element){
    var cElement = $(element);
    var left = 0;
    var top = 0;
    while(cElement && (cElement.tagName!="BODY")){
      left += cElement.offsetLeft;
      top += cElement.offsetTop;
      cElement = cElement.offsetParent;
    }
    return {top:top, left:left};
  },
  setOpacity: function(_element, _opacity){
    _element = $(_element);
    if(!_element) return;
    _element.style.filter = "alpha(opacity="+Math.round(_opacity*100)+")";
    _element.style.opacity = _opacity;
  },
  redirect: function(href){
	  if(href){
	  	var a = $('_miwok_system_href');
	  	var f = $('_miwok_system_form');
	  	if(a && a.click){
	  		a.href = href;
	  		a.click();
	  	}
	  	else if(f){
		  	f.action = href;
	  		f.submit();
	  	}
	    else {
	    	top.location.replace(href);
	    	//top.navigate(href);
	    }
	  }
  }
};
document.miwokRedirect = Miwok.Utils.redirect;
Miwok.modal = function(active){
	top.document._modal.style.visibility = active?'visible':'hidden';
};
// Profile
Miwok.UserProfile={};
Miwok.UserProfile.attachUser=function(target, data){
	target.style.cursor='pointer';
	target._data = data;
	target.onmouseover=function(){Miwok.UserProfile.show(this)};
	target.onmouseout=function(){Miwok.UserProfile.hide(this)};
};
Miwok.UserProfile.getProfile=function(){
	if(!top.document.userProfile){
		var userProfile = document.createElement('DIV');
		top.document.userProfile = userProfile;
		userProfile.style.position='absolute';
		userProfile.style.top='0px';
		userProfile.style.left='0px';
		userProfile.style.visibility='hidden';
		top.document.body.appendChild(userProfile);
		userProfile.isVisible = function (target){
			return this.style.visibility=='visible';
		};
		userProfile.onmouseover=function(){
			if(this._timer) clearTimeout(this._timer);
		};
		userProfile.onmouseout=function(){
			this.hide();
		};
		userProfile.hide=function(){
			if(this._timer) clearTimeout(this._timer);
			if(this.isVisible()){
				var _t = this;
				this._timer = setTimeout(function(){_t._hide();}, 300);
			}
		};
		userProfile._hide=function(){
			this._target = null;
		  this.style.visibility='hidden';
		  this.style.top='0px';
		  this.style.left='0px';
		};
		userProfile.show=function(target){
			if(this._timer) clearTimeout(this._timer);
			var _target = target;
			var _t = this;
			this._timer = setTimeout(function(){_t._show(_target);}, 300);
		};
		userProfile._show=function(target){
			if(this.isVisible()){
				if(this._target==target) return;
				this._hide();
			}
			if(!target) return;
			this._target=target;
			this._fill();
			this._positionAndSize();
		  this.style.visibility='visible';
		};
		userProfile._fill=function(){
			this._image.src = this._target.src;
			var infoContent = '<b>'+this._target._data.firstname+'&nbsp;'+this._target._data.lastname+'</b><br/><br/>';
			var a = '';
			if(this._target._data.streetapt)	a += this._target._data.streetapt+'<br/>';
			//if(this._target._data.city) a+= this._target._data.city;
			//if(this._target._data.state) a+= ', '+this._target._data.state;
			if(this._target._data.zip) a+= ' '+this._target._data.zip;
			if(a)	infoContent += a+'<br/>';
			if(this._target._data.phone)	infoContent+= this._target._data.phone+'<br/>';
			if(this._target._data.mylo)	infoContent+= '<a class="popup" href="mailto:'+this._target._data.mylo+'">'+this._target._data.mylo+'</a><br/>';
			infoContent+= '<br/><a class="popup" href="'+this._target._data.href+'">'+"View User's Profile"+'</a>';
			this._text.innerHTML = infoContent;
		};
		userProfile._positionAndSize=function(){
			this.childNodes[1].style.width=this.childNodes[0].offsetWidth+'px';
			this.childNodes[1].style.height=this.childNodes[0].offsetHeight+'px';
			var body = top.document.body;
			var pos = Position.cumulativeOffset(this._target);
			var x=pos[0]-1;
			var y=pos[1]+this._target.offsetHeight;
			var dX=body.clientWidth - pos[0];
			var dY=body.clientHeight - pos[1];
			if((dY<=this.offsetHeight)&&(pos[1]>=this.offsetHeight)) y=pos[1]-this.offsetHeight;
			if(dX<=this.offsetWidth) x=pos[0]-this.offsetWidth+this._target.offsetWidth+1;
			this.style.left=(x<0?0:x)+'px';
			this.style.top=(y<0?0:y)+'px';
		};
		userProfile.innerHTML = '<div class="popup_outer" style="position:absolute;top:0px;left:0px;"></div><iframe frameborder="0" style="width:1px;height:1px;"></iframe>';
		userProfile.childNodes[0].innerHTML = '<div class="popup_inner"></div>';
		var infoContent = '<table cellpadding="0" cellspacing="0" border="0">';
		infoContent+= '<tr><td class="popup_title" nowrap>User Information</td></tr>';
		infoContent+= '<tr><td><table cellpadding="0" cellspacing="10" border="0">';
		infoContent+= '<tr>';
		infoContent+= '		<td valign="top" width="50px"><div style="padding:1px; background:#999999;"><div style="padding:1px; background:#ffffff;"><img src="" width="48px" height="48px"></div></div></td>';
		infoContent+= '		<td valign="top" nowrap class="popup_text"></td>';
		infoContent+= '	</tr>';
		infoContent+= '	</table>';
		infoContent+= '</td></tr>';
		infoContent+= '</table>';
		userProfile.childNodes[0].childNodes[0].innerHTML = infoContent;
		var row = userProfile.childNodes[0].childNodes[0].childNodes[0].rows[1].cells[0].childNodes[0].rows[0];
		userProfile._image=row.cells[0].childNodes[0].childNodes[0].childNodes[0];
		userProfile._text=row.cells[1];
	}
	return top.document.userProfile;
};
Miwok.UserProfile.show=function(target){
	this.getProfile().show(target);
};
Miwok.UserProfile.hide=function(target){
	this.getProfile().hide();
};

// Calendar
Miwok._createPopap = function(title, optoins){
  var div = document.createElement('DIV');
  div.style.visibility='hidden';
  div.style.top='0px';
  div.style.left='0px';
  div.style.position='absolute';
  document.body.appendChild(div);
  div._options = {closeButton:false, leftOffset:0, topOffset:0};
  div._options = Object.extend(div._options,optoins||{});
  div.innerHTML = '<div class="popup_outer" style="position:absolute;top:0px;left:0px;"></div><iframe frameborder="0" style="width:1px;height:1px;margin:0px;padding:0px;"></iframe>';
  div._canvas=div.childNodes[1];
  Miwok.Utils.setOpacity(div.canvas, 0);
  div.childNodes[0].appendChild(document.createElement('DIV'));
  div.childNodes[0].childNodes[0].className='popup_inner';
  var _content = '';
  _content += '<table cellpadding="0" cellspacing="0" border="0" class="popup">';
  _content += '<tr><td class="popup_title">&nbsp;</td><td class="popup_title_bg" align="right" style="padding:2px 2px 2px 0px;"></td></tr>';
  _content += '<tr><td colspan="2"></td></tr>';
  _content += '</table>';
  div.childNodes[0].childNodes[0].innerHTML = _content;
  var tbl = div.childNodes[0].childNodes[0].childNodes[0];
  tbl.onselectstart = function() {return false;};
  tbl.ondrag = function() {return false;};
  div._contentContainer = tbl.rows[1].cells[0];
  if(title){
    tbl.rows[0].cells[0].innerHTML = title.escapeHTML();
    if(div._options.closeButton){
      var d = document.createElement('DIV');
      d.style.paddingLeft="2px";
      d.innerHTML='<div class="btnClose" style="overflow:hidden;" title="Close" onclick="this._popup._hide();"></div>';
      d.childNodes[0]._popup = div;
      tbl.rows[0].cells[1].appendChild(d);
    }
    else tbl.rows[0].cells[1].style.display='none';
  }
  else tbl.rows[0].style.display='none';
  div.getContentContainer = function (){
    return this._contentContainer;
  };
  div._setContent = function (content, className){
    this._contentContainer.innerHTML=content;
    if(className) this._contentContainer.className=className;
  };
  div._isVisible = function (target){
    return this.style.visibility=='visible';
  };
  div.__hide=function(){
    this.style.visibility='hidden';
  };
  div._hide=function(){
    this._target = null;
    this.__hide();
    this.style.top='0px';
    this.style.left='0px';
  };
  div._fill=function(){};
  div.__show=function(target){
    this.style.visibility='visible';
  };
  div._show=function(target){
    if(this._isVisible()){
      if(target&&(this._target==target)) return;
      this._hide();
    }
    this._target=target?target:null;
    this._fill();
    this._positionAndSize(this._target);
    this.__show();
  };
  div._positionAndSize=function(target){
    this._checkSize();
    var pos = this._calcPosition(target);
    this.style.left=pos.left+'px';
    this.style.top=pos.top+'px';
  };
  div._checkSize=function(){
    this.childNodes[1].style.width=this.childNodes[0].offsetWidth+'px';
    this.childNodes[1].style.height=this.childNodes[0].offsetHeight+'px';
  }
  div._calcPosition=function(target){
    var body = top.document.body;
    var x = ((body.clientWidth - this.offsetWidth)/2)+this._options.leftOffset;
    var y = ((body.clientHeight - this.offsetHeight)/2)+this._options.topOffset;
    if(target){
      var pos = Position.cumulativeOffset(target);
      x=pos[0]-this._options.leftOffset;
      y=pos[1]+target.offsetHeight-this._options.topOffset;
      var dX=body.clientWidth - pos[0];
      var dY=body.clientHeight - pos[1];
      if((dY<=this.offsetHeight)&&(pos[1]>=this.offsetHeight)) y=pos[1]-this.offsetHeight+this._options.topOffset;
      if(dX<=this.offsetWidth) x=pos[0]-this.offsetWidth+target.offsetWidth+this._options.leftOffset;
    }
    return {left:(x<0?0:x), top:(y<0?0:y)};
  };
  return div;
};
Miwok.attachCalendar = function(container, controlYear, controlMonth, controlDate){
  container = $(container);
  if(!container) return;
  target = document.createElement('INPUT');
  target.type='button';
  target.className='calBtn';
  target.tabIndex=-1;
  container.appendChild(target);
  
  controlYear = $(controlYear);
  controlMonth = $(controlMonth);
  controlDate = $(controlDate);
  if(!controlYear){
    controlYear = document.createElement('INPUT');
    var date = new Date();
    controlYear.value=date.getFullYear();
  }
  if((!controlYear)||(!controlMonth)||(!controlDate)) return;
  
  target.controlYear = controlYear;
  target.controlMonth = controlMonth;
  target.controlDate = controlDate;
  target.onclick = function(){this.calendar()._click(this);};
  target.onblur = function(){this.calendar()._blur();};
  target.calendar = function(){
    if(!top.document.miwokCalendar){
      var popup = Miwok._createPopap('Calendar', {closeButton:true});
      popup.onmouseover = function() {this.mousein = true;};
      popup.onmouseout = function() {this.mousein = false;if(this._target)this._target.focus();};
      top.document.miwokCalendar = popup;
      var _content = '';
      _content += '<table cellpadding="0" cellspacing="5" border="0" align="center"><tr><td><div class="calendarPrev" style="overflow:hidden"></div></td><td class="calendarMonthYearText" nowrap>September 2007</td><td><div class="calendarNext" style="overflow:hidden"></div></td></tr></table>';
      _content += '<table cellpadding="0" cellspacing="5" border="0" class="calendardays"></table>';
      _content += '<div style="padding:5px 5px 5px 5px;"><div class="popup_div" style="overflow:hidden;"></div></div>';
      _content += '<table cellpadding="0" cellspacing="5" border="0">';
      _content += '<tr><td nowrap><div class="calendar_legend_today" style="overflow:hidden;"></div></td><td class="calendar_legend"><u>Today</u> is</td><td class="calendar_legend" nowrap><b>21 04 1972</b></td></tr>';
      _content += '</table>';
      var cns = new Array('dayscolumn_other_month','dayscolumn_before_today','dayscolumn_after_today','dayscolumn_today');
      for(var i=0; i<cns.length;i++) _content += '<div class="'+cns[i]+'" style="position:absolute;top:0px;left:0px;visibility:hidden;"></div>';
      popup._setContent(_content, 'calendar');
      popup.calendar=new Object();
      popup.calendar.owner=popup;
      popup.calendar.daylist = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
      popup.calendar.daysFull = new Array('Sunday','Monday','Tuesday', 'Wednesday','Thursday','Friday','Saturday');
      popup.calendar.months = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
      popup.calendar.monthsFull = new Array('January', 'February', 'March', 'April', 'May', 'June','July', 'August', 'September', 'October', 'November', 'December');
      popup.calendar.monthNext_title = 'Go to the next month';
      popup.calendar.monthPrev_title = 'Go to the previous month';
      popup.calendar.maxrange_caption = 'This is the maximum range';
      popup.calendar.startDay = 1;

      popup.calendar.create=function(container){
        var tbl = container.childNodes[0];
        this.headerContainer=tbl.rows[0].cells[1];
        var element = tbl.rows[0].cells[0].childNodes[0];
        element.calendar = this;
        element.setAttribute('title', this.monthPrev_title);
        element.onclick=function(){this.calendar.prevMonth()};
        element = tbl.rows[0].cells[2].childNodes[0];
        element.calendar = this;
        element.setAttribute('title', this.monthNext_title);
        element.onclick=function(){this.calendar.nextMonth()};
        var thead,tbody,tr,td;
        tbl = container.childNodes[1];
        thead = document.createElement('thead');
        tr = document.createElement('tr');
        for(var i=this.startDay; i< this.startDay + 7;i++) {
          td = document.createElement('td');
          td.className='dayscolumnheading';
          td.innerHTML=popup.calendar.daylist[i].escapeHTML();
          tr.appendChild(td);
        }
        thead.appendChild(tr);
        tbl.appendChild(thead);
        tbody = document.createElement('tbody');
        this.cellsDay = new Array();
        for(var i=0;i<6;i++){
          tr = document.createElement('tr');
          for(var j=0;j<7;j++){
            td = document.createElement('td');
            td.setAttribute('nowrap', true);
            td.innerHTML=(''+j).escapeHTML();
            td.calendar=this;
            td.onclick=function(){this.calendar.cellClick(this);};
            tr.appendChild(td);
            this.cellsDay.push(td);
          }
          tbody.appendChild(tr);
        }
        tbl.appendChild(tbody);      
        tbl = container.childNodes[3];
        this.toDayLegendContainer = tbl.rows[0].cells[2].childNodes[0];
        tbl.rows[0].cells[1].childNodes[0].style.cursor='pointer';
        tbl.rows[0].cells[1].childNodes[0].calendar=this;
//        tbl.rows[0].cells[1].childNodes[0].onclick=function(){this.calendar.clear();};
        tbl.rows[0].cells[1].childNodes[0].onclick=function(){this.calendar.cellClick({date:new Date()});};
      };
      popup.calendar.cellClick=function(element){
        var target = this.owner._target;
        if(target){
          Miwok.setValueFormElement(target.controlYear, element.date.getFullYear());
          Miwok.setValueFormElement(target.controlMonth, element.date.getMonth());
          Miwok.setValueFormElement(target.controlDate, element.date.getDate());
        }
        this.owner._hide();
      };
      popup.calendar.clear=function(){
        var date = new Date();
        this.goToMonth(date.getFullYear(),date.getMonth());
      };
      popup.calendar.redraw=function(){
        var date = new Date();
        var curDate = date.getDate();
        this.monthDayCount = new Array(31,((this.year - 2000) % 4 ? 28 : 29),31,30,31,30,31,31,30,31,30,31);
        var beginDate = new Date(this.year,this.month,1);
        var endDate = new Date(this.year,this.month,this.monthDayCount[this.month]);
        var sdt = new Date(beginDate);
        sdt.setDate(sdt.getDate() + (this.startDay - beginDate.getDay()) - (this.startDay - beginDate.getDay() > 0 ? 7 : 0) );
        var displayMonth = this.year*12+this.month;
        var curMonth = date.getFullYear()*12+date.getMonth();
        var setClass;
        if(displayMonth<curMonth){
          setClass=function(date, month){
            var cn = td.date.getMonth()==month?'dayscolumn_before_today':'dayscolumn_other_month';
            if(cn!=td.className)td.className = cn; 
          }
        }
        else if(displayMonth>curMonth){
          setClass=function(date, month){
            var cn = td.date.getMonth()==month?'dayscolumn_after_today':'dayscolumn_other_month';
            if(cn!=td.className)td.className = cn; 
          }
        }
        else{
          setClass=function(date, month){
            var cn;
            if(td.date.getMonth()!=month) cn = 'dayscolumn_other_month';
            else cn = td.date.getDate()<curDate?'dayscolumn_before_today':(td.date.getDate()>curDate?'dayscolumn_after_today':'dayscolumn_today');
            if(cn!=td.className)td.className = cn; 
          }
        }
        for(var i=0;i<this.cellsDay.length;i++){
          var td = this.cellsDay[i];
          td.innerHTML=(''+sdt.getDate()).escapeHTML();
          td.date = new Date(sdt);
          setClass(td, this.month);
          sdt.setDate(sdt.getDate() + 1);
        };
        this.headerContainer.innerHTML=(this.monthsFull[this.month]+' '+this.year).escapeHTML();
        this.toDayLegendContainer.innerHTML=this.daysFull[date.getDay()]+', '+this.months[date.getMonth()]+' '+date.getDate()+', '+date.getFullYear();
      };
      popup.calendar.goToMonth = function (year,month){
        this.month = month;
        this.year = year;
        this.redraw();
      };
      popup.calendar.nextMonth = function (){
        if(this.month < 11) this.month++;
        else{
          this.month = 0;
          this.year++;
        }
        this.redraw();
      };
      popup.calendar.prevMonth = function (){
        if(this.month > 0) this.month--;
        else{
          this.month = 11;
          this.year--;
        }
        this.redraw();
      };
      popup.calendar.create(popup.getContentContainer());
      popup._fill=function(){popup.calendar.clear();};
      popup._fill();
      popup._checkSize();
      popup._checkSize=function(){};
      popup._blur = function (){
        if(!this.mousein){
          this.hide();
        }
      }
      popup._click = function (target){
        if(this._timer) clearTimeout(this._timer);
        var newTarget = this._target!=target;
        if(this._isVisible()) this._hide();
        if(newTarget)this.show(target);
      }
      popup.show = function (target){
        if(this._timer) clearTimeout(this._timer);
        this._show(target);
      };
      popup.hide = function (){
        var _t = this;
        this._timer = setTimeout(function(){_t._hide();}, 100);
      }
    }
    return top.document.miwokCalendar;
  };    
};

Miwok.showError=function(errMessage){
	var errBlock=$("errorblock");
	var errText=$("errortext");
	
	if(!errBlock || !errText) return;
	
	errText.update(errMessage);
	errBlock.show();
	window.scrollTo(0,0);
};

Miwok.addError=function(errMessage){
	var errBlock=$("errorblock");
	var errText=$("errortext");
	
	if(!errBlock || !errText) return;
	
	errMessage=errText.innerHTML+(errText.innerHTML.length>0?"<br/><br/>":"")+errMessage;
	errText.update(errMessage);
	errBlock.show();
	window.scrollTo(0,0);
}

Miwok.hideError=function(){
	var errBlock=$("errorblock");
	
	if(!errBlock) return;
	
	errBlock.hide();
};

Miwok.showInfo=function(infoMessage){
	var infBlock=$("infoblock");
	var infText=$("infotext");
	
	if(!infBlock || !infText) return;
	
	infText.update(infoMessage);
	infBlock.show();
	window.scrollTo(0,0);
};

Miwok.addInfo=function(infoMessage){
	var infBlock=$("infoblock");
	var infText=$("infotext");
	
	if(!infBlock || !infText) return;
	
	infoMessage=infText.innerHTML+(infText.innerHTML.length>0?"<br/><br/>":"")+infoMessage;
	infText.update(infoMessage);
	infBlock.show();
	window.scrollTo(0,0);
}

Miwok.hideInfo=function(){
	var infBlock=$("infoblock");
	
	if(!infBlock) return;
	
	infBlock.hide();
};


// Weather Airport
Miwok.WeatherAirport={};
Miwok.WeatherAirport.airportWeather=function(target, data){
	target.style.cursor='pointer';
	target._data = data;
	target.onmouseover=function(){Miwok.WeatherAirport.show(this)};
	target.onmouseout=function(){Miwok.WeatherAirport.hide(this)};
};
Miwok.WeatherAirport.getWeather=function(){
	if(!top.document.airportWeather){
		var airportWeather = document.createElement('DIV');
		top.document.airportWeather = airportWeather;
		airportWeather.style.position='absolute';
		airportWeather.style.top='0px';
		airportWeather.style.left='0px';
		airportWeather.style.visibility='hidden';
		top.document.body.appendChild(airportWeather);
		airportWeather.isVisible = function (target){
			return this.style.visibility=='visible';
		};
		airportWeather.onmouseover=function(){
			if(this._timer) clearTimeout(this._timer);
		};
		airportWeather.onmouseout=function(){
			this.hide();
		};
		airportWeather.hide=function(){
			if(this._timer) clearTimeout(this._timer);
			if(this.isVisible()){
				var _t = this;
				this._timer = setTimeout(function(){_t._hide();}, 300);
			}
		};
		airportWeather._hide=function(){
			this._target = null;
		  this.style.visibility='hidden';
		  this.style.top='0px';
		  this.style.left='0px';
		};
		airportWeather.show=function(target){
			if(this._timer) clearTimeout(this._timer);
			var _target = target;
			var _t = this;
			this._timer = setTimeout(function(){_t._show(_target);}, 300);
		};
		airportWeather._show=function(target){
			if(this.isVisible()){
				if(this._target==target) return;
				this._hide();
			}
			if(!target) return;
			this._target=target;
			this._fill();
			this._positionAndSize();
		  this.style.visibility='visible';
		};
		airportWeather._fill=function(){
			this._image.src = this._target.src;
			var infoContent = '<b>Temperature:&nbsp;'+this._target._data.temperature+'&nbsp;°F</b><br/>';
			var a = '';
			if(this._target._data.windspeed) a += 'Wind Speed:&nbsp;' + this._target._data.windspeed+'&nbsp;(knots)<br/>';
			if(this._target._data.winddirection) a += 'Wind Direction:&nbsp;' + this._target._data.winddirection+'<br/>';
			if(this._target._data.relativehumidity) a += 'Relative Humidity:&nbsp;' + this._target._data.relativehumidity+'%<br/>';
			if(this._target._data.cloudcoveramount) a += 'Cloud Cover Amount:&nbsp;' + this._target._data.cloudcoveramount+'%<br/>';
			if(this._target._data.snowamount) a += 'Snow Amount:&nbsp;' + this._target._data.snowamount+'(inches)<br/>';
			if(a)	infoContent += a;
			this._text.innerHTML = infoContent;
		};
		airportWeather._positionAndSize=function(){
			this.childNodes[1].style.width=this.childNodes[0].offsetWidth+'px';
			this.childNodes[1].style.height=this.childNodes[0].offsetHeight+'px';
			var body = top.document.body;
			var pos = Position.cumulativeOffset(this._target);
			var x=pos[0]-1;
			var y=pos[1]+this._target.offsetHeight;
			var dX=body.clientWidth - pos[0];
			var dY=body.clientHeight - pos[1];
			if((dY<=this.offsetHeight)&&(pos[1]>=this.offsetHeight)) y=pos[1]-this.offsetHeight;
			if(dX<=this.offsetWidth) x=pos[0]-this.offsetWidth+this._target.offsetWidth+1;
			this.style.left=(x<0?0:x)+'px';
			this.style.top=(y<0?0:y)+'px';
		};
		airportWeather.innerHTML = '<div class="popup_outer" style="position:absolute;top:0px;left:0px;"></div><iframe frameborder="0" style="width:1px;height:1px;"></iframe>';
		airportWeather.childNodes[0].innerHTML = '<div class="popup_inner"></div>';
		var infoContent = '<table cellpadding="0" cellspacing="0" border="0">';
		infoContent+= '<tr><td class="popup_title" nowrap>Weather Information</td></tr>';
		infoContent+= '<tr><td><table cellpadding="0" cellspacing="10" border="0">';
		infoContent+= '<tr>';
		infoContent+= '		<td valign="top" width="50px"><div style="padding:1px; background:#999999;"><div style="padding:1px; background:#ffffff;"><img src="" width="48px" height="48px"></div></div></td>';
		infoContent+= '		<td valign="top" nowrap class="popup_text"></td>';
		infoContent+= '	</tr>';
		infoContent+= '	</table>';
		infoContent+= '</td></tr>';
		infoContent+= '</table>';
		airportWeather.childNodes[0].childNodes[0].innerHTML = infoContent;
		var row = airportWeather.childNodes[0].childNodes[0].childNodes[0].rows[1].cells[0].childNodes[0].rows[0];
		airportWeather._image=row.cells[0].childNodes[0].childNodes[0].childNodes[0];
		airportWeather._text=row.cells[1];
	}
	return top.document.airportWeather;
};
Miwok.WeatherAirport.show=function(target){
	this.getWeather().show(target);
};
Miwok.WeatherAirport.hide=function(target){
	this.getWeather().hide();
};

// Operator
Miwok.Operator={};
Miwok.Operator.attachOperator=function(target, data){
	target.style.cursor='pointer';
	target._data = data;
	target.onmouseover=function(){Miwok.Operator.show(this)};
	target.onmouseout=function(){Miwok.Operator.hide(this)};
};
Miwok.Operator.getOperator=function(){
	if(!top.document.operator){
		var operator = document.createElement('DIV');
		top.document.operator = operator;
		operator.style.position='absolute';
		operator.style.top='0px';
		operator.style.left='0px';
		operator.style.visibility='hidden';
		top.document.body.appendChild(operator);
		operator.isVisible = function (target){
			return this.style.visibility=='visible';
		};
		operator.onmouseover=function(){
			if(this._timer) clearTimeout(this._timer);
		};
		operator.onmouseout=function(){
			this.hide();
		};
		operator.hide=function(){
			if(this._timer) clearTimeout(this._timer);
			if(this.isVisible()){
				var _t = this;
				this._timer = setTimeout(function(){_t._hide();}, 300);
			}
		};
		operator._hide=function(){
			this._target = null;
		  this.style.visibility='hidden';
		  this.style.top='0px';
		  this.style.left='0px';
		};
		operator.show=function(target){
			if(this._timer) clearTimeout(this._timer);
			var _target = target;
			var _t = this;
			this._timer = setTimeout(function(){_t._show(_target);}, 300);
		};
		operator._show=function(target){
			if(this.isVisible()){
				if(this._target==target) return;
				this._hide();
			}
			if(!target) return;
			this._target=target;
			this._fill();
			this._positionAndSize();
		  this.style.visibility='visible';
		};
		operator._fill=function(){
			this._image.src = this._target._data.image;
			var infoContent = 
				this._target._data.name+'<br/>'+
				'cert#: '+this._target._data.certificate;
			
			this._text.innerHTML = infoContent;
		};
		operator._positionAndSize=function(){
			this.childNodes[1].style.width=this.childNodes[0].offsetWidth+'px';
			this.childNodes[1].style.height=this.childNodes[0].offsetHeight+'px';
			var body = top.document.body;
			var pos = Position.cumulativeOffset(this._target);
			var x=pos[0]-1;
			var y=pos[1]+this._target.offsetHeight;
			var dX=body.clientWidth - pos[0];
			var dY=body.clientHeight - pos[1];
			if((dY<=this.offsetHeight)&&(pos[1]>=this.offsetHeight)) y=pos[1]-this.offsetHeight;
			if(dX<=this.offsetWidth) x=pos[0]-this.offsetWidth+this._target.offsetWidth+1;
			this.style.left=(x<0?0:x)+'px';
			this.style.top=(y<0?0:y)+'px';
		};
		operator.innerHTML = '<div class="popup_outer" style="position:absolute;top:0px;left:0px;"></div><iframe frameborder="0" style="width:1px;height:1px;"></iframe>';
		operator.childNodes[0].innerHTML = '<div class="popup_inner"></div>';
		var infoContent = '<table cellpadding="0" cellspacing="0" border="0">';
		infoContent+= '<tr><td class="popup_title" nowrap>Operated by</td></tr>';
		infoContent+= '<tr><td><img src="" border=""></td></tr>';
		infoContent+= '<tr><td valign="top" nowrap class="popup_text" style="padding:5px;"></td></tr>';
		infoContent+= '</table>';
		operator.childNodes[0].childNodes[0].innerHTML = infoContent;
		var row = operator.childNodes[0].childNodes[0].childNodes[0].rows[1];
		operator._image=row.cells[0].childNodes[0];
		operator._text=operator.childNodes[0].childNodes[0].childNodes[0].rows[2].cells[0];
	}
	return top.document.operator;
};
Miwok.Operator.show=function(target){
	this.getOperator().show(target);
};
Miwok.Operator.hide=function(target){
	this.getOperator().hide();
};


// Service Info
Miwok.ServiceInfo={};
Miwok.ServiceInfo.registrationInfo=function(target, data){
	target.style.cursor='pointer';
	target._data = data;
	target.onmouseover=function(){Miwok.ServiceInfo.show(this)};
	target.onmouseout=function(){Miwok.ServiceInfo.hide(this)};
};
Miwok.ServiceInfo.getServiceInfo=function(){
	if(!top.document.registrationInfo){
		var registrationInfo = document.createElement('DIV');
		top.document.registrationInfo = registrationInfo;
		registrationInfo.style.position='absolute';
		registrationInfo.style.top='0px';
		registrationInfo.style.left='0px';
		registrationInfo.style.visibility='hidden';
		top.document.body.appendChild(registrationInfo);
		registrationInfo.isVisible = function (target){
			return this.style.visibility=='visible';
		};
		registrationInfo.onmouseover=function(){
			if(this._timer) clearTimeout(this._timer);
		};
		registrationInfo.onmouseout=function(){
			this.hide();
		};
		registrationInfo.hide=function(){
			if(this._timer) clearTimeout(this._timer);
			if(this.isVisible()){
				var _t = this;
				this._timer = setTimeout(function(){_t._hide();}, 300);
			}
		};
		registrationInfo._hide=function(){
			this._target = null;
		  this.style.visibility='hidden';
		  this.style.top='0px';
		  this.style.left='0px';
		};
		registrationInfo.show=function(target){
			if(this._timer) clearTimeout(this._timer);
			var _target = target;
			var _t = this;
			this._timer = setTimeout(function(){_t._show(_target);}, 300);
		};
		registrationInfo._show=function(target){
			if(this.isVisible()){
				if(this._target==target) return;
				this._hide();
			}
			if(!target) return;
			this._target=target;
			this._fill();
			this._positionAndSize();
		  this.style.visibility='visible';
		};
		registrationInfo._fill=function(){
			this._image.src = this._target.src;
			var infoContent =  '<b>'+this._target._data.title+'</b><br/><br/>';
 			if(this._target._data.info && this._target._data.info.length > 0) infoContent+= '<b>'+this._target._data.info.replace(/;/g,'<br/><br/>')+'</b><br/><br/>';
			infoContent+= '<a class="popup" target="_blanck" href="'+this._target._data.morelink+'">'+"More info"+'</a>';
			this._text.innerHTML = infoContent;
		};
		registrationInfo._positionAndSize=function(){
			this.childNodes[1].style.width=this.childNodes[0].offsetWidth+'px';
			this.childNodes[1].style.height=this.childNodes[0].offsetHeight+'px';
			var body = top.document.body;
			var pos = Position.cumulativeOffset(this._target);
			var x=pos[0]-1;
			var y=pos[1]+this._target.offsetHeight;
			var dX=body.clientWidth - pos[0];
			var dY=body.clientHeight - pos[1];
			if((dY<=this.offsetHeight)&&(pos[1]>=this.offsetHeight)) y=pos[1]-this.offsetHeight;
			if(dX<=this.offsetWidth) x=pos[0]-this.offsetWidth+this._target.offsetWidth+1;
			this.style.left=(x<0?0:x)+'px';
			this.style.top=(y<0?0:y)+'px';
		};
		registrationInfo.innerHTML = '<div class="popup_outer" style="position:absolute;top:0px;left:0px;"></div><iframe frameborder="0" style="width:1px;height:1px;"></iframe>';
		registrationInfo.childNodes[0].innerHTML = '<div class="popup_inner"></div>';
		var infoContent = '<table cellpadding="0" cellspacing="0" border="0">';
		infoContent+= '<tr><td class="popup_title" nowrap>Service Information</td></tr>';
		infoContent+= '<tr><td><table cellpadding="0" cellspacing="10" border="0">';
		infoContent+= '<tr>';
		infoContent+= '		<td valign="top" width="26px"><div style="padding:1px; background:#999999;"><div style="padding:1px; background:#ffffff;"><img src="" width="24px" height="24px"></div></div></td>';
		infoContent+= '		<td valign="top" nowrap class="popup_text"></td>';
		infoContent+= '	</tr>';
		infoContent+= '	</table>';
		infoContent+= '</td></tr>';
		infoContent+= '</table>';
		registrationInfo.childNodes[0].childNodes[0].innerHTML = infoContent;
		var row = registrationInfo.childNodes[0].childNodes[0].childNodes[0].rows[1].cells[0].childNodes[0].rows[0];
		registrationInfo._image=row.cells[0].childNodes[0].childNodes[0].childNodes[0];
		registrationInfo._text=row.cells[1];
	}
	return top.document.registrationInfo;
};
Miwok.ServiceInfo.show=function(target){
	this.getServiceInfo().show(target);
};
Miwok.ServiceInfo.hide=function(target){
	this.getServiceInfo().hide();
};

// Airport
Miwok.Airport={};
Miwok.Airport.attachAirport=function(target, data){
	target.style.cursor='pointer';
	target._data = data;
	target.onmouseover=function(){Miwok.Airport.show(this)};
	target.onmouseout=function(){Miwok.Airport.hide(this)};
};
Miwok.Airport.getAirport=function(){
	if(!top.document.airport){
		var airport = document.createElement('DIV');
		top.document.airport = airport;
		airport.style.position='absolute';
		airport.style.top='0px';
		airport.style.left='0px';
		airport.style.visibility='hidden';
		top.document.body.appendChild(airport);
		airport.isVisible = function (target){
			return this.style.visibility=='visible';
		};
		airport.onmouseover=function(){
			if(this._timer) clearTimeout(this._timer);
		};
		airport.onmouseout=function(){
			this.hide();
		};
		airport.hide=function(){
			if(this._timer) clearTimeout(this._timer);
			if(this.isVisible()){
				var _t = this;
				this._timer = setTimeout(function(){_t._hide();}, 300);
			}
		};
		airport._hide=function(){
			this._target = null;
		  this.style.visibility='hidden';
		  this.style.top='0px';
		  this.style.left='0px';
		};
		airport.show=function(target){
			if(this._timer) clearTimeout(this._timer);
			var _target = target;
			var _t = this;
			this._timer = setTimeout(function(){_t._show(_target);}, 300);
		};
		airport._show=function(target){
			if(this.isVisible()){
				if(this._target==target) return;
				this._hide();
			}
			if(!target) return;
			this._target=target;
			this._fill();
			this._positionAndSize();
		  this.style.visibility='visible';
		};
		airport._fill=function(){
			var airport = this._target._data;
			this.title_.innerHTML = airport.code+' - '+airport.title;

			var infoContent = '<b>FlyMiwok Location:</b><br/>';//+airport.locationFbo+'<br/>';
			var a = '';
			var adr='';
			//if(airport.streetapt)	{
				a += 'c/o '+airport.locationFbo+'<br/>';
				adr+='c/o '+airport.locationFbo;
				
				a += airport.streetapt+'<br/>';
				adr+=airport.streetapt;
			//}
			//if(airport.city) {
				a+= airport.city;
				adr+= ', '+airport.city;
			//}
			//if(airport.state){ 
				a+= ', '+airport.state;
				adr+= ', '+airport.state;
			//}
			//if(airport.zip) {
				a+= ' '+airport.zip;
				adr+= ' '+airport.zip;
			//}
			if(a)	infoContent += a+'<br/>';
			if(airport.phone)	infoContent+= airport.phone;
			this.address_.innerHTML = infoContent;
			infoContent = '';
			for(var i=0;i<airport.services.length;i++){
				infoContent+= '<tr>';
				infoContent+= '<td><img src="'+airport.services[i].imageHref+'" border="0" width="20" height="20"></td>';
				infoContent+= '<td class="airportinfo_servicetitle" nowrap>'+airport.services[i].title+'</td>';
				infoContent+= '</tr>';
			};
			if(infoContent) infoContent = '<table cellpadding="0" cellspacing="5" border="0">'+infoContent+'</table>';
			else infoContent = '&nbsp;';
			this.services_.innerHTML = infoContent;
			this.directions_.innerHTML="Get Directions: <a href='http://www.google.com/maps?oi=map&gl=US&ct=directions-to&daddr="+adr+"' target='_blank' class='airportinfo'>To here</a> | <a href='http://www.google.com/maps?oi=map&gl=US&ct=directions-from&saddr="+adr+"' target='_blank' class='airportinfo'>From here</a>";
		};
		airport._positionAndSize=function(){
			this.childNodes[1].style.width=this.childNodes[0].offsetWidth+'px';
			this.childNodes[1].style.height=this.childNodes[0].offsetHeight+'px';
			var body = top.document.body;
			var pos = Position.cumulativeOffset(this._target);
			var x=pos[0]-1;
			var y=pos[1]+this._target.offsetHeight;
			var dX=body.clientWidth - pos[0];
			var dY=body.clientHeight - pos[1];
			if((dY<=this.offsetHeight)&&(pos[1]>=this.offsetHeight)) y=pos[1]-this.offsetHeight;
			if(dX<=this.offsetWidth) x=pos[0]-this.offsetWidth+this._target.offsetWidth+1;
			this.style.left=(x<0?0:x)+'px';
			this.style.top=(y<0?0:y)+'px';
		};

		airport.innerHTML = '<div class="airportinfo_outer" style="position:absolute;top:0px;left:0px;"></div><iframe frameborder="0" style="width:1px;height:1px;"></iframe>';
		airport=airport.childNodes[0];
		airport.innerHTML = '<div class="airportinfo_inner"></div>';
		airport=airport.childNodes[0];
		var infoContent = '<table cellpadding="0" cellspacing="0" border="0">';
		infoContent+= '<tr><td class="popup_title" nowrap>&nbsp;</td></tr>';
		infoContent+= '<tr><td>';
		infoContent+= '<table width="100%" cellpadding="0" cellspacing="5" border="0">';
		infoContent+= '<tr><td class="airportinfo_address" nowrap style="font-weight:bold;">&nbsp;</td></tr>';
		infoContent+= '<tr><td class="airportinfo_address" nowrap style="font-weight:normal;">&nbsp;</td></tr>';
		infoContent+= '<tr><td><div class="airportinfo_div" style="overflow:hidden;"></div></td></tr>';
		infoContent+= '</table>';
		infoContent+= '</td></tr>';
		infoContent+= '<tr><td style="padding-right:5px;padding-left:5px;" class="airportinfo_services" nowrap>Location Services:</td></tr>';
		infoContent+= '<tr><td style="padding-right:5px;padding-left:5px;">&nbsp;</td></tr>';
		infoContent+= '<tr><td style="padding-right:5px;padding-left:5px;"><div class="airportinfo_div" style="overflow:hidden;"></div></td></tr>';
		infoContent+= '<tr><td class="airportinfo_address" style="padding:5px 5px 5px 5px;" nowrap>&nbsp;</td></tr>';
		infoContent+= '</table>';
		airport.innerHTML = infoContent;
		airport = airport.childNodes[0];
		document.airport.table_ = airport;
		document.airport.title_ = airport.rows[0].cells[0]; 
		document.airport.address_ = airport.rows[1].cells[0].childNodes[0].rows[0].cells[0]; 
		document.airport.services_ = airport.rows[3].cells[0];
		document.airport.directions_ = airport.rows[5].cells[0];
	}
	return top.document.airport;
};
Miwok.Airport.show=function(target){
	this.getAirport().show(target);
};
Miwok.Airport.hide=function(target){
	this.getAirport().hide();
};

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear) {
	var DaysInMonth = 31;
	if (WhichMonth == "4" || WhichMonth == "6" || WhichMonth == "9" || WhichMonth == "11") DaysInMonth = 30;
	if (WhichMonth == "2" && (WhichYear/4) != Math.floor(WhichYear/4))  DaysInMonth = 28;
	if (WhichMonth == "2" && (WhichYear/4) == Math.floor(WhichYear/4))  DaysInMonth = 29;
	return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(YearObject,MonthObject,DaysObject) {
	var Month = (1*$F(MonthObject))+1;
	var Year = $F(YearObject);
	
	Month=""+Month;

	var DaysForThisSelection = DaysInMonth(Month, Year);
	var CurrentDaysInSelection = DaysObject.length;
	if (CurrentDaysInSelection > DaysForThisSelection) {
		for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++) {
			DaysObject.options[DaysObject.options.length - 1] = null
		}
	}
	if (DaysForThisSelection > CurrentDaysInSelection) {
		for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++) {
			NewOption = new Option(DaysObject.options.length + 1);
			DaysObject.options.add(NewOption);
		}
	}
	if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex = 0;
}
