//the main function, call to the effect object
// mad4milk.net
function init(){


	var stretchers = document.getElementsByClassName('stretcher');
	var toggles = document.getElementsByClassName('display');

	//accordion effect
	var myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: true, duration: 400}
	);

	//hash function

	function checkHash(){
		var found = false;
		toggles.each(function(a, i){
			if (window.location.href.indexOf(a.title) > 0) {
				myAccordion.showThisHideOpen(stretchers[i]);
				found = true;
			}
		});
		return found;
	}

	if (!checkHash()) myAccordion.showThisHideOpen(stretchers[0]);
}

//random images

function RandomizeImage(){
	
	var imagesarray = new Array("images/header-1.jpg", "images/header-2.jpg", "images/header-3.jpg", "images/header-4.jpg", "images/header-5.jpg", "images/header-6.jpg", "images/header-7.jpg", "images/header-8.jpg", "images/header-9.jpg", "images/header-10.jpg", "images/header-11.jpg", "images/header-12.jpg", "images/header-13.jpg", "images/header-14.jpg", "images/header-15.jpg")

	var randomnumber = Math.round(Math.random()*(imagesarray.length - 1))
	document.images.randomimg.src = imagesarray[randomnumber]
	
}

// addLoadEvent was written by Simon Willison
// learn more about the function here http://simon.incutio.com/archive/2004/05/26/addLoadEvent#comment3
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(RandomizeImage);


