var originalhtml = '';
var homedir = '/';

function setuppage(){
    originalhtml=document.getElementById('submenu').innerHTML;
	var pagename = document.getElementById('pagename').innerHTML;
	writemainmenu(pagename);
}

function resettitle(){
  var docdiv = document.getElementById('submenu');
  docdiv.style.paddingLeft = 0;
  docdiv.innerHTML = originalhtml;
}

function showsubmenu(selectedmenu)
{
  var docdiv = document.getElementById('submenu');
  var submenuhtml = '';
  var leftoffset = 0;
  
  if(selectedmenu == 'school'){
    submenuhtml = ' <a href="'+homedir+'ourschool.html"> The Be Ryong Master </a>&nbsp; | &nbsp;<a href="'+homedir+'blackbelts.html"> Our Blackbelts </a> ';
	leftoffset = 30;
  }else if(selectedmenu == 'programs'){
    submenuhtml = ' <a href="'+homedir+'tkdprogram.html"> Tae Kwon Do Program Description </a> '+
		'&nbsp; | &nbsp;<a href="'+homedir+'hkdprogram.html"> Hapkido Program Description </a> ';
	leftoffset = 60;
  }else if(selectedmenu == 'media'){
    submenuhtml = ' <a href="'+homedir+'photos.html"> Photos </a> '+
		'&nbsp; | &nbsp;<a href="'+homedir+'videos.html"> Videos </a> ';
	leftoffset = 280;
  }

  docdiv.style.paddingLeft = leftoffset;
  docdiv.innerHTML = submenuhtml;
}

function writemainmenu(currentpage){
	
	var docdiv = document.getElementById("mainmenuitems");
	var menuhtml = "<table width='100%' id='topmenu'><tr>";
	if(currentpage == 'home')
		menuhtml = menuhtml + "<td><div id='selectedmenu' onmouseover='showsubmenu(&quot;home&quot;);'>Home</div></td>";
	else
		menuhtml += "<td><a href='"+homedir+"home.html' onmouseover='showsubmenu(&quot;home&quot;);'>Home</a></td>";
		
	if(currentpage == 'school')
		menuhtml += "<td><div id='selectedmenu' onmouseover='showsubmenu(&quot;school&quot;);'>Our School</div></td>";
	else
	    menuhtml += "<td><a href='"+homedir+"ourschool.html' onmouseover='showsubmenu(&quot;school&quot;);'>Our School</a></td>";
	
	if(currentpage == 'programs')
		menuhtml += "<td><div id='selectedmenu' onmouseover='showsubmenu(&quot;programs&quot;);'>Programs</div></td>";
	else
	    menuhtml += "<td><a href='"+homedir+"tkdprogram.html' onmouseover='showsubmenu(&quot;programs&quot;);'>Programs</a></td>";
	
	if(currentpage == 'media')
		menuhtml += "<td><div id='selectedmenu' onmouseover='showsubmenu(&quot;media&quot;);'>Media</div></td>";
	else
	    menuhtml += "<td><a href='"+homedir+"photos.html' onmouseover='showsubmenu(&quot;media&quot;);'>Media</a></td>"

	if(currentpage == 'resources')
		menuhtml += "<td><div id='selectedmenu' onmouseover='showsubmenu(&quot;resources&quot;);'>Resources</div></td>";
	else
	    menuhtml += "<td><a href='"+homedir+"resources.html' onmouseover='showsubmenu(&quot;resources&quot;);'>Resources</a></td>";
	
	if(currentpage == 'guestbook')
		menuhtml += "<td><div id='selectedmenu' onmouseover='showsubmenu(&quot;guestbook&quot;);'>Guest Book</div></td>";
	else
	    menuhtml += "<td><a href='"+homedir+"guestbook.html' onmouseover='showsubmenu(&quot;guestbook&quot;);'>Guest Book</a></td>";

	if(currentpage == 'contact')
		menuhtml += "<td><div id='selectedmenu' onmouseover='showsubmenu(&quot;contact&quot;);'>Contact Us</div></td>";
	else
	    menuhtml += "<td><a href='"+homedir+"contact.html' onmouseover='showsubmenu(&quot;contact&quot;);'>Contact Us</a></td>";

    menuhtml += "</tr></table>";
	
	docdiv.innerHTML = menuhtml;
}

function showimage(imgurl)
{
	var docdiv = document.getElementById("imgpopup");
	docdiv.innerHTML = "<img src='"+imgurl+"' style='background-color:black;'/>";
	docdiv.style.display = "";
}

function changevideo(videourl)
{
	var docdiv = document.getElementById("video");

	
	docdiv.innerHTML = '<object width="448" height="272">' +
  		'<param name="movie" value="' + videourl + '"></param>' +
  		'<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>'+
		'<embed src="'+videourl+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="448" height="272"></embed>' +
  		'</object>'; 
		
}

function showhide(divitem)
{
   var docdivtext = document.getElementById("sh" + divitem);
   var docdivimg = document.getElementById("pm" + divitem);
   
   if(docdivtext.style.display == "none"){
		docdivtext.style.display = "";
		docdivimg.src = "images/minus.gif";
   }else{
		docdivtext.style.display = "none";
		docdivimg.src = "images/plus.gif";

   }
}

function expandcollapseall(){

  var docdiveexporcol = document.getElementById("expcol");
  var docdivs,i, index, docdivimg, docdivtext;
  docdivs = document.getElementsByTagName("div"); 
  
  if (docdiveexporcol.innerHTML == "Collapse All")
  {
    for(i in docdivs){
	  if(docdivs[i].id != null){
	  if(docdivs[i].id.indexOf('sh') > -1){
			index = docdivs[i].id.substring(2,docdivs[i].id.length);
			docdivimg = document.getElementById("pm" + index);
			docdivtext = document.getElementById("sh" + index);
			docdivtext.style.display = "none";
			docdivimg.src = "images/plus.gif";
	  }
	  }
    }
	docdiveexporcol.innerHTML = "Expand All";
  }else{
  
    for(i in docdivs){
	  if(docdivs[i].id != null){
	  if(docdivs[i].id.indexOf('sh') > -1){
			index = docdivs[i].id.substring(2,docdivs[i].id.length);
			docdivimg = document.getElementById("pm" + index);
			docdivtext = document.getElementById("sh" + index);
			docdivtext.style.display = "";
			docdivimg.src = "images/minus.gif";
	  }
	  }
  }
  
	docdiveexporcol.innerHTML = "Collapse All";
  }
}
