// VARIABLES THAT SHOULD BE SET FOR THIS SITE
var domain = 'amishpassport';
var navWidth = 0;

// POP-UP BOX FOR DISCOUNTS
function popBox(foo) {
	alert(foo);
}

// POP-UP WINDOW SCRIPT
function popup(file,name,wide,high) {
	window.open(file,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+wide+',height='+high)
}

// FORM ACTIVATION SCRIPT
function activate(brillig) {
	document.getElementById('config').name = "config";
	document.getElementById('config').value = brillig;
}

// SWITCHES DROP-DOWN MENUS ON
function menuSwitch(foo) {
	menuOff();
	document.getElementById('submenu'+foo).style.display = 'block';
	document.getElementById('submenu'+foo).style.visibility = 'visible';
	document.getElementById('submenu'+foo).style.width = (document.getElementById('link'+foo).offsetWidth-2) + 'px';
	
	navWidth = 0;
	for (i=0 ; i<(foo-1) ; i++) {
		if (document.getElementById('nav2').childNodes[i].id === 'link'+(i+1)) navWidth = navWidth+document.getElementById('nav2').childNodes[i].offsetWidth;
	}
	document.getElementById('submenu'+foo).style.marginLeft = (navWidth+15) + 'px';
}

// KILLS ALL DROP-DOWN MENUS
function menuOff() {
	var submenus;
	submenus = document.getElementsByTagName('ul');
	for (i=0 ; i<submenus.length ; i++) {
		if (submenus[i].className === 'hidden') submenus[i].style.display = 'none';
		if (submenus[i].className === 'hidden') submenus[i].style.visibility = 'hidden';
	}
}

// POPS UP THE POPUP WINDOW
function popme() {
	document.getElementById('popup').style.display = 'block';
}

// REPLICATE ALL FACTS HERE. MAKE SURE THE CLASS MATCHES THE ARRAY NAME.
facts = new Array();
facts[0] = '<p class="facts0">Between 1720 and 1755, around 300 Amish came to America through William Penn\'s invitation. He recognized their excellent farming abilities and believed that agriculture would be the economic success for the new land. The Amish welcomed a place to freely worship and live as they believed right without persecution. By 1860, over 3,000 Amish had migrated from Europe to America.</p>';
facts[1] = '<p class="facts1">Today over 90,000 Amish populate 20 of the United States, with Ohio, Pennsylvania and Indiana being the most inhabited.</p>';
facts[2] = '<p class="facts2">To be Amish, one good rule of thumb is not to have any unnecessary permanent physical attachments to the outside world.  This is why they do not have electricity, water or gas lines. The closest physical connection they have to the outside world is a farm lane.</p>';
facts[3] = '<p class="facts3">A prevailing mindset of the Amish is to live simply and practically. This is fleshed out in so many different ways.</p><ul><li>Amish use only gloss paint for their walls because it is easy to wash down.</li><li>Amish women and little girls wear aprons to keep their dresses cleaner so they don\'t have as many clothes to wash. </li><li>The Amish men wear suspenders to help hold their pants up so that the women don\'t have to sew zippers.  They sew only with hook and eye closures.</li><li>A wooden bench is used at the kitchen table along the one side so that more children can sit on it and less chairs are needed.</li><li>Amish women decorate with green plants rather than cut flowers. They believe flowers are meant to be planted outside and enjoyed outside. They last longer and cost less.</li><li>Beautiful calendars of farm scenes are also used for decoration in their homes. Again, low cost, plus they update monthly.</li><li>Only a couple sewing patterns are used to make clothing so that it goes faster when a new article is needed.</li></ul>';
facts[4] = '<p class="facts4">There are 3 main types of Amish buggies: the market wagon, the family buggy and the courting buggy. The market wagon is a hatchback so it can haul produce and equipment. While family buggy styles differ from one state to another, their individual characteristics have not changed in the last 50 years.  The courting buggy is just a two-seater, and is open. </p>';
facts[5] = '<p class="facts5">A great way to meet new friends and enjoy the day off if you are Amish is to go to a local farm sale. You can catch a good sale, make some money and shoot the breeze all in one place.  If you are visiting, try to coordinate your visit over one of these events. They are fun to go to and who knows, you may end up buying something yourself.</p>';
facts[6] = '<p class="facts6">Amish worship style is just as simple, practical and community-oriented as the rest of their lives. Worshipping God can take place anywhere, so why build another building for it? From this practical mindset, they worship in homes or barns. Often districts are made up of 25 families who take turn hosting. The handmade wooden benches are carted along with the hymnals to the next meeting place, in a specially made wagon. The host is also responsible to provide a meal. Bologna, cheese, handmade bread, canned produced such as pickles and red beets are spread out. And don\'t forget dessert! Pies, bread pudding and such line the other half of the table.</p>';
facts[7] = '<p class="facts7">Worship services are spoken in German and singing is in a Gregorian type chant. Poems are also read from the Ausbund, which is a collection written by Anabaptists while in prison and printed in 1564. </p><p>Singing and announcements prelude to two sermons preached by two different preachers. Prayer is offered in a kneeling position with elbows resting on the bench while one preacher prays out loud. Another song ends the service and ushers the women to busily prepare for the noon meal. </p><p>After lunch, adults and children go home to take care of the farm chores, while youth congregate to play ball and chat.</p>';
facts[8] = '<p class="facts8">Receiving an education means learning basic needs for life as a farmer, mother, housewife and business owner. A single lady with an eighth-grade education will teach twenty to thirty pupils in grades one thru eight. In 1972, the Supreme Court ruled that the Amish did not have to go to school after eighth grade. After this point, many boys and girls become full time helpers on the farm, in the family business, and in keeping the home. Many school years end with a picnic day on a neighboring farm. Parents, children and the teacher join in a festive day of good food and games for all.</p>';
facts[9] = '<p class="facts9">Amish women wear one style of dress and usually have only a few dresses. One for wash, one for wear, one for dress, and one for spare is all that is really needed. The dresses will all be solid colored worn with a white apron if single or black if you are married. </p>';
facts[10] = '<p class="facts10">Amish men wear "plain" suit coats that do not have any collars, buttons or lapels. The Amish, being pacifists, will not wear anything that represents a military uniform.  The coat and vest is closed with a hook and an eye. Their pants will close with either 12 or 14 buttons, unlike the military standard of 13.  </p>';
facts[11] = '<p class="facts11">The Amish start their day at sun up and work diligently until sun down. When daylight savings time changes, the Amish don\'t bother to change their clocks. They also don\'t bother with alarm clocks. The rooster starts crowing at daybreak and the shining sun is alarm enough to start the day\'s work. Similarly, when the sun goes down, there is no need to stay up longer. Gas lamps are lit to finish up dinner dishes, the chores and some homework. In general though, when the sun goes down, the Amish retire from a hard day\'s work.</p>';

// REPLICATE ALL TIPS HERE. MAKE SURE THE CLASS MATCHES THE ARRAY NAME.
tips = new Array();
tips[0] = '<p class="tips0">Many establishments are closed on Sunday. Enjoy a day like the Amish do, by relaxing, going for a picnic in the countryside or simply spending time with the family and friends you have traveled with. You may also feel free to take part in a Mennonite church service. Our travel consultant can direct you to a nearby church.</p>';
tips[1] = '<p class="tips1">Looking for a great picnic spot? You may want to visit the Wilderness Center, located in Wilmot. You will find a picnic area and miles of walking trails through wooded acreage.</p>';
tips[2] = '<p class="tips2">Driving in Holmes County requires a constant eye for slow moving vehicles: buggies, tractors, and bicyclists. When cresting a hill, slow down momentarily to make sure you are not approaching a buggy in your lane.</p>';
tips[3] = '<p class="tips3">If you would like to talk with an Amish person to discover more about their lifestyle, a great way to do that is by shopping at an Amish-owned business. Amish are very friendly and are often happy to become acquainted with you if you are approaching them in a normal manner and not stopping them from their tasks.</p>';
tips[4] = '<p class="tips4">Amish use bicycles as a means of transportation.  During your time visiting Amish country you will see many of them biking to and from work, or on their way to town or church. Use caution when passing them, especially on narrow back roads.</p>';
tips[5] = '<p class="tips5">Many visitors to Amish country like to stop and take pictures of the beautiful scenery. When stopping for these prime photo opportunities, take caution to park in appropriate places off the road.</p>';
tips[6] = '<p class="tips6">Amish prefer not to be photographed. When taking pictures, it is respectful to shoot scenery shots, pictures of their horses and buggies, while avoiding shots that would include face-on recognizable pictures.</p>';
tips[7] = '<p class="tips7">Looking for a unique experience on Sunday? Mennonite churches welcome visitors. You can find churches in the phone book or by calling Amish Country Travel. At most Mennonite churches, you will experience traditional singing from hymnals as well as a preaching service. Services are all held in English.</p>';
tips[8] = '<p class="tips8">During the summer in Mt Hope at the auction barn you will find an open air flea market with a parking lot filled with fresh produce stands, useful household items and where local farm boys come to buy and sell rabbits. Typically Mt Hope is a quieter town, but on auction day it is buzzing. The Amish usually use this day to also come into town for weekly grocery shopping and banking.  Visit <a href="http://www.mthopeauction.com" target="_blank">www.mthopeauction.com</a> to view upcoming auctions.</p>';
tips[9] = '<p class="tips9">Summer and autumn peak hours for local restaurants are between 11:30am and 1:30pm, and then again from 4:30 pm and 6:30pm.</p>';

function Next() {
	var objNum = '';
	for (ii=0 ; ii<facts.length ; ii++) {
		var content = document.getElementById('box1').innerHTML;
		if (content.search('facts'+ii)!==-1) objNum = 'facts'+ii;
		if (objNum!=='') {
			if (ii === (facts.length)-1) {
				document.getElementById('box1').innerHTML = facts[0];
			} else {
				document.getElementById('box1').innerHTML = facts[ii+1];
			}
		return false;
		}
	}
}

function Next2() {
	var objNum = '';
	for (ii=0 ; ii<tips.length ; ii++) {
		var content = document.getElementById('box1').innerHTML;
		if (content.search('tips'+ii)!==-1) objNum = 'tips'+ii;
		if (objNum!=='') {
			if (ii === (tips.length)-1) {
				document.getElementById('box1').innerHTML = tips[0];
			} else {
				document.getElementById('box1').innerHTML = tips[ii+1];
			}
		return false;
		}
	}
}

// MAKES THE MAIN COLUMN THE SAME HEIGHT AS THE SIDEBAR *IFF* THE SIDEBAR IS LONGER
function compare() {
	var adjustObj = '';
	var adjustHeight = 0;
	var adjustMath = 0;
	if (document.getElementById('contentBottom')) {
		adjustObj = 'contentBottom';
		adjustHeight = 22;
	}
	if (document.getElementById('home')) {
		adjustObj = 'main3';
		adjustHeight = 2;
		adjustMath = 0;
	}
	if (adjustObj !== '') {
		var mainCol = document.getElementById('main3').offsetHeight; //grab offset height for main col
		var sideCol = document.getElementById('side3').offsetHeight; //grab offset height for side col
		if ((mainCol-adjustMath) < sideCol) { //if the main col is shorter
			document.getElementById(adjustObj).style.height = (document.getElementById(adjustObj).offsetHeight + (sideCol-mainCol)-adjustHeight) + 'px'; //adjust the height of contentBottom so mainCol will be the same height in total.
		}
	}
}

// SCRIPTS THAT RUN AS SOON AS EACH INDIVIDUAL PAGE LOADS
function setup() {
	// AUTOMATICALLY OPEN EXTERNAL LINKS IN A NEW WINDOW
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var ii=0; ii<anchors.length; ii++) {
		if (anchors[ii].href.search(domain)===-1 && anchors[ii].href.search('http')!==-1) {
			anchors[ii].target = "_blank";
		}
	}
	// SETS UP SUBNAVIGATION MENUS
	var menus = '\
	<ul class="hidden" id="submenu4">\
		<li><a href="http://www.amishpassport.com/Categories/view/name/lodging">Lodging</a></li>\
		<li><a href="http://www.amishpassport.com/Categories/view/name/shopping">Shopping</a></li>\
		<li><a href="http://www.amishpassport.com/Categories/view/name/dining">Dining</a></li>\
		<li><a href="http://www.amishpassport.com/Categories/view/name/area-attractions">Area Attractions</a></li>\
		<li><a href="http://www.amishpassport.com/Categories/view/name/local">Local Patrons</a></li>\
	</ul>\
	<ul class="hidden" id="submenu5">\
		<li><a href="http://www.amishpassport.com/what-is-amish-country-travel">Overview</a></li>\
		<li><a href="http://www.amishpassport.com/philosophy">ACT Philosophy</a></li>\
		<li><a href="http://www.amishpassport.com/contact-amish-country-travel">Contact Us</a></li>\
	</ul>\
	';
 	document.getElementById('subnav').innerHTML = menus;
	compare();
	// DISPLAYS THE POPUP BOX
	if (document.getElementById('popup')) {
		setTimeout(popme,3000);
	}
}

window.onload = setup;