// Set Cookie Expiration in Days
num_days = 365;
// Set cookie name
thiscookie = "intraFUSIONhome"; 
// Call function to read cookie
readCookie(thiscookie);

// Read Cookie and Display Appropriate Movie
function readCookie(cookieName){
	var start = parseInt(getCookie(cookieName));
	if (!start)
	  {
		  start = 1;
	  }

		switch(start)
			{
			case 1:
				//Display Flash Movie 1
				// Call function to write Object tag code
				DisplayMovie('../wp-content/themes/intrafusion/flash/intrafusion_home1.swf')
				// Set new cookie value - increment +1
				setCookie(cookieName,2,num_days)
			  break;
			case 2:
				//Display Flash Movie 2
				// Call function to write Object tag code
				DisplayMovie('../wp-content/themes/intrafusion/flash/intrafusion_home2.swf')
				// Set new cookie value - increment +1
				setCookie(cookieName,3,num_days)
			  break;
			case 3:
				//Display Flash Movie 3
				// Call function to write Object tag code
				DisplayMovie('../wp-content/themes/intrafusion/flash/intrafusion_home3.swf')
				// Set new cookie value - increment +1
				setCookie(cookieName,1,num_days)
			  break;
			default:
			  //code to be executed if visit number is out of scope of cases
			  // alert("out of scope of visit numbers");
			  // alert(start);
			  
			}
}
 
// 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) {

document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="944" height="320" ');document.write('<param name="allowScriptAccess" value="sameDomain" />');
document.write('<param name="allowFullScreen" value="false" />');
document.write('<param name="movie" value="' + filepath + '" />');
document.write('<param name="quality" value="high" /><param name="wmode" value="transparent" />');
document.write('<param name="bgcolor" value="#ffffff" />');
document.write('<embed src="' + filepath + '" quality="high" wmode="transparent" bgcolor="#ffffff" width="944" height="320" name="intrafusion_animation" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />');
document.write('</object>');

}


// Get Cookie
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

// Set Cookie
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
} 
