//Open input url in window which is input height by input width
function openURL(URL,h,w) //url,height,width
{
	var openURL = window.open(URL,'','scrollbars=yes,menubar=no,height='+h+',width='+w+',resizable=yes,toolbar=no,location=no,status=no');
}

function SetAsHomepage()
{
	// If it's Internet Explorer, use automatic link
	// Be sure to change the "http://www.YourWebSiteHere.com\"
	// to the URL you want them to bookmark.
	if (document.all){
	document.write('<A HREF="javascript:history.go(0);" onClick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'http://intra.co.marion.or.us\');">');
	document.write('<font size="2" color="#3333cc" face=arial><B>Click here to make this your homepage</B></font></a>');
	}

	// If it's Netscape 6, tell user to drag link onto Home button
	// Be sure to change the "http://www.YourWebSiteHere.com\"
	// to the URL you want them to bookmark.
	else if (document.getElementById){
	document.write('<a href="http://intra.co.marion.or.us">Drag this link onto your Home button to make Marion County Intranet your homepage.</a>');
	}

	// If it's Netscape 4 or lower, give instructions to set Home Page
	else if (document.layers){
	document.write('<b>Make Marion County Intranet your homepage:</b><br>- Go to <b>Preferences</b> in the <B>Edit</B> Menu.<br>- Choose <b>Navigator</b> from the list on the left.<br>- Click on the <b>"Use Current Page"</b> button.');
	}

	// If it's any other browser, for which I don't know the specifications of home paging, display instructions
	else {
	document.write('<b>Make Marion County Intranet your homepage:</b><br>- Go to <b>Preferences</b> in the <B>Edit</B> Menu.<br>- Choose <b>Navigator</b> from the list on the left.<br>- Click on the <b>"Use Current Page"</b> button.');
	}
	//  End -->
}

//auto resize Iframe height to fit content
function autofitIframe(id)
{
	try
	{
		parent.document.getElementById(id).style.height="300px";
		parent.document.getElementById(id).style.height=(this.document.body.scrollHeight - 60)+"px";
	}
	catch(err)
	{
		parent.document.getElementById(id).style.height="600px";
		//if (!window.opera && !document.mimeType && document.all && document.getElementById)
		//{ 	
		//	parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px"; 
		//}
		//else if(document.getElementById)
		//{ 
		//	parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px"; 
		//}
	}
}

//resize iFrame to inner document height
function setIframeHeight(iframeName,iframeNumber)
    {
        try
        {
        document.domain = "co.marion.or.us";
        var iframeWindow = window.frames[iframeName];
        if (!iframeWindow)
        {
            iframeWindow = window.frames[iframeNumber];
        }
        var iframeElement = document.getElementById(iframeName);
        if ( iframeElement && iframeWindow )
        {
            var dHeight = 0;
            if (iframeWindow.document.height)
            {
                dHeight = iframeWindow.document.height;
            }
            else if (iframeWindow.document.body)
            {
                if (iframeWindow.document.body.scrollHeight)
                {
                    dHeight = iframeWindow.document.body.scrollHeight;
                }
            }
        }
        if (dHeight)
        {
            iframeElement.style.height = dHeight + 10 + "px";
        }
        }
        catch(err)
        {
            //do nothing
        }
    }

//show or hide document elements
function ShowHide(eID)
{
	objElement = document.getElementById(eID)
	
	if (objElement.style.display == 'none')
	{
		objElement.style.display = '';
	}
	else
	{
		objElement.style.display = 'none';
	}
}

//build Google Directions form
function BuildGoogleDirectionsForm(sLatitude,sLongitude,sLocationName)
{
	document.write('Type your full starting address<br />');
	document.write('<input id="txtStartAddress" size="40" name="txtStartAddress" /><br /><br />');
	document.write('Language: <select size="1" name="ddlstLanguage">');
	document.write('<option value="en" selected>English</option>');
	document.write('<option value="fr">French</option>');
	document.write('<option value="ru">Russian</option>');
	document.write('<option value="de">German</option>');
	document.write('<option value="ja">Japanese</option>');
	document.write('<option value="es">Spanish</option></select><br /><br />');
	document.write('<input onclick="window.open(\'http://maps.google.com/maps?saddr=\'+document.getElementById(\'txtStartAddress\').value+\'&amp;daddr=\'+\''+sLatitude+','+sLongitude+' ('+sLocationName+')\'+\'&amp;hl=\' + document.getElementById(\'ddlstLanguage\')[document.getElementById(\'ddlstLanguage\').selectedIndex].value);return false;" type="button" value="Get Directions" name="btnSubmit" /><br />');
	document.write('<font size="-1">Powered by Google™<br /><br />');
	document.write('These driving directions are provided as a ' +
			'general guide only. No representation is made or warranty given as ' +
			'to their content, road conditions or route usability or ' +
			'expeditiousness. You may find that construction projects, traffic, ' +
			'weather, or other events may cause conditions to differ from the map ' +
			'results, and you should plan your route accordingly. The user ' +
			'assumes all risk of use.</font>');
}