$(document).ready(function() {
	/* **
	*	Random banner		
	*/	
	var randomHeaderCount = 8;
	var rndNum = Math.ceil(Math.random() * randomHeaderCount);
	$("#featured-image").css({ background: 'url(/Portals/BVV/Skins/BVV/img/banner/afbeelding_0' + rndNum + '.jpg) no-repeat left top'});
	
	/* **
	*	Accordion (used for Dossiers)		
	*/
	if ($(".accordion").length > 0) {
		$(".accordion").accordion({ header: "h3.title", autoHeight: false });
	}
	
	/* **
	*	Fix right or left content height		
	*/
	var a = $("#content-left").height();
	var b = $("#content-right").height();
	
	if (a < b) { a = b; }
	
	if (a > 36) {
		$("#content-right").height(a);
	}
	
	
	
	if ($("#home-rotator").length > 0) {
		startRotator(home_);
		$(".logos-rotator-home").easySlider({
			auto: true, 
			continuous: true,
			numeric: false,
			pause: 3000,
			controlsShow: false
		});
	}
	
	if ($("#jobs-rotator").length > 0) {
		startRotator(jobs_);
		$(".logos-rotator-home").easySlider({
			auto: true, 
			continuous: true,
			numeric: false,
			pause: 3000,
			controlsShow: false
		});
	}
});

var skinPath = "";
function preloadImages(path) {
	skinPath = path;
}

var _gaq = _gaq || [];
	_gaq.push(
	  ['_setAccount', 'UA-18036321-5'],
	  ['_trackPageview'],
	  ['b._setAccount', 'UA-18707938-1'],
	  ['b._trackPageview']
	);

  	(function() {
    	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  	})();
	
	var home_ = new Array();
	var jobs_ = new Array();
	
	home_[0] = new logo('http://www.abiware.be','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/ABIWARE.png');
	home_[1] = new logo('http://www.brabo.be/','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/BRABO.png');
	home_[2] = new logo('http://www.firetechnics.be/','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/FIRETECHNICS.png');
	home_[3] = new logo('http://www.jomy.be','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/JOMY.png');
	home_[4] = new logo('http://www.msa.be/','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/MSA.png');
	home_[5] = new logo('http://www.protectas.be/','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/PROTECTAS.png');
	home_[6] = new logo('http://www.somati.com','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/SOMATI.png');
	home_[7] = new logo('http://www.vanassche-fire.be/','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/VANASSCHE.png');
	
	
	/* */
	
	jobs_[0] = new logo('http://www.aegbelgium.be','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/AEG.png');
	jobs_[1] = new logo('http://www.ardovlam.be/','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/ARDOVLAM.png');
	jobs_[2] = new logo('http://www.deboosere-telecom.be/','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/DEBOCOM.png');
	jobs_[3] = new logo('http://www.draeger.com/','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/DRAGER.png');
	jobs_[4] = new logo('http://www.promat.be/','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/PROMAT.png');
	jobs_[5] = new logo('http://www.abtechnics.be/','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/ABITECHNICS.png');
	home_[6] = new logo('http://www.haagen.eu/','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/HAAGEN.png');
	home_[7] = new logo('http://www.eyroflam.be/','http://www.brandweervlaanderen.be/Portals/BVV/Skins/BVV/img/fotoslider/EYROFLAM.png');
	
	
	

function $d() {
	var elements = [];
	
	for(var i = 0; i < arguments.length; i++) {
		var e = arguments[i];
		if (typeof e == 'string')
			e = document.getElementById(e);
		
		if (arguments.length == 1)
			return e;

		elements.push(e);
	}
	return elements;
}


function Randomize (myArray) {
  var i = myArray.length;
  if ( i == 0 ) return false;
  while ( --i ) {
	 var j = Math.floor( Math.random() * ( i + 1 ) );
	 var tempi = myArray[i];
	 var tempj = myArray[j];
	 myArray[i] = tempj;
	 myArray[j] = tempi;
   }
}	

function logo(location, image) {
	this.location = location
	this.image = image
}

function startRotator(arr) {
	Randomize(arr);
	var selected = new Array();
	selected = arr;
	
	for (y = 0; y < selected.length; y++) {
		document.getElementById('logos').innerHTML += '<li id="logo'+y+'" class="logo" style="float:left; margin: 0;"><div><a id="lnk'+y+'" href="" target="_blank"><img id="img'+y+'" style="margin: 0;" vspace="0" hspace="0" vspace="0" border="0" height="130" width="190" src="" /></a></div></li>';
	}
	
	for(i = 0; i < selected.length; i++) {
		var id = i;										
		var bla = $d('lnk' + id);
		$d('lnk' + id).href = selected[i].location;
		$d('img' + id).src = selected[i].image;
	}
}
