navHover = function() {
	var lis = document.getElementById('nav').getElementsByTagName('LI');
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			if (this.className == 'nav-first' || this.className == 'nav-last') {
				this.className+='iehover';
			} else {
				this.className+=' iehover';
			}
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(' iehover\\b'), '');
			this.className=this.className.replace(new RegExp('iehover\\b'), '');
		}
	}
}
if (window.attachEvent) window.attachEvent('onload', navHover);

function insertFlashMovie( id, height, width, bgcolor, id_name ){
 if(window.location.href.indexOf('w2.cloudspace.com/uptown_pub') != -1){
	 document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='"+width+"' id='"+id_name+"' align='middle' height='"+height+"'  > \n");
	 document.write("<param name='movie' value='http://w2.cloudspace.com/uptown_pub/swf/"+id+".swf?UTBC=http://w2.cloudspace.com/uptown_pub' /> \n");
	 document.write("<param name='quality' value='high' /> \n ");
	 document.write("<param name='bgcolor' value='"+bgcolor+"' /> \n ");
	 document.write("<param name='wmode' VALUE='transparent' /> \n ");
	 document.write("<param name='allowScriptAccess' value='sameDomain' /> \n ");
	 document.write("<embed src='http://w2.cloudspace.com/uptown_pub/swf/"+id+".swf?UTBC=http://w2.cloudspace.com/uptown_pub' quality='high' width='"+width+"' height='"+height+"' bgcolor='"+bgcolor+"' type='application/x-shockwave-flash' name='"+id_name+"' allowScriptAccess='sameDomain' align='middle' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' wmode='transparent' /> \n");
	 document.write("</object> \n");
	}else{
		document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='"+width+"' id='"+id_name+"' align='middle' height='"+height+"'  > \n");
	 document.write("<param name='movie' value='http://w2.cloudspace.com/uptown_pub/swf/"+id+".swf?UTBC=http://w2.cloudspace.com/uptown_pub' /> \n");
	 document.write("<param name='quality' value='high' /> \n ");
	 document.write("<param name='bgcolor' value='"+bgcolor+"' /> \n ");
	 document.write("<param name='wmode' VALUE='transparent' /> \n ");
	 document.write("<param name='allowScriptAccess' value='sameDomain' /> \n ");
	 document.write("<embed src='http://w2.cloudspace.com/uptown_pub/swf/"+id+".swf?UTBC=http://w2.cloudspace.com/uptown_pub' quality='high' width='"+width+"' height='"+height+"' bgcolor='"+bgcolor+"' type='application/x-shockwave-flash' name='"+id_name+"' allowScriptAccess='sameDomain' align='middle' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' wmode='transparent' /> \n");
	 document.write("</object> \n");
	}
}

function element(id) {
 if(document.getElementById != null) {
  return document.getElementById(id);
 }
 if(document.all != null) {
  return document.all[id];
 }
 if(document.layers != null) {
  return document.layers[id];
 }
 return null;
}

function tabSwitch(id) {
  var tabName = "tab" + id;
  var oldTabName = "tab" + current;
  var tab = element(tabName);
  var oldTab = element(oldTabName);

  if (id == current) {
  } else {
    var currDisplay = element(current);
    var newDisplay = element(id);

//alert("currDisplay: " + current + " " + currDisplay + " newDisplay: " + id + " " + newDisplay);

    obgString = 'url(http://www.uptownaltamonte.com/images/' + oldTabName + '2.jpg) top left no-repeat';
    ibgString = 'url(http://www.uptownaltamonte.com/images/' + tabName + '1.jpg) top left no-repeat';
    oldTab.style.background = obgString;
    tab.style.background = ibgString;
    current = id;

    currDisplay.style.display = 'none';
    newDisplay.style.display = 'block';
    if(typeof id != 'undefined') {
     /* setTimeout("rotateSImage(" + id + ");", 10500); */
    }
    currentSImage = 0;
  }
}

function parkDisp(id) {
  var paragraph;
  var parkP = "parkP";
  if (id == 1) {
    paragraph = "<img style='margin-left:1px;' src='images/parkThin1.jpg' /><br /><br />The European-style plaza is great for outdoor gatherings and family activities including rubbing stones, water features and natural landscapes along the lake. This area also serves as another new and unique venue for events, weddings and entertainment for the community.";
    var left = '65px';
  } else if (id == 2) {
    paragraph = "<img style='margin-left:1px;' src='images/parkThin2.gif' /><br /><br />The Tower at Uptown stands 62' and is clad in Minnesota Limestone with the top finial cast in bronze. This is the crowning feature of the new plaza offering a great location for outdoor gatherings and festivals for the City.";
    var left = '210px';
  } else if (id == 3) {
    paragraph = "<img style='margin-left:1px;' src='images/parkThin3.jpg' /><br /><br />Dedicated to former City Commissioner Eddie Rose, the amphitheater with stadium-style seating and a one-of-a-kind floating stage hosts a variety of cultural and entertaining events for the whole family to enjoy.";
    var left = '355px';
  }
  var pElem= element("parkP");
  pElem.innerHTML = paragraph;
  pElem.style.zIndex = 51;
  pElem.style.display = 'block';
  var pElem2= element("parkP2");
  pElem2.style.zIndex = 51;
  pElem2.style.left = left;
  pElem2.style.display = 'block';
}

function hidePark() {
  var pElem= element("parkP");
  pElem.style.display = 'none';
  var pElem2= element("parkP2");
  pElem2.style.display = 'none';
}

function eventDisp(id,date,placement) {
//  var paragraph = "<div style='display:block;width:14px;height:35px;background:url(http://www.uptownaltamonte.com/images/eventArrow.png) top left no-repeat;'></div>     <div style='border:1px solid #8e8e8e;background-color:#e0e0e0;position: relative; left:15px;width: 531px;'>      <div onclick=\"hideEvent()\" style=\"position:relative;display:block;width:20px;left:511px;height:20px;\">x</div><div id='eventInner'></div>     </div>";
  var dElem= element("event");
  dElem.style.display = 'none';
  if (id == 1) {
    ajax('includes/eventget.php','date='+date,fill,'event');
  } else if (id == 2) {
    paragraph += "The date of this event is: " + date;
  } else if (id == 3) {
    paragraph += "The date of this event is: " + date;
  }
  moveEventBox(placement);
//  dElem.innerHTML = paragraph;
}

function hideEvent() {
  var dElem= element("event");
  dElem.style.display = 'none';
  grayOut(false);
}


function ajax(url, vars, callbackFunction, elemName)
{
  var request = window.XMLHttpRequest ?
  new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0");
  request.open("POST", url, true);
  request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  request.onreadystatechange = function() {
    if (request.readyState == 4 && request.status == 200) {
      if (request.responseText) {
        callbackFunction(request.responseText, elemName);
      }
    }
  };
  request.send(vars);
}

function fill(responseText,elemName) {
 var e = element(elemName);
// e.innerHTML = responseText;
// e.innerHTML = "<div onclick=\"hideEvent()\" style=\"position:relative;display:block;width:20px;left:429px;height:20px;\">x</div><div id='eventInner'>" + responseText + "</div>";
e.innerHTML = "<div id='eventInner1'></div><div id='eventInner2'><div onclick=\"hideEvent()\" id='eventClose'></div><div id='eventInner'>" + responseText + "</div></div><div class='cB'></div>";
e.style.display = 'block';
}

function moveEventBox(position) {
  dElem = element('event');
  dElem.style.top  = '-350px';
  dElem.style.left =   '130px';
  dElem.style.zIndex = 51;
}

function grayOff() {
  hidePark()
  hideEvent();
  grayOut(false);
}

function grayOut(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 55;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.onclick = grayOff;
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (vis) {
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
        var pH1 = document.body.scrollHeight;
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
      var pH1 = document.body.offsetHeight;
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
       var pH1 = 0;
    }
    var pH2 = getWindowHeight();
    if (pH2 > pH1) {
      pageHeight=pH2+'px';
    }
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';
    dark.onclick=grayOff;
  } else {
     dark.style.display='none';
  }
}

function getWindowHeight() {
  var wh;
  d = document;
  if (typeof window.innerHeight != 'undefined') {
    wh = window.innerHeight;  // NN and Opera version
  } else {
    if (d.documentElement &&
        typeof d.documentElement.clientHeight!='undefined' &&
        d.documentElement.clientHeight != 0) {
      wh = d.documentElement.clientHeight;
    } else {
      if (d.body && typeof d.body.clientHeight != 'undefined') {
        wh = d.body.clientHeight;
      }
    }
  }
  return wh;
}

function eventOnload(date) {
  grayOut(true);
  eventDisp('1',onloadDate,'');
}

var tDisp;

function timedHover(id,date,placement) {
  tDisp = setTimeout("eventDisp('"+id+"','"+date+"','"+placement+"');grayOut(true);",500);
}

function timedHoverPark(id) {
  tDisp = setTimeout("parkDisp('"+id+"');grayOut(true);",500);
}

function cancelHover() {
  clearTimeout(tDisp);
}