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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function showBorder(obj, hide)
{
	if(hide)
		obj.style.border = "solid 0px white";
	else
		obj.style.border = "solid 1px white";
}

function underLink(obj, over)
{
	if(over){
		obj.style.textDecoration = "underline";
		obj.style.cursor = "hand";
	}else{
		obj.style.textDecoration = "none";
	}
}

function writeHeader(subdir, homeNav)
{
	
	
	document.write('<table cellspacing=0 cellpadding=0 width="820px">');
	document.write('     <tr>');
	if(subdir){
		document.write('				<td width="820px">');
		document.write('             <table width="100%" cellpadding=0 cellspacing=0>');
		document.write('                 <tr>');
		document.write('         						<td width="250px" valign=bottom>&nbsp;<img src="../images/header/nav_logo_horz.gif" /></td>');
		document.write('                     <td width="544px">');
		document.write('                         <table width="100%" cellpadding=3 cellspacing=0>');
		document.write('                             <tr>');
		document.write('                                 <td align=right class="office">Irvine <b>949.660.1994&nbsp;&nbsp;&nbsp;</b></td>');
		document.write('                             </tr>');
		document.write('                             <tr>');
		document.write('                                 <td align=right class="office">Riverside <b>951.682.8420&nbsp;&nbsp;&nbsp;</b></td>');
		document.write('                             </tr>');
		document.write('                             <tr>');
		document.write('                                 <td align=right class="office">Carlsbad <b>760.931.0664&nbsp;&nbsp;&nbsp;</b></td>');
		document.write('                             </tr>');
		document.write('                         </table>');
		document.write('                     </td>');
		document.write('                 </tr>');
		document.write('        		</table>');
		document.write('				</td>');
	}
	else{
		document.write('				<td width="820px">');
		document.write('             <table width="100%" cellpadding=0 cellspacing=0>');
		document.write('                 <tr>');
		document.write('         						<td width="250px" valign=bottom>&nbsp;<img src="images/header/nav_logo_horz.gif" /></td>');
		document.write('                     <td align="right">');
		document.write('                         <table width="100%" cellpadding=3 cellspacing=0>');
		document.write('                             <tr>');
		document.write('                                 <td align=right class="office">Irvine <b>949.660.1994&nbsp;&nbsp;&nbsp;</b></td>');
		document.write('                             </tr>');
		document.write('                             <tr>');
		document.write('                                 <td align=right class="office">Riverside <b>951.682.8420&nbsp;&nbsp;&nbsp;</b></td>');
		document.write('                             </tr>');
		document.write('                             <tr>');
		document.write('                                 <td align=right class="office">Carlsbad <b>760.931.0664&nbsp;&nbsp;&nbsp;</b></td>');
		document.write('                             </tr>');
		document.write('                         </table>');
		document.write('                     </td>');
		document.write('                 </tr>');
		document.write('        		</table>');
		document.write('				</td>');
	}
 	document.write('     </tr>');
 	
 	document.write('     <tr>');
	document.write('         <td width="820px" valign=bottom>');
	document.write('             <table width="100%" cellpadding=0 cellspacing=0>');
	document.write('                 <tr valign=bottom height="*">');
	document.write('                     <td valign=bottom >');
	document.write('                             <div id="chromemenu" class="chromestyle">');
	document.write('                                 <br/>');
	document.write('                                 <ul>');
	if(subdir){
		//document.write('                                     <li><a><img src="../images/spacer.gif" width="155px" height=1px"/></a></li>');
		document.write('                                     <li><a><img style="vertical-align:bottom" src="../images/header/nav_home.gif" onclick="document.location.href = \'../default.aspx\';" onMouseOver="MM_nbGroup(\'over\',\'home\',\'../images/header/nav_home_over.gif\',\'\',1)" onMouseOut="MM_nbGroup(\'out\')" name="home" /></a></li>');
		document.write('                                     <li><a rel="dropmenu1"><img style="vertical-align:bottom" src="../images/header/nav_services.gif" onclick="document.location.href = \'../services_overview.aspx\';" onMouseOver="MM_nbGroup(\'over\',\'services\',\'../images/header/nav_services_over.gif\',\'\',1)" onMouseOut="MM_nbGroup(\'out\')" name="services" /></a></li>');
		document.write('                                     <li><a rel="dropmenu2"><img style="vertical-align:bottom" src="../images/header/nav_experience.gif" onclick="document.location.href = \'../key_projects.aspx\';" onMouseOver="MM_nbGroup(\'over\',\'experience\',\'../images/header/nav_experience_over.gif\',\'\',1)" onMouseOut="MM_nbGroup(\'out\')" name="experience" /></a></li>');
		document.write('                                     <li><a rel="dropmenu3"><img style="vertical-align:bottom" src="../images/header/nav_company.gif" onclick="document.location.href = \'../corporate_profile.aspx\';" onMouseOver="MM_nbGroup(\'over\',\'company\',\'../images/header/nav_company_over.gif\',\'\',1)" onMouseOut="MM_nbGroup(\'out\')" name="company" /></a></li>	');
		document.write('                                     <li><a><img style="vertical-align:bottom" src="../images/header/nav_news.gif" onclick="document.location.href = \'../company_news.aspx\';" onMouseOver="MM_nbGroup(\'over\',\'news\',\'../images/header/nav_news_over.gif\',\'\',1)" onMouseOut="MM_nbGroup(\'out\')" name="news" /></a></li>	');
		document.write('                                     <li><a><img style="vertical-align:bottom" src="../images/header/nav_contact.gif" onclick="document.location.href = \'../contact.aspx\';" onMouseOver="MM_nbGroup(\'over\',\'contact\',\'../images/header/nav_contact_over.gif\',\'\',1)" onMouseOut="MM_nbGroup(\'out\')" name="contact" /></a></li>	');
	}else{
		if(homeNav){
			//document.write('                                     <li><a><img src="images/spacer.gif" width="155px" height=1px"/></a></li>');
			document.write('                                     <li><a><img src="images/header/nav_home.gif" style="vertical-align:bottom" onclick="document.location.href = \'default.aspx\';" onMouseOver="MM_nbGroup(\'over\',\'home\',\'images/header/nav_home_over.gif\',\'\',1)" onMouseOut="MM_nbGroup(\'out\')" name="home" /></a></li>');
		}else{
			//document.write('                                     <li><a><img src="images/spacer.gif" width="180px" height=1px"/></a></li>');
		}
		document.write('                                     <li><a rel="dropmenu1"><img src="images/header/nav_services.gif" style="vertical-align:bottom" onclick="document.location.href = \'services_overview.aspx\';" onMouseOver="MM_nbGroup(\'over\',\'services\',\'images/header/nav_services_over.gif\',\'\',1)" onMouseOut="MM_nbGroup(\'out\')" name="services" /></a></li>');
		document.write('                                     <li><a rel="dropmenu2"><img src="images/header/nav_experience.gif" style="vertical-align:bottom" onclick="document.location.href = \'key_projects.aspx\';" onMouseOver="MM_nbGroup(\'over\',\'experience\',\'images/header/nav_experience_over.gif\',\'\',1)" onMouseOut="MM_nbGroup(\'out\')" name="experience" /></a></li>');
		document.write('                                     <li><a rel="dropmenu3"><img src="images/header/nav_company.gif" style="vertical-align:bottom" onclick="document.location.href = \'corporate_profile.aspx\';" onMouseOver="MM_nbGroup(\'over\',\'company\',\'images/header/nav_company_over.gif\',\'\',1)" onMouseOut="MM_nbGroup(\'out\')" name="company" /></a></li>	');
		document.write('                                     <li><a><img src="images/header/nav_news.gif" style="vertical-align:bottom" onclick="document.location.href = \'company_news.aspx\';" onMouseOver="MM_nbGroup(\'over\',\'news\',\'images/header/nav_news_over.gif\',\'\',1)" onMouseOut="MM_nbGroup(\'out\')" name="news" /></a></li>	');
		document.write('                                     <li><a><img src="images/header/nav_contact.gif" style="vertical-align:bottom" onclick="document.location.href = \'contact.aspx\';" onMouseOver="MM_nbGroup(\'over\',\'contact\',\'images/header/nav_contact_over.gif\',\'\',1)" onMouseOut="MM_nbGroup(\'out\')" name="contact" /></a></li>	');
	}
	
	document.write('                                 </ul>');
	document.write('                              </div>');
	
	if(subdir){
		document.write('                             <div id="dropmenu1" class="dropmenudiv">');
		document.write('                                 <table background="../images/banners/dropdown.png" width="280px">');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="../transportation_traffic.aspx">Transportation Planning & Traffic Engineering</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="../systems_development.aspx">Information Systems & Database Development</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="../noise_air.aspx">Noise, Air Quality & Energy Studies</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="../strategic_planning.aspx">Strategic Planning & Funding Analysis</a></td>');
		document.write('                                     </tr>');
		document.write('                                 </table>');
		document.write('                             </div>');
		document.write('                             <div id="dropmenu2" class="dropmenudiv">');
		document.write('                                 <table background="../images/banners/dropdown.png" width="130px">');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="../key_projects.aspx">Key Projects</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="../client_list.aspx">Client Listing</a></td>');
		document.write('                                     </tr>');
		//document.write('                                     <tr>');
		//document.write('                                         <td><a href="../references.aspx">References</a></td>');
		//document.write('                                     </tr>');
		document.write('                                 </table>');
		document.write('                             </div>');                                           
		document.write('                             <div id="dropmenu3" class="dropmenudiv">');
		document.write('                                 <table background="../images/banners/dropdown.png" width="130px">');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="../corporate_profile.aspx">Corporate Profile</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="../guiding_principles.aspx">Guiding Principles</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="../key_personnel.aspx">Key Personnel</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="../careers.aspx">Careers</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="../ftp/ftp_login.aspx">FTP</a></td>');
		document.write('                                     </tr>');
		document.write('                                 </table>');
		document.write('                             </div>');
	}else{
		document.write('                             <div id="dropmenu1" class="dropmenudiv">');
		document.write('                                 <table background="images/banners/dropdown.png" width="280px">');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="transportation_traffic.aspx">Transportation Planning & Traffic Engineering</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="systems_development.aspx">Information Systems & Database Development</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="noise_air.aspx">Noise, Air Quality & Energy Studies</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="strategic_planning.aspx">Strategic Planning & Funding Analysis</a></td>');
		document.write('                                     </tr>');
		document.write('                                 </table>');
		document.write('                             </div>');
		document.write('                             <div id="dropmenu2" class="dropmenudiv">');
		document.write('                                 <table background="images/banners/dropdown.png" width="130px">');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="key_projects.aspx">Key Projects</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="client_list.aspx">Client Listing</a></td>');
		document.write('                                     </tr>');
		//document.write('                                     <tr>');
		//document.write('                                         <td><a href="references.aspx">References</a></td>');
		//document.write('                                     </tr>');
		document.write('                                 </table>');
		document.write('                             </div>');     
		                                     
		document.write('                             <div id="dropmenu3" class="dropmenudiv">');
		document.write('                                 <table background="images/banners/dropdown.png" width="130px">');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="corporate_profile.aspx">Corporate Profile</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="guiding_principles.aspx">Guiding Principles</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="key_personnel.aspx">Key Personnel</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="careers.aspx">Careers</a></td>');
		document.write('                                     </tr>');
		document.write('                                     <tr>');
		document.write('                                         <td><a href="ftp/ftp_login.aspx">FTP</a></td>');
		document.write('                                     </tr>');
		document.write('                                 </table>');
		document.write('                             </div>');
		

	}
	document.write('                     </td>');
	document.write('                 </tr>');
	document.write('             </table>');
	document.write('         </td>');
	document.write('     </tr>');
	document.write(' </table>	');
	document.close();
}

function showDrop(div,drop)
{
	if(drop)
		document.getElementById(div).style.display = "block";
	else
		document.getElementById(div).style.display = "none";
}

var UXR_ServerCall = false;

function SubmitFTPAccount()
{
	if(UXR_ServerCall){
		alert("Waiting for a response from the server, please wait");
		return;
	}
	var login = Trim(document.getElementById("Company_Textbox").value);
	if(login == ""){
		alert("Please enter a company name");
		return;
	}else if(login.length < 5){
		alert("Company name must be at least 5 characters");
		return;
	}
	UXR_ServerCall = true;
	urbanXroads.ftp.ftp_add.ValidateLogin(login, SubmitFTPAccount_Callback);  // asynchronous call
}

function SubmitFTPAccount_Callback(response)
{
	UXR_ServerCall = false;
	if(response.error != null){
		alert(response.error);
		return;
	}
	var ds = response.value;
	if(ds != ""){
		var conf = confirm("To prevent duplicate login names, the following logins are similar to the company name you provided:\n" +
												ds + "\n\nIf there is an existing matching login, please reuse the login or create another account. \nProceed creating FTP account?");
		if(conf)
			__doPostBack("Submit_LinkButton","");
	}else{
		__doPostBack("Submit_LinkButton","");
	}
}
			
function Trim(s) 
{
	// Remove leading spaces and carriage returns
	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r') || (s.substring(0,1) == '/'))
		s = s.substring(1,s.length);
		
	// Remove trailing spaces and carriage returns
	while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r') || (s.substring(s.length-1,s.length) == '/'))
		s = s.substring(0,s.length-1);
	return s;
}