//======================================================
// *** Gulfstream Global Client Scripts
// *** Copyright 2006 Gulfstream Aerospace Corporation
// -----------------------------------------------------
// *** Created 2006-02-06
//======================================================

//======================================================
// *** Browser Detection Scripts
// -----------------------------------------------------
// *** Identifies end user browser
//======================================================
var detect = navigator.userAgent.toLowerCase();
var OS,browser,total,thestring,place,nse;
var version = 0;
var pluginlist = "";

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


// *** outputs for testing purposes
//	document.write(browser + " " + version + " on " + OS);

/* plugin type detection */
/* list [Flash] [Windows Media Player] [Java] [Shockwave] [RealPlayer] [QuickTime] [Acrobat Reader] [SVG Viewer] [Ipix] */
// java - application/x-java-applet


//======================================================
// *** Detect user plugins
// -----------------------------------------------------
// *** Identifies end user plugins
//======================================================
var agt = navigator.userAgent.toLowerCase();

var ie = (agt.indexOf("msie") != -1);
var ns = (navigator.appName.indexOf("Netscape") != -1);

var win = ((agt.indexOf("win") != -1) || (agt.indexOf("32bit") != -1));
var mac = (agt.indexOf("mac") != -1);

if (ie && win) { 
	pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") + detectIE("PDF.PdfCtrl.5","Acrobat Reader") + detectIE("IPIX.ActiveXCtrl.5","Ipix"); 
}

if (ns || !win) {
	nse = "";	
	for ( var i=0; i<navigator.mimeTypes.length; i++) { 
		nse += navigator.mimeTypes[i].type.toLowerCase(); 
	}
	pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader") + detectNS("application/x-ipix","Ipix");
}

function detectIE(ClassID,name) { 
	result = false; 
	document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); 
	if (result){ 
		return name+','; 
	} else { 
		return '';
	}
}

function detectNS(ClassID,name) { 
	var n = ""; 
	if (nse.indexOf(ClassID) != -1){ 
		if (navigator.mimeTypes[ClassID].enabledPlugin != null){ 
			n = name+","; return n; 
		}
	}
}

pluginlist += navigator.javaEnabled() ? "Java," : "";
if (pluginlist.length > 0){ 
	pluginlist = pluginlist.substring(0,pluginlist.length-1);
}


// *** test for plugins ...
/* 
if (pluginlist.indexOf("Shockwave Director") != -1) { document.write("Shockwave Director installed<br />"); } else { document.write("Shockwave Director not installed<br />");}
if (pluginlist.indexOf("Shockwave Flash") != -1) { document.write("Shockwave Flash installed<br />"); } else { document.write("Shockwave Flash not installed<br />");}
if (pluginlist.indexOf("QuickTime") != -1) { document.write("QuickTime installed<br />"); } else { document.write("QuickTime not installed<br />");}
if (pluginlist.indexOf("SVG Viewer") != -1) { document.write("SVG Viewer installed<br />"); } else { document.write("SVG Viewer not installed<br />");}
if (pluginlist.indexOf("RealPlayer") != -1) { document.write("RealPlayer installed<br />"); } else { document.write("SRealPlayer not installed<br />");}
if (pluginlist.indexOf("Acrobat Reader") != -1) { document.write("Acrobat Reader installed<br />"); } else { document.write("Acrobat Reader not installed<br />");}
if (pluginlist.indexOf("Ipix") != -1) { document.write("Ipix installed<br />"); } else { document.write("Ipix not installed<br />");}

*/

//======================================================
// *** evalFlashPlayerVersion
// -----------------------------------------------------
// *** identifies flash player version and displays
// *** page nag message if minimum player version
// *** is not found
//======================================================
function evalFlashPlayerVersion(id){				
	
	var minPlayerVersion = 8;
	// *** if the flash player version is older than 8,
	// *** show the nag message.
	if(id<minPlayerVersion){
		document.getElementById("flashPlayerNagBanner").style.display = "block";
	}
}

//======================================================
// *** openPrintView
// -----------------------------------------------------
// *** captures page content and displays it in a
// *** new print-friendly page
//======================================================
function openPrintView(){

	// *** first gather	main content div
	var div = document.getElementById("mainContentBanner");
	// *** gather body content
	var bodyContent = div["innerHTML"];
	// *** compose content for print view
	var printHTML = "<html><head><title>Gulfstream</title>";
	// *** add stylesheet references
	printHTML += "<link rel='stylesheet' href='/_styles/gac_print.css' type='text/css' media='all' />";
	printHTML += "<link rel='stylesheet' href='/_styles/gac_text.css' type='text/css' media='all' />";
	printHTML += "<link rel='stylesheet' href='/_styles/gac_menu.css' type='text/css' media='all' />";
	printHTML += "<link rel='stylesheet' href='/_styles/sIFR-print.css' type='text/css' media='print' />";
	printHTML += "<link rel='stylesheet' href='/_styles/sIFR-screen.css' type='text/css' media='screen' />";
	printHTML += "</head>";
	printHTML += "<body>";
	printHTML += bodyContent;
	// *** add footer
	printHTML += "<div id='footerBanner'><div id='footerContent'>Copyright &copy; 2002-2006 Gulfstream Aerospace Corporation.  All Rights Reserved.</div></div>";

	// *** close out print view
	printHTML += "</body></html>";

	// *** open print window and write content to window
	var printWindow = window.open('/_forms/print.htm','printWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=700,height=750');
	//var nw = window.open("/_forms/print.htm");
	printWindow.document.write(printHTML);

}

//======================================================
// *** sendThisPage
// -----------------------------------------------------
// *** captures current page URL and opens 
// *** send page form
//======================================================
function sendThisPage(){
	
	var thisPageURL = window.location;
	//alert('thisPageURL = ' + thisPageURL);
	//window.location = '/cf/global/sendthispage.cfm?pageURL='+thisPageURL;
	var sendWindow = window.open('/cf/global/sendthispage.cfm?pageURL='+thisPageURL,'sendWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=550,height=320');
	
}