// Set Cookie Expiration in Days
num_days = 30;
// Set random number upper limit
rnd_upper_limit = 3;
// Set cookie name
thiscookie = "home_feb2010";
// Call function to read cookie
readCookie(thiscookie);

// Read Cookie and Display Appropriate Movie
function readCookie(cookieName){
    var start = document.cookie.indexOf(cookieName);
    if (start == -1){ 
		 // FIRST VISIT
        // Set cookie and expiration
        document.cookie = cookieName + "=yes; expires=" + ged(num_days);
		// Display Intro Movie using DisplayMovie('filepath','height','width') function

			// Call function to write Object tag code
			DisplayMovie('flash/box_of_chocolates.swf?button=1','570','980')	
		
    } else {
		// RETURN VISIT
		// Generate random number
		var randomnumber = Math.floor(Math.random()*(rnd_upper_limit));

		// Use random number to determine which movie to play
		// Display one Random Movie in case statement using DisplayMovie('filepath','height','width') function
		switch(randomnumber+1)
			{
			case 1:
				//Display Flash Movie 1
				// Call function to write Object tag code
				DisplayMovie('flash/conversation_hearts.swf?button=1','570','980')
			  break;
			case 2:
				//Display Flash Movie 2
				// Call function to write Object tag code
				DisplayMovie('flash/atgnat_intro_promo_revisit.swf?button=1','570','980')	
			  break;
			case 3:
				//Display Flash Movie 2
				// Call function to write Object tag code
				DisplayMovie('flash/box_of_chocolates.swf?button=1','570','980')
			  break;  
			default:
			  //code to be executed if randomnumber is out of scope of cases
			  alert("out of scope of random numbers");
			}
    }
}
 
// Set Date for Cookie Expiration - no editing necessary
function ged(noDays){
    var today = new Date();
    var expr = new Date(today.getTime() + noDays*24*60*60*1000);
    return  expr.toGMTString();
}

// Function to display Object tag code
function DisplayMovie(filepath,height,width) {
			document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,24" width="' + width + '" height="' + height + '">');
		    document.write('<param name="movie" value="' + filepath + '" />');
		    document.write('<param name="scale" value="noscale" />');
		    document.write('<!--[if !IE]> <-->');
		    document.write('<object data="' + filepath + '"');
            document.write('        width="' + width + '" height="' + height + '" type="application/x-shockwave-flash">');
		    document.write('  <param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer" />');
		    document.write(' <param name="scale" value="noscale" />');
		    document.write(' FAIL (the browser should render some flash content, not this).');
	        document.write('</object>');
		    document.write('<!--> <![endif]-->');
	   		document.write('</object>');
}