
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
	  // NS/Opera version >= 3 check for Flash plugin in plugin array
	  if (navigator.plugins != null && navigator.plugins.length > 0) {
			if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
				  var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
						var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
						descArray = flashDescription.split(" ");
						tempArrayMajor = descArray[2].split(".");
						versionMajor = tempArrayMajor[0];
				  if ( descArray[3] != "" ) {
						tempArrayMinor = descArray[3].split("r");
				  } else {
						tempArrayMinor = descArray[4].split("r");
				  }
						versionMinor = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
						flashVer = parseFloat(versionMajor + "." + versionMinor);
			} else {
				  flashVer = -1;
			}
	  }
	  // MSN/WebTV 2.6 supports Flash 4
	  else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	  // WebTV 2.5 supports Flash 3
	  else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	  // older WebTV supports Flash 2
	  else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	  // Can't detect in all other cases
	  else {
			
			flashVer = -1;
	  }
	  return flashVer;
}

// If called with no parameters this function returns a floating point value 
// which should be the version of the Flash Player or 0.0 
// ex: Flash Player 6r65 returns 6.65
// If called with reqMajorVer, reqMinorVer this function returns true if that version or greater is installed
function DetectFlashVer(reqMajorVer, reqMinorVer) 
{
	  reqVer = parseFloat(reqMajorVer + "." + reqMinorVer);
	  // loop backwards through the versions until we find the newest version      
	  for (i=25;i>0;i--) {      
			if (isIE && isWin && !isOpera) {;
					// This VBScript function is in the topnavigation include. Cant put it here because it is vbscript
				  versionStr = VBGetSwfVer(i);
			} else {
				  versionStr = JSGetSwfVer(i);
			}
			if (versionStr == -1) {
					return false;
			  } else if (versionStr != 0) {
				  if(isIE && isWin && !isOpera) {
						tempArray = versionStr.split(" ");
						tempString = tempArray[1];
						versionArray = tempString .split(",");
						
						versionMajor = versionArray[0];
						versionMinor   = versionArray[2];
						
						versionString = versionMajor + "." + versionMinor;
						versionNum = parseFloat(versionString);
				  } else {
						 versionNum = versionStr;
				  }
				  return (versionNum >= reqVer ? true : false );            
			}
	  }
	  
	  return (reqVer ? false : 0.0);
}



function WriteOutFlash(strLink, strFlash, strAltImage, width, height) {
	if ( DetectFlashVer(6,00)) {
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="' + width.toString() + '" height="' + height.toString() + '" id="Flash_Visual" align="middle">\n')
		document.write('<param name="allowScriptAccess" value="sameDomain" />\n')
		document.write('<param name="movie" value="' + strFlash + '" />\n')
		document.write('<param name="FlashVars" value="TargetOne=' + strLink + '" />\n')
		document.write('<param name="wmode" value="transparent"/>\n')
		document.write('<param name="quality" value="high" />\n')
		document.write('<param name="bgcolor" value="#ffffff" />\n')
		document.write('<embed src="' + strFlash + '" width="' + width.toString() + '" height="'+ height.toString() + '" quality="high" bgcolor="#ffffff" wmode="transparent" FlashVars="TargetOne=' + strLink + '"  name="Flash_Visual" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n')
		document.write('</object>\n');
	} else{
		// Show the alternative image
		document.write('<a href="' + strLink + '" target="_blank"><img src="' + strAltImage + '" border="0" /></a>');
	}				
}


function group_over(id, group) {
	document.getElementById("t" + id).className = group + '_group_selector';
	return;
}

function group_out(id) {
	document.getElementById("t" + id).className = 'group_selector';
	return;
}

function segment_over(id) {
	document.getElementById("t" + id).className = 'over_segment_selector';
	return;
}

function segment_out(id) {
	document.getElementById("t" + id).className = 'segment_selector';
	return;
}

function img_over(id) {
	document.getElementById("ig" + id).className = 'selected';
	return;
}

function img_out(id) {
	if (id != imgSelected)
		document.getElementById("ig" + id).className = 'gallery';
	return;
}

function showImage(id) {
	document.getElementById("ig" + imgSelected).className = 'gallery';
	document.getElementById("ig" + id).className = 'selected';
	document.getElementById("img_container").src = eval("img" + id).src
	imgSelected = id;

	return;
}

function showLarge() {
	imgPopup = window.open(arLargeVersions[imgSelected-1], "ImagePopup", "menubar=no,resizable=no,titlebar=yes,scrollbars=no,top=50,left=100,height=400,width=600,toolbar=no,location=no");
	imgPopup.document.write("<html>");
	imgPopup.document.write("<head>");
	imgPopup.document.write("<title>Yamaha Motor Europe</title>");
	imgPopup.document.write("</head>");
	imgPopup.document.write("<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>");
	imgPopup.document.write("<table width=100% border='0' cellpadding='0' cellspacing='0'>");
	imgPopup.document.write("  <tr bgcolor='#CCCCCC'>");
	imgPopup.document.write("    <td align=center><img src='" + arLargeVersions[imgSelected-1] + "'></td>");
	imgPopup.document.write("  </tr>");
	imgPopup.document.write("  <tr bgcolor='#CCCCCC'>");
	imgPopup.document.write("    <td height='30' align='right' valign='middle'><a href='javascript:window.close();' class='but_grey'>Close</a></td>");
	imgPopup.document.write("  </tr>");
	imgPopup.document.write("</table>");
	imgPopup.document.write("</body>");
	imgPopup.document.write("</html>");
	imgPopup.document.title = document.domain;
	setTimeout("imgPopup.focus()",255);

	return;
}

function showTab(id) {
	if (id == 'name') {
		document.getElementById("navname").className = 'dealer_tab_selected';
		document.getElementById("navloc").className = 'dealer_tab';
		document.getElementById("name").style.display = 'block';
		document.getElementById("loc").style.display = 'none';
	}
	else {
		document.getElementById("navname").className = 'dealer_tab';
		document.getElementById("navloc").className = 'dealer_tab_selected';
		document.getElementById("name").style.display = 'none';
		document.getElementById("loc").style.display = 'block';
	}

	return;
}

function showDD() {
	document.getElementById("ddlist").style.display = 'block';
}

function hideDD(obj) {
	document.getElementById("ddlist").style.display = 'none';
}


function hideDD_IE(obj) {
	if(!obj.contains(event.toElement)) {
		obj.style.display = 'none';
	}
}

function gotoURL(url) {
	document.location.href = url;
}
