// JavaScript Document

/* 
var PAGE = {home:1, about:2, pilots:3, aircraft:4, missions:5, gallery:6, videos:7, locations:8, news:9, testimonials:10, contact:11}
var currPage=PAGE.home;
var STATES = {expanded:1, contracted:2, special:3}
var currState;
*/

var PAGE = {home: 1, about: 2, pilots: 3, aircraft: 4, missions: 5, gallery: 6, videos: 7, locations: 8, news: 9, testimonials: 10, contact: 11}

function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) { 
	//Generic Animation Step Value Generator By www.hesido.com 
	var delta = maxValue - minValue; 
	var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
	return Math.ceil(stepp) 
}
 
function doWidthChangeMem(elem,startWidth,endWidth,steps,intervals,powr) { 
	//Width changer with Memory by www.hesido.com
	if (elem.widthChangeMemInt)
	window.clearInterval(elem.widthChangeMemInt);
	var actStep = 0;
	elem.widthChangeMemInt = window.setInterval(
		function() { 
		  elem.currentWidth = easeInOut(startWidth,endWidth,steps,actStep,powr);
		  elem.style.width = elem.currentWidth + "px"; 
		  actStep++;
		  if (actStep > steps) window.clearInterval(elem.widthChangeMemInt);
		} 
	,intervals)
}

function doHeightChangeMem(elem,startHeight,endHeight,steps,intervals,powr) { 
	//Width changer with Memory by www.hesido.com
	if (elem.heightChangeMemInt)
	window.clearInterval(elem.hightChangeMemInt);
	var actStep = 0;
	elem.heightChangeMemInt = window.setInterval(
		function() { 
		  elem.currentHeight = easeInOut(startHeight,endHeight,steps,actStep,powr);
		  elem.style.height = elem.currentHeight + "px"; 
		  actStep++;
		  if (actStep > steps) {
			window.clearInterval(elem.heightChangeMemInt);
			callExternalInterfaceDoResize(currState);
		  }
		} 
	,intervals)
}



function widthChange(inelem) 
{ 
	if (!inelem.currentWidth) inelem.currentWidth = 150; 
	//if no memory is set, set it first; 
	
	doWidthChangeMem(inelem,inelem.currentWidth,170,10,10,0.5); 
} 
	
function widthRestore(inelem) 
{ 
	if (!inelem.currentWidth) return; 
	doWidthChangeMem(inelem,inelem.currentWidth,150,10,10,0.5); 
}

/////// external interface functions ///////
function callExternalInterfaceDoResize(id) 
{
	thisMovie('main').doResize(id);
}

function callExternalInterfaceDoPage(id) 
{
	thisMovie('main').doPage(id);
}    
	
function thisMovie(movieName) 
{
	if (navigator.appName.indexOf("Microsoft") != -1) 
	{
		return window[movieName];
	}
	else 
	{
		return document[movieName];
	}
}

function heightChange(inelem) 
{ 
	elem = document.getElementById(inelem);


	if (!elem.currentHeight) elem.currentHeight = 340; 
	//if no memory is set, set it first; 
	
	doHeightChangeMem(elem,elem.currentHeight,650,10,10,0.5); 
} 

function heightChange2(inelem) 
{ 
	elem = document.getElementById(inelem);


	if (!elem.currentHeight) elem.currentHeight = 554; 
	//if no memory is set, set it first; 
	
	doHeightChangeMem(elem,elem.currentHeight,244,10,10,0.5); 
} 

function heightSpecial(inelem) 
{ 

	elem = document.getElementById(inelem);
	
	if (!elem.currentHeight) elem.currentHeight = 340; 
	//if no memory is set, set it first; 

	if (!elem.currentHeight) return; 
	doHeightChangeMem(elem,elem.currentHeight,125,10,10,0.5); 
}	

function heightSpecial2(inelem) 
{ 

	elem = document.getElementById(inelem);
	
	if (!elem.currentHeight) elem.currentHeight = 554; 
	//if no memory is set, set it first; 

	if (!elem.currentHeight) return; 
	doHeightChangeMem(elem,elem.currentHeight,769,10,10,0.5); 
}	

function heightRestore(inelem) 
{ 
	
	elem = document.getElementById(inelem);
	
	if (!elem.currentHeight) elem.currentHeight = 340; 
	//if no memory is set, set it first; 

	if (!elem.currentHeight) return; 
	doHeightChangeMem(elem,elem.currentHeight,340,10,10,0.5); 
}	

function heightRestore2(inelem) 
{ 

	elem = document.getElementById(inelem);
	
	if (!elem.currentHeight) elem.currentHeight = 554; 
	//if no memory is set, set it first; 

	if (!elem.currentHeight) return; 
	doHeightChangeMem(elem,elem.currentHeight,554,10,10,0.5); 
}	

function getHeight()
{
	elem = document.getElementById('flash');	
	return elem.style.height;
}

function getWidth()
{
	elem = document.getElementById('flash');
	return elem.currentWidth;
}  

function expand()
{
	currState=STATES.expanded;
	heightChange('flash');

	heightChange('main');
	heightChange2('Content')
	
}

function contract()
{
	currState=STATES.contracted;
	heightRestore('flash');

	heightRestore('main');
	heightRestore2('Content')
}	

function special()
{
	currState=STATES.special;
	heightSpecial('flash');

	heightSpecial('main');
	heightSpecial2('Content')
}		

function popup(mylink, windowname)
{
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else
		href=mylink.href;
	window.open(href, windowname, 'width=655,height=747,scrollbars=no');
	return false;
}

function randomString() 
{
	var sRnd = Math.floor(Math.random() * 10000000);
	return sRnd;
}
