function newWin(url,windowName,settings)
{
	var newWin = window.open(url,windowName,settings);
    newWin.focus();
}  


function checkBrowserVersion()
{
	if (document.getElementById && navigator.appName == "Netscape")
		return "NS6";
	else if (document.layers)
		return "NS4";
	else if (document.all)
		return "IE";
	else
		return "unknown";	
}

function MM_openBrWindow(theURL,winName,features) 
{ //v2.0
  var newWin = window.open(theURL,winName,features);
  newWin.focus();
}

function MM_closeBrWindow() 
{ //v2.0
  this.close();
}
function MM_checkBrowser() 
{ //v3.0
  verStr=navigator.appVersion, 
  app=navigator.appName, 
  version = parseFloat(verStr);
  if (app.indexOf('Netscape') != -1) 
  {
	return 0;
  } 
  else if (app.indexOf('Microsoft') != -1)
  {
	return 1;
  } 
  else
  {
	return -1; // other than IE or Netscape
  }
	  	
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function convertJSDate(type,value)
{
  returnString = "";
  if (type == "month")
  {
 	  if (value < 10)
		   value++; 
  }
  returnString = value.toString();
	if (returnString.length == 1)
	 		returnString = "0" + returnString;
	return returnString;
}

function redirectURL(theForm, url)
{
	theForm.action=url;
}

function redirect(url)
{
	window.location.href = url;
}


function populateSchedForm(theForm)
{
	tempDate = new Date();
	if (theForm.scheduleDate.value == "")
	{	
		theForm.scheduleDate.value = tempDate.getFullYear() + "-"
		+ (tempDate.getMonth() < 9 ? '0' : '') + (tempDate.getMonth() + 1) + "-"
		+ (tempDate.getDate() < 10 ? '0' : '') + tempDate.getDate();
	}
		
}
function populateTripForm(theForm)
{
	tempDate = new Date();
	if (theForm.travelDate.value == "")
	{	
		theForm.travelDate.value = tempDate.getFullYear() + "-"
		+ (tempDate.getMonth() < 9 ? '0' : '') + (tempDate.getMonth() + 1) + "-"
		+ (tempDate.getDate() < 10 ? '0' : '') + tempDate.getDate();
		
		hours = tempDate.getHours();
		minutes = tempDate.getMinutes();	
		tempMinutes = roundMinutes(minutes,'roundUp');
	
		switch(tempMinutes)
		{
			case 0: case 60:
				theForm.minutes.value = '00';
			break;
			
			case 5: case 65:
				theForm.minutes.value = '05';
			break;
			
			default:
				theForm.minutes.value = tempMinutes;
			break;
		}
	
		if (tempMinutes >= 60)
			hours++;
			
		if (hours < 12)
		{
			theForm.timeperiod[0].checked = true;
			if (hours == 0)
				hours += 12;
		}
		else if (hours >= 12 && hours < 24)
		{
			if (hours != 12)
				hours -= 12;
			theForm.timeperiod[1].checked = true;
		}
		else if (hours >= 24)
		{
			if (hours == 24)
				hours = 12;
			else
				hours -= 24;
			theForm.timeperiod[0].checked = true;	
		}
		theForm.hours.value = hours;
	}
}

function roundMinutes(minValue,type)
{
	remainder = minValue % 5;

	if (remainder == 0)
		return minValue;
	else
	{
		if (type == 'roundUp')
			return minValue + 5 - remainder;
		else
			return minValue - remainder;
	}
}

function clickIt(theForm)
{
	theForm.timeperiod[4].checked = true;
}

function trim(theString) 
{
	while (theString.substring(0,1) == " ")
		theString = theString.substring(1,theString.length);
	while (theString.substring(theString.length-1,theString.length) == " ")
		theString = theString.substring(0,theString.length-1);
	return theString;
}
