var pb  // postback value - set to 1 to flag for postback

function SetUpRedirect() {
//       The URL between the quotation 
//          marks needs to be changed.
var destination = "http://FlowTo.info/";
//       Pause can be changed by specifying a 
//          different number of milliseconds.
setTimeout("window.location='"+destination+"'",4000);
return true;
}



function setString(ddl,hval)
//ddl is a dropdown list
//Sets the hiddenvalue (hval) on the default page
//based on the selected value in ddl
{      
    for (var i=0;i<ddl.children.length;i++)
    {if (ddl.children(i).selected==true){y=ddl.children(i).value}}   
    objModel = document.getElementById(hval);
    objModel.value = y;
}


function mnuMain(val)
{
  objPage = document.getElementById('pageString');	
  bval = false;
  pb=1;
  switch(val)
  {
  case 'SettingsPage':
		objPage.value = 'Settings';
		break;
  case 'GcxPage':
		objPage.value = 'GCX';
		break;
  case 'ParametersPage':
		objPage.value = 'Parameters';
		break;		
  case 'ImportPage':
		objPage.value = 'Import';
		break;						
  case 'ScenarioPage':
		objPage.value = 'Scenario';
		break;		
  case 'SimulationPage':
		objPage.value = 'Simul';
		break;
  case 'ResultsPage':
		objPage.value = 'Results';
		break;
  case 'Register':
  		objPage.value = 'Register';		
  		break;
  case 'Logout':
  		objPage.value = 'Logout';
		break;
  case 'AdminPage':
  		objPage.value = 'Admin';
		break;
  case 'showUserHelp':
		popUpUserHelp();
		pb=0;  // no postback
		break;  
  case 'showReference':
  	    popUpReference();
		pb=0;  // no postback
		break;  
  case 'AB':
		popUpAbout();
		pb=0; // no postback
		break;		
  default:
      bval = true;
  }
  return bval;
}

function mnuWelcome(val)
{    
  objWelcome = document.getElementById('actionValue');	  
  objWelcome.value = val;
  __doPostBack('','');	
}

function setAction(val)
{    
  objWelcome = document.getElementById('actionValue');	  
  objWelcome.value = val;    
}

function mnuSettings(item)
{
	vw = document.getElementById('settingsViewValue');
	if (item.Value != null)
	{bval = mnuMain(item.Value);
	if (bval==true)	
	{
     switch(item.Value)
	 {
	   case 'viewCorr':
			vw.value= 101;
			break;
		case 'viewReg':
		    vw.value= 101;
			break;
	   case 'viewScen':
			vw.value= 102;
			break;
	   case 'viewRes':
			vw.value= 103;
			break;
	   case 'ReDef':
			setAction(1);	// Re-load defaults
			break;
		case 'SetDef':
			setAction(2);	// Set current as defaults
			break;
		case 'DownloadDS':
			setAction(3);	// Download dataset
			break;
		case 'UploadDS':
			setAction(4);	// Upload dataset
			break;
		default:
	 }						//end switch
	}						//end if - bval
   	if (pb==1) __doPostBack('lbPage','');			  
  }							//end if - not null
}							//end mnuSettings


function mnuGCX(item)
{
	vw = document.getElementById('gcxViewValue');
	if (item.Value != null)
	{bval = mnuMain(item.Value);
	if (bval==true)	
	{
     switch(item.Value)
	 {	   
		case 'addnewCrossing':
			setAction(83);	// 
			break;	
		case 'QuickImport':
		    popupQuickImport();
		    vw = document.getElementById('gcxResetValue');
		    vw.value="999"
		    pb = 0; // no postback
		    break;
		case 'DefCostsSelected':
		    setAction(84);	// Set default costs for selected crossing
			break;	
		case 'DefCostsAll':
		    setAction(85);	// Set default costs for all crossings
			break;			
		case 'GCXreport':
		    popUpPDF('Corridor');	// 
		    pb = 0; // no postback
			break;			
		case 'RGCXreport':
		    popUpPDF('Region');	// 
		    pb = 0; // no postback
			break;			
		case 'HSRreport':
		    popUpPDF('HSR');	// 
		    pb = 0; // no postback
			break;
        case 'CapPlanReport':
		    popUpPDF('CapPlan');	// 
		    pb = 0; // no postback
			break;
		case 'CapPlanRReport':
		    popUpPDF('CapPlanR');	// 
		    pb = 0; // no postback
			break;
	    default:
	 }						//end switch
	}						//end if - bval
   	if (pb==1) __doPostBack('lbPage','');			  
  }							//end if - not null
}	


function mnuViewGcx(x,val)
{
    vt = document.getElementById(x);
    if (vt.value != '-999')
	{
	    vw = document.getElementById('gcxViewValue');
	    vw.value= val;         
	    __doPostBack('','')
	}
}


function mnuParameters(item)
{
  vw = document.getElementById('strategiesViewValue');
if (item.Value != null)
	{bval = mnuMain(item.Value);
	if (bval==true)	
	{switch(item.Value)
	 {		
		case 'ParamsReport':
		    popUpPDF("Params");
			pb=0;
			break;
		default:
     }								//end switch
    }								//end if-then clause
   if (pb==1) __doPostBack('lbPage','');			  
  }									//end if - not null	  
}									//end mnuParameters

function mnuScenario(item)
{
if (item.Value != null)
	{bval = mnuMain(item.Value);
	if (bval==true)	
	{switch(item.Value)
	 {
		case 'ScenReport':
			popUpPDF("Scen");
			pb=0;
			break;		
		default:
	  }								//end switch
	}								//end if-then clause
  	if (pb==1) __doPostBack('lbPage','');			  
  }									//end if - not null	  
}									//end mnuScenario

function mnuSimul(item)
{
 if (item.Value != null)
	{bval = mnuMain(item.Value);
	if (bval==true)	
	{switch(item.Value)
	 {
	 default:
	 }									//end switch
	}									//end if-then clause
    if (pb==1) __doPostBack('lbPage','');			  
   }									//end if - not null	  
}										//end mnuSimul

function mnuImport(item)
{
 if (item.Value != null)
	{bval = mnuMain(item.Value);
	if (bval==true)	
	{switch(item.Value)
	 {
	 default:
	 }									//end switch
	}									//end if-then clause
    if (pb==1) __doPostBack('lbPage','');			  
   }									//end if - not null	  
}	

function mnuResults(item)
{   
   if (item.Value != null)
	{bval = mnuMain(item.Value);
	if (bval==true)	
	{switch(item.Value)
	 {
  case 'ResReport':
    popUpPDF("Res");
    pb=0;
	break;
  case 'ResCSV':
    setAction(91);	// Download results
    break;			    
  default:
     }								//end switch
    }								//end if-then clause
  	if (pb==1) __doPostBack('lbPage','');			  
 }									//end if - not null	  
}									//end mnuResults

function mnuRegister(item)
{ 
 if (item.Value != null)
	{bval = mnuMain(item.Value);
	if (bval==true)	
	{switch(item.Value)
	 {	
	 default:
	 }									//end switch
	}									//end if-then clause
    if (pb==1) __doPostBack('lbPage','');			  
   }									//end if - not null	  
}										//end mnuRegister - UpdateInfo


function mnuAdmin(item)
{ 
 if (item.Value != null)
	{bval = mnuMain(item.Value);
	if (bval==true)	
	{switch(item.Value)
	 {	
	 default:
	 }									//end switch
	}									//end if-then clause
    if (pb==1) __doPostBack('lbPage','');			  
   }									//end if - not null	  
}										//end mnuSimul

function mnuNew(item)
{   
   if (item.Value != null)
	{bval = mnuMain(item.Value);
	if (bval==true)	
	{switch(item.Value)
	 {
	 default:
     }								//end switch
    }								//end if-then clause
  	if (pb==1) __doPostBack('lbPage','');			  
 }									//end if - not null	  
}									//end mnuNew

function mnuGcxData(val)
{
  objPage = document.getElementById('gcxdataString');	
  bval = false;
  objPage.value = 'GCX_' + val; 
 __doPostBack('lbPage',''); 
}