// Opens a window with defined features.
//
function MM_openBrWindow( theURL, winName, features ) {
	var w = window.open( theURL, winName, features );
	if ( w == null ) {
		window.location = theURL;
	} else {
		w.focus();
	}
}

// Opens a popup window.
//
var popUpWin=0;
function popUpWindow( URLStr, left, top, width, height ) {
	if( popUpWin ) {
		if(!popUpWin.closed) popUpWin.close();
	}
	popUpWin = MM_openBrWindow( URLStr, 'popUpWin', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'' );
}

// Changes the location of a popup's parent window.
//
function changeParentLocation( url ) {

	if ( window.opener && !window.opener.closed ) {
		window.opener.location.href = url;
	} else {
		window.open( url );
	}

} // End changeParentLocation().

// Shows a css layer.
//
function showLayer( id ) {

	var obj = document.getElementById( id );
	if ( obj == null ) return;
	obj.style.display = "";

} // End showLayer().

// Hides a css layer.
//
function hideLayer( id ) {

	var obj = document.getElementById( id );
	if ( obj == null ) return;
	obj.style.display = "none";
	
} // End hideLayer().

// Shows a tire's overview html content.
//
var overviewPane = null;
function changeTireOverview( tireId ) {

	// Hide the previous overview pane.
	if ( overviewPane != null ) {
		overviewPane.style.display = 'none';
	} // End if.
	
	// Get the selected tire's overview pane.
	var obj = document.getElementById( tireId + "_overview" );
	overviewPane = obj;

	// Show the overview pane.
	overviewPane.style.display = '';

} // End changeTireOverview().

// Called on a tire's sizes/specs page to change the tire size data.
//
function changeTireSize( tireSize, serviceDescription, sidewall,
						approvedRim, rimWidth, sectionWidth,
						outsideDiameter, treadWidth, maxLoad, prodcode ) {

	// The 'changeHtml()' function is located in the DynamicHtml.js file.
	changeHtml( "tireSize", tireSize );
	changeHtml( "serviceDescription", serviceDescription );
	changeHtml( "sidewall", sidewall );
	changeHtml( "approvedRim", approvedRim );
	changeHtml( "rimWidth", rimWidth );
	changeHtml( "sectionWidth", sectionWidth );
	changeHtml( "outsideDiameter", outsideDiameter );
	changeHtml( "treadWidth", treadWidth );
	changeHtml( "maxLoad", maxLoad );
	
	var obj = document.getElementById( "printTireSizeLink" );
	obj.href = "javascript:printTireSize( \"" + prodcode + "\" );";

} // End changeTireSize().

// Opens a popup window with a specified tire size's printable data.
//
function printTireSize( prodcode ) {

	// Exit the function if the user did not select a tire size.
	if ( prodcode == null ) {
		alert( "Please select a tire size from the above list." );
		return;
	}

	MM_openBrWindow( "/cfmx/web/gyeagle/tirePrint_ca.cfm?PRODCODE=" + prodcode, "printTireSize", "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=750,height=500" );

} // End printTireSize().

// Opens the tire comparison tool.
//
function compareTire( tireId ) {

	MM_openBrWindow( "/cfmx/web/gyeagle/compareTires.cfm?PRODLINE=" + tireId, "compareTires", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=650,height=480,left=10,top=10,screenX=10,screenY=10" );

} // End compareTire().

// Opens the Service Description popup window.
//
function showServiceDescPopup() {
	
	MM_openBrWindow( '/eagle/popup_serviceDesc.html','FitmentDescription','width=600,height=300,scrollbars=yes' );

} // End showServiceDescPopup().

// Opens the Sidewall popup window.
//
function showSidewallPopup() {
	
	MM_openBrWindow( '/eagle/popup_sidewall.html','FitmentDescription','width=600,height=300,scrollbars=yes' );

} // End showSidewallPopup().

// Opens the RunOnFlat popup window.
//
function showRunOnFlatPopup() {
	
	MM_openBrWindow( '/eagle/popup_runFlat.html','RunOnFlat','width=440,height=500,scrollbars=no' );

} // End showRunOnFlatPopup().

// Shows the Eagle F1 All Season video popup.
//
function showEagleF1ASVideoPopup() {

	MM_openBrWindow('/eagle/eagleF1AS_video.html','Commercial','width=360,height=340');

} // End showEagleF1ASVideoPopup().

// Shows the Eagle F1 GS-D3 news articles popup.
//
function showEagleF1GSD3Popup() {

	MM_openBrWindow( '/eagle/popup_eagleF1GSD3News.html','EagleF1GSD3News','width=300,height=320,scrollbars=yes' );

} // End showEagleF1GSD3Popup().

// Shows the Eagle F1 GS-D3 news article.
//
function showEagleF1GSD3Article( type ) {

	switch( type ) {
		case "carAndDriver":
			//MM_openBrWindow( '/eagle/articles/eagleF1GSD3_carAndDriver.html','EagleF1GSD3Article','width=600,height=400,scrollbars=yes' );
			MM_openBrWindow( '/eagle/pdf/eagleF1GSD3_article1.pdf','EagleF1GSD3Article','' );
			break;

		case "eurotuner":
			MM_openBrWindow( '/eagle/articles/eagleF1GSD3_eurotuner.html','EagleF1GSD3Article','width=600,height=400,scrollbars=yes' );
			break;

	} // End switch.

} // End showEagleF1GSD3Popup().

// Shows the Eagle GT-HR news articles popup.
//
function showEagleGTHRPopup() {

	MM_openBrWindow( '/eagle/popup_eagleGTHRNews.html','EagleGTHRNews','width=600,height=400,scrollbars=yes' );

} // End showEagleGTHRPopup().

// Shows the Eagle ResponsEdge Performance Package popup.
//
function showEagleREPerfPkgPopup() {

	MM_openBrWindow( '/eagle/popup_eagleREPerfPkg.html','EagleREPerfPkg',"toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=600,height=400" );

} // End showEagleREPerfPkgPopup().

// Shows and hides layers with specified ids depending if the user's
// browser has the Flash plugin.
//
function checkFlashPlugin( flashLayerId, noFlashLayerId ) {

	var flashLayer = document.getElementById( flashLayerId );
	var noFlashLayer = document.getElementById( noFlashLayerId );

	// If the user's browser has the flash plugin...
	if ( MM_FlashCanPlay == true ) {

		// Show the container with Flash content and hide the
		// container with Flash-less content.
		flashLayer.style.display = "";
		noFlashLayer.style.display = "none";

	// Else, if the user's browser does not have the flash plugin...
	} else {

		// Show the container with Flash-less content and hide the
		// container with Flash content.
		noFlashLayer.style.display = "";
		flashLayer.style.display = "none";

	} // End if.

} // End checkFlashPlugin().