var openIntervalID = 0;
var closeIntervalID = 0;
var currentXPosition = 0;
var currentYPosition = 0;
var currentSubmenu = "Nothing";
var isSubmenuOpen = 0;

function TitleBar() {
  document.write('<div id="TitleBar" style="position:absolute; left:0px; top:0px; width:680px; height:200px">');
  document.write('<table width="100%" border="0px" cellpadding="0px" cellspacing="0px">');
  document.write('<tr><td align="right"><img src="images/hcdc3.jpg"  height="150px"></td>');
  document.write('<td align="left"><img src="images/title.jpg" height="150px"></td></tr></table></div>');
}

function FooterBar(){
  document.write('<div id="FooterDiv" style="position:absolute; left:0px; top:4000px; visibility:visible; width:790px; height:55px; background-color: #800055">');
  document.write('<p class="FooterInfo">Harrison County Development Corporation, 109 N. 4th Ave. Suite 2, Logan, IA 51546 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(712) 644-3081<br><br>');
  document.write('Copyright 2008 HCDC All rights reserved.</p></div>');
}

//This functions sets the Top position of the submenu division <SMEltName> 
//to the top position of the main menu division <MMEltName>
function SetSubmenuYPosition(MMEltName,SMEltName) {
  var theMainMenu = document.getElementById(MMEltName);
  var theSubmenu = document.getElementById(SMEltName);
  currentYPosition = parseInt(theMainMenu.style.top);
  theSubmenu.style.top = currentYPosition+"px";
}

//This function slides the submenu out from left to right.
function SlideSubmenuOut(SMEltName) {
  //alert(SMEltName);
  var theSubmenu = document.getElementById(SMEltName);

  //alert(currentXPosition);
  var pxInterval = 4;
  currentXPosition = parseInt(theSubmenu.style.left)+pxInterval;
  if (currentXPosition > 144) {
	 openIntervalID = self.clearInterval(openIntervalID);
  } else {
  //alert(currentXPosition);
    theSubmenu.style.left = parseInt(currentXPosition)+"px";
  }
  isSubmenuOpen = 1;
}


//This function slides the submenu in from right to left.
function SlideSubmenuIn(SMEltName) {
    //alert(SMEltName);
    var theSubmenu = document.getElementById(SMEltName);
    //alert(currentXPosition);
    var pxInterval = 4;
    currentXPosition = parseInt(theSubmenu.style.left)-pxInterval;
    if (currentXPosition < 0) {  
       theSubmenu.style.left = 0;
	   theSubmenu.style.visibility = "hidden";
	   closeIntervalID = self.clearInterval(closeIntervalID);
    } else {
    //alert(currentXPosition);
      theSubmenu.style.left = parseInt(currentXPosition)+"px";
    }
}


function OpenSubmenu2(SMEltNm) {
  var theSubmenu = document.getElementById(SMEltNm);
  currentSubmenu = theSubmenu.id;
  theSubmenu.style.visibility = "visible";
  openIntervalID = self.setInterval(function(){SlideSubmenuOut(SMEltNm)}, 10);
}

function OpenSubmenu(SMEltNm) {
  var theSubmenu = document.getElementById(SMEltNm);
  currentSubmenu = theSubmenu.id;
  theSubmenu.style.visibility = "visible";
}

function HideSubmenu(SMEltNm) {
//	if (isSubmenuOpen == 1) {
//  closeIntervalID = self.setInterval(function(){SlideSubmenuIn(SMEltNm)}, 10);
  var theSubmenu = document.getElementById(SMEltNm);
  theSubmenu.style.visibility = "hidden";
  //theSubmenu.style.left = "0px";
  currentSubmenu = "Nothing";
}

function setPage(pageSource)
{
	var theIFrame = document.getElementById("PageContent");
	theIFrame.src = pageSource;
	//var thePrintFriendly = document.getElementById("PrinterFriendly");
	//thePrintFriendly.href = pageSource;
}

/*
  if (SMEltNm == '#')
  {
	var i = 0;
	var chkSubs = new Array();
	
	chkSubs[0] = document.getElementById('LocationSub');
	chkSubs[1] = document.getElementById('TourismSub');
	chkSubs[2] = document.getElementById('EventsSub');
	chkSubs[3] = document.getElementById('NewsSub');
	
	for (i=0; i<chkSubs.length; i++)
	{
		var chkSub = chkSubs[i];
		chkSub.style.visibility = "hidden";
		chkSub.style.left = 0;
	}
  }
  
  function SlideSubmenu2(SMEltName) {
  //alert(SMEltName);
  var currentXPosition = 0;
  
  var pxInterval = 4;
  while (currentXPosition<=142) {
    var theSubmenu = document.getElementById(SMEltName);
    var currentXPosition = parseInt(theSubmenu.style.left);
  //alert(currentXPosition);
    theSubmenu.style.left = parseInt(currentXPosition+pxInterval)+"px";
    //currentXPosition = parseInt(theSubmenu.style.left);
  }

}
  */
