function ToggleDisplay(elementID) {
	if(document.getElementById) { 
		if (document.getElementById(elementID).style.display == 'none')
			document.getElementById(elementID).style.display = '';
		else
			document.getElementById(elementID).style.display = 'none';
	}
}

function ToggleDirBlurb(ExpandID,ExpansionCounter) {
	document.getElementById(ExpandID).style.display = 'none';
	document.getElementById(ExpansionCounter).style.display = 'inline';
	return false;
}


function checkEmailAddress(field) {
	var good;
	var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);

	if (goodEmail) {
		good = true;
	}
	else {
		alert('Please enter a valid address.');
		field.focus();
		field.select();
		good = false;
  }
	return good;
}



function emailURL() {
	var good;
	var emailsubject="Listing I found on Bransontravelandvacation.com";
	var emailmessage= 
		document.tellfriendform.firstname.value+",%0D"+
		"%0D"+
		"Visit this page on Bransontravelandvacation.com:%0D"+
		location.href+"%0D"+
		"%0D"+
		"Sincerely,"+	"%0D"+
		"{type your name here}";

	good = checkEmailAddress(document.tellfriendform.email);

	if (good) {
		//window.location = "mailto:"+document.tellfriendform.email.value+"?subject="+emailsubject+"&body="+document.title+" "+currentwindowlocation;
		window.location = "mailto:"+document.tellfriendform.email.value+"?subject="+emailsubject+"&body="+emailmessage;
  }
}



function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}



function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}



/* ***************************************************************
		Initializes page javascripts that would otherwise cause 
		page flashing
***************************************************************** */
function init() {

	// Test for Friend forms and Page help drop-downs
	try {
		// sets drop-down containers animated by moo.fx to zero height
		window.ToggleFriendForm		= new Fx.Slide('TellAFriendContainer', {duration: 300}).hide();
		window.TogglePageHelp 		= new Fx.Slide('pagehelp', {duration: 300}).hide();
	
	} catch(e) { /* If no FriendForms on page, do nothing */ }


	// To prevent a javascript error if there is not tabbed elements on a page, we try and catch the call to initialize tabber
 	try {
		/*
		Since we specified manualStartup=true, tabber will not run after
		the onload event. Instead let's run it now, to prevent any delay
		while images load. */	
		tabberAutomatic(tabberOptions);
		
	} catch(e) { /* if tabber is not included, do nothing */ 	}
	
	try {

		window.click_count = 0;

		/* Load Google Maps for pages that need it */	
		window.onload 		= StartMap;
		window.onunload		= GUnload;
	
	} catch(e) { /* if no map is included, do nothing */ 	} 	


	// Set default tab on page
	try {
		if(location.href.contains('#blog')) {
			document.getElementById('maintab').tabber.tabShow(0);
			document.getElementById('detailstab').tabber.tabShow(0);
		} else { 
			document.getElementById('maintab').tabber.tabShow($ES('#maintab div.maintab').length - 1);
		}
		
	} catch(e) { /* if no blog anchor in URI, do nothing */ }


}

