/* 
Handy dandy bgimg rotator thing: css and js! 

Credit goes to:
Script taken from leemessenger.co.uk - Please do not remove this line 

Found on this site:
http://www.blogfodder.co.uk/2008/1/1/javascript-css-random-background-image

*/

function ChangeCSSBgImg() {
if (!document.getElementById) return false;

var MyElement = "portoHed" //The ID of the element you want to change
var ImgPath = "http://www.dogmo.com/img/" //The file path to your images. 
/** 
* Made the image path absolute, so it would work with my WP template. 
* Not sure if this is bad yet. -ew 
**/


if (!document.getElementById(MyElement)) return false;

/** 
*
* the array: 
* holds all the images, be sure to update the array number
* imgs need to be minimum of 960 wide x 320 high
*
**/
var random_images = new Array ();

random_images[0] = "bg_sfsunset.jpg";
random_images[1] = "bg_bay.jpg";
random_images[2] = "bg_bp.jpg";
random_images[3] = "bg_fishcake.jpg";
random_images[4] = "bg_bonklet01.jpg";
random_images[5] = "bg_feat.jpg";
random_images[6] = "bg_kehoecurl.jpg";
random_images[7] = "bg_lakem00.jpg";
random_images[8] = "bg_lakem01.jpg";
random_images[9] = "bg_nordhoff.jpg";
random_images[10] = "bg_oad00.jpg";
random_images[11] = "bg_oad01.jpg";
random_images[12] = "bg_oad02.jpg";
random_images[13] = "bg_oad03.jpg";
random_images[14] = "bg_rememb01.jpg";
random_images[15] = "bg_rememb02.jpg";
random_images[16] = "bg_tokiberry.jpg";


var $header = document.getElementById(MyElement);
var $backgroundurl = $header.style.backgroundImage;
var ImgURL = "url(" + ImgPath + random_images[rand(random_images.length)] + ")";

if ($backgroundurl != ImgURL) {
$header.style.backgroundImage = ImgURL;	
}

movement = setTimeout("ChangeCSSBgImg()",10000); // time in milliseconds 
}

/* random number generator */
function rand(n) {
    return ( Math.floor ( Math.random ( ) * n ) );
}

/* Custom onload function */

function addLoadEvent(func) {
    var oldonload = window.onload;
        if (typeof window.onload != 'function') {
        window.onload = func;
        } else {
        window.onload = function() {
    oldonload();
func();
}
}
}

/* trigger onload */

addLoadEvent(ChangeCSSBgImg);
