
<!--

// -----------------------------------------------------------------------------
// define
var swfWidth = 1000;
var swfHeight = 750;
var shoppingToolsLeft = 624;
var shoppingToolsTop = 38;
var lineUpLeft = 821;
var lineUpTop = 4;
var iframeTop = 130;
var iframeLeft = 140;
var iframeVisible = false;
// -----------------------------------------------------------------------------


// -----------------------------------------------------------------------------
//pop up

// this will center the window within the browser and bring the window to focus
//javascript:popUpProps('test.html','winName','400','300',',menubar=0,resizable=0,scrollbars=0,titlebar=0,toolbar=0');
var winProps;
function popUpProps(url, windowName, width, height, props)
{
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	var propsCentered = "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + props;

	if(winProps == null || winProps.closed) {
		winProps = window.open(url, windowName, propsCentered);
		winProps.focus();
	} else {	
		winProps.close();
		winProps = window.open(url, windowName, propsCentered);
		winProps.focus();
	}
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// iframe

//localConnection for iframe
var connID = generateConnID();

function generateConnID(){
	var connID = 0;
	connID = Math.floor(Math.random()*20000000)
	return connID;
}


var BrowserDetectMZ6 = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetectMZ6.init();

var Window = {	
	//Returns an integer representing the width of the browser window (without the scrollbar).
	getWindowWidth : function() {
	return (document.layers||(document.getElementById&&!document.all)) ? window.outerWidth : (document.all ? document.body.clientWidth : 0);
	},
 
	//Returns an integer representing the height of the browser window (without the scrollbar).
	getWindowHeight : function() {	
	return window.innerHeight ? window.innerHeight :(document.getBoxObjectFor ? Math.min(document.documentElement.clientHeight, document.body.clientHeight) : ((document.documentElement.clientHeight != 0) ? document.documentElement.clientHeight : (document.body ? document.body.clientHeight : 0)));
	},	
 
	//Returns an integer representing the scrollWidth of the window. 
	getScrollWidth : function() {
	return document.all ? Math.max(Math.max(document.documentElement.offsetWidth, document.documentElement.scrollWidth), document.body.scrollWidth) : (document.body ? document.body.scrollWidth : ((document.documentElement.scrollWidth != 0) ? document.documentElement.scrollWidth : 0));
	},
 
	//Returns an integer representing the scrollHeight of the window. 
	getScrollHeight : function(){		
		return document.all ? Math.max(Math.max(document.documentElement.offsetHeight, document.documentElement.scrollHeight), Math.max(document.body.offsetHeight, document.body.scrollHeight)) : (document.body ? document.body.scrollHeight : ((document.documentElement.scrollHeight != 0) ? document.documentElement.scrollHeight : 0));
	},			
 
	//Returns an integer representing the scrollLeft of the window (the number of pixels the window has scrolled from the left).
	getScrollLeft : function() {
		return document.all ? (!document.documentElement.scrollLeft ? document.body.scrollLeft : document.documentElement.scrollLeft) : ((window.pageXOffset != 0) ? window.pageXOffset : 0);
	},
 
	//Returns an integer representing the scrollTop of the window (the number of pixels the window has scrolled from the top).
	getScrollTop : function() {
		return document.all ? (!document.documentElement.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop) : ((window.pageYOffset != 0) ? window.pageYOffset : 0);
	}
}

function swfResize(){
	var widthOffset = 1;
	
	if(BrowserDetectMZ6.browser == "Firefox" && BrowserDetectMZ6.OS == "Windows"){
		widthOffset = 26;
	}else if(BrowserDetectMZ6.browser == "Firefox" && BrowserDetectMZ6.OS == "Mac"){
		widthOffset = 17;
	}else if(BrowserDetectMZ6.browser == "Safari" && BrowserDetectMZ6.OS == "Windows"){
		widthOffset = 20;
	}else if(BrowserDetectMZ6.browser == "Safari" && BrowserDetectMZ6.OS == "Mac"){
		widthOffset = 17;
	}
	
    if(Window.getWindowWidth() > swfWidth){	
		document.getElementById("swfIndex").style.width = (Window.getWindowWidth() - widthOffset) + "px";
    }else{
		document.getElementById("swfIndex").style.width = (swfWidth) + "px";
    }
    if(Window.getWindowHeight() > swfHeight){
		document.getElementById("swfIndex").style.height = (Window.getWindowHeight()+5) + "px";
    }else{
		document.getElementById("swfIndex").style.height = (swfHeight+5) + "px";
    }
    
	if(Window.getWindowWidth() > swfWidth ){
		document.getElementById("divShoppingTools").style.left = (((Window.getWindowWidth() - widthOffset - swfWidth) / 2) + shoppingToolsLeft) + "px";
		document.getElementById("divLineUp").style.left = (((Window.getWindowWidth() - widthOffset - swfWidth) / 2) + lineUpLeft) + "px";
	}else{
		document.getElementById("divShoppingTools").style.left = shoppingToolsLeft + "px";
		document.getElementById("divLineUp").style.left = lineUpLeft + "px";
	}
	if(Window.getWindowHeight() > swfHeight && Window.getWindowHeight() <= 895){
		document.getElementById("divShoppingTools").style.top = ((Window.getWindowHeight() - swfHeight) + shoppingToolsTop ) + "px";
		document.getElementById("divLineUp").style.top = ((Window.getWindowHeight() - swfHeight) + lineUpTop ) + "px";
	}else if(Window.getWindowHeight() > swfHeight && Window.getWindowHeight() > 895){
		document.getElementById("divShoppingTools").style.top = (shoppingToolsTop + 146) +  "px";
		document.getElementById("divLineUp").style.top = (lineUpTop + 146) +  "px";
	}else{
		document.getElementById("divShoppingTools").style.top = shoppingToolsTop + "px";
		document.getElementById("divLineUp").style.top = lineUpTop + "px";
	}
	
	//divFrame
	if(Window.getWindowWidth() > swfWidth ){
		document.getElementById("divFrame").style.left = (iframeLeft + (Window.getWindowWidth() - widthOffset  - swfWidth) / 2) + "px";
		document.getElementById("divFrameBkg").style.left = (iframeLeft + (Window.getWindowWidth() - widthOffset  - swfWidth) / 2) + "px";
	}else{
		document.getElementById("divFrame").style.left = iframeLeft + "px";
		document.getElementById("divFrameBkg").style.left = iframeLeft + "px";
	}
	if(Window.getWindowHeight() > swfHeight && Window.getWindowHeight() <= 895){
		document.getElementById("divFrame").style.top = ((Window.getWindowHeight() - swfHeight) + iframeTop ) + "px";
		document.getElementById("divFrameBkg").style.top = ((Window.getWindowHeight() - swfHeight) + iframeTop ) + "px";
	}else if(Window.getWindowHeight() > swfHeight && Window.getWindowHeight() > 895){
		document.getElementById("divFrame").style.top = (iframeTop + 146) +  "px";
		document.getElementById("divFrameBkg").style.top = (iframeTop + 146) +  "px";
	}else{
		document.getElementById("divFrame").style.top = iframeTop + "px";
		document.getElementById("divFrameBkg").style.top = iframeTop + "px";
	}
}


function showShoppingTools(){
	document.getElementById("divShoppingTools").style.visibility="visible";
	document.getElementById("divLineUp").style.visibility="visible";
	swfResize();
}

function createIFrame(source,x,y,w,h) {	
	document.getElementById("divFrame").style.visibility = "visible";
	document.getElementById("divFrame").style.width = w + "px";
	document.getElementById("divFrame").style.height = h + "px";
    document.getElementById("divFrame").innerHTML = "<iframe id='divFrameConfigurator' src='" + source + "'frameborder='0' scrolling='auto' onload='javascript:divFrameConfiguratorOnLoad();'></iframe>";
	document.getElementById("divFrameConfigurator").style.width = w;
	document.getElementById("divFrameConfigurator").style.height = h;
	
	
	iframeVisible = true;
}

function divFrameConfiguratorOnLoad(){
	if(BrowserDetectMZ6.browser != "Explorer"){
		document.getElementById("divFrameBkg").style.visibility = "visible";
		setTimeout(showSite, 10);
	}
}

function showSite(){
	
}

function moveIFrame(x,y) {
	document.getElementById("divFrame").style.left = x + "px";
	document.getElementById("divFrame").style.top = y + "px";
}

function removeIFrame(){
	document.getElementById("divFrame").style.visibility = "hidden";
	document.getElementById("divFrame").innerHTML = "";
	document.getElementById("divFrameBkg").style.visibility = "hidden";
	iframeVisible = false;
}
	
function showIFrame(currentNav){ 	
	swfResize();
	document.getElementById("divShoppingTools").style.visibility = "visible";
	document.getElementById("divLineUp").style.visibility = "visible";
}

function enableIFrame(){
	document.getElementById("divShoppingTools").style.height = "30px";
	if(iframeVisible && BrowserDetectMZ6.browser != "Explorer"){
		document.getElementById("divFrame").style.visibility = "visible";
		document.getElementById("divFrameBkg").style.visibility = "hidden";
	}
}

function disableIFrame(){
	document.getElementById("divShoppingTools").style.height = "160px";
	if(iframeVisible && BrowserDetectMZ6.browser != "Explorer"){
		document.getElementById("divFrame").style.visibility = "hidden";
		document.getElementById("divFrameBkg").style.visibility = "visible";
	}
}

function enableIFrameLineUp(){
	document.getElementById("divLineUp").style.height = "30px";
	if(iframeVisible && BrowserDetectMZ6.browser != "Explorer"){
		document.getElementById("divFrame").style.visibility = "visible";
		document.getElementById("divFrameBkg").style.visibility = "hidden";
	}
}

function disableIFrameLineUp(){
	document.getElementById("divLineUp").style.height = "240px";
	if(iframeVisible && BrowserDetectMZ6.browser != "Explorer"){
		document.getElementById("divFrame").style.visibility = "hidden";
		document.getElementById("divFrameBkg").style.visibility = "visible";
	}
}

function startMouseTrack(){
	document.onmousemove = mouseTrack;
}

function startMouseTrackLineUp(){
	document.onmousemove = mouseTrackLineUp;
}

function stopMouseTrack(){
	document.onmousemove = "";
}

function mouseTrack(event){
	var offset = Window.getScrollLeft();
	var left = Number(document.getElementById("divShoppingTools").style.left.replace("px", "")) - offset;
	var right = Number(document.getElementById("divShoppingTools").style.left.replace("px", "")) + Number(document.getElementById("divShoppingTools").style.width.replace("px", "")) - offset;
	var top = document.getElementById("divShoppingTools").style.top.replace("px", "");
	var bottom = Number(document.getElementById("divShoppingTools").style.top.replace("px", "")) + Number(document.getElementById("divShoppingTools").style.height.replace("px", ""));
	
	if(BrowserDetectMZ6.browser == "Explorer"){
		event = window.event;
	}
	
	if(event.clientX > right){
		document.getElementById("swfShoppingTools").shopOut();
		stopMouseTrack();
	}
	if(event.clientX < left){
		document.getElementById("swfShoppingTools").shopOut();
		stopMouseTrack();
	}
	if(event.clientY > bottom){
		document.getElementById("swfShoppingTools").shopOut();
		stopMouseTrack();
	}
	if(event.clientY < top){
		document.getElementById("swfShoppingTools").shopOut();
		stopMouseTrack();
	}
}

function mouseTrackLineUp(event){
	var offset = Window.getScrollLeft();
	
	var leftLineUp = Number(document.getElementById("divLineUp").style.left.replace("px", "")) - offset;
	var rightLineUp = Number(document.getElementById("divLineUp").style.left.replace("px", "")) + Number(document.getElementById("divLineUp").style.width.replace("px", "")) - offset;
	var topLineUp = document.getElementById("divLineUp").style.top.replace("px", "");
	var bottomLineUp = Number(document.getElementById("divLineUp").style.top.replace("px", "")) + Number(document.getElementById("divLineUp").style.height.replace("px", ""));
	
	if(BrowserDetectMZ6.browser == "Explorer"){
		event = window.event;
	}
	
	if(event.clientX > rightLineUp){
		document.getElementById("swfLineUp").shopOut();
		stopMouseTrack();
	}
	if(event.clientX < leftLineUp){
		document.getElementById("swfLineUp").shopOut();
		stopMouseTrack();
	}
	if(event.clientY > bottomLineUp){
		document.getElementById("swfLineUp").shopOut();
		stopMouseTrack();
	}
	if(event.clientY < topLineUp){
		document.getElementById("swfLineUp").shopOut();
		stopMouseTrack();
	}
}

function openWindowBlank(url) {
	var windowprops = 'top=0,left=0,toolbar=yes,location=yes,directories=no,status=yes,scrollbars=yes,menubar=yes,resizable=yes';
	var popup = window.open(url,'Mazda6WindowBlank',windowprops);
	var intWidth = screen.availWidth? screen.availWidth : screen.width;
	var intHeight = screen.availHeight? screen.availHeight: screen.height-30;
    if(popup == null){
        alert("Please disable your popup blocker to view this link."); 
    }else{
	    popup.resizeTo(intWidth, intHeight);
        popup.outerWidth = intWidth;
	    popup.outerHeight = intHeight;
		popup.focus();
    }
}

function openSocialPrompt(text, url){
	
	prompt(text, url);
}

function openSocialWindowBlank(url) {
	var windowprops = 'top=0,left=0,toolbar=yes,location=yes,directories=no,status=yes,scrollbars=yes,menubar=yes,resizable=yes';
	var popup = window.open(url,'Mazda6WindowBlank',windowprops);
	var intWidth = 790;
	var intHeight = 600;
    if(popup == null){
        alert("Please disable your popup blocker to view this link."); 
    }else{
	    popup.resizeTo(intWidth, intHeight);
        popup.outerWidth = intWidth;
	    popup.outerHeight = intHeight;
		popup.focus();
    }
}


// -----------------------------------------------------------------------------
//other
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
	return "";
  else
	return results[1];
}
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------


// -->