// google maps

    var map;
    var gdir;
    var geocoder = null;
    var addressMarker;


    function initialize() {
      if (GBrowserIsCompatible()) {     
        map = new GMap2(document.getElementById("map_canvas"));
        gdir = new GDirections(map, document.getElementById("textual_div"));
        GEvent.addListener(gdir, "load", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", handleErrors);

        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.addControl(new GOverviewMapControl());
        map.addControl(new GScaleControl());

	setDirections("Katowice, Grunwaldzka", "Jaworzno, Grunwaldzka 2", "pl");
      }
    }
    
    function setDirections(fromAddress, toAddress, locale) {
      gdir.load("from: " + fromAddress + " to: " + toAddress,
                { "locale": locale });
    }

	function handleErrors(){
	 if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) alert("Nie znaleziono lokalizacji. Proszę sprawdzić poprawno¶ć wpisu.\nError code: " + gdir.getStatus().code);
	 else if (gdir.getStatus().code == G_GEO_SERVER_ERROR) alert("Kierunek nie może zostać przetworzony\n Error code: " + gdir.getStatus().code);
	 else if (gdir.getStatus().code == G_GEO_MISSING_QUERY) alert("Błąd wyszukiwania. ");
	 else if (gdir.getStatus().code == G_GEO_BAD_KEY) alert("Błąd wyszukiwania. ");
	 else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) alert("Błąd wyszukiwania. ");
	 else alert("Wystąpił nieznany błąd.");
	}



	function onGDirectionsLoad(){ 
	}

// koniec google maps


function select(imgName) {
	imgOn = eval(imgName + "_on.src");
	document[imgName].src = imgOn;
}

function unselect(imgName) {
	imgOff = eval(imgName + "_off.src");
	document[imgName].src = imgOff;
}

var browser = checkBrowser();

function checkBrowser(){
	var is_major=parseInt(navigator.appVersion);
	this.nver=is_major;
	this.ver=navigator.appVersion;
	this.agent=navigator.userAgent;
	this.dom=document.getElementById?1:0;
	this.opera=window.opera?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1&&this.dom&&!this.opera)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1&&this.dom&&!this.opera)?1:0;
	this.ie4=(document.all&&!this.dom&&!this.opera)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6;
	this.ns6=(this.dom&&parseInt(this.ver)>=5)?1:0;
	this.hotjava=(this.agent.toLowerCase().indexOf('hotjava')!=-1)?1:0;
	this.ns4=(document.layers&&!this.dom&&!this.hotjava)?1:0;
	this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera);
	return this;
}

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function navi_DoFSCommand(command, args) {
	var naviObj = isInternetExplorer ? document.all.navi : document.navi;
	if (command=='changeLayerHeight') { changeLayerHeight(args,'menu_top') };

}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub navi_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call navi_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

function changeLeft(name,state){
	var h=document.body.clientWidth;
	h=h/2-state;
	if (h<178) h=178;
	browser.ns4?document.layers[name].left=h+'px':document.all?document.all[name].style.left=h:document.getElementById(name).style.left=h+'px';
} 

function zamknijokno(){
	browser.ns4?document.layers['baner'].style.visibility="hidden":document.all?document.all['baner'].style.visibility="hidden":document.getElementById('baner').style.visibility="hidden";	
}

function changeTop(name){
	var h=document.body.scrollTop;
//	alert(name);
	browser.ns4?document.layers[name].style.top=h+'px':document.all?document.all[name].style.top=h:document.getElementById(name).style.top=h+'px';
} 

function createStartLayer(name,z,left,top,width,height){
	document.write(browser.ns4?'<layer id="'+name+'" z-index="'+z+'" left="'+left+'" top='+top+'" width="'+width+'" height="'+height+'"'+' visibility="visible">\n':'<div id="'+name+'" style="position:absolute;z-index:'+z+';left:'+left+'px;top:'+top+'px;width:'+width+'px;height:'+height+'px;visibility:visible;">\n');
} 

function createStartLayer2(name,z,left,top){
	var width = document.body.clientWidth;
	var height = document.body.clientHeight;

	document.write(browser.ns4?'<layer id="'+name+'" z-index="'+z+'" left="'+left+'px" top='+top+'px" width="100%" height="100%"'+' visibility="visible">\n':'<div id="'+name+'" style="position:absolute;z-index:'+z+';left:'+left+'px;top:'+top+'px;width:100%;height:100%;visibility:visible;">\n');
} 

function createEndLayer(){
	document.write(browser.ns4?'</layer>\n':'</div>\n');
} 

function changeLayerVisibility(name,action) {
	switch(action) {
		case "show":var state=browser.ns4?'show':'visible';break;
		case "hide":var state=browser.ns4?'hide':'hidden';break;
	}
	browser.ns4?document.layers[name].visibility=state:document.all?document.all[name].style.visibility=state:document.getElementById(name).style.visibility=state;
}

function changeLayerHeight(state,name) {
	browser.ns4?document.layers[name].height=state:document.all?document.all[name].style.height=state:document.getElementById(name).style.height=state+'px';
}


function changeLinkColor(name,colorValue) {
	browser.ie?eval(name+".style.color='"+colorValue+"'"):'';
	browser.opera?eval(name+".style.color='"+colorValue+"'"):'';
	browser.ns6?eval("document.getElementById('"+name+"').style.color='"+colorValue+"'"):'';
}

function newWindow(width,height,filename,target,p) {
	var winWidth = (screen.width - width) / 2;
	var winHeight = (screen.height - height) / 2;
	if (!target) {
		target = 'cnewwindow';
	}
	if (p) {
		winprops = 'width='+width+',height='+height+',top='+winHeight+',left='+winWidth;
	} else {
		winprops = 'width='+width+',height='+height+',top='+winHeight+',left='+winWidth+',scrollbars=1';
	}
	window.open(filename,target,winprops);
}

function img(width,height,filename,nazwa) {
	width += 20;
	height += 80;
	var winWidth = (screen.width - (width)) / 2;
	var winHeight = (screen.height - (height)) / 2;
	winprops = 'width='+width+',height='+height+',top='+winHeight+',left='+winWidth+',scrollbars=0';
	window.open('img_popup.php?img='+filename+'&nazwa='+nazwa,'hyundaiimgpopup',winprops);
//	alert("width="+width+", height="+height+", filename="+filename);
}

function changeImg(imgName,dest) {
	document[dest].src = eval(imgName + ".src");
}





function m_out(a, w, h, w2, h2){
a.style.width=w;
a.style.height=h;
a.width=w;
a.height=h;
a.innerHeight=h;
}

function m_over(a, w, h, w2, h2){
a.style.width=w2;
a.style.height=h2;
a.width=w2;
a.height=h2;
a.innerHeight=h2;
}

function insertSWF(nazwa, width, height, name){
	var newObject = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'" id="'+name+'"><param name="movie" value="'+nazwa+'"><param name="wmode" value="transparent"><param name="menu" value="false"><param name="quality" value="high"><param name="loop" value="false" /><param name="scale" value="noscale" /><param name="salign" value="lt" /><embed src="'+nazwa+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="noscale" salign="lt" width="'+width+'" height="'+height+'" wmode="transparent" menu="false" name="'+name+'"></embed></object>';
	document.write(newObject);
}
function insertTOPLAYER(nazwa, width, height, name){
	var newObject = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'" id="'+name+'"><param name="movie" value="'+nazwa+'"><param name="wmode" value="transparent"><param name="menu" value="false"><param name="quality" value="high"><param name="loop" value="false" /><param name="scale" value="noscale" /><param name="salign" value="cm" /><embed src="'+nazwa+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="noscale" salign="cm" width="'+width+'" height="'+height+'" wmode="transparent" menu="false" name="'+name+'"></embed></object>';
	document.write(newObject);
}

function insertTOPLAYER2(nazwa, width, height, name){
	var newObject = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'" id="'+name+'"><param name="movie" value="'+nazwa+'"><param name="wmode" value="transparent"><param name="menu" value="false"><param name="quality" value="high"><param name="loop" value="false" /><param name="scale" value="noscale" /><param name="salign" value="cm" /><embed src="'+nazwa+'&click=http://www.hyundai.raba2.pl/?hy=promocje.htm" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="noscale" salign="cm" width="'+width+'" height="'+height+'" wmode="transparent" menu="false" name="'+name+'"></embed></object>';
	document.write(newObject);
}


function random(){
var theSwf=["show.swf", "show1.swf"];
var theSwf1=["doublebillboard_750x200_v1_afilo.swf", "doublebillboard_750x200_v1_afilo.swf"];
var theSwf2=["rekl_serwis.swf", "rekl_serwis.swf"];
theSwf.sort(function random() {return 0.5 - Math.random()});
theSwf1.sort(function random() {return 0.5 - Math.random()});
theSwf2.sort(function random() {return 0.5 - Math.random()});
document.write('<script type="text/javascript">'+
		'var FO = { movie:"verticalscrollerserwis.swf", wmode:"transparent", width:"210", height:"250", majorversion:"8", build:"0", xi:"true" };'+
		'UFO.create(FO, "serwis");'+
		'var FO = { movie:"menu_hyundai_g.swf", wmode:"transparent", width:"500", height:"70", majorversion:"8", build:"0", xi:"true" };'+
		'UFO.create(FO, "menu_g");'+
		'var FO = { movie:"samochody_menu.swf", wmode:"transparent", width:"800", height:"20", majorversion:"8", build:"0", xi:"true" };'+
		'UFO.create(FO, "sam_g");'+
		'var FO = { movie:"'+theSwf[0]+'", wmode:"transparent", width:"780", height:"260", majorversion:"8", build:"0", xi:"true" };'+
		'UFO.create(FO, "show");'+
		//'var FO = { movie:"odliczanie_VAT_napromocje1.swf", wmode:"transparent", width:"350", height:"77", majorversion:"8", build:"0", xi:"true" };'+
		'var FO = { movie:"'+theSwf1[0]+'", wmode:"transparent", width:"780", height:"208", majorversion:"8", build:"0", xi:"true" };'+
		'UFO.create(FO, "vat22");'+
		'var FO = { movie:"'+theSwf2[0]+'", wmode:"transparent", width:"350", height:"100", majorversion:"8", build:"0", xi:"true" };'+
		'UFO.create(FO, "v22");'+
		'</script>');		
}

// fadein

//document.write("<style type='text/css'>#thephoto {visibility:hidden;}</style>");

function initImage() {
	imageId = 'thephoto';
	image = document.getElementById(imageId);
	setOpacity(image, 0);
	image.style.visibility = "visible";
	fadeIn(imageId,0);
		}

function fadeIn(objId,opacity) 
	{
		if (document.getElementById) 
			{		
			obj = document.getElementById(objId);
			if (opacity <= 100) 
				{
				setOpacity(obj, opacity);
				opacity += 10;
				window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
				}
			}
	}

function setOpacity(obj, opacity) {	
	opacity = (opacity == 100)?99.999:opacity;	
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;}
	//window.onload = function() {initImage()}

// koniec fadein