// programmer only needs to set the 2 variables below (flagged with setme)

// (setme)  directory containing images (part after the host namein the url)
 var dir = "http://www.qualitysilage.com/images/random-images/"
// (setme)  number of random images in the random_images_directory
var number_of_images = 5;

// gets the server host name
//var host_server = location.host; 
// read our cookie named thinggie
     var t= readCookie( 'bg_img' );
	
// if our cookie exists - set the input field to that value
     if (t) {
//  prepend image name with directory
        image = dir + t;
     }else{

       rand_seed = number_of_images;		 
       random_number= Math.floor(Math.random()* rand_seed + 1 );
// select a random image name.
         var simage = "image" + random_number + ".jpg";
// prepend path to image name
        image = dir + simage;		 
		 
// if our cookie does not exist - create a cookie , with a value of image name - no path
// the cookie will be trashed when the browser is closed.
        createCookie('bg_img',simage,0);
     }
