
if (window.addEventListener) {
  window.addEventListener('load', ChevyInit, false); 
 } else if (window.attachEvent) { 
  window.attachEvent('onload', ChevyInit);
 }

var vozila = ['spark', 'aveo', 'lacetti', 'tacuma', 'epica', 'captiva', 'cruze'];
var CarHoverInfoBox;
var CHIBText;
function ChevyInit() {
	VideoInit();
	CCInit();
	PreloadImages();
}
var aPreloaded = new Array;
function PreloadImages() {
	var i;
	var img;
	for (i=0; i<vozila.length; i++) {
		img = aPreloaded[i] = new Image;
		var slika = 'sl/a/'+vozila[i]+'.png';
		img.src=slika;
	}
}

function CCInit() {
	var i, car;
	for (i=0; i<vozila.length; i++) {
		car = GEBID('CS'+vozila[i]);
		car.onmouseover = CCMouseOver;
		car.onmouseout  = CCMouseOut;
		car.onclick = CCNavigateConfirm;
	}
	CarHoverInfoBox = GEBID('CSInfo');
	CHIBText = CarHoverInfoBox.innerHTML;
	
	function CCMouseOver() {
		var model = this.id.substring(2);
		var slika = 'sl/a/'+model+'.png';
		CarHoverInfoBox.innerHTML="<img src='"+slika+"' />";
	}
	function CCMouseOut() {
		CarHoverInfoBox.innerHTML = CHIBText;
	}
	
	function CCNavigateConfirm() {
		/* Dealer guidelines, 27. apr. 2007, stran 18, 5.2.2 */
		if(confirm('To je zunanja povezava. Odprlo se bo okno z vsebino, ki ni na naši strani. Nadaljujem?')) {
			popUp(this.href);
		}
		return false;
	}
}




function popUp(URL) {
	window.open(URL, 0, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=1010,height=800,left = 135,top = 112');
}



function GEBID(el) {
	if (document.getElementById) {
		return document.getElementById(el);
	} else {
  		if(document.all) {
  			if(typeof document.all[el]!="undefined") {
    			return document.all[el];
    		} else {
    			return null;
    		}
  		} else if (document.layers) {
 			if(typeof document[el]!="undefined") {
    			return document[el];
    		}
    	} else {
    		return null;
    	}
	}
}

function VideoInit() {
	if ($('VideoContainer')) {
        var obj = new Swiff('mediaplayer.swf', {
            id: 'TheMovie',
            width: 530,
            height: 313,
            params: {
                /*wmode: 'transparent',*/
                bgcolor: 'none',
                allowfullscreen: 'false'
            },
            vars: {
                file: 'movies/AVEO.flv',
                width: '530',
                height: '313',
                /*autostart: 'true',*/
                bufferlength: '5',
                shownavigation: 'false',
				image: 'movies/AVEO.jpg'

            }
        });
        $('VideoContainer').grab(obj);
    }
}
