/*
	This is the javascript file for the FMCSA Web site
*/

/* Printing Functions */
		var oPrintWindow = null;
		function Print(sPage)
		{
			if (oPrintWindow != null && oPrintWindow.closed == false)
				oPrintWindow.close();
			var oPrintWindow = window.open("/print.asp?URL="+sPage, "fmcsa_PrintWindow", "height=680, width=680, resizable=yes, dependent=yes, scrollbars=yes");
		}

		var js_url

		function print_appendix(sPage) {

				window.open(sPage , 'fmcsa_PrintWindow', 'height=680, width=680, resizable=yes, dependent=yes, scrollbars=yes')

		}

		function PrintURL(sPage)
		{
			if (oPrintWindow != null && oPrintWindow.closed == false)
				oPrintWindow.close();
			var oPrintWindow = window.open(sPage, "fmcsa_PrintWindow", "height=680, width=800, resizable=yes, dependent=yes, scrollbars=yes");
		}

/* Formatting Functions */

		function fixTD()
		{
			var theight = -1;
			for (var i=0; i < document.all.length; i++) {
				
				if(document.all.item(i).id.toString() == "TOCTop") {
					theight = document.all.item(i).offsetHeight;
				} 
				
				if(document.all.item(i).id.toString() == "toc1") {
					document.all.item(i).height = theight - document.all.item(i).offsetTop-5;
				}
			}			
        }

/* Search Functions */

		function clearSearch()
		{
			var txtSearch ;
			var txtSearch=document.getElementById("q");
			
			txtSearch.value=txtSearch.value.replace(/^ */, "").replace(/ *$/, "");
			//if (txtSearch.value.toLowerCase() == "Search This Site".toLowerCase())
				txtSearch.value = "";
        }

		function fillSearch()
		{
			var txtSearch ;
			var txtSearch=document.getElementById("q");
			
			txtSearch.value=txtSearch.value.replace(/^ */, "").replace(/ *$/, "");
			if (txtSearch.value.toLowerCase() == "".toLowerCase())
				txtSearch.value = "Search All FMCSA Sites";
        }
        
/* Date Format */

		function print_date(){
			var cur_date = new Date();
   			var hours = cur_date.getHours();
   			hours -= 5;
			cur_date.setHours(hours);
			var monthName = new Array("January", "February", "March", "April",
   			 							"May", "June", "July", "August", "September",
   										"October", "November", "December");
			var cur_month=cur_date.getMonth();
			cur_day = cur_date.getDate();
			var suffix = "th";
			if ((cur_day == 1) || (cur_day == 21) || (cur_day == 31)) {
				suffix = "st"
			} else if ((cur_day == 2)  || (cur_day == 22)) {
					suffix = "nd"
					}
					else if ((cur_day == 3) || (cur_day == 23)) {
						suffix = "rd"
						}
			suffix = "";
			/* var GMTtime = new Date();*/
			document.write(monthName[cur_month] + '&#160;' + cur_day + suffix + ',&#160;' + cur_date.getFullYear());
			/* document.write ('<br/>' + GMTtime.getMonth() + '&#160;' + GMTtime.getDate() + '&#160;' + GMTtime.getFullYear() + '&#160;' + GMTtime.getHours()) */
		}        
		
function search_rules() {
	document.google.Google_URL.value = "http://google.dot.gov/search?q=site:www.fmcsa.dot.gov/rules-regulations/administration/fmcsr/ " + document.google.q1.value + "&num=1000&btnG=Search&site=DOT_Pages&output=xml&client=DOT_Pages&filter=0";
	<!--alert(document.google.Google_URL.value); -->
	document.google.submit();
	 return true;
   }