
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;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
//////////////////////////////////////
function rv_Foto(image,tit,pozadie){
  nazov = tit;
  img = image;
  bkgs = pozadie;
  foto1= new Image();
  foto1.src=(img);
  Kontrola(img);
}
function Kontrola(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    view_rvFoto(img,nazov,bkgs);
  }
  else{
    funkcia="Kontrola('"+img+"')";
    interval=setTimeout(funkcia,20);
  }
}
function view_rvFoto(img,nazov,bkgs){
  s_o=foto1.width;
  v_o=foto1.height;
    if ((s_o >= screen.width) && (v_o < screen.height))
	  { sirka_o= (screen.width/s_o)*s_o;
		vyska_o= (screen.width/s_o)*v_o;
	  }
  else if ((s_o < screen.width) && (v_o >= screen.height))
	  { vyska_o= (screen.height/v_o)*v_o;
		sirka_o= (screen.height/v_o)*s_o;
	  }
  else if ((s_o >= screen.width) && (v_o >= screen.height))
	  { if ( s_o > v_o)
			  {sirka_o= (screen.width/s_o)*s_o;
			   vyska_o= (screen.width/s_o)*v_o;
			  }
		else ( v_o > s_o)
			  {vyska_o= (screen.height/v_o)*v_o;
			   sirka_o= (screen.height/v_o)*s_o;
			  }
	  }
  else {sirka_o=foto1.width+10;vyska_o=foto1.height+10;}
  l_rv=(screen.width/2) - (sirka_o/2);
  t_rv=(screen.height/2) -(vyska_o/2);
  vyska_ob=vyska_o+19;
  stringa="width="+sirka_o+",height="+vyska_ob;
  titulka_top = vyska_o + 8;
  titulka_s = sirka_o - 10;
finale=window.open("","",stringa);
finale.moveTo(l_rv,t_rv)
finale.document.write( "<HTML><title>"+nazov+"</title>")
finale.document.write( "<body bgcolor=#"+bkgs+" leftmargin=0 marginheight=0 marginwidth=0 topmargin=5>\n<p align='center'>")
finale.document.write( "<IMG name=foto src="+img+" onClick=window.close() alt='kliknutím zatvorte' style='margin-top:18px;cursor:pointer'><br><div style='POSITION: relative;top:-"+titulka_top+"px;left:5px;FONT-SIZE: 10px; COLOR: #ffffff;BACKGROUND-COLOR: #333333; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif;padding-left:3px;padding-top:3px;padding-bottom:3px;width:"+titulka_s+"'>"+nazov+"</div></BODY></HTML>");    
}
function rv_win(pozadie,naz,fp,s_txt){
	f_pisma = fp;
	sprava = s_txt;
	bkg_rv = pozadie;
	win_rv = naz;
	v_rv=(screen.width/2.3);
    s_rv=(screen.height/2.3);
	left_rv = (screen.width/2) - (v_rv/2);
	top_rv  = (screen.height/2) - (s_rv/2);
	udaje_rv = "width="+v_rv+",height="+s_rv+",top="+top_rv+",left="+left_rv;
ok=window.open("","",udaje_rv);
ok.document.write( "<HTML><title>Téma: "+win_rv+"</title>")
ok.document.write( "<body leftmargin=0 marginheight=0 marginwidth=0 topmargin=10 style='BACKGROUND-IMAGE: url("+bkg_rv+");FONT-FAMILY: Verdana,Tahoma,Arial CE, Arial, sans-serif;FONT-SIZE: 12px;FONT-WEIGHT: bold;COLOR:"+f_pisma+"'><table width=100% height=100% onClick=window.close()><td align=center valign=center>"+sprava+"</td></table></BODY></HTML>")
}
