/**********************************************
javascript from Highland Park UMC (http://www.hpumc.org/)
bd574a
***********************************************/

function show_drop_menu(menu_id, link_id)
{
    if (document.getElementById(menu_id)) {
        var left = getOffsetLeft(link_id) - 1 + 'px';
        var top = getOffsetTop(link_id) + document.getElementById(link_id).offsetHeight + 'px';
        document.getElementById(menu_id).style.left = left;
        document.getElementById(menu_id).style.top = top;
        document.getElementById(link_id).style.backgroundColor = '#3366ff';
        document.getElementById(menu_id).style.visibility = 'visible';
    }
}

function hide_drop_menu(menu_id, link_id)
{
    if (document.getElementById(menu_id)) {
        document.getElementById(menu_id).style.visibility = 'hidden';
        document.getElementById(link_id).style.backgroundColor = '';
    }
}

function getOffsetTop(element)
{
    el = document.getElementById(element);
    xPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function getOffsetLeft(element)
{
    el = document.getElementById(element);
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}





/**********************************************
javascript � John Millhouse (homepage.mac.com/millhouse)

function getmenu(menu) 
***********************************************/

function getmenu(menu)
{
switch(menu)
{
case "home":
	base="http://www.milfordumc.org/";
	sublink=["page04.html"];
	subname=["Help"];
	break
 
case "mission":
	base="http://www.milfordumc.org/";
	sublink=["page10.html#mission","page10.html#vision","page10.html#values"];
	subname=["Mission","Vision","Values"];
	break
 
case "aboutus":
	base="http://www.milfordumc.org/";
	sublink=["page25.html","page21.html","page22.html"];
	subname=["Pastor's Welcome","Staff","History"];
	break
 
case "happenings":
	base="http://www.milfordumc.org/";
	sublink=["page31.html","page32.html","page33.html","page34.html","page35.html","page36.html","blog/index.html"];
	subname=["Upcoming events","Calendar","Sermons","Newsletters","Documents","Committees","MUMC Blog"];
	break
 
case "directions":
	base="http://www.milfordumc.org/";
	sublink=["map.html","page40.html"];
	subname=["Google Map","Static Map"];
	break
 
case "worship":
	base="http://www.milfordumc.org/";
	sublink=["page51.html","page52.html", "page54.asp", "page55.asp"];
	subname=["Worship times","Sunday School times", "A/V Signup", "Usher Signup"];
	break
 
case "ministries":
	base="http://www.milfordumc.org/";
	sublink=["page627.html","serve/BAT.asp","page659.html","page61.html","page610.html","page67.html","page658.html","page613.html","page63.html","pray/index.html","page616.html","page617.html","page64.html","page62.html","page618.html","page68.html"];
	subname=["Afternoon Off","BAT","Cell Groups","Christian Education","Divorce Care Support Group","Driving Ministry","Milford Area Senior Center","Men's Ministries","Music Ministries","Prayer Requests","Sacred Dance","Seasoned Generation","Stephen Ministry","Youth ministries/Youth Groups","White Tops","Women's Ministries"];
	break
 
case "contact":
	base="http://www.milfordumc.org/";
	sublink=["page21.html","page72.html"];
	subname=["Staff","Committees"];
	break
 
case "media":
	base="http://www.milfordumc.org/";
	sublink=["page81.html","page82.html","page83.html"];
	subname=["Audio","Video","Pictures"];
	break
 
case "links":
	base="";
	sublink=["http://www.umc.org","http://www.neumc.org/","http://www.upperroom.org/","http://www.stephenministries.org/","http://www.churchworldservice.org/","http://www.oneyearbibleonline.com/index.html","http://www.wanakee.org"];
	subname=["United Methodist Church Online","New England Conference","The Upper Room","Stephen Ministry, St. Louis", "Church World Service","One Year Bible Online","Wanakee"];
	break

default:
	base="";
	sublink= []; 
	subname= [];
} /* End switch */
return [base, sublink, subname];
}

function initdropmenu()
{
	var allmenu = ["home","mission","aboutus","happenings","directions","worship","ministries","contact","media","links"];
	var base='http://www.milfordumc.org/';
	var head= "<li><a href='";
	var tail= "</a></li>";
	var mid="'>";
	var submenu= new Array            /* Array of submenu id */
	for (i in allmenu)
	{
	 document.write('<div id=\"drop_menu_'+allmenu[i]+'\" class=\"drop-menu\" onmouseover=\"show_drop_menu(\'drop_menu_'+allmenu[i]+'\', \''+allmenu[i]+'\')\" onmouseout=\"hide_drop_menu(\'drop_menu_'+allmenu[i]+'\', \''+allmenu[i]+'\')\">');
	 document.write('<ul>');
	 submenu=getmenu(allmenu[i]);
	 base=submenu[0];
	 sublink=submenu[1];
	 subname=submenu[2];
	 // document.write('</ul>');
	 for (i in sublink)
	 {
	 document.write(head + base + sublink[i] + mid + subname[i] + tail);
	 }
	 document.write('</ul></div>');
	}
}



/**********************************************
javascript � John Millhouse (homepage.mac.com/millhouse)

function nav(menu) writes a navigation menu on your page. 
It will set the link id for the current page to "current".
This is useful if you have alot of pages with the same navigation.
***********************************************/

function nav(menu)
{

if (menu=="") {menu="home"};
banner2(menu);

	var allmenu = new Array
	var mainlink= new Array           /* Array of main menu html filesnames */
	var mainname= new Array           /* Array of main menu display names */
	var sublink= new Array            /* Array of submenu html filesnames */
	var subname= new Array            /* Array of submenu display names */

/* Write main menu and submenu */

base= "";
allmenu = ["home","mission","aboutus","happenings","directions","worship","ministries","contact","media","links"];
mainlink=["index.html","page10.html","page20.html","page30.html","map.html","page50.html","page60.html","page70.html","page80.html","sitemap.html"];
mainname=["Home","Mission","About Us","Happenings","Directions","Worship","Ministries","Contact Us","Media","Links"];
	var base='http://www.milfordumc.org/';	   /* Path to your directory */
	var head= "<a href='";
	var tail= "</a>";
	var mid="'>";


	document.write('<div id="navigation">');
    document.write('<table style="width: 100%; background-color: #a01111" cellspacing="0" cellpadding="0" border="0">');
    document.write('<tr>');
    document.write('<td id="menu">');
    
	for (i in mainlink)   /* Loop through main menu */
	{
	 mid='\' id=\"'+allmenu[i]+'\" onmouseover=\"show_drop_menu(\'drop_menu_'+allmenu[i]+'\', \''+allmenu[i]+'\')\" onmouseout=\"hide_drop_menu(\'drop_menu_'+allmenu[i]+'\', \''+allmenu[i]+'\')\">'
	 if (allmenu[i]==menu) {head="<a class='current' href='"}
	 else {head="<a href='"}
	 document.write(head + base + mainlink[i] + mid + mainname[i] + tail);
	}
    document.write('</td>');
    document.write('</tr>');
    document.write('</table>');
	document.write('</div>');
} /* End function nav */




/**********************************************
javascript freeware

function lastupdate() writes last updated date.
***********************************************/

function lastupdate()
{
	 lastmod = document.lastModified     
	 lastmoddate = Date.parse(lastmod)  

	 if(lastmoddate == 0){document.writeln("")} 
	 else 
	 {
	 d = new Date(lastmod);
	 var text = " refresh for latest"
	 var day=d.getDate()
	 var mon=d.getMonth()
	 var year=d.getFullYear()
	 var month=new Array(12)
	 month[0]="Jan"
	 month[1]="Feb"
	 month[2]="Mar"
	 month[3]="Apr"
	 month[4]="May"
	 month[5]="Jun"
	 month[6]="Jul"
	 month[7]="Aug"
	 month[8]="Sep"
	 month[9]="Oct"
	 month[10]="Nov"
	 month[11]="Dec"
	 window.status="As of: " + day + " " + month[mon] + " " + year + text;
	 document.write("Last update: " + day + " " + month[mon] + " " + year);
	 }
}



/**********************************************
javascript � John Millhouse (homepage.mac.com/millhouse)

function footer() writes church address and email
address in the footer.  Also displays last updated
date.
***********************************************/

function footer(mirror)
{
	var valid=true;
	var sublink=["index.html","page10.html","page20.html","page30.html","map.html","page50.html","page60.html","page70.html","page80.html","sitemap.html"];
	var subname=["Home","Mission","About Us","Happenings","Directions","Worship","Ministries","Contact Us","Media","Sitemap"];
	var base='http://www.milfordumc.org/';
	var head= "<li><a href='";
	var tail1= "</a>\n";
	var tail2= "</a></li>\n";
	var tail3= "</li>\n";
	var mid="'>";
	var opage=location.pathname;
	if (opage.indexOf("Image")>0) {opage=""};
	if (opage.indexOf("outreach")>0) {opage=""};

	document.write('<div id="footer">\n');
	document.write('<ul id="footnav">\n');
	 for (i=0;i<sublink.length;i++)
	 {
	 document.write(head + base + sublink[i] + mid + subname[i] + tail2);
	 }
	document.write('</ul>\n');
	document.write('<p>Milford United Methodist Church,<br /><a href="http://www.milfordumc.org/map.html">327 North River Road</a>, Milford, NH 03055<br />\n');
	document.write('Mailing address: P.O. Box 476, Milford, NH 03055<br />\n');
	document.write('Church (603) 673-2669, Church Fax (603) 673-9372<br />\n');
	document.write('Church Office Hours - M-F 10am-2pm<br />\n');
	document.write('Email:  <a href="mailto:pastor@milfordumc.org">Pastor</a> | <a href="mailto:office@milfordumc.org">Church</a> | <a href="mailto:milfordumc@me.com">Webmaster</a></p>');
	if (mirror=="asp") {
	 document.write('<p></p>')
	 }
	else {
	 document.write('<p>');
	 lastupdate();
	 document.write('</p>');
// 	 document.write("<br /><a href='http://homepage.mac.com/milfordumc" + opage + "'>Mirror site</a></p>")
	 }
 
	 if (valid) {
	 document.write('<div class="valid"><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.milfordumc.org/images/valid-xhtml10-blue.png" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a></div>\n');}

	document.write('</div>\n');

	var browser=navigator.platform
 
	if (browser == "iPhone") 
	{replacejscssfile("../mobile.css", "../iphone.css", "css");
   replacejscssfile("mobile.css", "iphone.css", "css")  }

	initdropmenu();
}




    
/**********************************************
javascript � John Millhouse (homepage.mac.com/millhouse)

The Cross and Flame is a registered trademark and the use 
is supervised by the General Council on Finance and Administration 
of The United Methodist Church. Permission to use the Cross and 
Flame must be obtained from the General Council on Finance and 
Administration of The United Methodist Church - Legal Department, 
1000 17th Avenue South Nashville, TN 37212.

function banner() 
***********************************************/

function banner(menu)
{

}


function banner2(menu)
{
	document.write('<div id="banner" class="' + menu + '">\n');
	 document.write('<div id="mainlink"><p><a href="http://www.milfordumc.org/blog/index.html">Blog</a> | <a href="http://www.milfordumc.org/pray/prayreq.asp">Pray</a> | <a href="http://www.milfordumc.org/give/index.html">Give</a> | <a href="http://www.milfordumc.org/serve/volreq.asp">Serve</a></p><form style="margin-top:4px;margin-bottom:4px" method="get" name="searchform" action="http://www.google.com/search" target="_blank"><input type="hidden" name="sitesearch" value="www.milfordumc.org" /><input type="text" style="width:130px" name="as_q" size="20" />&nbsp;<input style="width:auto;font-weight:bold" type="submit" value="search"/></form></div>');
	document.write('</div>'); 
}


/**********************************************
http://www.javascriptkit.com - Comprehensive
JavaScript tutorials and over 400+ free scripts.
***********************************************/

function createjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 return fileref
}

function replacejscssfile(oldfilename, newfilename, filetype){
 var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type to create nodelist using
 var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding attribute to test for
 var allsuspects=document.getElementsByTagName(targetelement)
 for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove
  if (allsuspects[i] && allsuspects[i].getAttribute(targetattr)!=null && allsuspects[i].getAttribute(targetattr).indexOf(oldfilename)!=-1){
   var newelement=createjscssfile(newfilename, filetype)
   allsuspects[i].parentNode.replaceChild(newelement, allsuspects[i])
  }
 }
}

function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

// replacejscssfile("oldstyle.css", "newstyle", "css") 
// Replace all occurences "oldstyle.css" with "newstyle.css"
// loadjscssfile("mystyle.css", "css") 
//
// dynamically load and add this .css file










