function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*
  Function:   UpdateDestPorts
  Parameters    originPorts - reference to the combo box containing the origin ports
                destPorts   - combo box that will be populated with the destination ports
                destValues  - string containing the destination port id to be inserted into the destPorts
                
  loops through the origin ports and copies each port entry whose id is found in destValues.
 */
 function UpdateDestPorts(originPorts, destPorts, destValues)
 {
    // Clear the current destination ports
    while(destPorts.options.length != 1 )
    {
      destPorts.options.remove(1);
    }
        
    // Now loop through the origin ports and see which need 
    // to be added to the destination select box
    for(i=0; i<originPorts.options.length; i++ )
    {
      if ( destValues.indexOf("," + originPorts.options(i).value + ",") != -1 )
      {
        var opt = window.document.createElement("OPTION");
        opt.text = originPorts.options(i).text;
        opt.value = originPorts.options(i).value;
        destPorts.options.add(opt);
      }
    }
 }
 
 /*
  Function:       UpdateMonthDays
  Parameters      month - integer month
                  destPorts   - combo box that will be populated with the days
 */
function UpdateMonthDays(month, uiDays)
{
   var days    = new makeArray0(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
   var time    = new Date();
   var Year    = time.getFullYear();   

   // if the current month is greater than 8 (August) and the selected month is less than
   // 8 then the year is moved ahead one.
   if ( (time.getMonth() > 8) && (month < 8 ) )
      Year++;
   
    if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
         days[1] = 29;
    else
         days[1] = 28;

	if ( uiDays.options[0].text == "-")
	{
		if ( uiDays.options.length == 1 )
		{
			uiDays.options[0].text = "1";
			uiDays.options[0].value = "1";
		}
		else
		{
			if (uiDays.options[1].text != "1")
			{
				uiDays.options[0].text = "1";
				uiDays.options[0].value = "1";
			}
		}
	}
	
	if ( uiDays.options.length == days[month] )
		return;
	
	if ( uiDays.options.length > days[month] )
	{
		for( diff = uiDays.options.length - days[month]; diff != 0; diff--)
		{
			uiDays.options.remove(uiDays.options.length - diff);
		}
		return;
	}
	
   // Add the missing days to the combo box
   var i = days[month] - uiDays.options.length;
   for( diff = 1; diff <= i; diff++)
   {
        var opt = window.document.createElement("OPTION");
        opt.text = (1 + uiDays.options.length);
        opt.value = (1 + uiDays.options.length);
        uiDays.options.add(opt);
   }
}

function makeArray0() {
    for (i = 0; i<makeArray0.arguments.length; i++)
        this[i] = makeArray0.arguments[i];
}

//********************************
// Start functions for popup calendar
//********************************
   var today = new Date();
   var day   = today.getDate();
   var calWinMonth = today.getMonth();
   var calWinYear  = y2k(today.getYear());
	var uiComboMonth;
	var uiComboDay;
	
   //******* Get year
      function y2k(number) {
         return (number < 1000) ? number + 1900 : number;
      }

   //******* Format single digit number to two digits -to be used with the UpdateDepartDate function
      function RoundOut(number) {
         return (number < 10) ? '0' + number : number;
      }

   //******* Update the depart date fields -to be used with the RoundOut function
      function UpdateDate(day) {
			var count = 0;
			
			if ( uiComboMonth.options.length == 13 )
				count = 1;

			uiComboMonth.options.selectedIndex = parseInt(calWinMonth) + parseInt(count);
			UpdateMonthDays( uiComboMonth.options.selectedIndex, uiComboDay );
			uiComboDay.options.selectedIndex = day - 1;
      }

   //******* Open Calendarwindow
      function OpenCalWinDepart(folderLanguagePath, uiCombo, uiDays) {
         var attributes;
         var winX;
         var winY;
    
         // Update the month and year
         if ( (uiCombo.selectedIndex == 0) && (uiCombo.options.length == 13) )
			window.calWinMonth = today.getMonth();
		else
		{
			if (uiCombo.options.length == 13)
			{
				window.calWinMonth = uiCombo.selectedIndex - 1;
			}
			else
			{
				window.calWinMonth = uiCombo.selectedIndex;
			}
		}
         uiComboMonth = uiCombo;
         uiComboDay = uiDays;

         // Check browser
         if (navigator.appName == "Netscape") {
            // open window for netscape
            winX = (screen.availWidth - 181)*.5;
            winY = (screen.availHeight - 250)*.5;
            attributes = "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,height=250,width=161,left=";
             attributes += winX;
             attributes += ",top=";
            attributes += winY;
            myWindow = open("select_date.htm","calwin",attributes);
         }
         else {
            // open window for ie
            attributes = "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,height=250,width=161,left=";
            attributes += (window.event.clientX-167);
            attributes += ",top=";
            attributes += window.event.clientY+103;
            myWindow = open("select_date.htm","calwin",attributes);
         }
         if (myWindow.opener == null) 
			myWindow.opener = self;
         return false;
      }
     

//****************************************
//******* Open window for routes help
//****************************************
	function StartHelp(page) {
		var winX;
		var winY;
		var attributes;

			winX = (screen.availWidth - 450)*.5;
			winY = (screen.availHeight - 400)*.5;
			attributes = "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,height=400,width=450,left=";
			attributes += winX;
			attributes += ",top=";
			attributes += winY;
			myWindow = open(page,"ShowHelp",attributes);
	}

//****************************************
//	Open window for page print
//****************************************

	function OpenPagePrint(page) {
		var winX;
		var winY;
		var attributes;

			winX = (screen.availWidth - 500)*.5;
			winY = (screen.availHeight - 400)*.5;
			attributes = "toolbar=no,menubar=yes,location=no,scrollbars=yes,resizable=yes,height=400,width=500,left=";
			attributes += winX;
			attributes += ",top=";
			attributes += winY;
			myWindow = open(page,"PagePrint",attributes);
	}
	
//****************************************
//	Open window for photo viewing
//****************************************
	function OpenPhoto(page) {
		var winX;
		var winY;
		var attributes;

			winX = (screen.availWidth - 570)*.5;
			winY = (screen.availHeight - 450)*.5;
			attributes = "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,height=450,width=570,left=";
			attributes += winX;
			attributes += ",top=";
			attributes += winY;
			myWindow = open(page,"ShowPhotos",attributes);
	}
	
