function openFull(url,width,height,top,left)
{
	if(!width)
		width =  800;
		
	if(!height)
		height =  600;
		
    window.open(url,'',"scrollbars=yes,resizable=yes,toolbar=yes,location=yes,status=no,menubar=yes,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left);
}

function openMedium(url,width,height,top,left)
{
	if(!width)
		width =  800;
		
	if(!height)
		height =  600;
		
    window.open(url,'',"scrollbars=yes,resizable=yes,toolbar=no,location=no,status=no,menubar=yes,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left);
}

function openSimple(url,width,height,top,left)
{
	if(!width)
		width =  800;
		
	if(!height)
		height =  600;
		
    window.open(url,'',"scrollbars=no,resizable=yes,toolbar=no,location=no,status=no,menubar=no,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left);
}

function openSimpleWithScroll(url,width,height,top,left)
{
	if(!width)
		width =  800;
		
	if(!height)
		height =  600;
		
    window.open(url,'',"scrollbars=yes,resizable=yes,toolbar=no,location=no,status=no,menubar=no,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left);
}

function openEmailNotification(showUnder)
{
	var topicID = getTopic();
	//alert(topicID);
	var div_id = "divNotification";
	var ypos = 0;
	
	try
	{
		var email_div =
		document.getElementById
		? document.getElementById(div_id)
		: document.all
		? document.all[div_id]
		: document.layers[div_id];
			 
		if (navigator.appName.indexOf ("Microsoft") ==-1) 
		{
			ypos = (window.document.body.scrollTop + window.document.body.clientHeight) - 146;
			var flashMovie = thisMovie("EmailNotificationMovie");
			//MOVIE BECOMES UNDEFINED AT THIS POINT IN FIREFOX
			if( flashMovie != null )
			{
				if(flashMovie.frameNum=="0" || flashMovie.frameNum=="-1")
				{
				flashMovie.SetVariable("topicId", topicID);
				flashMovie.Play();
				//email_div.style.left = thisMovie("ContentArea_Template_Footer_SearchSubmittal1").style.left;
				email_div.style.top = ypos + "px";
				//	email_div.style.left = "190px";
				setTimeout("waitTimer()", 200);
				}
					else
						{
						flashMovie.Play(1);
						}
				}
					else
						{
						rerouteSubscriptionRequest();	
						}
				}
		else
		{
			ypos = window.document.body.clientHeight - 126;
			//document.getElementById("divNotification").style.left = document.getElementById("ContentArea_Template_Footer_SearchSubmittal1").style.left;
			var flashMovie = thisMovie("EmailNotificationMovie");
			if(flashMovie != null)
			{
			if(document.getElementById("EmailNotificationMovie").frameNum=="0")
			{
				document.getElementById("divNotification").style.top = ypos;
			//	document.getElementById("divNotification").style.left = "100px";
				if(document.getElementById("groupname").value.length > 0){
					document.getElementById("EmailNotificationMovie").FlashVars = "topicId=" + topicID + "&a=" + document.getElementById("groupname").value;
			}else{
					document.getElementById("EmailNotificationMovie").FlashVars = "topicId=" + topicID + "&a=" + document.getElementById("inherits").value;
				}
				document.getElementById("EmailNotificationMovie").Play();
				setTimeout("waitTimer()", 200);
			}
			else
			{
				document.getElementById("EmailNotificationMovie").GotoFrame(0);
			}
			}
			else
			{
				rerouteSubscriptionRequest();
			}
		}
	}
	catch ( e )
	{
		//alert(e);
		//If Flash is not installed, go straight to the signup page
//		openMedium('/EmailUpdate.aspx',710,590);
		alert(e);
//		window.location.href='/EmailUpdate.aspx';
	}
///openMedium('/blast/blast_redirect.asp',710,590);
}

function rerouteSubscriptionRequest()
{
				var query=document.URL.split("?");
			var temp=(query.length==2?query[1]:"");
				openMedium('/emailupdate.aspx?'+temp,710,590);
}

function waitTimer() {
	if (navigator.appName.indexOf ("Microsoft") ==-1) 
	{
		//alert(thisMovie("EmailNotificationMovie").PercentLoaded());
		if(thisMovie("EmailNotificationMovie").CurrentFrame=="0")

		{
			openMedium('/blast/blast_redirect.asp',710,590);
		}
	}
	else
	{
		if(document.getElementById("EmailNotificationMovie").frameNum=="0")
		{
			openMedium('/blast/blast_redirect.asp',710,590);
		}
	}
}

function playmovie() {
    thisMovie("EmailNotificationMovie").Play();

}
function movieIsLoaded (theMovie) {
  if (typeof(theMovie) != "undefined") {
    return theMovie.PercentLoaded() == 100;
  } else {
    return false;
  }
}
function thisMovie(movieName) {
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
if (navigator.appName.indexOf ("Microsoft") !=-1) {
	try
	{
		return window[movieName];
	}
	catch(e)
{
	return null;
}
  }	else {
	try
	{
		
	if(document[movieName].length != undefined){
		return document[movieName][1];
	}
	return document[movieName];
	}
	catch(e)
{
	return null;
}
  }
}
function holidayTakeFlight()
{
	openMedium('/HolidaysTakeFlight_promo.htm',570,600);
}

function parentLocation(url)
{
		if(window.opener)
			window.opener.location.href = url;
		else
			openFull(url,800,590,25,75);
}

function openWayfinder( vidNum )
{
	openSimple("/Airport_Wayfinder.aspx?v=" + vidNum, 611,472);
}


function getTopic()
{
	var dir = location.href.substring(0,location.href.lastIndexOf('/')+1); 
    var url = location.href.substring(dir.length,location.href.length+1); 
	var topicID = "";
	var docTitle = document.title;
	var docGroup = docTitle.substring(0,docTitle.indexOf(' - '));
	
	url = url.toUpperCase();
	
	//Use the Page Title to determine the default topic
	switch (docGroup)
	{
	case "Portland International Airport":
		{
			topicID = "5";  //Airport Travel Updates and Information 
			if(docTitle.search(/Portland International Airport - Conference Center/) >= 0)
			{
				topicID = "30";
			}
			break;
		}
	case "General Aviation":
		{
			topicID = "1";  //News - Aviation
			if(docTitle.search(/General Aviation - Hillsboro/) >= 0 || docTitle.search(/General Aviation - Troutdale/) >= 0 || docTitle.search(/General Aviation - Mulino/) >= 0)
			{
				topicID = "23";
			}

			break;
		}
	case "Port of Portland":
		{
			topicID = "43";  //All Port of Portland News and Updates
			
			if(docTitle.search(/Port of Portland - Marine/) >= 0)
			{
				topicID = "37";
			}
			if(docTitle.search(/Port of Portland - Commission/) >= 0)
			{
				topicID = "9";
			}
			if(docTitle.search(/Port of Portland - Noise/) >= 0)
			{
				topicID = "23";
			}
			if(docTitle.search(/Port of Portland - Citizen Noise Advisory Committee/) >= 0)
			{
				topicID = "23";
			}
			if(docTitle.search(/Port of Portland - Environmental/) >= 0)
			{
				topicID = "20";
			}
			if(docTitle.search(/Port of Portland - Terminal 4 Early Action/) >= 0)
			{
				topicID = "20";
			}
			if(url.substring(0,8) == "MAR_SVC_")
			{
				topicID = "16";
			}
			break;
		}
		case "Hillsboro Airport":
		{
			topicID = "23";  //Airport Travel Updates and Information 
			break;
		}
		case "Channel Deepening":
		{
			topicID = "37";  //Marine Terminals News
			break;
		}
	default:
		{
			break;
		}
	}
	
	//Use the exact URL to manage exceptions to the defaults
	switch (url)
	{
	case "AVIATION_PRESS.ASPX": case "AVIATION_PRESS_ARCH.ASPX": 
		{
			topicID = "1";  //News - Aviation
			break;
		}
	case "MARINE_PRESS.ASPX": case "MARINE_PRESS_ARCH.ASPX": 
		{
			topicID =  "2";  //News - Marine
			break;
		}
	case "": 
		{
			topicID =  "3";  //News - Business Development
			break;
		}
	case "": 
		{
			topicID =  "4";  //News - Corporate
			break;
		}
	case "PDX_HOME.ASPX": 
		{
			topicID =  "5";  //Airport Travel Updates and Information 
			break;
		}
	case "COMM_ANNOUNCE.ASPX": case "COMM_AGENDA.ASPX": case "COMM_MINUTES.ASPX": case "COMM_INFO.ASPX": 
		{
			topicID =  "9";  // Commission Meeting Updates 
			break;
		}
	case "MARINE_STAT.ASPX": 
		{
			topicID =  "10";  // Facts & Figures - Marine 
			break;
		}
	case "AVIATION_STAT.ASPX": case "AVIATION_STAT_ARCH.ASPX":  case "LNDNG_FEES.ASPX": 
		{
			topicID =  "11";  // Facts & Figures - Aviation 
			break;
		}
	case "PORTDISPATCH.ASPX": 
		{
			topicID =  "16";  // Freight Transportation News 
			break;
		}
	case "STRATEGICPLANBUDGET.ASPX": case "AUDIT.ASPX": 
		{
			topicID =  "17";  // Financial and Planning Information 
			break;
		}
	case "CAREER_JOBS_OPN.ASPX": case "CAREER_INTERN.ASPX": case "CAREER_HOW_TO.ASPX":  case "CAREER_APPLICATION.ASPX": case "CAREER_LINKS.ASPX": 
		{
			topicID =  "18";  // Career Opportunity News and Job Postings 
			break;
		}
	case "COMMUNITY_AFFAIRS_CALENDAR.ASPX": case "T4_EA_HOME.aspx":  
		{
			topicID = "19";  // Calendar of Events and Public Hearings 
			break;
		}
	case "POP_BLDG.ASPX": case "PDX_MP_HOME.ASPX": case "PROJECT_MAP.ASPX": case "PDX_DEICING.ASPX": case "PDX_DEICING_CURRSTAT.ASPX": case "MITI_HOME.ASPX": case "T4_EA_HOME.aspx": 
		{
			topicID =  "20";  //  Community and Environmental News and Updates  
			break;
		}
	case "HAIR_AGENDA.ASPX": case "HIO_LNDNG_FEES.ASPX": 
		{
			topicID = "21";  //   Hillsboro  
			break;
		}
	case "INTL_AIR_SVC_CMTE.ASPX": 
		{
			topicID = "22";  //   International Air Service   
			break;
		}
	case "CNAC_AGENDA.ASPX": 
		{
			topicID =  "23";  // Airport Noise Information and Updates 
			break;
		}
	case "REYNOLDS_HOME.ASPX": 
		{
			topicID =  "28";  // Reynolds Industrial Site 
			break;
		}
	case "PDXAMINER.ASPX": 
		{
			topicID =  "29";  // News for Airport Employees  
			break;
		}
	case "": 
		{
			topicID =  "30";  // PDX Conference Center News and Updates  
			break;
		}
	case "CRCSC_HOME.ASPX": case "CRCSC_INTRMDAL_RAIL_HOME.ASPX": 
		{
			topicID =  "32";  // Columbia River Container Service Committee (CRCSC) 
			break;
		}
	case "MARINE_TERMINALS_MAP.ASPX": case "TOYOTA_HOME.ASPX": case "WHI_HOME.ASPX": case "T2_HOME.ASPX": case 		"T4_HOME.ASPX": case "T5_HOME.ASPX": case "T6_HOME.ASPX": case "MAR_SVC_FRT_FWDS.ASPX": case "MAR_SVC_RLTD_LINKS.ASPX":
		{
			topicID =  "37";  // Marine Terminals News and Updates 
			break;
		}
	case "": 
		{
			topicID =  "38";  // Columbia River Boating News and Updates 
			break;
		}
	case "T6_CRANE_HOME.ASPX": case "T6_CRANE_PHTOGALLERY.ASPX": 
		{
			topicID =  "41";  // Terminal 6 Crane 
			break;
		}
	case "MEDIA_PUB_OUTREACH.ASPX": case "POP_PRESS.ASPX": 
		{
			topicID =  "1-2-3-4";  // Terminal 6 Crane 
			break;
		}
	case "RULES_ORD_POL.ASPX": 
		{
			topicID =  "10-11";  // Terminal 6 Crane 
			break;
		}
		
	default:
		{
			break;
		}
	}
	return topicID;
}


//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

//Generates the Javascript after the loading of the page.
function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
	
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
