var GEMenu={divclass:'anylinkmenu', inlinestyle:'', linktarget:''}
GEMenu.items=[
	["Severe WX (airmets/sigmet/convectives)", "/kml/severeWX_nl.kmz", "title='Google Earth Airmets, Sigmets, Convectives color coded with altitude'"],
	["In-Flight WX (taf/metar/winds)", "/kml/inflightwx.kmz", "title='World Coverage update every 10 minutes'"],
	["Mosaic Radar (with animation)", "/kml/mosaicloop/mosaic_loop.kmz", ""],
	["Single Site Radar (with animation)", "/kml/ssr/SSR_index.kmz", "title='Google Earth Single Site Radar'"],
	["TFR (temporary flight restrictions)", "/kml/tfr/tfr_nl.kmz", "title='Google Earth TFR'"],
	["SUA (special use airspace)", "/kml/sua_nl.kml", "title='Google Earth SUA'"]
];

var WXMenu={divclass:'anylinkmenu', inlinestyle:'', linktarget:''}
WXMenu.items=[
	["Severe WX (airmets/sigmet/convectives)", "/wx/severeWXZULU.html", "target=_severewx title='Airmet, Sigmet, Convective Sigmet with Route Overlay'"],
	["SSR & VAD winds", "/ssr.html", "target=_ssr title='Single Site Radar & Velocity Azimuth Display  Winds'"],
	["Weather Charts", "/wx/wxcharts.html", "target=_wxcharts title='Prog charts, lifted index etc with route overlay - demo only'"]
];

var BriefingMenu={divclass:'anylinkmenu', inlinestyle:'', linktarget:''}
BriefingMenu.items=[
	["Registration Is Required For This Menu", "/catalyst/register.cat", "title='Registration is Required' style='color:red'"],
	["Top 20 Flights", "/catalyst/register.cat", "title='Display last 20 flights'"],
	["Plan, Brief, Search (enroute wx, notam, simulation)","/catalyst/register.cat","title='Enoute Briefing with WX, NOTAM, TFR, Flight Simulation, Route Overlay on Google Earth, 2-D WX'"],
	["Area/Balloon Briefing","/catalyst/register.cat","title='Area Brief - Balloon Flight Projection with RUC2 Winds'"],
	["Decode Airways","/catalyst/register.cat","title='Decode airways and display on Google Earth'"],
	["Locate Aircraft Position","/catalyst/register.cat","title='Locate a aircraft position on Google Earth - use for flight following, Search & Rescue'"],
	["Retrieve NOTAM by location","/catalyst/register.cat","title='Quick NOTAM Retrieval by Location'"],
	["File Flight Plan via Duats","/catalyst/register.cat","title='File Flight Plans via Duats'"]
];

var AdminMenu={divclass:'anylinkmenu', inlinestyle:'', linktarget:''}
AdminMenu.items=[
	["About Us", "/whoweare.html", "title='Information about us'"],
	["Contacts", "http://www.atispace.com/contacts.html", "target=_info title='Contact Us'"]
];

var Guides={divclass:'anylinkmenu', inlinestyle:'', linktarget:''}
Guides.items=[
	["WX Color", "/metarcolors.html", "target=_info title='WX Color Code'"],
	["Flight Sim Guide", "http://earth.google.com/intl/en/userguide/v4/flightsim/index.html", "target=_info title='Using Google Earth Flight Simulator'"],
	["Google Earth Guide", "http://earth.google.com/intl/en/userguide/v4", "target=_info title='Google Earth How To'"]
];

var PubsAndNews={divclass:'anylinkmenu', inlinestyle:'', linktarget:''}
PubsAndNews.items=[
	["Aviation News", "/rss/aviationNews.html", "target=_info title='Breaking Aviation News'"],
	["Publications", "/rss/pubs.html", "target=_info title='Aviation Articles and Publications'"]
];

function cslink(id,value) {
	document.getElementById(id).innerHTML=value;
}
function hideit(id){
	document.getElementById(id).style.display="none";
}
function displayit(id){
	document.getElementById(id).style.display="";
}

function swapBtn(id,img) {
	document.images[id].src = "/images/mainpage/" + img;
}

function setStep(dir) {
	if (playit==false) jiteration = jiteration + dir;
	jiteration = (jiteration < 0) ? preLoad.length -1 : (jiteration >= preLoad.length) ? 0 : jiteration;
	stepit = true;
	playit = true;
	if (playit) cImage("pawFeatures");
}

function setPlayPause(val) {
	stepit = false;
	playit = val;
	if (playit) cImage("pawFeatures");
}

function cImage(imageName) {
	//alert(playit + ":image # " + jiteration);
	if (playit) {
		//ie
		if (document.all) {
			document.images[imageName].style.filter="blendTrans(duration=2)";
			document.images[imageName].style.filter="blendTrans(duration=crossFadeDuration)";
			document.images[imageName].filters.blendTrans.Apply();
			document.images[imageName].src = preLoad[jiteration].src;
			document.images[imageName].filters.blendTrans.Play();
		}
		else {
			//alert('ff');
			blendimage(imageName+"Div", imageName, preLoad[jiteration].src, crossFadeDuration)
		}
		
		
		cslink(imageName+"Title","<fieldset style='height:100px;'><legend>"+IMG[jiteration].title+"</legend><font class=thblue>"+IMG[jiteration].desc+"</font></fieldset>");
		//cslink(imageName+"Desc","<font class=thblue>"+IMG[jiteration].desc+"</font></fieldset>");

		if (stepit) { playit = false; return;}
		jiteration = jiteration + 1;
		if (jiteration > (IMG.length - 1)) jiteration = 0;
		timeOut = setTimeout('cImage("'+imageName+'")', slideShowSpeed);
	}	
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}
			
function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}



function ads(_imageurl,_title,_desc) {
	this.imageurl = _imageurl;
	this.title = _title;
	this.desc = _desc;
}

var IMG = new Array();
IMG[IMG.length] = new ads("/images/mainpage/main.gif",		"Pilots",			"Will you and your passenger be safer by you being more aware? Will you be more aware if you can get a get a weather briefing, simulate and fly your route over live weather, PIREPs, RADAR, NOTAM, TFR with road, terrain, landmarks before your flight?  Do you even know what severe weather is heading your way?  What if you can visualize it in 3-D with the route of flight?");
IMG[IMG.length] = new ads("/images/mainpage/inflight.gif",	"Flight Services",		"With the consolidation of flight services, do you really know your AOR or it is AORs? Are you comfortable briefing areas you have never heard of? Are you using all available information and resources to assist pilots? What if you can see the same weather, maps, charts, radar, NOTAM, TFRs that pilots see in pre-flight and the same roads, landmarks, mountains, rivers, lakes during in-flight?");
IMG[IMG.length] = new ads("/images/mainpage/charts.gif",	"Flight Planning",		"Map routes, Overlay Route on Google Map & Microsoft Map in 2-D or 3-D, View Charts, Airport Diagrams, and Terminal Procedures. There is also a built in ETE/ETA calculations based on route of flight and speed.");
IMG[IMG.length] = new ads("/images/mainpage/enroutewx.gif",	"Enroute Weather Briefing",	"Obtain Weather and NOTAM briefing along the route of flight.  See color coded textual and graphical weather. Overlay the route of flight on 2-D Severe weather map and WX charts. Weather products available: Single Site RADAR, Mosaic RADAR, VAD Winds, RUC Winds, Winds Aloft, PIREPs, Airmets/Sigmets/Convective Sigmets, TAF, METARs");
IMG[IMG.length] = new ads("/images/mainpage/balloon.gif",	"Area/Balloon Briefing",	"Take the guess work out of which direction to fly or finding an area to land! Balloon pilots can obtain an area briefing for their exact launch site and get winds information at every flight level using RUC data.  A Flight path projection base on surface conditions of the nearest METAR and all RUC levels and forecasts.  Couple this with the RUC data and you will have more information than any existing FSS!");
IMG[IMG.length] = new ads("/images/mainpage/wxcharts.gif",	"Weather Charts",		"Automatically overlay the route of flight on all FAX, SIG, PROGs, Lifted Index, Temperature and other weather charts for a route briefing. ");
IMG[IMG.length] = new ads("/images/mainpage/inflight.gif",	"3-D & 4-D WX Products",	"Overlay route of flight on RADAR, Airmets, Sigmets, Convective Sigmets, TFR, SUAs, Lightning, TAFs, METARs, PIREPs, Winds Aloft.");
IMG[IMG.length] = new ads("/images/mainpage/tfr.gif",		"Specialists & Controllers",    "Your job just got a whole lot easier for Flight Following, Search & Rescue, and assisting Lost/Disoriented Pilots. Overlay the route with terrain, landmarks, roads, weather, TFRs. Pin point the exact location and terrain of the aircraft before providing service. How can you help a disoriented pilot if you yourself don't know where he is?");
IMG[IMG.length] = new ads("/images/mainpage/nicole.gif",	"Pilot in Training",		"Unfamiliar with routes? Afraid of violating P40! Now you can visualize TFRs, landmarks, roads, terrain along the route of flight before taking off. Terminal Procedures, Airport Diagrams are available for every flight.");
IMG[IMG.length] = new ads("/images/mainpage/simheli.gif",	"Flight Simulation",		"What does the ground look like at your altitude and speed?  Hook up a joystick or use the keyboard to fly the route.  Or better yet, get a briefing, open up the built in flight simulation in Internet Explorer or Firefox, select an aircraft, press play and we will take you on a 3-D tour.");


var slideShowSpeed = 5000;
var crossFadeDuration = 1000;
var timeOut;
var jiteration = 0;
var stepit = false;
var playit = true;
var preLoad = new Array();
for (var iii = 0; iii < IMG.length; iii++) {
	preLoad[iii] = new Image();
	preLoad[iii].src = IMG[iii].imageurl;
}
